Revision 44270 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/service/ExportJDBCService.java
ExportJDBCService.java | ||
---|---|---|
27 | 27 |
import org.apache.commons.lang3.StringUtils; |
28 | 28 |
import org.cresques.cts.ICoordTrans; |
29 | 29 |
import org.cresques.cts.IProjection; |
30 |
import org.gvsig.export.ExportAttributes; |
|
30 | 31 |
|
31 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
32 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
... | ... | |
106 | 107 |
FeatureStoreProviderFactory factory = (FeatureStoreProviderFactory) manager.getStoreProviderFactory(explorer.getStoreName()); |
107 | 108 |
|
108 | 109 |
boolean preferNotToUseNonNullRestrictions = factory.preferNotToUseNonNullRestrictions(); |
110 |
ExportAttributes exportAttributes = getParameters().getExportAttributes(); |
|
109 | 111 |
|
110 |
targetTempFeatureType = getParameters().getSourceFeatureType().getCopy();
|
|
112 |
targetTempFeatureType = exportAttributes.getTargetFeatureType().getCopy();
|
|
111 | 113 |
targetEditableFeatureType = targetTempFeatureType.getEditable(); |
112 | 114 |
|
113 | 115 |
// Remove inherited primary keys from the data source and remove NotNull |
114 | 116 |
// restrictions if proceed. |
115 | 117 |
for (int i = 0; i < targetEditableFeatureType.size(); i++) { |
116 |
EditableFeatureAttributeDescriptor x = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i);
|
|
117 |
x.setIsPrimaryKey(false);
|
|
118 |
EditableFeatureAttributeDescriptor eAttr = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i);
|
|
119 |
eAttr.setIsPrimaryKey(false);
|
|
118 | 120 |
if( preferNotToUseNonNullRestrictions ) { |
119 |
x.setAllowNull(true);
|
|
121 |
eAttr.setAllowNull(true);
|
|
120 | 122 |
} |
121 | 123 |
} |
122 | 124 |
|
... | ... | |
124 | 126 |
|| this.getParameters().getRemoveSpacesInIdentifiers() |
125 | 127 |
|| this.getParameters().getTranslateHyphens()) { |
126 | 128 |
for (int i = 0; i < targetEditableFeatureType.size(); i++) { |
127 |
EditableFeatureAttributeDescriptor x = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i); |
|
128 |
x.setName(getTranslatedIdentifier(x.getName())); |
|
129 |
EditableFeatureAttributeDescriptor eAttr = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i); |
|
130 |
String identifier = eAttr.getName(); |
|
131 |
String translatedIdentifier = getTranslatedIdentifier(identifier); |
|
132 |
eAttr.setName(translatedIdentifier); |
|
133 |
String sourceField = exportAttributes.getSourceName(identifier); |
|
134 |
exportAttributes.getExportAttribute(sourceField).setNewName(translatedIdentifier); |
|
129 | 135 |
} |
130 | 136 |
} |
131 | 137 |
|
... | ... | |
320 | 326 |
// geometria o tenga mas de una. |
321 | 327 |
targetFeature.set(targetGeometryIndex, feature.get(sourceGeometryIndex)); |
322 | 328 |
} else { |
323 |
FeatureAttributeDescriptor x = theSourceFeatureType.getAttributeDescriptor(i); |
|
324 |
int targetAttributeIndex = theTargetFeatureType.getIndex(getTranslatedIdentifier(x.getName())); |
|
329 |
FeatureAttributeDescriptor sourceField = theSourceFeatureType.getAttributeDescriptor(i); |
|
330 |
// String name = getTranslatedIdentifier(x.getName()); |
|
331 |
String targetField = this.getParameters().getExportAttributes().getTargetName(sourceField.getName()); |
|
332 |
int targetAttributeIndex = theTargetFeatureType.getIndex(targetField); |
|
325 | 333 |
if (targetAttributeIndex < 0) { |
326 |
throw new RuntimeException("Can't locate column '" + x.getName() + "' in the target table."); |
|
334 |
continue; |
|
335 |
//throw new RuntimeException("Can't locate column '" + x.getName() + "' in the target table."); |
|
327 | 336 |
} |
328 |
targetFeature.set(targetAttributeIndex, feature.get(x.getName()));
|
|
337 |
targetFeature.set(targetAttributeIndex, feature.get(sourceField.getName()));
|
|
329 | 338 |
} |
330 | 339 |
} |
331 | 340 |
|
Also available in: Unified diff