Revision 43722

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/FeatureManager.java
166 166
       	return getCorrectFeature(feature, store,featureType);
167 167
    }
168 168

  
169
    private Feature getCorrectFeature(Feature feature, FeatureStore store,
170
			FeatureType featureType) throws DataException {
171
    	 Iterator iterator=featureType.iterator();
172
         EditableFeature newFeature;
173
//         newFeature = feature.getEditable();
174
         newFeature = store.createNewFeature(featureType, false);
175
         FeatureType orgType = feature.getType();
176
         int orgIndex;
177
         while (iterator.hasNext()) {
178
 			FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) iterator.next();
179
 			orgIndex = orgType.getIndex(fad.getName());
180
 			if (orgIndex<0){
181
 				continue;
182
 			}
183
 			if (fad.isAutomatic() || fad.isReadOnly()
184
					|| fad.getEvaluator() != null) {
185
				continue;
186
			}
187
 			Object value = feature.get(orgIndex);
188
			if (value == null && !fad.allowNull()) {
189
				continue;
190
			}
191
			newFeature.set(orgIndex, value);
192
 		}
193
        return newFeature.getNotEditableCopy();
194
	}
169
    private Feature getCorrectFeature(
170
            Feature feature, 
171
            FeatureStore store,
172
            FeatureType featureType
173
        ) throws DataException {
195 174

  
175
        Feature sourceFeature = feature;
176
        FeatureType sourceType = sourceFeature.getType();
177
        
178
        FeatureType targetType = featureType;
179
        EditableFeature targetFeature = store.createNewFeature(featureType, false);
180
        
181
        for (FeatureAttributeDescriptor targetAttrDescriptor : targetType) {
182
            if ( targetAttrDescriptor.isAutomatic() || 
183
                 targetAttrDescriptor.isReadOnly() || 
184
                 targetAttrDescriptor.getEvaluator() != null) {
185
                 continue;
186
            }
187
            int sourceIndex = sourceType.getIndex(targetAttrDescriptor.getName());
188
            if (sourceIndex<0){
189
                continue;
190
            }
191
            Object value = sourceFeature.get(sourceIndex);
192
            if (value == null && !targetAttrDescriptor.allowNull()) {
193
                continue;
194
            }
195
            targetFeature.set(targetAttrDescriptor.getIndex(),value);
196
        }
197
        return targetFeature.getNotEditableCopy();        
198
    }
199

  
196 200
	/**
197 201
     * DOCUMENT ME!
198 202
     *

Also available in: Unified diff