Revision 44395 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/AbstractExportService.java

View differences:

AbstractExportService.java
110 110
//        }
111 111
//        return this.attributeNamesTranslator;
112 112
//    }
113

  
114 113
    @Override
115 114
    public List<OpenDataStoreParameters> getTargetOpenStoreParameters() throws ExportException {
116 115
        List<OpenDataStoreParameters> r = new ArrayList<>();
......
151 150
            dataManager.newStore(explorerName, providerName, newStoreParameters, true);
152 151
            target = (FeatureStore) dataManager.openStore(providerName, openStoreParameters);
153 152

  
154
            FeatureType theTargetFeatureType = this.getParameters().getExportAttributes().getTargetFeatureType();//target.getDefaultFeatureType();
153
            FeatureType theTargetFeatureType;
154
            if (this.getParameters().getExportAttributes().isActive()) {
155
                theTargetFeatureType = this.getParameters().getExportAttributes().getTargetFeatureType();
156
            } else {
157
                theTargetFeatureType = target.getDefaultFeatureType();
158
            }
155 159
            FeatureType theSourceFeatureType = featureSet.getDefaultFeatureType();
156 160

  
157 161
            ExportGeometryHelper geomHelper = null;
......
170 174
            target.edit(FeatureStore.MODE_APPEND);
171 175
            it = featureSet.fastIterator();
172 176

  
173
            long featureCount = 0;
177
            long featureCount = 1;
174 178
            while (it.hasNext()) {
175 179
                this.getTaskStatus().setCurValue(featureCount);
176 180

  
......
214 218
    protected void copyValues(Feature source, EditableFeature target) {
215 219
        FeatureType sourceType = source.getType();
216 220
        FeatureType targetType = target.getType();
221
        ExportAttributes exp = this.getParameters().getExportAttributes();
222
        boolean isActive = exp.isActive();
217 223
        for (FeatureAttributeDescriptor targetAttr : targetType) {
218 224
            if (targetAttr.isReadOnly() || targetAttr.isComputed()) {
219 225
                continue;
220 226
            }
221 227
            String targetAttrName = targetAttr.getName();
222 228
            //translate field
223
            String sourceAttrName = getParameters().getExportAttributes().getSourceName(targetAttrName);
224
            ExportAttributes exp = this.getParameters().getExportAttributes();
225
            for (ExportAttributes.ExportAttribute exportAttribute : exp) {
226
                if (StringUtils.equals(exportAttribute.getNewName(),targetAttrName)) {
227
                    sourceAttrName = exportAttribute.getName();
229
            FeatureAttributeDescriptor sourceAttr;
230
            String sourceAttrName;
231
            if (isActive) {
232
                sourceAttrName = exp.getSourceName(targetAttrName);
233
                for (ExportAttributes.ExportAttribute exportAttribute : exp) {
234
                    if (StringUtils.equals(exportAttribute.getNewName(), targetAttrName)) {
235
                        sourceAttrName = exportAttribute.getName();
236
                    }
228 237
                }
238

  
239
                sourceAttr = sourceType.getAttributeDescriptor(sourceAttrName);
240
            } else {
241
                sourceAttrName = targetAttrName;
242
                sourceAttr = sourceType.getAttributeDescriptor(targetAttrName);
229 243
            }
230

  
231
            FeatureAttributeDescriptor sourceAttr = sourceType.getAttributeDescriptor(sourceAttrName);
232 244
            if (sourceAttr != null) {
233 245
                Object value = source.get(sourceAttrName);
234 246
                if (value == null) {

Also available in: Unified diff