Revision 44411
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/java/org/gvsig/export/app/extension/ExportHistoryBookmarksExtension.java | ||
---|---|---|
1 |
package org.gvsig.export.app.extension; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashMap; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
import org.gvsig.andami.PluginServices; |
|
8 |
import org.gvsig.andami.PluginsLocator; |
|
9 |
import org.gvsig.andami.PluginsManager; |
|
10 |
import org.gvsig.andami.plugins.Extension; |
|
11 |
import org.gvsig.export.ExportLocator; |
|
12 |
import org.gvsig.export.ExportManager; |
|
13 |
import org.gvsig.export.ExportParameters; |
|
14 |
import org.gvsig.tools.bookmarksandhistory.Bookmark; |
|
15 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
|
16 |
import org.gvsig.tools.bookmarksandhistory.History; |
|
17 |
import org.gvsig.tools.dynobject.DynObject; |
|
18 |
|
|
19 |
/** |
|
20 |
* |
|
21 |
* @author osc |
|
22 |
*/ |
|
23 |
public class ExportHistoryBookmarksExtension extends Extension { |
|
24 |
|
|
25 |
@Override |
|
26 |
public void initialize() { |
|
27 |
loadExportHistoryParameters(); |
|
28 |
loadExportBookmarksParameters(); |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public void execute(String actionCommand) { |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public boolean isEnabled() { |
|
38 |
return true; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public boolean isVisible() { |
|
43 |
return true; |
|
44 |
} |
|
45 |
|
|
46 |
private void loadExportHistoryParameters() { |
|
47 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
48 |
final PluginServices plugin = pluginManager.getPlugin(this); |
|
49 |
final ExportManager exportManager = ExportLocator.getManager(); |
|
50 |
History<ExportParameters> history = exportManager.getHistory(); |
|
51 |
pluginManager.addShutdownTask("saveExportHistory", new Runnable() { |
|
52 |
@Override |
|
53 |
public void run() { |
|
54 |
DynObject properties = plugin.getPluginProperties(); |
|
55 |
ArrayList<ExportParameters> var = new ArrayList<>(); |
|
56 |
if (history == null) { |
|
57 |
return; |
|
58 |
} |
|
59 |
for (ExportParameters historyBookmark : history) { |
|
60 |
if (historyBookmark != null) { |
|
61 |
var.add(historyBookmark); |
|
62 |
} else { |
|
63 |
logger.warn("Trying to save history but value is null"); |
|
64 |
} |
|
65 |
} |
|
66 |
properties.setDynValue("exportHistory", var); |
|
67 |
} |
|
68 |
}, false, 100); |
|
69 |
DynObject pluginProperties = plugin.getPluginProperties(); |
|
70 |
List<ExportParameters> dynBookmarks = (List<ExportParameters>) pluginProperties.getDynValue("exportHistory"); |
|
71 |
if (dynBookmarks == null) { |
|
72 |
return; |
|
73 |
} |
|
74 |
for (ExportParameters exportParameters : dynBookmarks) { |
|
75 |
history.add(exportParameters); |
|
76 |
} |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
private void loadExportBookmarksParameters() { |
|
81 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
82 |
final PluginServices plugin = pluginManager.getPlugin(this); |
|
83 |
DynObject pluginProperties = plugin.getPluginProperties(); |
|
84 |
final ExportManager exportManager = ExportLocator.getManager(); |
|
85 |
Bookmarks<ExportParameters> bookmarks = exportManager.getBookmarks(); |
|
86 |
pluginManager.addShutdownTask("saveExportBookmarks", new Runnable() { |
|
87 |
@Override |
|
88 |
public void run() { |
|
89 |
DynObject properties = plugin.getPluginProperties(); |
|
90 |
Map<String, ExportParameters> var = new HashMap<>(); |
|
91 |
for (Bookmark<ExportParameters> exportBookmark : bookmarks) { |
|
92 |
ExportParameters value = exportBookmark.getValue(); |
|
93 |
if (value != null) { |
|
94 |
var.put(exportBookmark.getName(), value); |
|
95 |
} else { |
|
96 |
logger.warn("Trying to save bookmark but value is null"); |
|
97 |
} |
|
98 |
} |
|
99 |
properties.setDynValue("exportBookmarks", var); |
|
100 |
} |
|
101 |
}, false, 100); |
|
102 |
Map<String, ExportParameters> dynBookmarks = (Map<String, ExportParameters>) pluginProperties.getDynValue("exportBookmarks"); |
|
103 |
if (dynBookmarks == null) { |
|
104 |
return; |
|
105 |
} |
|
106 |
for (String key : dynBookmarks.keySet()) { |
|
107 |
ExportParameters bookmarkParameters = dynBookmarks.get(key); |
|
108 |
if (bookmarkParameters != null) { |
|
109 |
bookmarks.add(key, bookmarkParameters); |
|
110 |
} else { |
|
111 |
logger.warn("Trying to add bookmark but value is null"); |
|
112 |
} |
|
113 |
; |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/java/org/gvsig/export/app/extension/ExportTable.java | ||
---|---|---|
67 | 67 |
panel.addFinishListener(new ExportFinishListenerAdapter() { |
68 | 68 |
@Override |
69 | 69 |
public void finished(JExportProcessPanel exportPanel) { |
70 |
doAddTable(process);
|
|
70 |
doAddStore(process);
|
|
71 | 71 |
} |
72 | 72 |
}); |
73 | 73 |
JComponent component = panel.asJComponent(); |
... | ... | |
80 | 80 |
WindowManager.MODE.WINDOW |
81 | 81 |
); |
82 | 82 |
} |
83 |
|
|
83 | 84 |
|
84 |
private void doAddTable(ExportProcess process) {
|
|
85 |
public void doAddStore(ExportProcess process) {
|
|
85 | 86 |
ApplicationManager application = ApplicationLocator.getManager(); |
86 | 87 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
87 | 88 |
if (process.getTargetOpenStoreParameters()==null) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
1 | 1 |
<?xml version="1.0"?> |
2 | 2 |
<!-- |
3 | 3 |
Definitions of plugin persistence org.gvsig.exportto.app.extension. |
4 |
-->
|
|
4 |
--> |
|
5 | 5 |
<definitions> |
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.exportto.app.extension"> |
|
9 |
<description>Persistence of the Export plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="enabledProviders" type="Set" classOfItems="java.lang.String" mandatory="false"> |
|
12 |
<description>List of export to provider names enabled by the user</description> |
|
13 |
</field> |
|
14 |
<field name="disabledProviders" type="Set" classOfItems="java.lang.String" mandatory="false"> |
|
15 |
<description>List of export to provider names disabled by the user</description> |
|
16 |
</field> |
|
17 |
</fields> |
|
18 |
</class> |
|
19 |
</classes> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.exportto.app.extension"> |
|
9 |
<description>Persistence of the Export plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="enabledProviders" type="Set" classOfItems="java.lang.String" mandatory="false"> |
|
12 |
<description>List of export to provider names enabled by the user</description> |
|
13 |
</field> |
|
14 |
<field name="disabledProviders" type="Set" classOfItems="java.lang.String" mandatory="false"> |
|
15 |
<description>List of export to provider names disabled by the user</description> |
|
16 |
</field> |
|
17 |
<field name="exportBookmarks" type="Map" classOfItems="org.gvsig.export.ExportParameters" mandatory="false"> |
|
18 |
<description></description> |
|
19 |
</field> |
|
20 |
<field name="exportHistory" type="List" classOfItems="org.gvsig.export.ExportParameters" mandatory="false"> |
|
21 |
<description></description> |
|
22 |
</field> |
|
23 |
</fields> |
|
24 |
</class> |
|
25 |
</classes> |
|
20 | 26 |
</definitions> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
82 | 82 |
_Select_simplified_export=Selecci\u00f3n de exportaci\u00f3n simplificada |
83 | 83 |
_Use_simplified_export=Usar exportaci\u00f3n simplificada |
84 | 84 |
_Use_simplified_export_description=Usar exportaci\u00f3n simplificada permite exportar rapidamente un shape indicando \u00fanicamente el fichero de destino.\nSi desea seleccionar la codificaci\u00f3n o el campo geometria a usar, desactive el check de 'Usar exportaci\u00f3n simplificada'. |
85 |
_A_filter_is_already_applied_to_this_export_process=Un filtro ya est\u00e1 aplicado a este proceso de exportaci\u00f3n |
|
86 |
_Its_going_to_be_replace_by_the_filter_in_the_parameters=Va a ser reemplazado por el filtro de los parametros |
|
87 |
_Do_you_want_to_keep_the_applied_filter=\u00bfDesea mantener el filtro aplicado? |
|
88 |
_Filter_to_apply=Filtro a aplicar |
|
85 | 89 |
_Name=Nombre |
86 | 90 |
_New_name=Nuevo nombre |
87 | 91 |
_Size=Tama\u00f1o |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
84 | 84 |
_Select_simplified_export=Select simplified export |
85 | 85 |
_Use_simplified_export=Use simplified export |
86 | 86 |
_Use_simplified_export_description=Using simplified export allows you to quickly export a shape indicating only the destination file.\nIf you want to select the encoding or the geometry field to be used, uncheck the 'Use simplified export' check. |
87 |
_A_filter_is_already_applied_to_this_export_process=A filter is already applied to this export process |
|
88 |
_Its_going_to_be_replace_by_the_filter_in_the_parameters=it's going to be replace by the filter in the parameters |
|
89 |
_Do_you_want_to_keep_the_applied_filter=\u00bfDesea mantener el filtro aplicado? |
|
90 |
_Filter_to_apply=Filter to apply |
|
87 | 91 |
_Name=Name |
88 | 92 |
_New_name=New name |
89 | 93 |
_Size=Size |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
81 | 81 |
active="true" |
82 | 82 |
priority="1"> |
83 | 83 |
</extension> |
84 |
<extension class-name="org.gvsig.export.app.extension.ExportHistoryBookmarksExtension" |
|
85 |
description="Load and save history and bookmarks parameters for Export" |
|
86 |
active="true" |
|
87 |
priority="1"> |
|
88 |
</extension> |
|
84 | 89 |
</extensions> |
85 | 90 |
</plugin-config> |
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 | ||
---|---|---|
5 | 5 |
import org.gvsig.expressionevaluator.Expression; |
6 | 6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
7 | 7 |
import org.gvsig.fmap.dal.feature.FeatureType; |
8 |
import org.gvsig.tools.persistence.Persistent; |
|
8 | 9 |
import org.gvsig.tools.util.LabeledValue; |
9 | 10 |
|
10 | 11 |
/** |
11 | 12 |
* |
12 | 13 |
* @author jjdelcerro |
13 | 14 |
*/ |
14 |
public interface ExportParameters extends Cloneable, LabeledValue { |
|
15 |
public interface ExportParameters extends Cloneable, LabeledValue, Persistent {
|
|
15 | 16 |
|
16 | 17 |
public static final int USE_ALL_FEATURES = 0; |
17 | 18 |
public static final int USE_SELECTED_FEATURES = 1; |
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/ExportLibrary.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.export; |
25 | 25 |
|
26 |
import org.gvsig.export.spi.AbstractExportParameters; |
|
27 |
import org.gvsig.export.spi.AbstractExportParametersGeometry; |
|
28 |
import org.gvsig.export.spi.CutAttributeNamesTranslator; |
|
29 |
import org.gvsig.export.spi.DummyAttributeNamesTranslator; |
|
26 | 30 |
import org.gvsig.tools.library.AbstractLibrary; |
27 | 31 |
import org.gvsig.tools.library.LibraryException; |
28 | 32 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
... | ... | |
53 | 57 |
throw new ReferenceNotRegisteredException( |
54 | 58 |
ExportLocator.MANAGER_NAME, ExportLocator.getInstance()); |
55 | 59 |
} |
60 |
|
|
61 |
AbstractExportParameters.registerPersistence(); |
|
62 |
AbstractExportParametersGeometry.registerPersistence(); |
|
63 |
DummyAttributeNamesTranslator.registerPersistence(); |
|
64 |
CutAttributeNamesTranslator.registerPersistence(); |
|
65 |
|
|
56 | 66 |
} |
57 | 67 |
|
58 | 68 |
} |
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/ExportAttributes.java | ||
---|---|---|
10 | 10 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
11 | 11 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
12 | 12 |
import org.gvsig.fmap.dal.feature.FeatureType; |
13 |
import org.gvsig.tools.persistence.Persistent; |
|
13 | 14 |
import org.gvsig.tools.util.UnmodifiableBasicList; |
14 | 15 |
|
15 | 16 |
/** |
16 | 17 |
* |
17 | 18 |
* @author osc |
18 | 19 |
*/ |
19 |
public interface ExportAttributes extends UnmodifiableBasicList<ExportAttribute>, Cloneable { |
|
20 |
public interface ExportAttributes extends UnmodifiableBasicList<ExportAttribute>, Cloneable, Persistent {
|
|
20 | 21 |
|
21 | 22 |
public ExportAttributes clone() throws CloneNotSupportedException; |
22 | 23 |
|
... | ... | |
24 | 25 |
|
25 | 26 |
public boolean isActive(); |
26 | 27 |
|
27 |
public interface ExportAttribute extends Cloneable { |
|
28 |
public interface ExportAttribute extends Cloneable, Persistent {
|
|
28 | 29 |
|
29 | 30 |
public FeatureAttributeDescriptor getDescriptor(); |
30 | 31 |
|
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/AttributeNamesTranslator.java | ||
---|---|---|
1 | 1 |
package org.gvsig.export.spi; |
2 | 2 |
|
3 | 3 |
import org.gvsig.export.ExportAttributes; |
4 |
import org.gvsig.tools.persistence.Persistent; |
|
4 | 5 |
|
5 | 6 |
/** |
6 | 7 |
* This class provide the methods to translate the name of the fields |
... | ... | |
8 | 9 |
* This class should be state-less. |
9 | 10 |
* @author osc |
10 | 11 |
*/ |
11 |
public interface AttributeNamesTranslator extends Cloneable { |
|
12 |
public interface AttributeNamesTranslator extends Cloneable, Persistent {
|
|
12 | 13 |
|
13 | 14 |
boolean isValidName(ExportAttributes attributes, int index, String newName); |
14 | 15 |
|
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/AbstractExportParametersGeometry.java | ||
---|---|---|
12 | 12 |
import org.gvsig.fmap.geom.GeometryManager; |
13 | 13 |
import org.gvsig.fmap.geom.type.GeometryType; |
14 | 14 |
import org.gvsig.export.ExportParametersGeometry; |
15 |
import org.gvsig.tools.ToolsLocator; |
|
16 |
import org.gvsig.tools.dynobject.DynStruct; |
|
17 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
18 |
import org.gvsig.tools.persistence.PersistentState; |
|
19 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
15 | 20 |
|
16 | 21 |
/** |
17 | 22 |
* |
18 | 23 |
* @author jjdelcerro |
19 | 24 |
*/ |
20 |
public abstract class AbstractExportParametersGeometry
|
|
25 |
public abstract class AbstractExportParametersGeometry |
|
21 | 26 |
extends AbstractExportParameters |
22 |
implements ExportParametersGeometry |
|
23 |
{ |
|
27 |
implements ExportParametersGeometry { |
|
24 | 28 |
|
25 | 29 |
private IProjection contextProjection; |
26 | 30 |
private IProjection sourceProjection; |
... | ... | |
28 | 32 |
|
29 | 33 |
private ICoordTrans sourceTransformation; |
30 | 34 |
private ICoordTrans targetTransformation; |
31 |
|
|
35 |
|
|
32 | 36 |
private int geometryChecks; |
33 | 37 |
private int geometryChecksAction; |
34 | 38 |
private boolean tryToFixGeometry; |
... | ... | |
39 | 43 |
public AbstractExportParametersGeometry(ExportServiceFactory factory) { |
40 | 44 |
super(factory); |
41 | 45 |
} |
42 |
|
|
46 |
|
|
43 | 47 |
@Override |
44 | 48 |
public boolean needsSelectTargetProjection() { |
45 | 49 |
return true; |
46 |
}
|
|
50 |
} |
|
47 | 51 |
|
48 | 52 |
@Override |
49 | 53 |
public void setContextProjection(IProjection projection) { |
... | ... | |
82 | 86 |
|
83 | 87 |
@Override |
84 | 88 |
public IProjection getTargetProjection() { |
85 |
if( this.targetProjection == null ) {
|
|
89 |
if (this.targetProjection == null) {
|
|
86 | 90 |
return this.sourceProjection; |
87 | 91 |
} |
88 | 92 |
return this.targetProjection; |
... | ... | |
97 | 101 |
public ICoordTrans getTargetTransformation() { |
98 | 102 |
return targetTransformation; |
99 | 103 |
} |
100 |
|
|
104 |
|
|
101 | 105 |
@Override |
102 | 106 |
public int getGeometryChecks() { |
103 | 107 |
return this.geometryChecks; |
... | ... | |
174 | 178 |
); |
175 | 179 |
return type; |
176 | 180 |
} catch (Exception ex) { |
177 |
throw new RuntimeException("Can't create geoemtry type from type "+geometryType+", subtype "+geometrySubtype+".", ex);
|
|
181 |
throw new RuntimeException("Can't create geoemtry type from type " + geometryType + ", subtype " + geometrySubtype + ".", ex);
|
|
178 | 182 |
} |
179 | 183 |
} |
180 | 184 |
|
185 |
@Override |
|
181 | 186 |
public ExportParameters clone() throws CloneNotSupportedException { |
182 |
return super.clone(); |
|
187 |
AbstractExportParametersGeometry clone = (AbstractExportParametersGeometry) super.clone(); |
|
188 |
clone.setContextProjection(this.contextProjection); |
|
189 |
clone.setSourceProjection(this.sourceProjection); |
|
190 |
clone.setTargetProjection(this.targetProjection); |
|
191 |
clone.setSourceTransformation(this.sourceTransformation); |
|
192 |
clone.setTargetTransformation(this.targetTransformation); |
|
193 |
clone.setSourceGeometryFieldName(this.geometryFieldName); |
|
194 |
clone.setGeometryChecks(this.geometryChecks); |
|
195 |
clone.setGeometryChecksAction(this.geometryChecksAction); |
|
196 |
clone.setTryToFixGeometry(this.tryToFixGeometry); |
|
197 |
clone.setTargetGeometryType(this.geometryType); |
|
198 |
clone.setTargetGeometrySubtype(this.geometrySubtype); |
|
199 |
return clone; |
|
183 | 200 |
} |
184 | 201 |
|
202 |
public static void registerPersistence() { |
|
203 |
|
|
204 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
205 |
if (manager.getDefinition("AbstractExportParametersGeometry") == null) { |
|
206 |
DynStruct definition = manager.addDefinition(AbstractExportParametersGeometry.class, |
|
207 |
"AbstractExportParametersGeometry", "AbstractExportParametersGeometry persistence definition", null, null); |
|
208 |
definition.addDynFieldObject("contextProjection").setClassOfValue(IProjection.class); |
|
209 |
definition.addDynFieldObject("sourceProjection").setClassOfValue(IProjection.class); |
|
210 |
definition.addDynFieldObject("targetProjection").setClassOfValue(IProjection.class); |
|
211 |
definition.addDynFieldObject("sourceTransformation").setClassOfValue(ICoordTrans.class); |
|
212 |
definition.addDynFieldObject("targetTransformation").setClassOfValue(ICoordTrans.class); |
|
213 |
definition.addDynFieldInt("geometryChecks"); |
|
214 |
definition.addDynFieldInt("geometryChecksAction"); |
|
215 |
definition.addDynFieldBoolean("tryToFixGeometry"); |
|
216 |
definition.addDynFieldString("geometryFieldName"); |
|
217 |
definition.addDynFieldInt("geometryType"); |
|
218 |
definition.addDynFieldInt("geometrySubtype"); |
|
219 |
definition.extend(manager.getDefinition("AbstractExportParameters")); |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
224 |
super.saveToState(state); |
|
225 |
state.set("contextProjection", this.contextProjection); |
|
226 |
state.set("sourceProjection", this.sourceProjection); |
|
227 |
state.set("targetProjection", this.targetProjection); |
|
228 |
state.set("sourceTransformation", this.sourceTransformation); |
|
229 |
state.set("targetTransformation", this.targetTransformation); |
|
230 |
state.set("geometryChecks", this.geometryChecks); |
|
231 |
state.set("geometryChecksAction", this.geometryChecksAction); |
|
232 |
state.set("tryToFixGeometry", this.tryToFixGeometry); |
|
233 |
state.set("geometryFieldName", this.geometryFieldName); |
|
234 |
state.set("geometryType", this.geometryType); |
|
235 |
state.set("geometrySubtype", this.geometrySubtype); |
|
236 |
} |
|
237 |
|
|
238 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
239 |
super.loadFromState(state); |
|
240 |
this.contextProjection = (IProjection) state.get("contextProjection"); |
|
241 |
this.sourceProjection = (IProjection) state.get("sourceProjection"); |
|
242 |
this.targetProjection = (IProjection) state.get("targetProjection"); |
|
243 |
this.sourceTransformation = (ICoordTrans) state.get("sourceTransformation"); |
|
244 |
this.targetTransformation = (ICoordTrans) state.get("targetTransformation"); |
|
245 |
this.geometryChecks = state.getInt("geometryChecks"); |
|
246 |
this.geometryChecksAction = state.getInt("geometryChecksAction"); |
|
247 |
this.tryToFixGeometry = state.getBoolean("tryToFixGeometry"); |
|
248 |
this.geometryFieldName = state.getString("geometryFieldName"); |
|
249 |
this.geometryType = state.getInt("geometryType"); |
|
250 |
this.geometrySubtype = state.getInt("geometrySubtype"); |
|
251 |
} |
|
252 |
|
|
185 | 253 |
} |
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.gvsig.tools.ToolsLocator; |
|
14 |
import org.gvsig.tools.dynobject.DynStruct; |
|
15 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
16 |
import org.gvsig.tools.persistence.PersistentState; |
|
17 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
13 | 18 |
import org.slf4j.Logger; |
14 | 19 |
import org.slf4j.LoggerFactory; |
15 | 20 |
|
... | ... | |
25 | 30 |
private Object context; |
26 | 31 |
protected ExportAttributes exportAttributes = null; |
27 | 32 |
private Date date = new Date(); |
28 |
private final ExportServiceFactory factory; |
|
33 |
public ExportServiceFactory factory; |
|
34 |
|
|
29 | 35 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractExportParameters.class); |
30 | 36 |
|
31 | 37 |
public AbstractExportParameters(ExportServiceFactory factory) { |
... | ... | |
126 | 132 |
public Date getCreationDate() { |
127 | 133 |
return this.date; |
128 | 134 |
} |
129 |
|
|
135 |
|
|
130 | 136 |
public void setCreationDate(Date date) { |
131 | 137 |
this.date = date; |
132 | 138 |
} |
... | ... | |
171 | 177 |
public ExportServiceFactory getFactory() { |
172 | 178 |
return this.factory; |
173 | 179 |
} |
174 |
|
|
180 |
|
|
175 | 181 |
@Override |
176 | 182 |
public FeatureType getTargetFeatureType() { |
177 |
if (this.getExportAttributes()==null) {
|
|
183 |
if (this.getExportAttributes() == null) {
|
|
178 | 184 |
LOGGER.warn("Not been able to get target feature type from export attributes because it's null"); |
179 | 185 |
return null; |
180 | 186 |
} |
181 | 187 |
return this.getExportAttributes().getTargetFeatureType(); |
182 | 188 |
} |
183 | 189 |
|
190 |
public static void registerPersistence() { |
|
191 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
192 |
if (manager.getDefinition("AbstractExportParameters") == null) { |
|
193 |
DynStruct definition = manager.addDefinition(AbstractExportParameters.class, |
|
194 |
"AbstractExportParameters", "AbstractExportParameters persistence definition", null, null); |
|
195 |
definition.addDynFieldInt("featuresToUse").setMandatory(false); |
|
196 |
definition.addDynFieldObject("filterExpression").setClassOfValue(Expression.class).setMandatory(false); |
|
197 |
definition.addDynFieldObject("exportAttributes").setClassOfValue(ExportAttributes.class).setMandatory(false); |
|
198 |
definition.addDynFieldDate("dateCreation").setMandatory(false); |
|
199 |
definition.addDynFieldString("factory"); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
204 |
state.set("featuresToUse", this.featuresToUse); |
|
205 |
state.set("filterExpression", this.filterExpression); |
|
206 |
state.set("exportAttributes", this.exportAttributes); |
|
207 |
state.set("dateCreation", this.date); |
|
208 |
state.set("factory", this.factory.getName()); |
|
209 |
} |
|
210 |
|
|
211 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
212 |
this.featuresToUse = state.getInt("featuresToUse"); |
|
213 |
this.filterExpression = (Expression) state.get("filterExpression"); |
|
214 |
this.exportAttributes = (ExportAttributes) state.get("exportAttributes"); |
|
215 |
this.date = state.getDate("dateCreation"); |
|
216 |
String nameFactory = state.getString("factory"); |
|
217 |
ExportServiceFactory statefactory = ExportLocator.getServiceManager().getServiceFactory(nameFactory); |
|
218 |
this.factory = statefactory; |
|
219 |
} |
|
220 |
|
|
184 | 221 |
} |
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/CutAttributeNamesTranslator.java | ||
---|---|---|
7 | 7 |
import org.apache.commons.lang3.StringUtils; |
8 | 8 |
import org.gvsig.export.ExportAttributes; |
9 | 9 |
import org.gvsig.export.ExportAttributes.ExportAttribute; |
10 |
import org.gvsig.tools.ToolsLocator; |
|
11 |
import org.gvsig.tools.dynobject.DynStruct; |
|
12 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
13 |
import org.gvsig.tools.persistence.PersistentState; |
|
14 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
10 | 15 |
|
11 | 16 |
public class CutAttributeNamesTranslator implements AttributeNamesTranslator { |
12 | 17 |
|
13 |
public final int maxNameLen;
|
|
18 |
public int maxNameLen; |
|
14 | 19 |
|
15 | 20 |
public CutAttributeNamesTranslator(int maxNameLen) { |
16 | 21 |
this.maxNameLen = maxNameLen; |
17 | 22 |
} |
18 | 23 |
|
24 |
public CutAttributeNamesTranslator() { |
|
25 |
|
|
26 |
} |
|
27 |
|
|
19 | 28 |
private String buildTranslatedName(String source_name, Collection<String> current_names) { |
20 | 29 |
|
21 | 30 |
int len = source_name.length(); |
... | ... | |
50 | 59 |
target_name = source_name + i; |
51 | 60 |
} |
52 | 61 |
} else { |
53 |
if (len == this.maxNameLen-1) {
|
|
62 |
if (len == this.maxNameLen - 1) {
|
|
54 | 63 |
target_name = source_name.substring(0, 7) + i;; |
55 | 64 |
} else { |
56 | 65 |
target_name = source_name + i; |
... | ... | |
123 | 132 |
String target_name = buildTranslatedName(name, names); |
124 | 133 |
return target_name; |
125 | 134 |
} |
126 |
|
|
135 |
|
|
127 | 136 |
@Override |
128 | 137 |
public CutAttributeNamesTranslator clone() { |
129 | 138 |
CutAttributeNamesTranslator clone = null; |
130 | 139 |
try { |
131 |
clone = ( CutAttributeNamesTranslator)super.clone();
|
|
140 |
clone = (CutAttributeNamesTranslator) super.clone();
|
|
132 | 141 |
} catch (CloneNotSupportedException ex) { |
133 | 142 |
Logger.getLogger(CutAttributeNamesTranslator.class.getName()).log(Level.SEVERE, null, ex); |
134 | 143 |
} |
135 |
|
|
144 |
|
|
136 | 145 |
return clone; |
137 |
|
|
146 |
|
|
138 | 147 |
} |
139 | 148 |
|
140 | 149 |
@Override |
... | ... | |
142 | 151 |
String s = StringUtils.left(name, maxNameLen); |
143 | 152 |
return s; |
144 | 153 |
} |
154 |
|
|
155 |
public static void registerPersistence() { |
|
156 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
157 |
if (manager.getDefinition("CutAttributeNamesTranslator") == null) { |
|
158 |
DynStruct definition = manager.addDefinition(CutAttributeNamesTranslator.class, |
|
159 |
"CutAttributeNamesTranslator", "CutAttributeNamesTranslator persistence definition", null, null); |
|
160 |
definition.addDynFieldInt("maxNameLen"); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
166 |
state.set("maxNameLen", this.maxNameLen); |
|
167 |
} |
|
168 |
|
|
169 |
@Override |
|
170 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
171 |
this.maxNameLen = state.getInt("maxNameLen"); |
|
172 |
} |
|
145 | 173 |
} |
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/DummyAttributeNamesTranslator.java | ||
---|---|---|
1 | 1 |
package org.gvsig.export.spi; |
2 | 2 |
|
3 | 3 |
import org.gvsig.export.ExportAttributes; |
4 |
import org.gvsig.tools.ToolsLocator; |
|
5 |
import org.gvsig.tools.dynobject.DynStruct; |
|
6 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
7 |
import org.gvsig.tools.persistence.PersistentState; |
|
8 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
4 | 9 |
|
5 | 10 |
public class DummyAttributeNamesTranslator implements AttributeNamesTranslator { |
6 | 11 |
|
7 | 12 |
public DummyAttributeNamesTranslator() { |
8 |
|
|
13 |
|
|
9 | 14 |
} |
10 |
|
|
15 |
|
|
16 |
public static void registerPersistence() { |
|
17 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
18 |
if (manager.getDefinition("DummyAttributeNamesTranslator") == null) { |
|
19 |
DynStruct definition = manager.addDefinition(DummyAttributeNamesTranslator.class, |
|
20 |
"DummyAttributeNamesTranslator", "DummyAttributeNamesTranslator persistence definition", null, null); |
|
21 |
definition.addDynFieldInt("a"); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
11 | 25 |
@Override |
26 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
27 |
state.set("a", 0); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
32 |
int a = state.getInt("a"); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
12 | 36 |
public boolean isValidName(ExportAttributes attributes, int index, String name) { |
13 | 37 |
return true; |
14 | 38 |
} |
... | ... | |
17 | 41 |
public String getNameSuggestion(ExportAttributes attributes, int index, String name) { |
18 | 42 |
return name; |
19 | 43 |
} |
20 |
|
|
44 |
|
|
21 | 45 |
@Override |
22 | 46 |
public AttributeNamesTranslator clone() throws CloneNotSupportedException { |
23 | 47 |
return (AttributeNamesTranslator) super.clone(); |
... | ... | |
27 | 51 |
public String getNameSuggestion(String name) { |
28 | 52 |
return name; |
29 | 53 |
} |
54 |
|
|
30 | 55 |
} |
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 | ||
---|---|---|
3 | 3 |
import java.util.List; |
4 | 4 |
import java.util.Objects; |
5 | 5 |
import javax.swing.JOptionPane; |
6 |
import org.apache.commons.lang3.StringUtils; |
|
6 | 7 |
import org.cresques.cts.ICoordTrans; |
7 | 8 |
import org.cresques.cts.IProjection; |
8 | 9 |
import org.gvsig.export.ExportException; |
... | ... | |
15 | 16 |
import org.gvsig.export.spi.ExportServiceManager; |
16 | 17 |
import org.gvsig.expressionevaluator.Expression; |
17 | 18 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
19 |
import org.gvsig.fmap.dal.exception.DataException; |
|
18 | 20 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
19 | 21 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
22 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
20 | 23 |
import org.gvsig.tools.ToolsLocator; |
21 | 24 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
22 | 25 |
import org.gvsig.tools.task.TaskStatus; |
... | ... | |
39 | 42 |
private Object context; |
40 | 43 |
private Expression filterExpression; |
41 | 44 |
private int featuresToUse; |
42 |
// private AttributeNamesTranslator attributeNamesTranslator; |
|
43 | 45 |
|
44 | 46 |
public DefaultExportProcess() { |
45 | 47 |
|
... | ... | |
59 | 61 |
params.setSourceProjection(this.sourceProjection); |
60 | 62 |
params.setSourceTransformation(this.sourceTransformation); |
61 | 63 |
params.setContext(this.context); |
64 |
|
|
65 |
if (this.sourceFeatureStore != null) { |
|
66 |
try { |
|
67 |
FeatureType ftype = this.sourceFeatureStore.getDefaultFeatureType(); |
|
68 |
if (ftype != null) { |
|
69 |
params.setSourceGeometryFieldName(ftype.getDefaultGeometryAttributeName()); |
|
70 |
} |
|
71 |
} catch (DataException ex) { |
|
72 |
// |
|
73 |
} |
|
74 |
} |
|
62 | 75 |
} |
63 | 76 |
this.parameters.setFilterExpresion(this.filterExpression); |
64 | 77 |
this.parameters.setFeaturesToUse(this.featuresToUse); //valor que use la expression si no es nula |
... | ... | |
74 | 87 |
this.parameters.setContext(this.context); |
75 | 88 |
|
76 | 89 |
this.featuresToUse = this.parameters.getFeaturesToUse(); |
77 |
if (!Objects.equals(this.filterExpression, this.parameters.getFilterExpresion())) { |
|
90 |
if (this.filterExpression == null) { |
|
91 |
this.filterExpression = this.parameters.getFilterExpresion(); |
|
92 |
} else if (this.filterExpression.isEmpty()) { |
|
93 |
this.filterExpression = this.parameters.getFilterExpresion(); |
|
94 |
} else if (!Objects.equals(this.filterExpression, this.parameters.getFilterExpresion())) { |
|
95 |
StringBuilder message = new StringBuilder(); |
|
96 |
message.append(ToolsLocator.getI18nManager().getTranslation("_A_filter_is_already_applied_to_this_export_process")); |
|
97 |
message.append(":\n"); |
|
98 |
message.append(StringUtils.abbreviate(this.filterExpression.getPhrase(), 30)); |
|
99 |
message.append("\n"); |
|
100 |
message.append(ToolsLocator.getI18nManager().getTranslation("_Its_going_to_be_replace_by_the_filter_in_the_parameters")); |
|
101 |
message.append(":\n"); |
|
102 |
if (this.parameters.getFilterExpresion() != null) { |
|
103 |
message.append(StringUtils.abbreviate(this.parameters.getFilterExpresion().getPhrase(), 30)); |
|
104 |
} else { |
|
105 |
message.append("empty filter"); |
|
106 |
} |
|
107 |
message.append("\n"); |
|
108 |
message.append(ToolsLocator.getI18nManager().getTranslation("_Do_you_want_to_keep_the_applied_filter")); |
|
78 | 109 |
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"), |
|
110 |
message.toString(),//ToolsLocator.getI18nManager().getTranslation("_Do_you_want_to_keep_the_applied_filter_and_not_use_the_one_in_the_parameters"),
|
|
80 | 111 |
ToolsLocator.getI18nManager().getTranslation("_Filter_to_apply"), |
81 | 112 |
JOptionPane.YES_NO_OPTION, |
82 | 113 |
JOptionPane.WARNING_MESSAGE, |
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/ExportLibraryImpl.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.gvsig.export.ExportLibrary; |
27 | 27 |
import org.gvsig.export.ExportLocator; |
28 |
import org.gvsig.export.impl.service.DefaultExportAttribute; |
|
29 |
import org.gvsig.export.impl.service.DefaultExportAttributes; |
|
28 | 30 |
import org.gvsig.export.impl.service.DefaultExportServiceManager; |
29 | 31 |
import org.gvsig.tools.library.AbstractLibrary; |
30 | 32 |
import org.gvsig.tools.library.LibraryException; |
... | ... | |
50 | 52 |
|
51 | 53 |
@Override |
52 | 54 |
protected void doPostInitialize() throws LibraryException { |
53 |
// Do nothing |
|
55 |
DefaultExportAttributes.registerPersistence(); |
|
56 |
DefaultExportAttribute.registerPersistence(); |
|
54 | 57 |
} |
55 | 58 |
|
56 | 59 |
} |
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/service/DefaultExportAttribute.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.export.ExportAttributes; |
9 | 9 |
import org.gvsig.export.ExportAttributes.ExportAttribute; |
10 |
import org.gvsig.export.spi.AbstractExportParameters; |
|
10 | 11 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
12 |
import org.gvsig.export.spi.ExportServiceFactory; |
|
13 |
import org.gvsig.expressionevaluator.Expression; |
|
11 | 14 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
15 |
import org.gvsig.tools.ToolsLocator; |
|
16 |
import org.gvsig.tools.dynobject.DynStruct; |
|
17 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
18 |
import org.gvsig.tools.persistence.PersistentState; |
|
19 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
12 | 20 |
|
13 | 21 |
public class DefaultExportAttribute implements ExportAttributes.ExportAttribute { |
14 | 22 |
|
15 |
private final FeatureAttributeDescriptor fad;
|
|
23 |
private FeatureAttributeDescriptor fad; |
|
16 | 24 |
private String newName = null; |
17 | 25 |
private int newDataType; |
18 | 26 |
private int size; |
... | ... | |
21 | 29 |
|
22 | 30 |
public DefaultExportAttribute(FeatureAttributeDescriptor fad) { |
23 | 31 |
this.fad = fad; |
32 |
} |
|
24 | 33 |
|
34 |
public DefaultExportAttribute() { |
|
35 |
|
|
25 | 36 |
} |
26 | 37 |
|
27 | 38 |
@Override |
... | ... | |
84 | 95 |
|
85 | 96 |
@Override |
86 | 97 |
public ExportAttribute clone() throws CloneNotSupportedException { |
87 |
DefaultExportAttribute clone = new DefaultExportAttribute((FeatureAttributeDescriptor) fad.clone()); |
|
88 |
clone.setExported(this.exported); |
|
89 |
clone.setNewName(this.newName); |
|
90 |
clone.setNewType(this.newDataType); |
|
91 |
clone.setSize(this.size); |
|
92 |
return clone; |
|
98 |
DefaultExportAttribute clone = new DefaultExportAttribute((FeatureAttributeDescriptor) fad.clone());
|
|
99 |
clone.setExported(this.exported);
|
|
100 |
clone.setNewName(this.newName);
|
|
101 |
clone.setNewType(this.newDataType);
|
|
102 |
clone.setSize(this.size);
|
|
103 |
return clone;
|
|
93 | 104 |
} |
94 |
|
|
105 |
|
|
106 |
public static void registerPersistence() { |
|
107 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
108 |
if (manager.getDefinition("ExportAttribute") == null) { |
|
109 |
DynStruct definition = manager.addDefinition(DefaultExportAttribute.class, |
|
110 |
"ExportAttribute", "ExportAttribute persistence definition", null, null); |
|
111 |
definition.addDynFieldObject("fad").setClassOfValue(FeatureAttributeDescriptor.class); |
|
112 |
definition.addDynFieldString("newName").setMandatory(false); |
|
113 |
definition.addDynFieldInt("newDataType").setMandatory(false); |
|
114 |
definition.addDynFieldInt("size").setMandatory(false); |
|
115 |
definition.addDynFieldBoolean("exported").setMandatory(false); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
120 |
state.set("fad", this.fad); |
|
121 |
state.set("newName", this.newName); |
|
122 |
state.set("newDataType", this.newDataType); |
|
123 |
state.set("size", this.size); |
|
124 |
state.set("exported", this.exported); |
|
125 |
|
|
126 |
} |
|
127 |
|
|
128 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
129 |
FeatureAttributeDescriptor stateFad = (FeatureAttributeDescriptor) state.get("fad"); |
|
130 |
this.fad = stateFad; |
|
131 |
this.newName = state.getString("newName"); |
|
132 |
this.newDataType = state.getInt("newDataType"); |
|
133 |
this.size = state.getInt("size"); |
|
134 |
this.exported = state.getBoolean("exported"); |
|
135 |
} |
|
136 |
|
|
95 | 137 |
} |
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/service/DefaultExportAttributes.java | ||
---|---|---|
16 | 16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
17 | 17 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
18 | 18 |
import org.gvsig.fmap.dal.feature.FeatureType; |
19 |
import org.gvsig.tools.ToolsLocator; |
|
20 |
import org.gvsig.tools.dynobject.DynStruct; |
|
21 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
22 |
import org.gvsig.tools.persistence.PersistentState; |
|
23 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
19 | 24 |
import org.slf4j.Logger; |
20 | 25 |
import org.slf4j.LoggerFactory; |
21 | 26 |
|
22 | 27 |
public final class DefaultExportAttributes implements ExportAttributes { |
23 | 28 |
|
24 |
private List<ExportAttribute> exportAttributes;
|
|
25 |
private AttributeNamesTranslator namesTranslator = null;
|
|
26 |
private FeatureType sourceFeatureType;
|
|
27 |
static final Logger LOGGER = LoggerFactory.getLogger(DefaultExportAttributes.class);
|
|
28 |
private boolean active;
|
|
29 |
private List<ExportAttribute> exportAttributes;
|
|
30 |
private AttributeNamesTranslator namesTranslator = null;
|
|
31 |
private FeatureType sourceFeatureType;
|
|
32 |
static final Logger LOGGER = LoggerFactory.getLogger(DefaultExportAttributes.class);
|
|
33 |
private boolean active;
|
|
29 | 34 |
|
30 |
public DefaultExportAttributes() { //FeatureType ftype) { |
|
31 |
// this.setSourceFeatureType(ftype); |
|
32 |
this.namesTranslator = new DummyAttributeNamesTranslator(); |
|
33 |
this.active = false; |
|
34 |
} |
|
35 |
public DefaultExportAttributes() { |
|
36 |
this.namesTranslator = new DummyAttributeNamesTranslator(); |
|
37 |
this.active = false; |
|
38 |
} |
|
35 | 39 |
|
36 |
public void fillExportAttributes(FeatureType ftype) {
|
|
37 |
ArrayList attrs = new ArrayList();
|
|
38 |
if (ftype != null) {
|
|
39 |
for (FeatureAttributeDescriptor fad : ftype) {
|
|
40 |
DefaultExportAttribute exportAttribute = new DefaultExportAttribute(fad);
|
|
41 |
String newName = this.getNamesTranslator().getNameSuggestion(fad.getName());
|
|
42 |
exportAttribute.setNewName(newName);
|
|
43 |
exportAttribute.setNewType(fad.getDataType().getType());
|
|
44 |
exportAttribute.setSize(fad.getSize());
|
|
45 |
exportAttribute.setExported(true);
|
|
46 |
attrs.add(exportAttribute);
|
|
47 |
}
|
|
48 |
}
|
|
49 |
this.setExportAttributes(attrs);
|
|
50 |
this.fixAttributeNames();
|
|
40 |
public void fillExportAttributes(FeatureType ftype) {
|
|
41 |
ArrayList attrs = new ArrayList();
|
|
42 |
if (ftype != null) {
|
|
43 |
for (FeatureAttributeDescriptor fad : ftype) {
|
|
44 |
DefaultExportAttribute exportAttribute = new DefaultExportAttribute(fad);
|
|
45 |
String newName = this.getNamesTranslator().getNameSuggestion(fad.getName());
|
|
46 |
exportAttribute.setNewName(newName);
|
|
47 |
exportAttribute.setNewType(fad.getDataType().getType());
|
|
48 |
exportAttribute.setSize(fad.getSize());
|
|
49 |
exportAttribute.setExported(true);
|
|
50 |
attrs.add(exportAttribute);
|
|
51 |
}
|
|
52 |
}
|
|
53 |
this.setExportAttributes(attrs);
|
|
54 |
this.fixAttributeNames();
|
|
51 | 55 |
|
52 |
}
|
|
56 |
}
|
|
53 | 57 |
|
54 |
@Override |
|
55 |
public void setNamesTranslator(AttributeNamesTranslator namesTranslator) { |
|
56 |
this.namesTranslator = namesTranslator; |
|
57 |
if (this.sourceFeatureType != null) { |
|
58 |
this.fillExportAttributes(sourceFeatureType); |
|
59 |
} |
|
60 |
} |
|
58 |
@Override |
|
59 |
public void setNamesTranslator(AttributeNamesTranslator namesTranslator) { |
|
60 |
if (this.namesTranslator != namesTranslator) { |
|
61 |
this.namesTranslator = namesTranslator; |
|
62 |
if (this.sourceFeatureType != null) { |
|
63 |
this.fillExportAttributes(sourceFeatureType); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
61 | 67 |
|
62 |
@Override
|
|
63 |
public AttributeNamesTranslator getNamesTranslator() {
|
|
64 |
return this.namesTranslator;
|
|
65 |
}
|
|
68 |
@Override
|
|
69 |
public AttributeNamesTranslator getNamesTranslator() {
|
|
70 |
return this.namesTranslator;
|
|
71 |
}
|
|
66 | 72 |
|
67 |
@Override
|
|
68 |
public List<ExportAttribute> toList() {
|
|
69 |
return this.exportAttributes;
|
|
70 |
}
|
|
73 |
@Override
|
|
74 |
public List<ExportAttribute> toList() {
|
|
75 |
return this.exportAttributes;
|
|
76 |
}
|
|
71 | 77 |
|
72 |
@Override
|
|
73 |
public boolean isEmpty() {
|
|
74 |
return this.exportAttributes.isEmpty();
|
|
75 |
}
|
|
78 |
@Override
|
|
79 |
public boolean isEmpty() {
|
|
80 |
return this.exportAttributes.isEmpty();
|
|
81 |
}
|
|
76 | 82 |
|
77 |
@Override
|
|
78 |
public int size() {
|
|
79 |
return this.exportAttributes.size();
|
|
80 |
}
|
|
83 |
@Override
|
|
84 |
public int size() {
|
|
85 |
return this.exportAttributes.size();
|
|
86 |
}
|
|
81 | 87 |
|
82 |
@Override
|
|
83 |
public Iterator<ExportAttribute> iterator() {
|
|
84 |
return this.exportAttributes.iterator();
|
|
85 |
}
|
|
88 |
@Override
|
|
89 |
public Iterator<ExportAttribute> iterator() {
|
|
90 |
return this.exportAttributes.iterator();
|
|
91 |
}
|
|
86 | 92 |
|
87 |
@Override
|
|
88 |
public ExportAttribute get(int position) {
|
|
89 |
return this.exportAttributes.get(position);
|
|
90 |
}
|
|
93 |
@Override
|
|
94 |
public ExportAttribute get(int position) {
|
|
95 |
return this.exportAttributes.get(position);
|
|
96 |
}
|
|
91 | 97 |
|
92 |
@Override
|
|
93 |
public ExportAttribute getExportAttribute(String name) {
|
|
94 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
95 |
if (StringUtils.equals(exportAttribute.getName(), name)) {
|
|
96 |
return exportAttribute;
|
|
97 |
}
|
|
98 |
}
|
|
99 |
return null;
|
|
100 |
}
|
|
98 |
@Override
|
|
99 |
public ExportAttribute getExportAttribute(String name) {
|
|
100 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
101 |
if (StringUtils.equals(exportAttribute.getName(), name)) {
|
|
102 |
return exportAttribute;
|
|
103 |
}
|
|
104 |
}
|
|
105 |
return null;
|
|
106 |
}
|
|
101 | 107 |
|
102 |
@Override
|
|
103 |
public FeatureType getTargetFeatureType() {
|
|
104 |
if (!this.isAttributeNamesValid()) {
|
|
105 |
this.fixAttributeNames();
|
|
106 |
LOGGER.warn("An extra fix attributes names in the feature type has been made");
|
|
107 |
}
|
|
108 |
EditableFeatureType targetFeatureType = this.getSourceFeatureType().getCopy().getEditable();
|
|
109 |
for (FeatureAttributeDescriptor attrSource : this.getSourceFeatureType()) {
|
|
110 |
FeatureAttributeDescriptor attr = targetFeatureType.getAttributeDescriptor(attrSource.getName());
|
|
111 |
String name = attr.getName();
|
|
112 |
ExportAttribute exportAttr = this.getExportAttribute(name);
|
|
113 |
if (!exportAttr.isExported()) {
|
|
114 |
targetFeatureType.remove(name);
|
|
115 |
continue;
|
|
116 |
}
|
|
108 |
@Override
|
|
109 |
public FeatureType getTargetFeatureType() {
|
|
110 |
if (!this.isAttributeNamesValid()) {
|
|
111 |
this.fixAttributeNames();
|
|
112 |
LOGGER.warn("An extra fix attributes names in the feature type has been made");
|
|
113 |
}
|
|
114 |
EditableFeatureType targetFeatureType = this.getSourceFeatureType().getCopy().getEditable();
|
|
115 |
for (FeatureAttributeDescriptor attrSource : this.getSourceFeatureType()) {
|
|
116 |
FeatureAttributeDescriptor attr = targetFeatureType.getAttributeDescriptor(attrSource.getName());
|
|
117 |
String name = attr.getName();
|
|
118 |
ExportAttribute exportAttr = this.getExportAttribute(name);
|
|
119 |
if (!exportAttr.isExported()) {
|
|
120 |
targetFeatureType.remove(name);
|
|
121 |
continue;
|
|
122 |
}
|
|
117 | 123 |
|
118 |
EditableFeatureAttributeDescriptor eAttr = targetFeatureType.getEditableAttributeDescriptor(name);
|
|
119 |
if (this.getTargetName(name) == null ? name != null : !this.getTargetName(name).equals(name)) {
|
|
120 |
eAttr.setName(this.getTargetName(name));
|
|
121 |
}
|
|
122 |
int type = attr.getDataType().getType();
|
|
123 |
if (type != this.getTargetType(name)) {
|
|
124 |
eAttr.setDataType(this.getTargetType(name));
|
|
125 |
eAttr.setDefaultValue(null); // TODO: delete default value
|
|
126 |
}
|
|
127 |
int size = exportAttr.getSize();
|
|
128 |
eAttr.setSize(size);
|
|
129 |
}
|
|
130 |
return targetFeatureType.getNotEditableCopy();
|
|
131 |
}
|
|
124 |
EditableFeatureAttributeDescriptor eAttr = targetFeatureType.getEditableAttributeDescriptor(name);
|
|
125 |
if (this.getTargetName(name) == null ? name != null : !this.getTargetName(name).equals(name)) {
|
|
126 |
eAttr.setName(this.getTargetName(name));
|
|
127 |
}
|
|
128 |
int type = attr.getDataType().getType();
|
|
129 |
if (type != this.getTargetType(name)) {
|
|
130 |
eAttr.setDataType(this.getTargetType(name));
|
|
131 |
eAttr.setDefaultValue(null); // TODO: delete default value
|
|
132 |
}
|
|
133 |
int size = exportAttr.getSize();
|
|
134 |
eAttr.setSize(size);
|
|
135 |
}
|
|
136 |
return targetFeatureType.getNotEditableCopy();
|
|
137 |
}
|
|
132 | 138 |
|
133 |
@Override
|
|
134 |
public void setSourceFeatureType(FeatureType sourceFeatureType) {
|
|
135 |
if (sourceFeatureType != this.sourceFeatureType) {
|
|
136 |
this.sourceFeatureType = sourceFeatureType;
|
|
137 |
this.fillExportAttributes(this.sourceFeatureType);
|
|
138 |
}
|
|
139 |
}
|
|
139 |
@Override
|
|
140 |
public void setSourceFeatureType(FeatureType sourceFeatureType) {
|
|
141 |
if (!sourceFeatureType.equals(this.sourceFeatureType)) {
|
|
142 |
this.sourceFeatureType = sourceFeatureType;
|
|
143 |
this.fillExportAttributes(this.sourceFeatureType);
|
|
144 |
}
|
|
145 |
}
|
|
140 | 146 |
|
141 |
@Override
|
|
142 |
public FeatureType getSourceFeatureType() {
|
|
143 |
return this.sourceFeatureType;
|
|
144 |
}
|
|
147 |
@Override
|
|
148 |
public FeatureType getSourceFeatureType() {
|
|
149 |
return this.sourceFeatureType;
|
|
150 |
}
|
|
145 | 151 |
|
146 |
@Override
|
|
147 |
public String getTargetName(String name) {
|
|
148 |
for (int i = 0; i < exportAttributes.size(); i++) {
|
|
149 |
ExportAttribute exportAttribute = exportAttributes.get(i);
|
|
150 |
if (StringUtils.equals(exportAttribute.getName(), name)) {
|
|
151 |
String newName = exportAttribute.getNewName();
|
|
152 |
@Override
|
|
153 |
public String getTargetName(String name) {
|
|
154 |
for (int i = 0; i < exportAttributes.size(); i++) {
|
|
155 |
ExportAttribute exportAttribute = exportAttributes.get(i);
|
|
156 |
if (StringUtils.equals(exportAttribute.getName(), name)) {
|
|
157 |
String newName = exportAttribute.getNewName();
|
|
152 | 158 |
//TODO return value or fixed value? |
153 | 159 |
// if (!this.namesTranslator.isValidName(this, i, newName)) { |
154 | 160 |
// newName = this.namesTranslator.getNameSuggestion(this, i, newName); |
155 | 161 |
// //exportAttribute.setNewName(newName); //Change the name in the exportAttribute after chacking |
156 | 162 |
// } |
157 |
return newName;
|
|
158 |
}
|
|
159 |
}
|
|
160 |
return null;
|
|
161 |
}
|
|
163 |
return newName;
|
|
164 |
}
|
|
165 |
}
|
|
166 |
return null;
|
|
167 |
}
|
|
162 | 168 |
|
163 |
@Override
|
|
164 |
public String getSourceName(String name) {
|
|
165 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
166 |
if (StringUtils.equalsIgnoreCase(exportAttribute.getNewName(), name)) {
|
|
167 |
return exportAttribute.getName();
|
|
168 |
}
|
|
169 |
}
|
|
170 |
return null;
|
|
171 |
}
|
|
169 |
@Override
|
|
170 |
public String getSourceName(String name) {
|
|
171 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
172 |
if (StringUtils.equalsIgnoreCase(exportAttribute.getNewName(), name)) {
|
|
173 |
return exportAttribute.getName();
|
|
174 |
}
|
|
175 |
}
|
|
176 |
return null;
|
|
177 |
}
|
|
172 | 178 |
|
173 |
@Override
|
|
174 |
public int getTargetType(String name) {
|
|
175 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
176 |
if (StringUtils.equals(exportAttribute.getName(), name)) {
|
|
177 |
return exportAttribute.getNewDataType();
|
|
178 |
}
|
|
179 |
}
|
|
180 |
return 0;
|
|
181 |
}
|
|
179 |
@Override
|
|
180 |
public int getTargetType(String name) {
|
|
181 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
182 |
if (StringUtils.equals(exportAttribute.getName(), name)) {
|
|
183 |
return exportAttribute.getNewDataType();
|
|
184 |
}
|
|
185 |
}
|
|
186 |
return 0;
|
|
187 |
}
|
|
182 | 188 |
|
183 |
@Override
|
|
184 |
public int getSourceType(String name) {
|
|
185 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
186 |
if (StringUtils.equals(exportAttribute.getNewName(), name)) {
|
|
187 |
return exportAttribute.getDataType();
|
|
188 |
}
|
|
189 |
}
|
|
190 |
return 0;
|
|
191 |
}
|
|
189 |
@Override
|
|
190 |
public int getSourceType(String name) {
|
|
191 |
for (ExportAttribute exportAttribute : this.exportAttributes) {
|
|
192 |
if (StringUtils.equals(exportAttribute.getNewName(), name)) {
|
|
193 |
return exportAttribute.getDataType();
|
|
194 |
}
|
|
195 |
}
|
|
196 |
return 0;
|
|
197 |
}
|
|
192 | 198 |
|
193 |
@Override
|
|
194 |
public boolean isAttributeNamesValid() {
|
|
195 |
if (this.namesTranslator == null) {
|
|
196 |
return true;
|
|
197 |
}
|
|
198 |
for (int i = 0; i < exportAttributes.size(); i++) {
|
|
199 |
ExportAttribute attr = exportAttributes.get(i);
|
|
200 |
if (!this.namesTranslator.isValidName(this, i, attr.getNewName())) {
|
|
201 |
return false;
|
|
202 |
}
|
|
203 |
}
|
|
204 |
return true;
|
|
205 |
}
|
|
199 |
@Override
|
|
200 |
public boolean isAttributeNamesValid() {
|
|
201 |
if (this.namesTranslator == null) {
|
|
202 |
return true;
|
|
203 |
}
|
|
204 |
for (int i = 0; i < exportAttributes.size(); i++) {
|
|
205 |
ExportAttribute attr = exportAttributes.get(i);
|
|
206 |
if (!this.namesTranslator.isValidName(this, i, attr.getNewName())) {
|
|
207 |
return false;
|
|
208 |
}
|
|
209 |
}
|
|
210 |
return true;
|
|
211 |
}
|
|
206 | 212 |
|
207 |
@Override
|
|
208 |
public void fixAttributeNames() {
|
|
209 |
if (this.isAttributeNamesValid() == true) {
|
|
210 |
return;
|
|
211 |
}
|
|
212 |
if (this.namesTranslator == null) {
|
|
213 |
return;
|
|
214 |
}
|
|
215 |
int n = 0;
|
|
216 |
while (!this.isAttributeNamesValid()) {
|
|
217 |
for (int i = 0; i < exportAttributes.size(); i++) {
|
|
218 |
ExportAttribute attr = exportAttributes.get(i);
|
|
219 |
String newName = attr.getNewName();
|
|
220 |
if (!this.namesTranslator.isValidName(this, i, newName)) {
|
|
221 |
String sug = this.namesTranslator.getNameSuggestion(this, i, newName);
|
|
222 |
attr.setNewName(sug);
|
|
223 |
}
|
|
224 |
}
|
|
225 |
if (n > 5000) {
|
|
226 |
LOGGER.warn("Not been able to fix attribute field names, it will require a manual operation");
|
|
227 |
break;
|
|
228 |
}
|
|
229 |
n += 1;
|
|
230 |
}
|
|
213 |
@Override
|
|
214 |
public void fixAttributeNames() {
|
|
215 |
if (this.isAttributeNamesValid() == true) {
|
|
216 |
return;
|
|
217 |
}
|
|
218 |
if (this.namesTranslator == null) {
|
|
219 |
return;
|
|
220 |
}
|
|
221 |
int n = 0;
|
|
222 |
while (!this.isAttributeNamesValid()) {
|
|
223 |
for (int i = 0; i < exportAttributes.size(); i++) {
|
|
224 |
ExportAttribute attr = exportAttributes.get(i);
|
|
225 |
String newName = attr.getNewName();
|
|
226 |
if (!this.namesTranslator.isValidName(this, i, newName)) {
|
|
227 |
String sug = this.namesTranslator.getNameSuggestion(this, i, newName);
|
|
228 |
attr.setNewName(sug);
|
|
229 |
}
|
|
230 |
}
|
|
231 |
if (n > 5000) {
|
|
232 |
LOGGER.warn("Not been able to fix attribute field names, it will require a manual operation");
|
|
233 |
break;
|
|
234 |
}
|
|
235 |
n += 1;
|
|
236 |
}
|
|
231 | 237 |
|
232 |
}
|
|
238 |
}
|
|
233 | 239 |
|
234 |
@Override
|
|
235 |
public ExportAttributes clone() throws CloneNotSupportedException {
|
|
236 |
DefaultExportAttributes clone = (DefaultExportAttributes) super.clone();
|
|
237 |
this.namesTranslator.clone();
|
|
238 |
clone.setNamesTranslator(this.namesTranslator.clone());
|
|
240 |
@Override
|
|
241 |
public ExportAttributes clone() throws CloneNotSupportedException {
|
|
242 |
DefaultExportAttributes clone = (DefaultExportAttributes) super.clone();
|
|
243 |
this.namesTranslator.clone();
|
|
244 |
clone.setNamesTranslator(this.namesTranslator.clone());
|
|
239 | 245 |
|
240 |
List cloneListAttribute = new ArrayList();
|
|
241 |
for (ExportAttribute exportAttribute : exportAttributes) {
|
|
242 |
cloneListAttribute.add(exportAttribute.clone());
|
|
243 |
}
|
|
244 |
clone.setExportAttributes(cloneListAttribute);
|
|
246 |
List cloneListAttribute = new ArrayList();
|
|
247 |
for (ExportAttribute exportAttribute : exportAttributes) {
|
|
248 |
cloneListAttribute.add(exportAttribute.clone());
|
|
249 |
}
|
|
250 |
clone.setExportAttributes(cloneListAttribute);
|
|
245 | 251 |
|
246 |
return clone;
|
|
247 |
}
|
|
252 |
return clone;
|
|
253 |
}
|
|
248 | 254 |
|
249 |
@Override
|
|
250 |
public void setExportAttributes(List<ExportAttribute> exportAttributes) {
|
|
251 |
this.exportAttributes = exportAttributes;
|
|
252 |
}
|
|
255 |
@Override
|
|
256 |
public void setExportAttributes(List<ExportAttribute> exportAttributes) {
|
|
257 |
this.exportAttributes = exportAttributes;
|
|
258 |
}
|
|
253 | 259 |
|
254 |
@Override
|
|
255 |
public void setActive(boolean active) {
|
|
256 |
this.active = active;
|
|
257 |
}
|
|
260 |
@Override
|
|
261 |
public void setActive(boolean active) {
|
|
262 |
this.active = active;
|
|
263 |
}
|
|
258 | 264 |
|
259 |
@Override
|
|
260 |
public boolean isActive() {
|
|
261 |
return this.active;
|
|
262 |
}
|
|
265 |
@Override
|
|
266 |
public boolean isActive() {
|
|
267 |
return this.active;
|
|
268 |
}
|
|
263 | 269 |
|
270 |
public static void registerPersistence() { |
|
271 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
272 |
if (manager.getDefinition("ExportAttributes") == null) { |
|
273 |
DynStruct definition = manager.addDefinition(DefaultExportAttributes.class, |
|
274 |
"ExportAttributes", "ExportAttributes persistence definition", null, null); |
|
275 |
definition.addDynFieldList("exportAttributes").setClassOfItems(ExportAttribute.class); |
|
276 |
definition.addDynFieldObject("namesTranslator").setClassOfValue(AttributeNamesTranslator.class); |
|
277 |
definition.addDynFieldObject("sourceFeatureType").setClassOfValue(FeatureType.class); |
|
278 |
definition.addDynFieldBoolean("active"); |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
@Override |
|
283 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
284 |
state.set("exportAttributes", this.exportAttributes.iterator()); |
|
285 |
state.set("namesTranslator", this.namesTranslator); |
|
286 |
state.set("sourceFeatureType", this.sourceFeatureType); |
|
287 |
state.set("active", this.active); |
|
288 |
} |
|
289 |
|
|
290 |
@Override |
|
291 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
292 |
Iterator it = state.getIterator("exportAttributes"); |
|
293 |
List<ExportAttribute> data = new ArrayList<ExportAttribute>(); |
|
294 |
while (it.hasNext()) { |
|
295 |
ExportAttribute ref = (ExportAttribute) it.next(); |
|
296 |
data.add(ref); |
|
297 |
} |
|
298 |
this.exportAttributes = data; |
|
299 |
|
|
300 |
AttributeNamesTranslator nameTranslatorState = (AttributeNamesTranslator) state.get("namesTranslator"); |
|
301 |
if (nameTranslatorState != null) { |
|
302 |
this.namesTranslator = nameTranslatorState; |
|
303 |
} |
|
304 |
this.sourceFeatureType = (FeatureType) state.get("sourceFeatureType"); |
|
305 |
this.active = state.getBoolean("active"); |
|
306 |
} |
|
307 |
|
|
264 | 308 |
} |
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/ExportJDBCParametersImpl.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.export.spi.AbstractExportParametersGeometry; |
9 | 9 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
10 |
import org.gvsig.tools.ToolsLocator; |
|
11 |
import org.gvsig.tools.dynobject.DynStruct; |
|
12 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
13 |
import org.gvsig.tools.persistence.PersistentState; |
|
14 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
10 | 15 |
|
11 | 16 |
/** |
12 | 17 |
* |
... | ... | |
41 | 46 |
public ExportJDBCParametersImpl(ExportJDBCServiceFactory factory) { |
42 | 47 |
super(factory); |
43 | 48 |
this.exportAttributes.setNamesTranslator(new ExportJDBCAttributeNamesTranslator(this)); |
44 |
|
|
49 |
|
|
45 | 50 |
this.canCreatetable = true; |
46 | 51 |
this.translateIdentifiersToLowerCase = true; |
47 | 52 |
this.removeSpacesInIdentifiers = true; |
... | ... | |
50 | 55 |
this.updateTableStatistics = true; |
51 | 56 |
} |
52 | 57 |
|
58 |
public ExportJDBCParametersImpl() { |
|
59 |
super(null); |
|
60 |
} |
|
61 |
|
|
53 | 62 |
@Override |
54 | 63 |
public String getServiceName() { |
55 | 64 |
return ExportJDBCServiceFactory.SERVICE_NAME; |
... | ... | |
392 | 401 |
return this.removeSpacesInIdentifiers; |
393 | 402 |
} |
394 | 403 |
|
404 |
@Override |
|
395 | 405 |
public ExportJDBCParameters clone() throws CloneNotSupportedException { |
396 | 406 |
ExportJDBCParameters clone = (ExportJDBCParameters) super.clone(); |
397 | 407 |
clone.setExplorerParameters((JDBCServerExplorerParameters) this.explorerParameters.getCopy()); |
398 |
clone.getExportAttributes().setNamesTranslator(new ExportJDBCAttributeNamesTranslator(clone)); |
|
399 | 408 |
return clone; |
400 | 409 |
} |
401 | 410 |
|
411 |
public static void registerPersistence() { |
|
412 |
|
|
413 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
414 |
if (manager.getDefinition("ExportJDBCParametersImpl") == null) { |
|
415 |
DynStruct definition = manager.addDefinition(ExportJDBCParametersImpl.class, |
|
416 |
"ExportJDBCParametersImpl", "ExportJDBCParametersImpl persistence definition", null, null); |
|
417 |
definition.addDynFieldObject("explorerParameters").setClassOfValue(JDBCServerExplorerParameters.class); |
|
418 |
definition.addDynFieldString("schema"); |
|
419 |
definition.addDynFieldString("tableName"); |
|
420 |
definition.addDynFieldBoolean("canCreatetable"); |
|
421 |
definition.addDynFieldString("primaryKeyName"); |
|
422 |
definition.addDynFieldString("storeName"); |
|
423 |
definition.addDynFieldString("explorerName"); |
|
424 |
definition.addDynFieldBoolean("translateIdentifiersToLowerCase"); |
|
425 |
definition.addDynFieldBoolean("removeSpacesInIdentifiers"); |
|
426 |
definition.addDynFieldBoolean("translateHyphens"); |
|
427 |
definition.addDynFieldString("selectRole"); |
|
428 |
definition.addDynFieldString("insertRole"); |
|
429 |
definition.addDynFieldString("updateRole"); |
|
430 |
definition.addDynFieldString("deleteRole"); |
|
431 |
definition.addDynFieldString("truncateRole"); |
|
432 |
definition.addDynFieldString("referenceRole"); |
|
433 |
definition.addDynFieldString("triggerRole"); |
|
434 |
definition.addDynFieldString("allRole"); |
|
435 |
definition.addDynFieldString("postCreatingStatement"); |
|
436 |
definition.addDynFieldBoolean("createIndexInGeometryRow"); |
|
437 |
definition.addDynFieldBoolean("updateTableStatistics"); |
|
438 |
definition.extend(manager.getDefinition("AbstractExportParametersGeometry")); |
|
439 |
} |
|
440 |
} |
|
441 |
|
|
442 |
@Override |
|
443 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
444 |
super.saveToState(state); |
|
445 |
state.set("explorerParameters", explorerParameters); |
|
446 |
state.set("schema", schema); |
|
447 |
state.set("tableName", tableName); |
|
448 |
state.set("canCreatetable", canCreatetable); |
|
449 |
state.set("primaryKeyName", primaryKeyName); |
|
450 |
state.set("storeName", storeName); |
|
451 |
state.set("explorerName", explorerName); |
|
452 |
state.set("translateIdentifiersToLowerCase", translateIdentifiersToLowerCase); |
|
453 |
state.set("removeSpacesInIdentifiers", removeSpacesInIdentifiers); |
|
454 |
state.set("translateHyphens", translateHyphens); |
|
455 |
state.set("selectRole", selectRole); |
|
456 |
state.set("insertRole", insertRole); |
|
457 |
state.set("updateRole", updateRole); |
Also available in: Unified diff