Revision 23303 branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/JDBCStore.java
JDBCStore.java | ||
---|---|---|
8 | 8 |
import java.util.HashMap; |
9 | 9 |
import java.util.Iterator; |
10 | 10 |
|
11 |
import org.gvsig.tools.exception.BaseException; |
|
12 | 11 |
import org.gvsig.fmap.data.CloseException; |
13 | 12 |
import org.gvsig.fmap.data.DataException; |
14 | 13 |
import org.gvsig.fmap.data.DataExplorer; |
... | ... | |
36 | 35 |
import org.gvsig.metadata.IMetadata; |
37 | 36 |
import org.gvsig.metadata.IMetadataManager; |
38 | 37 |
import org.gvsig.metadata.MetadataManager; |
38 |
import org.gvsig.tools.exception.BaseException; |
|
39 | 39 |
|
40 | 40 |
public abstract class JDBCStore extends DBStore { |
41 | 41 |
|
... | ... | |
215 | 215 |
obj=commandsfeatures.next(); |
216 | 216 |
if (obj instanceof FeatureCommand){ |
217 | 217 |
feature = ((FeatureCommand)obj).getFeature(); |
218 |
if (feature instanceof CreatedFeature) |
|
218 |
if (feature instanceof CreatedFeature) {
|
|
219 | 219 |
continue; |
220 |
} |
|
220 | 221 |
|
221 | 222 |
selectiveWriter.deleteFeature(feature); |
222 | 223 |
} |
... | ... | |
275 | 276 |
} |
276 | 277 |
|
277 | 278 |
public String getFilterForID(DBFeatureType fType, Object[] featureKey) { |
278 |
if (fType.getFieldsId().length != 1) |
|
279 |
if (fType.getFieldsId().length != 1) {
|
|
279 | 280 |
throw new UnsupportedOperationException("ID fields > 1"); |
281 |
} |
|
280 | 282 |
String id =fType.getFieldsId()[0]; |
281 | 283 |
return id + " = " + objectToSqlString(featureKey[0]); |
282 | 284 |
} |
... | ... | |
298 | 300 |
} |
299 | 301 |
|
300 | 302 |
public Feature getFeatureByID(FeatureID id,FeatureType featureType) throws ReadException{ |
301 |
return getFeatureByID((DBFeatureType)featureType,((DBFeatureID)id).getKey());
|
|
303 |
return getFeatureByID(featureType,((DBFeatureID)id).getKey()); |
|
302 | 304 |
} |
303 | 305 |
|
304 | 306 |
public IMetadata getMetadata() throws BaseException { |
... | ... | |
352 | 354 |
|
353 | 355 |
|
354 | 356 |
protected abstract Feature createFeatureFromResulset(ResultSet rs, DBFeatureType featureType2) throws ReadException; |
357 |
|
|
358 |
|
|
359 |
protected FeatureType checkFeatureTypeForCollection(FeatureType fType) |
|
360 |
throws DataException { |
|
361 |
if (!this.useSqlSource) { |
|
362 |
return super.checkFeatureTypeForCollection(fType); |
|
363 |
} |
|
364 |
FeatureType defType = this.getDefaultFeatureType(); |
|
365 |
if (fType == null || fType.equals(defType)) { |
|
366 |
return defType.getSubFeatureType(null); |
|
367 |
} |
|
368 |
if (!fType.isSubtypeOf(defType)) { |
|
369 |
throw new ReadException("invalid type", this.getName()); |
|
370 |
} |
|
371 |
Iterator iterDef = defType.iterator(); |
|
372 |
Iterator iterType = fType.iterator(); |
|
373 |
|
|
374 |
AttributeDescriptor defAttr; |
|
375 |
AttributeDescriptor attr; |
|
376 |
|
|
377 |
while (iterDef.hasNext()) { |
|
378 |
defAttr = (AttributeDescriptor) iterDef.next(); |
|
379 |
attr = (AttributeDescriptor) iterType.next(); |
|
380 |
if (!( |
|
381 |
defAttr.getName().equals(attr.getName()) |
|
382 |
&& defAttr.getDataType().equals(attr.getDataType()) |
|
383 |
&& defAttr.getSize() == attr.getSize() |
|
384 |
&& defAttr.isReadOnly() == attr.isReadOnly() |
|
385 |
&& defAttr.isEvaluated() == attr.isEvaluated() |
|
386 |
)) { |
|
387 |
throw new ReadException("invalid type", this.getName()); |
|
388 |
} |
|
389 |
} |
|
390 |
while (iterType.hasNext()) { |
|
391 |
attr = (AttributeDescriptor) iterType.next(); |
|
392 |
if (!attr.isEvaluated()) { |
|
393 |
throw new ReadException("invalid type", this.getName()); |
|
394 |
} |
|
395 |
} |
|
396 |
|
|
397 |
return fType; |
|
398 |
} |
|
399 |
|
|
355 | 400 |
} |
Also available in: Unified diff