Revision 44406
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/export/impl/DefaultExportProcess.java | ||
---|---|---|
1 | 1 |
package org.gvsig.export.impl; |
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 |
import java.util.Objects; |
|
5 |
import javax.swing.JOptionPane; |
|
4 | 6 |
import org.cresques.cts.ICoordTrans; |
5 | 7 |
import org.cresques.cts.IProjection; |
6 | 8 |
import org.gvsig.export.ExportException; |
... | ... | |
15 | 17 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
16 | 18 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
17 | 19 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
20 |
import org.gvsig.tools.ToolsLocator; |
|
21 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
18 | 22 |
import org.gvsig.tools.task.TaskStatus; |
19 | 23 |
|
20 | 24 |
/** |
... | ... | |
68 | 72 |
this.service = this.factory.createService(this.parameters); |
69 | 73 |
this.parameters.setSourceFeatureStore(this.sourceFeatureStore); |
70 | 74 |
this.parameters.setContext(this.context); |
71 |
|
|
75 |
|
|
72 | 76 |
this.featuresToUse = this.parameters.getFeaturesToUse(); |
73 |
this.filterExpression = this.parameters.getFilterExpresion(); |
|
77 |
if (Objects.equals(this.filterExpression, this.parameters.getFilterExpresion())) { |
|
78 |
int keepFilter = ToolsSwingLocator.getThreadSafeDialogsManager().confirmDialog( |
|
79 |
ToolsLocator.getI18nManager().getTranslation("_Do_you_want_to_keep_the_applied_filter_and_not_use_the_one_in_the_parameters"), |
|
80 |
ToolsLocator.getI18nManager().getTranslation("_Filter_to_apply"), |
|
81 |
JOptionPane.YES_NO_OPTION, |
|
82 |
JOptionPane.WARNING_MESSAGE, |
|
83 |
"exporto-overwrite-expression-parameters"); |
|
84 |
if (keepFilter == JOptionPane.YES_OPTION) { |
|
85 |
this.parameters.setFilterExpresion(this.filterExpression); |
|
86 |
} else { |
|
87 |
this.filterExpression = this.parameters.getFilterExpresion(); |
|
88 |
} |
|
89 |
} else { |
|
90 |
this.filterExpression = this.parameters.getFilterExpresion(); |
|
91 |
} |
|
92 |
|
|
74 | 93 |
if (this.parameters instanceof ExportParametersGeometry) { |
75 | 94 |
ExportParametersGeometry pa = (ExportParametersGeometry) this.parameters; |
76 | 95 |
this.contextProjection = pa.getContextProjection(); |
77 | 96 |
this.sourceProjection = pa.getSourceProjection(); |
78 | 97 |
this.sourceTransformation = pa.getSourceTransformation(); |
98 |
|
|
79 | 99 |
} |
80 | 100 |
} |
81 |
|
|
101 |
|
|
82 | 102 |
@Override |
83 |
public void setSourceFeatureStore(FeatureStore store) { |
|
103 |
public void setSourceFeatureStore(FeatureStore store |
|
104 |
) { |
|
84 | 105 |
this.sourceFeatureStore = store; |
85 | 106 |
if (this.parameters != null) { |
86 | 107 |
this.parameters.setSourceFeatureStore(sourceFeatureStore); |
... | ... | |
88 | 109 |
} |
89 | 110 |
|
90 | 111 |
@Override |
91 |
public void setContextProjection(IProjection projection) { |
|
112 |
public void setContextProjection(IProjection projection |
|
113 |
) { |
|
92 | 114 |
this.contextProjection = projection; |
93 | 115 |
if (this.parameters instanceof ExportParametersGeometry) { |
94 | 116 |
((ExportParametersGeometry) this.parameters).setContextProjection(projection); |
... | ... | |
96 | 118 |
} |
97 | 119 |
|
98 | 120 |
@Override |
99 |
public void setSourceTransformation(ICoordTrans transformation) { |
|
121 |
public void setSourceTransformation(ICoordTrans transformation |
|
122 |
) { |
|
100 | 123 |
this.sourceTransformation = transformation; |
101 | 124 |
if (this.parameters instanceof ExportParametersGeometry) { |
102 | 125 |
((ExportParametersGeometry) this.parameters).setSourceTransformation(transformation); |
... | ... | |
104 | 127 |
} |
105 | 128 |
|
106 | 129 |
@Override |
107 |
public void setSourceProjection(IProjection projection) { |
|
130 |
public void setSourceProjection(IProjection projection |
|
131 |
) { |
|
108 | 132 |
this.sourceProjection = projection; |
109 | 133 |
if (this.parameters instanceof ExportParametersGeometry) { |
110 | 134 |
((ExportParametersGeometry) this.parameters).setSourceProjection(projection); |
... | ... | |
117 | 141 |
} |
118 | 142 |
|
119 | 143 |
@Override |
120 |
public void setContext(Object context) { |
|
144 |
public void setContext(Object context |
|
145 |
) { |
|
121 | 146 |
this.context = context; |
122 | 147 |
if (this.parameters != null) { |
123 | 148 |
this.parameters.setContext(context); |
... | ... | |
178 | 203 |
} |
179 | 204 |
|
180 | 205 |
@Override |
181 |
public void setFilterExpression(Expression expression) { |
|
206 |
public void setFilterExpression(Expression expression |
|
207 |
) { |
|
182 | 208 |
this.filterExpression = expression; |
183 | 209 |
if (this.parameters != null) { |
184 | 210 |
this.parameters.setFilterExpresion(expression); |
... | ... | |
191 | 217 |
} |
192 | 218 |
|
193 | 219 |
@Override |
194 |
public void setFeaturesToUse(int featuresToUse) { |
|
220 |
public void setFeaturesToUse(int featuresToUse |
|
221 |
) { |
|
195 | 222 |
this.featuresToUse = featuresToUse; |
196 | 223 |
if (this.parameters != null) { |
197 | 224 |
this.parameters.setFeaturesToUse(featuresToUse); |
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/AbstractExportParameters.java | ||
---|---|---|
10 | 10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 | 11 |
import org.gvsig.export.ExportParameters; |
12 | 12 |
import org.gvsig.expressionevaluator.Expression; |
13 |
import org.slf4j.Logger; |
|
14 |
import org.slf4j.LoggerFactory; |
|
13 | 15 |
|
14 | 16 |
/** |
15 | 17 |
* |
... | ... | |
24 | 26 |
protected ExportAttributes exportAttributes = null; |
25 | 27 |
private Date date = new Date(); |
26 | 28 |
private final ExportServiceFactory factory; |
29 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractExportParameters.class); |
|
27 | 30 |
|
28 | 31 |
public AbstractExportParameters(ExportServiceFactory factory) { |
29 | 32 |
this.factory = factory; |
... | ... | |
168 | 171 |
public ExportServiceFactory getFactory() { |
169 | 172 |
return this.factory; |
170 | 173 |
} |
174 |
|
|
175 |
@Override |
|
176 |
public FeatureType getTargetFeatureType() { |
|
177 |
if (this.getExportAttributes()==null) { |
|
178 |
LOGGER.warn("Not been able to get target feature type from export attributes because it's null"); |
|
179 |
return null; |
|
180 |
} |
|
181 |
return this.getExportAttributes().getTargetFeatureType(); |
|
182 |
} |
|
171 | 183 |
|
172 | 184 |
} |
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/ExportParameters.java | ||
---|---|---|
52 | 52 |
public ExportParameters clone() throws CloneNotSupportedException; |
53 | 53 |
|
54 | 54 |
public ExportServiceFactory getFactory(); |
55 |
|
|
56 |
public FeatureType getTargetFeatureType(); |
|
55 | 57 |
|
56 | 58 |
} |
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.shape/src/main/java/org/gvsig/export/shape/service/ExportShapeService.java | ||
---|---|---|
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.List; |
6 | 6 |
import org.apache.commons.io.FilenameUtils; |
7 |
import org.apache.commons.lang3.StringUtils; |
|
7 | 8 |
import org.cresques.cts.ICoordTrans; |
8 | 9 |
import org.cresques.cts.IProjection; |
9 | 10 |
import org.gvsig.export.ExportException; |
10 | 11 |
import org.gvsig.export.spi.AbstractExportService; |
11 | 12 |
import org.gvsig.export.spi.ExportService; |
12 | 13 |
import org.gvsig.export.spi.ExportServiceFactory; |
14 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
13 | 15 |
import org.gvsig.fmap.dal.DALLocator; |
14 | 16 |
import org.gvsig.fmap.dal.DataManager; |
15 | 17 |
import org.gvsig.fmap.dal.DataServerExplorer; |
... | ... | |
85 | 87 |
} catch (Exception e) { |
86 | 88 |
throw new ExportException(e); |
87 | 89 |
} |
88 |
explorerParams.setRoot(this.getParameters().getFile().getParent()); |
|
90 |
File parametersFile = ExpressionUtils.evaluateFilename(this.getParameters().getFile()); |
|
91 |
explorerParams.setRoot(parametersFile.getParent()); |
|
89 | 92 |
|
90 | 93 |
FilesystemServerExplorer explorer; |
91 | 94 |
try { |
... | ... | |
103 | 106 |
try { |
104 | 107 |
FilesystemServerExplorer explorer = (FilesystemServerExplorer) this.createServerExplorer(); |
105 | 108 |
NewFeatureStoreParameters newStoreParameters = (NewFeatureStoreParameters) explorer.getAddParameters( |
106 |
this.getParameters().getFile()
|
|
109 |
ExpressionUtils.evaluateFilename(this.getParameters().getFile())
|
|
107 | 110 |
); |
108 | 111 |
newStoreParameters.setDynValue("Encoding", this.getParameters().getEncoding()); |
109 | 112 |
newStoreParameters.setDynValue("CRS", this.getParameters().getTargetProjection()); |
110 | 113 |
FeatureType ft; |
111 | 114 |
if (this.getParameters().getExportAttributes() != null) { |
112 | 115 |
ft = this.getParameters().getExportAttributes().getTargetFeatureType(); |
113 |
|
|
114 | 116 |
} else { |
115 | 117 |
ft = this.getParameters().getSourceFeatureType(); |
116 | 118 |
} |
... | ... | |
145 | 147 |
@Override |
146 | 148 |
public void export(FeatureSet featureSet) throws ExportException { |
147 | 149 |
|
148 |
File parametersFile = this.getParameters().getFile();
|
|
150 |
File parametersFile = ExpressionUtils.evaluateFilename(this.getParameters().getFile());
|
|
149 | 151 |
String pathName = FilenameUtils.removeExtension(parametersFile.getAbsolutePath()); |
150 | 152 |
|
151 | 153 |
int geometryType = this.getParameters().getTargetGeometryTypeAsInt(); |
... | ... | |
233 | 235 |
} |
234 | 236 |
|
235 | 237 |
geomFieldDescTarget.setGeometryType(gty); |
236 |
geomFieldDescTarget.setName(this.getParameters().getExportAttributes().getTargetName("GEOMETRY")); |
|
238 |
String newGeometryFieldName; |
|
239 |
if (this.getParameters().getExportAttributes().getTargetName("GEOMETRY")==null) { |
|
240 |
newGeometryFieldName = "GEOMETRY"; |
|
241 |
} else { |
|
242 |
newGeometryFieldName = this.getParameters().getExportAttributes().getTargetName("GEOMETRY"); |
|
243 |
} |
|
244 |
geomFieldDescTarget.setName(newGeometryFieldName); |
|
237 | 245 |
type.setDefaultGeometryAttributeName(geomFieldDescTarget.getName()); |
238 | 246 |
|
239 | 247 |
// ========================== |
240 |
fixNames(type); |
|
248 |
//fixNames(type);
|
|
241 | 249 |
// ========================== |
242 | 250 |
|
243 | 251 |
params.setDefaultFeatureType(type.getNotEditableCopy()); |
... | ... | |
396 | 404 |
private void fixNames(EditableFeatureType eft) { |
397 | 405 |
|
398 | 406 |
FeatureAttributeDescriptor[] atts = eft.getAttributeDescriptors(); |
399 |
EditableFeatureAttributeDescriptor efad;
|
|
407 |
String defaultGeometryField = eft.getDefaultGeometryAttributeName();
|
|
400 | 408 |
for (FeatureAttributeDescriptor att : atts) { |
401 | 409 |
String new_name = this.getParameters().getExportAttributes().getTargetName(att.getName()); |
402 | 410 |
if (new_name != null) { |
403 |
eft.remove(att.getName()); |
|
404 |
efad = eft.add(new_name, att.getType(), att.getSize()); |
|
411 |
//efad = eft.add(new_name, att.getType(), att.getSize()); |
|
412 |
EditableFeatureAttributeDescriptor efad = eft.getEditableAttributeDescriptor(att.getName()); |
|
413 |
efad.setName(new_name); |
|
414 |
efad.setType(att.getDataType()); |
|
415 |
efad.setSize(att.getSize()); |
|
405 | 416 |
efad.setPrecision(att.getPrecision()); |
417 |
|
|
406 | 418 |
if (att.getDataType().getType() == DataTypes.GEOMETRY) { |
407 | 419 |
efad.setGeometryType(att.getGeomType()); |
420 |
if (StringUtils.equals(defaultGeometryField, att.getName())) { |
|
421 |
eft.setDefaultGeometryAttributeName(new_name); |
|
422 |
} |
|
408 | 423 |
} |
409 | 424 |
} |
410 | 425 |
} |
411 | 426 |
} |
412 |
|
|
427 |
|
|
413 | 428 |
/** |
414 | 429 |
* @param gitem |
415 | 430 |
* @param geometryType2 |
Also available in: Unified diff