Revision 46875 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
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