Revision 44610

View differences:

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
2461 2461
    public EditableFeature createNewFeature(Feature defaultValues) throws DataException {
2462 2462
        FeatureType ft = this.getDefaultFeatureType();
2463 2463
        EditableFeature f = this.createNewFeature(ft, false);
2464
		for( FeatureAttributeDescriptor desc : ft ) {
2465
			try {
2466
				f.set(desc.getName(), defaultValues.get(desc.getName()));
2467
			} catch(Throwable th) {
2468
				// Ignore
2469
			}
2470
		}
2464
        f.copyFrom(defaultValues);
2471 2465
        return f;
2472 2466
    }
2473 2467

  
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
243 243
    public void copyFrom(Feature source) {
244 244
        // iterate over the attributes and copy one by one
245 245
        FeatureType sourceType = source.getType();
246
        Iterator it = this.getType().iterator();
247
        while ( it.hasNext() ) {
248
            FeatureAttributeDescriptor attr = (FeatureAttributeDescriptor) it.next();
249
            if( sourceType.get(attr.getName())!=null ) {
250
                set(attr.getIndex(), source.get(attr.getName()));
246
        for (FeatureAttributeDescriptor attr : this.getType()) {
247
            if (attr==null || attr.isAutomatic() || attr.isReadOnly() || attr.isComputed() ) {
248
                continue;
251 249
            }
250
            Object value = source.get(attr.getName());
251
            if (value == null && !attr.allowNull()) {
252
                continue;
253
            }
254
            try {
255
                set(attr.getIndex(), value);
256
            } catch(Throwable th) {
257
                // Ignore
258
            }
252 259
        }
253 260
    }
254 261

  

Also available in: Unified diff