Revision 47594
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/DefaultEditableFeature.java | ||
---|---|---|
519 | 519 |
} |
520 | 520 |
|
521 | 521 |
@Override |
522 |
public void copyFrom(Feature source, Predicate<FeatureAttributeDescriptor> filter) {
|
|
523 |
copyFrom(source, filter, null);
|
|
522 |
public void copyFrom(Feature source, Predicate<FeatureAttributeDescriptor> copy) {
|
|
523 |
copyFrom(source, copy, null);
|
|
524 | 524 |
} |
525 | 525 |
|
526 | 526 |
@Override |
527 |
public void copyFrom(Feature source, Predicate<FeatureAttributeDescriptor> filter, Invocable onerror) {
|
|
527 |
public void copyFrom(Feature source, Predicate<FeatureAttributeDescriptor> copy, Invocable onerror) {
|
|
528 | 528 |
// iterate over the attributes and copy one by one |
529 | 529 |
if( source == null ) { |
530 | 530 |
throw new IllegalArgumentException("'source' argument can't be null"); |
531 | 531 |
} |
532 | 532 |
FeatureType sourceType = source.getType(); |
533 | 533 |
for (FeatureAttributeDescriptor attrTarget : this.getType()) { |
534 |
if( !canSetValue(attrTarget, filter) ) {
|
|
534 |
if( !canSetValue(attrTarget, copy) ) {
|
|
535 | 535 |
continue; |
536 | 536 |
} |
537 | 537 |
String attrname = attrTarget.getName(); |
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/DefaultFeature.java | ||
---|---|---|
181 | 181 |
return this.canSetValue(this.getType().getAttributeDescriptor(name), null); |
182 | 182 |
} |
183 | 183 |
|
184 |
public boolean canSetValue(FeatureAttributeDescriptor attr,Predicate<FeatureAttributeDescriptor> filter) {
|
|
184 |
public boolean canSetValue(FeatureAttributeDescriptor attr,Predicate<FeatureAttributeDescriptor> copy) {
|
|
185 | 185 |
// helper function to use in copyFrom |
186 | 186 |
if (attr==null ) { |
187 | 187 |
return false; |
... | ... | |
192 | 192 |
if( this.isInserted() && attr.isReadOnly()) { |
193 | 193 |
return false; |
194 | 194 |
} |
195 |
if( filter!=null && !filter.test(attr) ) {
|
|
195 |
if( copy!=null && !copy.test(attr) ) {
|
|
196 | 196 |
return false; |
197 | 197 |
} |
198 | 198 |
return true; |
Also available in: Unified diff