Revision 46875
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStoreTransforms.java | ||
---|---|---|
98 | 98 |
this.transforms.add(transform); |
99 | 99 |
transform.setFeatureStore(store); |
100 | 100 |
transform.setSourceMetadata(this.store.metadata); |
101 |
transform.apply(this.store); |
|
101 | 102 |
this.notifyChangeToStore(); |
102 | 103 |
if( this.isTramsformValues == null || (!this.isTramsformValues) ) { |
103 | 104 |
if( transform.isTransformsOriginalValues() ) { |
... | ... | |
131 | 132 |
@Override |
132 | 133 |
public Object remove(int index) { |
133 | 134 |
checkEditingMode(); |
134 |
Object trans = this.transforms.remove(index); |
|
135 |
FeatureStoreTransform trans = this.transforms.remove(index); |
|
136 |
trans.revoke(this.store); |
|
137 |
|
|
135 | 138 |
this.notifyChangeToStore(); |
136 | 139 |
this.isTramsformValues = null; |
137 | 140 |
return trans; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
598 | 598 |
return envelope; |
599 | 599 |
} |
600 | 600 |
FeatureAttributeDescriptor attrdesc = this.getDefaultFeatureType().getDefaultGeometryAttribute(); |
601 |
if (attrdesc == null || !attrdesc.isComputed()) {
|
|
601 |
if (attrdesc == null || (!attrdesc.isComputed() && this.getTransforms().isEmpty())) {
|
|
602 | 602 |
return null; |
603 | 603 |
} |
604 | 604 |
final int index = attrdesc.getIndex(); |
... | ... | |
1358 | 1358 |
if (!this.provider.supportsAppendMode()) { |
1359 | 1359 |
mode = MODE_FULLEDIT; |
1360 | 1360 |
} |
1361 |
if (!this.canBeEdited()) { |
|
1362 |
throw new IllegalStateException(this.getName()); |
|
1363 |
} |
|
1361 | 1364 |
switch (mode) { |
1362 | 1365 |
case MODE_QUERY: |
1363 | 1366 |
throw new IllegalStateException(this.getName()); |
1364 | 1367 |
|
1365 | 1368 |
case MODE_FULLEDIT: |
1366 |
if (!this.transforms.isEmpty()) { |
|
1367 |
throw new IllegalStateException(this.getName()); |
|
1368 |
} |
|
1369 | 1369 |
if (notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING, |
1370 | 1370 |
newSessionCode, mode).isCanceled()) { |
1371 | 1371 |
return; |
... | ... | |
1385 | 1385 |
break; |
1386 | 1386 |
|
1387 | 1387 |
case MODE_APPEND: |
1388 |
if (!this.transforms.isEmpty()) { |
|
1389 |
throw new IllegalStateException(this.getName()); |
|
1390 |
} |
|
1391 | 1388 |
if (notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING, |
1392 | 1389 |
newSessionCode, mode).isCanceled()) { |
1393 | 1390 |
return; |
... | ... | |
1403 | 1400 |
if (!this.provider.supportsPassThroughMode()) { |
1404 | 1401 |
throw new IllegalStateException(this.getName()); |
1405 | 1402 |
} |
1406 |
if (!this.transforms.isEmpty()) { |
|
1407 |
throw new IllegalStateException(this.getName()); |
|
1408 |
} |
|
1409 | 1403 |
if (notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING, |
1410 | 1404 |
newSessionCode, mode).isCanceled()) { |
1411 | 1405 |
return; |
... | ... | |
3383 | 3377 |
if (this.transforms.hasDynValue(name)) { |
3384 | 3378 |
return true; |
3385 | 3379 |
} |
3380 |
if (this.provider.hasDynValue(name)) { |
|
3381 |
return true; |
|
3382 |
} |
|
3383 |
if (METADATA_PROVIDER.equalsIgnoreCase(name)) { |
|
3384 |
return true; |
|
3385 |
} else if (METADATA_CONTAINERNAME.equalsIgnoreCase(name)) { |
|
3386 |
return true; |
|
3387 |
} else if (METADATA_FEATURETYPE.equalsIgnoreCase(name)) { |
|
3388 |
return true; |
|
3389 |
} |
|
3386 | 3390 |
return this.metadata.hasDynValue(name); |
3387 | 3391 |
} |
3388 | 3392 |
|
... | ... | |
4046 | 4050 |
return false; |
4047 | 4051 |
} |
4048 | 4052 |
} |
4053 |
|
|
4054 |
public boolean canBeEdited() { |
|
4055 |
return this.transforms.isEmpty(); |
|
4056 |
} |
|
4049 | 4057 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFetureStore.java | ||
---|---|---|
985 | 985 |
public FeatureSelection getFeatureSelectionQuietly() { |
986 | 986 |
return null; |
987 | 987 |
} |
988 |
|
|
989 |
@Override |
|
990 |
public boolean canBeEdited() { |
|
991 |
return true; |
|
992 |
} |
|
988 | 993 |
|
989 | 994 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureStoreTransform.java | ||
---|---|---|
128 | 128 |
* @throws Exception |
129 | 129 |
*/ |
130 | 130 |
public void setUp() throws Exception ; |
131 |
|
|
132 |
public void apply(FeatureStore store); |
|
133 |
|
|
134 |
public void revoke(FeatureStore store); |
|
131 | 135 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/AbstractFeatureStoreTransform.java | ||
---|---|---|
24 | 24 |
package org.gvsig.fmap.dal.feature; |
25 | 25 |
|
26 | 26 |
import java.util.ArrayList; |
27 |
import java.util.HashMap; |
|
27 | 28 |
import java.util.List; |
29 |
import java.util.Map; |
|
28 | 30 |
import org.apache.commons.lang3.StringUtils; |
31 |
import org.gvsig.fmap.dal.DataStore; |
|
29 | 32 |
|
30 | 33 |
import org.gvsig.fmap.dal.exception.DataException; |
31 | 34 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
67 | 70 |
|
68 | 71 |
private DynObject originalMetadata = null; |
69 | 72 |
|
73 |
private final Map<String, Object> metadataValues = new HashMap<>(); |
|
74 |
|
|
70 | 75 |
public AbstractFeatureStoreTransform() { |
71 | 76 |
this(null, ""); |
72 | 77 |
} |
... | ... | |
163 | 168 |
|
164 | 169 |
@Override |
165 | 170 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
166 |
throw new DynFieldNotFoundException(name, "transform"); |
|
171 |
if(metadataValues.containsKey(name)) { |
|
172 |
return metadataValues.get(name); |
|
173 |
} |
|
174 |
return null; |
|
167 | 175 |
} |
168 | 176 |
|
169 | 177 |
@Override |
170 | 178 |
public boolean hasDynValue(String name) { |
179 |
if(metadataValues.containsKey(name)) { |
|
180 |
return true; |
|
181 |
} |
|
171 | 182 |
return false; |
172 | 183 |
} |
173 |
|
|
184 |
|
|
174 | 185 |
@Override |
175 | 186 |
public void setDynValue(String name, Object value) |
176 | 187 |
throws DynFieldNotFoundException { |
177 |
throw new DynFieldNotFoundException(name, "transform");
|
|
188 |
metadataValues.put(name, value);
|
|
178 | 189 |
} |
179 |
|
|
190 |
|
|
180 | 191 |
@Override |
181 | 192 |
public Object clone() throws CloneNotSupportedException { |
182 | 193 |
return super.clone(); |
183 | 194 |
|
184 | 195 |
} |
185 | 196 |
|
197 |
@Override |
|
198 |
public void apply(FeatureStore store) { |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
202 |
public void revoke(FeatureStore store) { |
|
203 |
} |
|
204 |
|
|
186 | 205 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureStore.java | ||
---|---|---|
1426 | 1426 |
|
1427 | 1427 |
public Iterable<Feature> getFeaturesIterable(Iterator<FeatureReference> references); |
1428 | 1428 |
|
1429 |
public boolean canBeEdited(); |
|
1430 |
|
|
1431 |
|
|
1429 | 1432 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/SHPStoreProvider.java | ||
---|---|---|
139 | 139 |
return super.getDynValue(name); |
140 | 140 |
} |
141 | 141 |
|
142 |
@Override |
|
143 |
public boolean hasDynValue(String name) throws DynFieldNotFoundException { |
|
144 |
if (DataStore.METADATA_CRS.equalsIgnoreCase(name)) { |
|
145 |
|
|
146 |
return this.getShpParameters().getCRS() != null; |
|
147 |
|
|
148 |
} else if (DataStore.METADATA_ENVELOPE.equalsIgnoreCase(name)) { |
|
149 |
try { |
|
150 |
return this.shpFile.getFullExtent() != null; |
|
151 |
} catch (ReadException e) { |
|
152 |
return false; |
|
153 |
} |
|
154 |
} |
|
155 |
return super.hasDynValue(name); |
|
156 |
} |
|
157 |
|
|
142 | 158 |
protected void initResource(DBFStoreParameters params, DataStoreProviderServices storeServices) |
143 | 159 |
throws InitializeException { |
144 | 160 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.join/src/main/java/org/gvsig/app/join/dal/feature/JoinTransform.java | ||
---|---|---|
33 | 33 |
import java.util.Objects; |
34 | 34 |
import java.util.logging.Level; |
35 | 35 |
import org.apache.commons.lang3.StringUtils; |
36 |
import org.gvsig.fmap.dal.DataStore; |
|
36 | 37 |
import org.gvsig.fmap.dal.DataTypes; |
37 | 38 |
|
38 | 39 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
53 | 54 |
import org.gvsig.tools.dataTypes.CoercionException; |
54 | 55 |
import org.gvsig.tools.dataTypes.DataType; |
55 | 56 |
import org.gvsig.tools.dispose.DisposableIterator; |
57 |
import org.gvsig.tools.dynobject.DynObject; |
|
56 | 58 |
import org.gvsig.tools.dynobject.DynStruct; |
59 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
57 | 60 |
import org.gvsig.tools.evaluator.Evaluator; |
58 | 61 |
import org.gvsig.tools.evaluator.EvaluatorData; |
59 | 62 |
import org.gvsig.tools.evaluator.EvaluatorException; |
... | ... | |
119 | 122 |
private String prefix2; |
120 | 123 |
|
121 | 124 |
private CoercionContext attr1Context; |
125 |
private boolean hasGeometryAdded; |
|
126 |
private Object previousMetadataEnvelope; |
|
122 | 127 |
|
123 | 128 |
/** |
124 | 129 |
* A default constructor |
... | ... | |
126 | 131 |
public JoinTransform() { |
127 | 132 |
store1NamesMap = new HashMap<>(); |
128 | 133 |
store2NamesMap = new HashMap<>(); |
134 |
this.hasGeometryAdded = false; |
|
129 | 135 |
} |
130 | 136 |
|
131 | 137 |
/** |
... | ... | |
278 | 284 |
if( (prefix != null) && (!prefix.equals("")) ) { |
279 | 285 |
attName = prefix + "_" + attName; |
280 | 286 |
} |
287 |
|
|
288 |
FeatureAttributeDescriptor geomAttr = targetFeatureType.getDefaultGeometryAttribute(); |
|
281 | 289 |
|
282 | 290 |
// If an attribute already exists, calculate an alternate name and add it to our type |
283 | 291 |
int j = 0; |
... | ... | |
292 | 300 |
editableFeatureAttributeDescriptor.setScale(featureAttributeDescriptor.getScale()); |
293 | 301 |
if( featureAttributeDescriptor.getType() == DataTypes.GEOMETRY ) { |
294 | 302 |
editableFeatureAttributeDescriptor.setGeometryType(featureAttributeDescriptor.getGeomType()); |
303 |
if(geomAttr == null) { |
|
304 |
this.hasGeometryAdded = true; |
|
305 |
} |
|
295 | 306 |
} |
296 | 307 |
// keep correspondence between original name and transformed name |
297 | 308 |
storeMap.put(featureAttributeDescriptor.getName(), attName); |
... | ... | |
556 | 567 |
attrs = (String[]) state.getArray("attrs", String.class); |
557 | 568 |
} |
558 | 569 |
|
570 |
// @Override |
|
571 |
// public void apply(FeatureStore store) { |
|
572 |
// super.apply(store); |
|
573 |
// if(hasGeometryAdded){ |
|
574 |
// try { |
|
575 |
// this.previousMetadataEnvelope = this.getSourceMetadata().getDynValue(DataStore.METADATA_ENVELOPE); |
|
576 |
// this.getSourceMetadata().setDynValue(DataStore.METADATA_ENVELOPE, this.store2.getEnvelope()); |
|
577 |
// } catch (DataException ex) { |
|
578 |
// logger.warn("Can't calculate envelope of transform '"+DataStore.getNameQuietly(this.getFeatureStore())+"'", ex); |
|
579 |
// } |
|
580 |
// } |
|
581 |
// } |
|
582 |
// |
|
583 |
// @Override |
|
584 |
// public void revoke(FeatureStore store) { |
|
585 |
// super.revoke(store); |
|
586 |
// this.getSourceMetadata().setDynValue(DataStore.METADATA_ENVELOPE, this.previousMetadataEnvelope); |
|
587 |
// } |
|
588 |
|
|
589 |
@Override |
|
590 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
|
591 |
if(super.hasDynValue(name)) { |
|
592 |
return super.getDynValue(name); |
|
593 |
} |
|
594 |
switch(name){ |
|
595 |
case DataStore.METADATA_ENVELOPE: |
|
596 |
case DataStore.METADATA_CRS: |
|
597 |
if(hasGeometryAdded){ |
|
598 |
return this.store2.getDynValue(name); |
|
599 |
} |
|
600 |
break; |
|
601 |
} |
|
602 |
return null; |
|
603 |
} |
|
604 |
|
|
605 |
@Override |
|
606 |
public boolean hasDynValue(String name) { |
|
607 |
if(super.hasDynValue(name)) { |
|
608 |
return true; |
|
609 |
} |
|
610 |
switch(name){ |
|
611 |
case DataStore.METADATA_ENVELOPE: |
|
612 |
case DataStore.METADATA_CRS: |
|
613 |
if(hasGeometryAdded){ |
|
614 |
return this.store2.hasDynValue(name); |
|
615 |
} |
|
616 |
default: |
|
617 |
return false; |
|
618 |
} |
|
619 |
} |
|
620 |
|
|
559 | 621 |
} |
Also available in: Unified diff