svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / postgresql / PostgreSQLStoreProvider.java @ 28676
History | View | Annotate | Download (18.4 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 IVER T.I {{Task}}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.dal.store.postgresql; |
29 |
|
30 |
import java.security.InvalidParameterException; |
31 |
import java.sql.Connection; |
32 |
import java.sql.PreparedStatement; |
33 |
import java.sql.ResultSet; |
34 |
import java.sql.SQLException; |
35 |
import java.util.ArrayList; |
36 |
import java.util.Iterator; |
37 |
import java.util.List; |
38 |
import java.util.regex.Matcher; |
39 |
import java.util.regex.Pattern; |
40 |
|
41 |
import org.cresques.cts.IProjection; |
42 |
import org.gvsig.fmap.dal.DALLocator; |
43 |
import org.gvsig.fmap.dal.DataManager; |
44 |
import org.gvsig.fmap.dal.DataServerExplorer; |
45 |
import org.gvsig.fmap.dal.DataStoreNotification; |
46 |
import org.gvsig.fmap.dal.DataTypes; |
47 |
import org.gvsig.fmap.dal.exception.CloseException; |
48 |
import org.gvsig.fmap.dal.exception.DataException; |
49 |
import org.gvsig.fmap.dal.exception.InitializeException; |
50 |
import org.gvsig.fmap.dal.exception.OpenException; |
51 |
import org.gvsig.fmap.dal.exception.ReadException; |
52 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
53 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
54 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
55 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
56 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
57 |
import org.gvsig.fmap.dal.feature.FeatureType; |
58 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
59 |
import org.gvsig.fmap.dal.feature.spi.FeatureData; |
60 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
61 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
62 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
63 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
64 |
import org.gvsig.fmap.dal.resource.exception.ResourceBeginException; |
65 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
66 |
import org.gvsig.fmap.dal.store.jdbc.JDBCExecuteSQLException; |
67 |
import org.gvsig.fmap.dal.store.jdbc.JDBCSQLException; |
68 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreProvider; |
69 |
import org.gvsig.fmap.geom.Geometry; |
70 |
import org.gvsig.fmap.geom.operation.towkb.ToWKB; |
71 |
import org.gvsig.fmap.geom.primitive.Envelope; |
72 |
import org.gvsig.tools.ToolsLocator; |
73 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
74 |
import org.gvsig.tools.dynobject.DynClass; |
75 |
import org.gvsig.tools.dynobject.DynObjectManager; |
76 |
import org.gvsig.tools.exception.BaseException; |
77 |
import org.gvsig.tools.persistence.PersistenceException; |
78 |
import org.gvsig.tools.persistence.PersistentState; |
79 |
import org.slf4j.Logger; |
80 |
import org.slf4j.LoggerFactory; |
81 |
|
82 |
public class PostgreSQLStoreProvider extends JDBCStoreProvider implements |
83 |
PostgreSQLHelperUser { |
84 |
|
85 |
final static private Logger logger = LoggerFactory |
86 |
.getLogger(PostgreSQLStoreProvider.class); |
87 |
|
88 |
public static String NAME = "PostgreSQLStore"; |
89 |
public static String DESCRIPTION = "PostgreSQL source"; |
90 |
private static final String DYNCLASS_NAME = "PostgreSQLStore"; |
91 |
private static DynClass DYNCLASS = null; |
92 |
|
93 |
|
94 |
protected PostgreSQLStoreParameters params;
|
95 |
protected PostgreSQLHelper helper;
|
96 |
protected boolean directSQLMode; |
97 |
|
98 |
private Long totalCount = null; |
99 |
|
100 |
protected static void registerDynClass() { |
101 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
102 |
DynClass dynClass; |
103 |
if (DYNCLASS == null) { |
104 |
dynClass = dynman.add(DYNCLASS_NAME, DESCRIPTION); |
105 |
|
106 |
dynClass.extend(dynman.get(FeatureStore.DYNCLASS_NAME)); |
107 |
DYNCLASS = dynClass; |
108 |
} |
109 |
} |
110 |
|
111 |
public PostgreSQLStoreProvider() {
|
112 |
super();
|
113 |
} |
114 |
|
115 |
public PostgreSQLStoreProvider(PostgreSQLStoreParameters params)
|
116 |
throws InitializeException {
|
117 |
super();
|
118 |
this.init(params);
|
119 |
} |
120 |
|
121 |
protected void init(PostgreSQLStoreParameters params) |
122 |
throws InitializeException {
|
123 |
this.params = params;
|
124 |
this.dynObject = (DelegatedDynObject) ToolsLocator
|
125 |
.getDynObjectManager().createDynObject(DYNCLASS); |
126 |
|
127 |
this.dynObject.setDynValue("DefaultSRS", null); |
128 |
this.dynObject.setDynValue("Envelope", null); |
129 |
|
130 |
helper = new PostgreSQLHelper(this, params); |
131 |
|
132 |
if (params.getSQL() != null && (params.getSQL()).trim().length() > 0) { |
133 |
directSQLMode = true;
|
134 |
} |
135 |
} |
136 |
|
137 |
protected String compoundCountSelect(String filter) { |
138 |
if (this.directSQLMode) { |
139 |
return null; |
140 |
} |
141 |
// Select
|
142 |
StringBuilder sql = new StringBuilder(); |
143 |
sql.append("Select count(");
|
144 |
String[] pkFields = params.getPkFields(); |
145 |
if (pkFields != null && pkFields.length == 1) { |
146 |
sql.append(helper.escapeFieldName(pkFields[0]));
|
147 |
} else {
|
148 |
sql.append('*');
|
149 |
|
150 |
} |
151 |
sql.append(") ");
|
152 |
|
153 |
sql.append("from ");
|
154 |
|
155 |
sql.append(params.tableID()); |
156 |
sql.append(' ');
|
157 |
|
158 |
appendWhere(sql, filter); |
159 |
|
160 |
return sql.toString();
|
161 |
} |
162 |
|
163 |
private void appendWhere(StringBuilder sql, String filter) { |
164 |
filter = fixFilter(filter); |
165 |
String initialFilter = params.getInitialFilter();
|
166 |
if ((initialFilter != null && initialFilter.length() != 0) |
167 |
|| (filter != null && filter.length() != 0)) { |
168 |
sql.append("where (");
|
169 |
|
170 |
if (initialFilter != null && initialFilter.length() != 0 |
171 |
&& filter != null && filter.length() != 0) { |
172 |
// initialFilter + filter
|
173 |
sql.append('(');
|
174 |
sql.append(initialFilter); |
175 |
sql.append(") and (");
|
176 |
sql.append(filter); |
177 |
sql.append(')');
|
178 |
} else if (initialFilter != null && initialFilter.length() != 0) { |
179 |
// initialFilter only
|
180 |
sql.append(initialFilter); |
181 |
} else {
|
182 |
// filter only
|
183 |
sql.append(filter); |
184 |
} |
185 |
sql.append(") ");
|
186 |
} |
187 |
|
188 |
} |
189 |
|
190 |
private String fixFilter(String filter) { |
191 |
if (filter == null) { |
192 |
return null; |
193 |
} |
194 |
|
195 |
// Transform SRS to code
|
196 |
// GeomFromText\s*\(\s*'[^']*'\s*,\s*('[^']*')\s*\)
|
197 |
Pattern pattern = Pattern |
198 |
.compile("GeomFromText\\s*\\(\\s*'[^']*'\\s*,\\s*'([^']*)'\\s*\\)");
|
199 |
Matcher matcher = pattern.matcher(filter);
|
200 |
StringBuilder strb = new StringBuilder(); |
201 |
int pos = 0; |
202 |
String srsCode;
|
203 |
while (matcher.find(pos)) {
|
204 |
strb.append(filter.substring(pos, matcher.start(1)));
|
205 |
srsCode = matcher.group(1).trim();
|
206 |
if (srsCode.startsWith("'")) { |
207 |
srsCode = srsCode.substring(1);
|
208 |
} |
209 |
if (srsCode.endsWith("'")) { |
210 |
srsCode = srsCode.substring(0, srsCode.length() - 1); |
211 |
} |
212 |
strb.append(helper.getPostgisSRID(srsCode)); |
213 |
strb.append(filter.substring(matcher.end(1), matcher.end()));
|
214 |
pos = matcher.end(); |
215 |
|
216 |
} |
217 |
strb.append(filter.substring(pos)); |
218 |
|
219 |
return strb.toString();
|
220 |
} |
221 |
|
222 |
public String compoundSelect(FeatureType type, |
223 |
String filter,
|
224 |
String order,
|
225 |
long limit, long offset) throws DataException { |
226 |
StringBuilder sql = new StringBuilder(); |
227 |
if (directSQLMode) {
|
228 |
if (filter != null || order != null) { |
229 |
// FIXME Exception
|
230 |
throw new UnsupportedOperationException(); |
231 |
} |
232 |
sql.append(params.getSQL()); |
233 |
sql.append(' ');
|
234 |
} else {
|
235 |
FeatureAttributeDescriptor[] fields = type
|
236 |
.getAttributeDescriptors(); |
237 |
|
238 |
// Select
|
239 |
sql.append("Select ");
|
240 |
for (int i = 0; i < fields.length - 1; i++) { |
241 |
sql.append(helper.getSqlFieldName(fields[i])); |
242 |
sql.append(", ");
|
243 |
} |
244 |
sql.append(helper.getSqlFieldName(fields[fields.length - 1]));
|
245 |
sql.append(' ');
|
246 |
|
247 |
|
248 |
FeatureAttributeDescriptor[] pkFields = store
|
249 |
.getProviderFeatureType(type.getId()).getPrimaryKey(); |
250 |
|
251 |
if (pkFields != null && pkFields.length > 0) { |
252 |
// checks for pk fields are in select
|
253 |
boolean toAdd;
|
254 |
for (int i = 0; i < pkFields.length; i++) { |
255 |
toAdd = true;
|
256 |
for (int j = 0; j < fields.length; j++) { |
257 |
if (pkFields[i].getName().equals(fields[j].getName())) {
|
258 |
toAdd = false;
|
259 |
break;
|
260 |
} |
261 |
if (toAdd) {
|
262 |
sql.append(", ");
|
263 |
sql.append(helper.getSqlFieldName(pkFields[i])); |
264 |
} |
265 |
} |
266 |
} |
267 |
sql.append(' ');
|
268 |
} |
269 |
|
270 |
|
271 |
// table
|
272 |
sql.append("from ");
|
273 |
sql.append(params.tableID()); |
274 |
sql.append(' ');
|
275 |
|
276 |
// Where
|
277 |
appendWhere(sql, filter); |
278 |
|
279 |
// Order
|
280 |
if ((params.getInitialOrder() != null && params |
281 |
.getInitialOrder().length() != 0)
|
282 |
|| (order != null && order.length() != 0)) { |
283 |
sql.append("order by ");
|
284 |
|
285 |
if (order != null && order.length() != 0) { |
286 |
// order
|
287 |
sql.append(order); |
288 |
} else {
|
289 |
// initial order
|
290 |
sql.append(params.getInitialOrder()); |
291 |
} |
292 |
sql.append(' ');
|
293 |
} |
294 |
} |
295 |
// limit
|
296 |
if (limit >= 1) { |
297 |
sql.append("limit ");
|
298 |
sql.append(limit); |
299 |
sql.append(' ');
|
300 |
} |
301 |
|
302 |
// offset
|
303 |
if (offset >= 1) { |
304 |
sql.append("offset ");
|
305 |
sql.append(offset); |
306 |
sql.append(' ');
|
307 |
} |
308 |
|
309 |
|
310 |
return sql.toString();
|
311 |
} |
312 |
|
313 |
public FeatureStoreProvider initialize(FeatureStoreProviderServices store)
|
314 |
throws InitializeException {
|
315 |
super.initialize(store);
|
316 |
this.initFeatureType();
|
317 |
return this; |
318 |
} |
319 |
|
320 |
|
321 |
protected void initFeatureType() throws InitializeException { |
322 |
|
323 |
EditableFeatureType edFType = null;
|
324 |
try {
|
325 |
edFType = this.store.createFeatureType();
|
326 |
|
327 |
helper.loadFeatureType(edFType, params); |
328 |
|
329 |
} catch (DataException e) {
|
330 |
throw new InitializeException(this.getName(), e); |
331 |
} |
332 |
|
333 |
FeatureType defaultType = edFType.getNotEditableCopy(); |
334 |
List types = new ArrayList(1); |
335 |
types.add(defaultType); |
336 |
this.store.setFeatureTypes(types, defaultType);
|
337 |
try {
|
338 |
loadMetadata(); |
339 |
} catch (DataException e) {
|
340 |
throw new InitializeException(e); |
341 |
} |
342 |
} |
343 |
|
344 |
public Object createNewOID() { |
345 |
return null; |
346 |
} |
347 |
|
348 |
|
349 |
public FeatureData getFeatureDataByReference(
|
350 |
FeatureReferenceProviderServices reference) throws DataException {
|
351 |
return getFeatureDataByReference(reference, store
|
352 |
.getDefaultFeatureType()); |
353 |
} |
354 |
|
355 |
public FeatureData getFeatureDataByReference(
|
356 |
FeatureReferenceProviderServices reference, FeatureType featureType) |
357 |
throws DataException {
|
358 |
open(); |
359 |
resourceBegin(); |
360 |
try {
|
361 |
StringBuilder filter = new StringBuilder(); |
362 |
FeatureAttributeDescriptor[] pk = store.getFeatureType(
|
363 |
featureType.getId()).getPrimaryKey(); |
364 |
|
365 |
List values = new ArrayList(); |
366 |
|
367 |
int i;
|
368 |
for (i = 0; i < pk.length - 1; i++) { |
369 |
values.add(helper.dalValueToJDBC(pk[i], reference |
370 |
.getKeyValue(pk[i].getName()))); |
371 |
filter.append(helper.getSqlFieldName(pk[i])); |
372 |
filter.append(" = ? AND ");
|
373 |
} |
374 |
values.add(helper.dalValueToJDBC(pk[i], reference.getKeyValue(pk[i] |
375 |
.getName()))); |
376 |
filter.append(helper.getSqlFieldName(pk[i])); |
377 |
filter.append(" = ? ");
|
378 |
|
379 |
|
380 |
String sql = compoundSelect(featureType, filter.toString(), null, |
381 |
1, 0); |
382 |
|
383 |
FeatureData data; |
384 |
int rsId = createResultSet(sql, values.toArray());
|
385 |
try{
|
386 |
if (!resulsetNext(rsId)) {
|
387 |
// FIXME Exception
|
388 |
throw new RuntimeException("Reference Not found"); |
389 |
} |
390 |
data = createFeatureData(featureType); |
391 |
loadFeatureData(data, rsId); |
392 |
} finally {
|
393 |
closeResulset(rsId); |
394 |
} |
395 |
|
396 |
return data;
|
397 |
|
398 |
} finally {
|
399 |
resourceEnd(); |
400 |
} |
401 |
|
402 |
} |
403 |
|
404 |
public int getFeatureReferenceOIDType() { |
405 |
return DataTypes.UNKNOWN;
|
406 |
} |
407 |
|
408 |
public String getName() { |
409 |
return NAME;
|
410 |
} |
411 |
|
412 |
public Iterator getChilds() { |
413 |
return null; |
414 |
} |
415 |
|
416 |
public void open() throws OpenException { |
417 |
helper.open(); |
418 |
} |
419 |
|
420 |
|
421 |
public boolean allowWrite() { |
422 |
return false; |
423 |
} |
424 |
|
425 |
public void close() throws CloseException { |
426 |
helper.close(); |
427 |
} |
428 |
|
429 |
public Object getSourceId() { |
430 |
return this.params.getSourceId(); |
431 |
} |
432 |
|
433 |
protected ResultSet createNewResultSet(String sql, Object[] values) |
434 |
throws DataException {
|
435 |
this.open();
|
436 |
Connection conn =null; |
437 |
PreparedStatement st=null; |
438 |
ResultSet rs=null; |
439 |
this.resourceBegin();
|
440 |
try{
|
441 |
conn = this.helper.getConnection();
|
442 |
st = conn.prepareStatement(sql); |
443 |
|
444 |
if (values != null) { |
445 |
Object value;
|
446 |
for (int i = 0; i < values.length; i++) { |
447 |
value = values[i]; |
448 |
if (value instanceof Geometry) { |
449 |
byte[] bytes; |
450 |
try {
|
451 |
bytes = (byte[]) ((Geometry) value) |
452 |
.invokeOperation(ToWKB.CODE, null);
|
453 |
} catch (BaseException e) {
|
454 |
// FIXME
|
455 |
throw new InvalidParameterException(); |
456 |
} |
457 |
st.setBytes(i + 1, bytes);
|
458 |
} |
459 |
st.setObject(i + 1, value);
|
460 |
} |
461 |
|
462 |
} |
463 |
|
464 |
try {
|
465 |
rs = st.executeQuery(); |
466 |
} catch (SQLException e1){ |
467 |
try {st.close(); } catch (Exception e2) { }; |
468 |
try {conn.close();} catch (Exception e2) { }; |
469 |
throw new JDBCExecuteSQLException(sql,e1); |
470 |
} |
471 |
rs.setFetchSize(5000); // TODO add to params? |
472 |
return rs;
|
473 |
} catch (SQLException e) { |
474 |
// TODO throw exception ???
|
475 |
try {rs.close(); } catch (Exception e1) { }; |
476 |
try {st.close(); } catch (Exception e1) { }; |
477 |
try {conn.close();} catch (Exception e1) { }; |
478 |
throw new JDBCSQLException(e); |
479 |
}finally{
|
480 |
this.resourceEnd();
|
481 |
} |
482 |
} |
483 |
|
484 |
protected long getCount(String filter) throws DataException { |
485 |
this.open();
|
486 |
if (filter == null && totalCount != null) { |
487 |
return totalCount.longValue();
|
488 |
} |
489 |
long count = 0; |
490 |
String sql = compoundCountSelect(filter);
|
491 |
resourceBegin(); |
492 |
try {
|
493 |
ResultSet rs = createNewResultSet(sql, null); |
494 |
try {
|
495 |
if (rs.next()) {
|
496 |
count = rs.getLong(1);
|
497 |
} |
498 |
} catch (SQLException e) { |
499 |
throw new JDBCSQLException(e); |
500 |
} finally {
|
501 |
closeResulset(rs); |
502 |
} |
503 |
} finally {
|
504 |
resourceEnd(); |
505 |
} |
506 |
if (filter == null) { |
507 |
totalCount = new Long(count); |
508 |
} |
509 |
return count;
|
510 |
} |
511 |
|
512 |
protected void resourceBegin() throws ResourceBeginException { |
513 |
this.helper.begin();
|
514 |
|
515 |
} |
516 |
|
517 |
protected void resourceEnd() { |
518 |
this.helper.end();
|
519 |
} |
520 |
|
521 |
protected boolean closeResource(ResourceProvider resource) { |
522 |
try {
|
523 |
this.helper.close();
|
524 |
} catch (CloseException e) {
|
525 |
logger.error("Exception in close Request", e);
|
526 |
} |
527 |
return !this.helper.isOpen(); |
528 |
} |
529 |
|
530 |
|
531 |
protected void loadFeatureDataValue(FeatureData data, ResultSet rs, |
532 |
FeatureAttributeDescriptor attr) throws DataException {
|
533 |
if (attr.getDataType() == DataTypes.GEOMETRY) {
|
534 |
byte[] buffer; |
535 |
try {
|
536 |
buffer = rs.getBytes(attr.getIndex() + 1);
|
537 |
if (buffer == null) { |
538 |
data.set(attr.getIndex(), null);
|
539 |
} else {
|
540 |
data.set(attr.getIndex(), this.helper
|
541 |
.getGeometry(buffer)); |
542 |
} |
543 |
} catch (SQLException e) { |
544 |
throw new JDBCSQLException(e); |
545 |
} catch (BaseException e) {
|
546 |
throw new ReadException(getName(), e); |
547 |
} |
548 |
|
549 |
} else {
|
550 |
super.loadFeatureDataValue(data, rs, attr);
|
551 |
} |
552 |
} |
553 |
|
554 |
public FeatureSetProvider createSet(FeatureQuery query,
|
555 |
FeatureType featureType) throws DataException {
|
556 |
|
557 |
return new PostgreSQLSetProvider(this, query, featureType); |
558 |
} |
559 |
|
560 |
public void dispose() throws CloseException { |
561 |
this.close();
|
562 |
this.helper.dispose();
|
563 |
super.dispose();
|
564 |
} |
565 |
|
566 |
|
567 |
public DataServerExplorer getExplorer() throws ReadException { |
568 |
DataManager manager = DALLocator.getDataManager(); |
569 |
PostgreSQLServerExplorerParameters exParams; |
570 |
try {
|
571 |
exParams = (PostgreSQLServerExplorerParameters) manager |
572 |
.createServerExplorerParameters(PostgreSQLServerExplorer.NAME); |
573 |
exParams.setHost(params.getHost()); |
574 |
exParams.setPort(params.getPort()); |
575 |
exParams.setDBName(params.getDBName()); |
576 |
exParams.setUser(params.getUser()); |
577 |
exParams.setPassword(params.getPassword()); |
578 |
exParams.setCatalog(params.getCatalog()); |
579 |
exParams.setSchema(params.getSchema()); |
580 |
exParams.setJDBCDriverClassName(params.getJDBCDriverClassName()); |
581 |
exParams.setUseSSL(params.getUseSSL()); |
582 |
|
583 |
return manager.createServerExplorer(exParams);
|
584 |
} catch (DataException e) {
|
585 |
throw new ReadException(this.getName(), e); |
586 |
} catch (ValidateDataParametersException e) {
|
587 |
// TODO Auto-generated catch block
|
588 |
throw new ReadException(this.getName(), e); |
589 |
} |
590 |
} |
591 |
|
592 |
protected void loadMetadata() throws DataException { |
593 |
IProjection srs = params.getSRS(); |
594 |
|
595 |
if (srs == null) { |
596 |
srs = store.getDefaultFeatureType().getDefaultSRS(); |
597 |
} |
598 |
|
599 |
|
600 |
this.dynObject.setDynValue("DefaultSRS", srs); |
601 |
|
602 |
String defGeomName = this.store.getDefaultFeatureType() |
603 |
.getDefaultGeometryAttributeName(); |
604 |
Envelope env = null;
|
605 |
if (defGeomName != null && defGeomName.length() > 0) { |
606 |
env = this.helper
|
607 |
.getFullEnvelopeOfField(this.params,
|
608 |
defGeomName, |
609 |
this.params.getWorkingArea());
|
610 |
|
611 |
} |
612 |
this.dynObject.setDynValue("Envelope", env); |
613 |
|
614 |
} |
615 |
|
616 |
private void clearMetadata() { |
617 |
this.dynObject.setDynValue("DefaultSRS", null); |
618 |
this.dynObject.setDynValue("Envelope", null); |
619 |
} |
620 |
|
621 |
public void closeDone() throws DataException { |
622 |
clearMetadata(); |
623 |
|
624 |
} |
625 |
|
626 |
public void opendDone() throws DataException { |
627 |
// Nothing to do
|
628 |
} |
629 |
|
630 |
public Envelope getEnvelope() throws DataException { |
631 |
this.open();
|
632 |
return (Envelope) this.dynObject.getDynValue("Envelope"); |
633 |
} |
634 |
|
635 |
public void resourceChanged(ResourceProvider resource) { |
636 |
this.store.notifyChange(DataStoreNotification.RESOURCE_CHANGED,
|
637 |
resource); |
638 |
} |
639 |
|
640 |
public boolean canWriteGeometry(int geometryType) throws DataException { |
641 |
return false; |
642 |
} |
643 |
|
644 |
public boolean allowAutomaticValues() { |
645 |
return true; |
646 |
} |
647 |
|
648 |
public void performEditing(Iterator deleteds, Iterator inserteds, |
649 |
Iterator updateds, Iterator originalFeatureTypesUpdated) |
650 |
throws PerformEditingException {
|
651 |
// FIXME exception
|
652 |
throw new UnsupportedOperationException(); |
653 |
|
654 |
} |
655 |
|
656 |
protected PostgreSQLHelper getHelper() {
|
657 |
return helper;
|
658 |
} |
659 |
|
660 |
protected void resetCount() { |
661 |
totalCount = null;
|
662 |
} |
663 |
|
664 |
public long getFeatureCount() throws DataException { |
665 |
return getCount(null); |
666 |
} |
667 |
|
668 |
public boolean supportsAppendMode() { |
669 |
return false; |
670 |
} |
671 |
|
672 |
|
673 |
public void endAppend() throws DataException { |
674 |
// FIXME exception
|
675 |
throw new UnsupportedOperationException(); |
676 |
|
677 |
} |
678 |
|
679 |
public void append(FeatureData featureData) throws DataException { |
680 |
// FIXME exception
|
681 |
throw new UnsupportedOperationException(); |
682 |
|
683 |
} |
684 |
|
685 |
public void beginAppend() throws DataException { |
686 |
// FIXME exception
|
687 |
throw new UnsupportedOperationException(); |
688 |
} |
689 |
|
690 |
// ************************************************************************************//
|
691 |
|
692 |
|
693 |
// ************************************************************************************//
|
694 |
|
695 |
|
696 |
|
697 |
public PersistentState getState() throws PersistenceException { |
698 |
// TODO Auto-generated method stub
|
699 |
return null; |
700 |
} |
701 |
|
702 |
public void loadState(PersistentState state) throws PersistenceException { |
703 |
// TODO Auto-generated method stub
|
704 |
|
705 |
} |
706 |
|
707 |
public void loadFromState(PersistentState state) |
708 |
throws PersistenceException {
|
709 |
// TODO Auto-generated method stub
|
710 |
|
711 |
} |
712 |
|
713 |
/* (non-Javadoc)
|
714 |
* @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState)
|
715 |
*/
|
716 |
public void saveToState(PersistentState state) throws PersistenceException { |
717 |
// TODO Auto-generated method stub
|
718 |
|
719 |
} |
720 |
|
721 |
} |