Revision 46646
tags/org.gvsig.desktop-2.0.389/license.txt | ||
---|---|---|
1 |
gvSIG. Desktop Geographic Information System. |
|
2 |
|
|
3 |
Copyright (C) 2007-2020 gvSIG Association. |
|
4 |
|
|
5 |
This program is free software; you can redistribute it and/or |
|
6 |
modify it under the terms of the GNU General Public License |
|
7 |
as published by the Free Software Foundation; either version 3 |
|
8 |
of the License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
|
|
18 |
For any additional information, do not hesitate to contact us |
|
19 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportParametersGeometry.java | ||
---|---|---|
1 |
package org.gvsig.export; |
|
2 |
|
|
3 |
import org.cresques.cts.ICoordTrans; |
|
4 |
import org.cresques.cts.IProjection; |
|
5 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @author jjdelcerro |
|
10 |
*/ |
|
11 |
public interface ExportParametersGeometry extends ExportParameters { |
|
12 |
|
|
13 |
public static final int CHECKGEOMETRY_NONE = 0; |
|
14 |
public static final int CHECKGEOMETRY_CHECK_IF_CORRUPT = 1; |
|
15 |
public static final int CHECKGEOMETRY_CHECK_IF_VALID = 2; |
|
16 |
|
|
17 |
public static final int CHECKGEOMETRYACTION_SET_GEOMETRY_TO_NULL = 0; |
|
18 |
public static final int CHECKGEOMETRYACTION_SKIP_FEATURE = 1; |
|
19 |
public static final int CHECKGEOMETRYACTION_ABORT = 2; |
|
20 |
|
|
21 |
|
|
22 |
public void setContextProjection(IProjection projection); |
|
23 |
|
|
24 |
public IProjection getContextProjection(); |
|
25 |
|
|
26 |
|
|
27 |
public void setSourceProjection(IProjection projection); |
|
28 |
|
|
29 |
public IProjection getSourceProjection(); |
|
30 |
|
|
31 |
public void setSourceTransformation(ICoordTrans transformation); |
|
32 |
|
|
33 |
public ICoordTrans getSourceTransformation(); |
|
34 |
|
|
35 |
|
|
36 |
public void setTargetProjection(IProjection targetProjection); |
|
37 |
|
|
38 |
public IProjection getTargetProjection(); |
|
39 |
|
|
40 |
public void setTargetTransformation(ICoordTrans transformation); |
|
41 |
|
|
42 |
public ICoordTrans getTargetTransformation(); |
|
43 |
|
|
44 |
public ICoordTrans getTransformationToUse(); |
|
45 |
|
|
46 |
|
|
47 |
public int getGeometryChecks(); |
|
48 |
|
|
49 |
public int getGeometryChecksAction(); |
|
50 |
|
|
51 |
public boolean getTryToFixGeometry(); |
|
52 |
|
|
53 |
public void setGeometryChecks(int geometryChecks); |
|
54 |
|
|
55 |
public void setGeometryChecksAction(int geometryChecksAction); |
|
56 |
|
|
57 |
public void setTryToFixGeometry(boolean tryToFixGeometry); |
|
58 |
|
|
59 |
public String getSourceGeometryFieldName(); |
|
60 |
|
|
61 |
public void setSourceGeometryFieldName(String geometryFieldName); |
|
62 |
|
|
63 |
public GeometryType getTargetGeometryType(); |
|
64 |
|
|
65 |
public int getTargetGeometryTypeAsInt(); |
|
66 |
|
|
67 |
public int getTargetGeometrySubtype(); |
|
68 |
|
|
69 |
public void setTargetGeometryType(GeometryType type); |
|
70 |
|
|
71 |
public void setTargetGeometryType(int type); |
|
72 |
|
|
73 |
public void setTargetGeometrySubtype(int subtype); |
|
74 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.export; |
|
25 |
|
|
26 |
import org.gvsig.export.spi.ExportServiceManager; |
|
27 |
import org.gvsig.tools.locator.BaseLocator; |
|
28 |
import org.gvsig.tools.locator.Locator; |
|
29 |
import org.gvsig.tools.locator.LocatorException; |
|
30 |
|
|
31 |
/** |
|
32 |
* This locator is the entry point for the Exportto library, providing |
|
33 |
* access to all Exportto services through the {@link ExportManager} . |
|
34 |
* |
|
35 |
* @author gvSIG team |
|
36 |
* @version $Id$ |
|
37 |
*/ |
|
38 |
public class ExportLocator extends BaseLocator { |
|
39 |
|
|
40 |
public static final String MANAGER_NAME = "Export.manager"; |
|
41 |
public static final String MANAGER_DESCRIPTION = "Export Manager"; |
|
42 |
|
|
43 |
public static final String ENTRIES_MANAGER_NAME = "Export.entriesManager"; |
|
44 |
public static final String ENTRIES_MANAGER_DESCRIPTION = "Export Entries Manager"; |
|
45 |
|
|
46 |
public static final String SERVICE_MANAGER_NAME = "Export.serviceManager"; |
|
47 |
public static final String SERVICE_MANAGER_DESCRIPTION = "Export Service Manager"; |
|
48 |
|
|
49 |
private static final String LOCATOR_NAME = "Export.locator"; |
|
50 |
|
|
51 |
/** |
|
52 |
* Unique instance. |
|
53 |
*/ |
|
54 |
private static final ExportLocator INSTANCE = new ExportLocator(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Return the singleton instance. |
|
58 |
* |
|
59 |
* @return the singleton instance |
|
60 |
*/ |
|
61 |
public static ExportLocator getInstance() { |
|
62 |
return INSTANCE; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Return the Locator's name. |
|
67 |
* |
|
68 |
* @return a String with the Locator's name |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
public final String getLocatorName() { |
|
72 |
return LOCATOR_NAME; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Return a reference to the ExportManager. |
|
77 |
* |
|
78 |
* @return a reference to the ExportManager |
|
79 |
* @throws LocatorException |
|
80 |
* if there is no access to the class or the class cannot be |
|
81 |
* instantiated |
|
82 |
* @see Locator#get(String) |
|
83 |
*/ |
|
84 |
public static ExportManager getManager() throws LocatorException { |
|
85 |
return (ExportManager) getInstance().get(MANAGER_NAME); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Registers the Class implementing the ExportManager interface. |
|
90 |
* |
|
91 |
* @param clazz |
|
92 |
* implementing the ExportManager interface |
|
93 |
*/ |
|
94 |
public static void registerManager(Class<? extends ExportManager> clazz) { |
|
95 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Return a reference to the ExportServiceMnager. |
|
100 |
* |
|
101 |
* @return a reference to the ExportServiceMnager |
|
102 |
* @throws LocatorException |
|
103 |
* if there is no access to the class or the class cannot be |
|
104 |
* instantiated |
|
105 |
* @see Locator#get(String) |
|
106 |
*/ |
|
107 |
public static ExportServiceManager getServiceManager() throws LocatorException { |
|
108 |
return (ExportServiceManager) getInstance().get(SERVICE_MANAGER_NAME); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Registers the Class implementing the ExportServiceManager interface. |
|
113 |
* |
|
114 |
* @param clazz |
|
115 |
* implementing the ExportServiceManager interface |
|
116 |
*/ |
|
117 |
public static void registerServiceManager(Class<? extends ExportServiceManager> clazz) { |
|
118 |
getInstance().register(SERVICE_MANAGER_NAME, SERVICE_MANAGER_DESCRIPTION, clazz); |
|
119 |
} |
|
120 |
|
|
121 |
} |
|
0 | 122 |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportParameters.java | ||
---|---|---|
1 |
package org.gvsig.export; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import org.gvsig.export.spi.ExportServiceFactory; |
|
5 |
import org.gvsig.expressionevaluator.Expression; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
9 |
import org.gvsig.tools.persistence.Persistent; |
|
10 |
import org.gvsig.tools.util.LabeledValue; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author jjdelcerro |
|
15 |
*/ |
|
16 |
public interface ExportParameters extends Cloneable, LabeledValue, Persistent { |
|
17 |
|
|
18 |
public static final int USE_ALL_FEATURES = 0; |
|
19 |
public static final int USE_SELECTED_FEATURES = 1; |
|
20 |
public static final int USE_FILTERED_FEATURES = 2; |
|
21 |
|
|
22 |
public String getServiceName(); |
|
23 |
|
|
24 |
public boolean needsSelectTargetProjection(); |
|
25 |
|
|
26 |
public FeatureType getSourceFeatureType(); |
|
27 |
|
|
28 |
public void setSourceFeatureType(FeatureType sourceFeatureType); |
|
29 |
|
|
30 |
public void setSourceFeatureStore(FeatureStore sourceFeatureStore); |
|
31 |
|
|
32 |
public FeatureStore getSourceFeatureStore(); |
|
33 |
|
|
34 |
public int getFeaturesToUse(); |
|
35 |
|
|
36 |
public void setFeaturesToUse(int feturesToUse); |
|
37 |
|
|
38 |
public Expression getFilterExpresion(); |
|
39 |
|
|
40 |
public void setFilterExpresion(Expression expression); |
|
41 |
|
|
42 |
public FeatureQuery getFeatureQuery(); |
|
43 |
|
|
44 |
public void setFeatureQuery(FeatureQuery query); |
|
45 |
|
|
46 |
public Object getContext(); |
|
47 |
|
|
48 |
public void setContext(Object context); |
|
49 |
|
|
50 |
public ExportAttributes getExportAttributes(); |
|
51 |
|
|
52 |
public void setExportAttributes(ExportAttributes exportAttributes); |
|
53 |
|
|
54 |
public Date getCreationDate(); |
|
55 |
|
|
56 |
public void setCreationDate(Date date); |
|
57 |
|
|
58 |
public ExportParameters clone() throws CloneNotSupportedException; |
|
59 |
|
|
60 |
public ExportServiceFactory getFactory(); |
|
61 |
|
|
62 |
public FeatureType getTargetFeatureType(); |
|
63 |
|
|
64 |
public void resetVolatileValues(); |
|
65 |
|
|
66 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportParametersFile.java | ||
---|---|---|
1 |
package org.gvsig.export; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import org.gvsig.tools.util.HasAFile; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public interface ExportParametersFile extends HasAFile { |
|
11 |
|
|
12 |
@Override |
|
13 |
public File getFile(); |
|
14 |
|
|
15 |
@Override |
|
16 |
public void setFile(File file); |
|
17 |
|
|
18 |
public File getEvaluatedFile(); |
|
19 |
|
|
20 |
public String getFileExtension(); |
|
21 |
|
|
22 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/Filter.java | ||
---|---|---|
1 |
package org.gvsig.export; |
|
2 |
|
|
3 |
/** |
|
4 |
* |
|
5 |
* @author jjdelcerro |
|
6 |
*/ |
|
7 |
public interface Filter<T> { |
|
8 |
|
|
9 |
public boolean apply(T obj); |
|
10 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.export; |
|
25 |
|
|
26 |
import org.gvsig.export.spi.AbstractExportParameters; |
|
27 |
import org.gvsig.export.spi.AbstractExportParametersFile; |
|
28 |
import org.gvsig.export.spi.AbstractExportParametersFile.ExportParametersFileHelper; |
|
29 |
import org.gvsig.export.spi.AbstractExportParametersGeometry; |
|
30 |
import org.gvsig.export.spi.AbstractExportParametersGeometryFile; |
|
31 |
import org.gvsig.tools.library.AbstractLibrary; |
|
32 |
import org.gvsig.tools.library.LibraryException; |
|
33 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
34 |
|
|
35 |
/** |
|
36 |
* Library for API initialization and configuration. |
|
37 |
* |
|
38 |
* @author gvSIG team |
|
39 |
* @version $Id$ |
|
40 |
*/ |
|
41 |
public class ExportLibrary extends AbstractLibrary { |
|
42 |
|
|
43 |
@Override |
|
44 |
public void doRegistration() { |
|
45 |
registerAsAPI(ExportLibrary.class); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doInitialize() throws LibraryException { |
|
50 |
// Do nothing |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected void doPostInitialize() throws LibraryException { |
|
55 |
// Validate there is any implementation registered. |
|
56 |
ExportManager manager = ExportLocator.getManager(); |
|
57 |
if (manager == null) { |
|
58 |
throw new ReferenceNotRegisteredException( |
|
59 |
ExportLocator.MANAGER_NAME, ExportLocator.getInstance()); |
|
60 |
} |
|
61 |
|
|
62 |
AbstractExportParameters.registerPersistence(); |
|
63 |
AbstractExportParametersGeometry.registerPersistence(); |
|
64 |
AbstractExportParametersFile.registerPersistence(); |
|
65 |
AbstractExportParametersGeometryFile.registerPersistence(); |
|
66 |
ExportParametersFileHelper.registerPersistence(); |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
} |
|
0 | 71 |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/ExportAttributes.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.export; |
|
7 |
|
|
8 |
import java.util.List; |
|
9 |
import org.gvsig.export.ExportAttributes.ExportAttribute; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
12 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
13 |
import org.gvsig.tools.namestranslator.NamesTranslator; |
|
14 |
import org.gvsig.tools.persistence.Persistent; |
|
15 |
import org.gvsig.tools.util.UnmodifiableBasicList; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author osc |
|
20 |
*/ |
|
21 |
public interface ExportAttributes extends UnmodifiableBasicList<ExportAttribute>, Cloneable, Persistent { |
|
22 |
|
|
23 |
public ExportAttributes clone() throws CloneNotSupportedException; |
|
24 |
|
|
25 |
public void setActive(boolean b); |
|
26 |
|
|
27 |
public boolean isActive(); |
|
28 |
|
|
29 |
public interface ExportAttribute extends Cloneable, Persistent { |
|
30 |
|
|
31 |
public FeatureAttributeDescriptor getDescriptor(); |
|
32 |
|
|
33 |
public String getName(); |
|
34 |
|
|
35 |
public String getNewName(); |
|
36 |
|
|
37 |
public int getDataType(); |
|
38 |
|
|
39 |
public int getNewDataType(); |
|
40 |
|
|
41 |
public boolean isExported(); |
|
42 |
|
|
43 |
public boolean isComputed(); |
|
44 |
|
|
45 |
public int getSize(); |
|
46 |
|
|
47 |
public void setSize(int size); |
|
48 |
|
|
49 |
public int setNewName(String name); |
|
50 |
|
|
51 |
public void setNewType(int dataType); |
|
52 |
|
|
53 |
public void setExported(boolean exported); |
|
54 |
|
|
55 |
public void setComputed(boolean computed); |
|
56 |
|
|
57 |
public boolean isFromQuery(); |
|
58 |
|
|
59 |
public ExportAttribute clone() throws CloneNotSupportedException; |
|
60 |
} |
|
61 |
|
|
62 |
public ExportAttribute getExportAttribute(String name); |
|
63 |
|
|
64 |
public FeatureType getTargetFeatureType(); |
|
65 |
|
|
66 |
public void setSourceFeatureType(FeatureType sourceFeatureType, FeatureQuery query); |
|
67 |
|
|
68 |
public FeatureType getSourceFeatureType(); |
|
69 |
|
|
70 |
public String getTargetName(String name); |
|
71 |
|
|
72 |
public String getSourceName(String name); |
|
73 |
|
|
74 |
public int getTargetType(String name); |
|
75 |
|
|
76 |
public int getSourceType(String name); |
|
77 |
|
|
78 |
public void setNamesTranslator(NamesTranslator attnt); |
|
79 |
|
|
80 |
public NamesTranslator getNamesTranslator(); |
|
81 |
|
|
82 |
public void setExportAttributes(List<ExportAttribute> exportAttributes); |
|
83 |
|
|
84 |
public boolean isQueryAttribute(FeatureAttributeDescriptor attr); |
|
85 |
|
|
86 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/ExportGeometryHelper.java | ||
---|---|---|
1 |
package org.gvsig.export.spi; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
4 |
import org.gvsig.fmap.dal.feature.Feature; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public interface ExportGeometryHelper { |
|
11 |
|
|
12 |
boolean canProcessGeometry(); |
|
13 |
|
|
14 |
int copyGeometry(Feature sourceFeature, EditableFeature targetFeature); |
|
15 |
|
|
16 |
String getLastErrorMessage(); |
|
17 |
|
|
18 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/ExportServiceManager.java | ||
---|---|---|
1 |
package org.gvsig.export.spi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import org.cresques.cts.ICoordTrans; |
|
5 |
import org.gvsig.export.ExportAttributes; |
|
6 |
import org.gvsig.export.ExportParameters; |
|
7 |
import org.gvsig.export.ExportParametersGeometry; |
|
8 |
import org.gvsig.export.Filter; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
10 |
import org.gvsig.fmap.geom.Geometry; |
|
11 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
|
12 |
import org.gvsig.tools.bookmarksandhistory.History; |
|
13 |
|
|
14 |
/** |
|
15 |
* |
|
16 |
* @author jjdelcerro |
|
17 |
*/ |
|
18 |
public interface ExportServiceManager { |
|
19 |
|
|
20 |
public interface FixGeometryStatus { |
|
21 |
public static final int STATE_OK = 0; |
|
22 |
public static final int STATE_SKIP = 1; |
|
23 |
public static final int STATE_ABORT = 2; |
|
24 |
|
|
25 |
public Geometry getGeometry(); |
|
26 |
public int getState(); |
|
27 |
public String getMessage(); |
|
28 |
} |
|
29 |
|
|
30 |
public List<ExportServiceFactory> getAllServiceFactories(); |
|
31 |
|
|
32 |
public List<ExportServiceFactory> getServiceFactories(Filter<ExportServiceFactory> filter); |
|
33 |
|
|
34 |
public ExportServiceFactory getServiceFactory(String name); |
|
35 |
|
|
36 |
public ExportService createService(ExportParameters paramaters); |
|
37 |
|
|
38 |
public ExportParameters createServiceParameters(String name); |
|
39 |
|
|
40 |
public void register(ExportServiceFactory factory); |
|
41 |
|
|
42 |
public FixGeometryStatus fixGeometry( |
|
43 |
ExportParametersGeometry parameters, |
|
44 |
ICoordTrans coord_trans, |
|
45 |
Geometry geometry |
|
46 |
); |
|
47 |
|
|
48 |
public ExportGeometryHelper createGeometryHelper( |
|
49 |
ExportParametersGeometry parameters, |
|
50 |
FeatureType theTargetFeatureType, |
|
51 |
FeatureType theSourceFeatureType |
|
52 |
); |
|
53 |
|
|
54 |
public ExportAttributes createExportAttributes(); |
|
55 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/AbstractExportServiceFactory.java | ||
---|---|---|
1 |
package org.gvsig.export.spi; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
import org.gvsig.tools.ToolsLocator; |
|
6 |
import org.gvsig.tools.i18n.I18nManager; |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jjdelcerro |
|
11 |
*/ |
|
12 |
public abstract class AbstractExportServiceFactory implements ExportServiceFactory { |
|
13 |
|
|
14 |
private final String name; |
|
15 |
private final String description; |
|
16 |
|
|
17 |
private static final Map<ExportServiceFactory, Boolean>serviceEnabled = new HashMap<>(); |
|
18 |
private final String label; |
|
19 |
|
|
20 |
public AbstractExportServiceFactory( |
|
21 |
String name, |
|
22 |
String label, |
|
23 |
String description |
|
24 |
) { |
|
25 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
26 |
this.name = name; |
|
27 |
this.label = i18n.getTranslation(label); |
|
28 |
this.description = i18n.getTranslation(description); |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public String getName() { |
|
33 |
return name; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public String getLabel() { |
|
38 |
return label; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public String getDescription() { |
|
43 |
return description; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public boolean isEnabled() { |
|
48 |
Boolean enabled = serviceEnabled.getOrDefault(this, true); |
|
49 |
return enabled; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public void setEnabled(boolean value) { |
|
54 |
serviceEnabled.put(this, value); |
|
55 |
} |
|
56 |
|
|
57 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/ExportService.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.export.spi; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
import org.gvsig.export.ExportException; |
|
28 |
import org.gvsig.export.ExportParameters; |
|
29 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
32 |
import org.gvsig.tools.task.MonitorableTask; |
|
33 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
34 |
|
|
35 |
/** |
|
36 |
* <p> |
|
37 |
* This service is used to export a source {@link FeatureStore} to a target |
|
38 |
* {@link FeatureStore}. |
|
39 |
* </p> |
|
40 |
* <p> |
|
41 |
* It inherits if {@link MonitorableTask}, and it means that the export process |
|
42 |
* can be monitorized by one or more observers that can listen all the export |
|
43 |
* events. |
|
44 |
* <p> |
|
45 |
* |
|
46 |
* @author gvSIG team |
|
47 |
* @version $Id$ |
|
48 |
*/ |
|
49 |
public interface ExportService extends MonitorableTask { |
|
50 |
|
|
51 |
public interface ExportFinishListener { |
|
52 |
|
|
53 |
public void cancelled(ExportService exportService); |
|
54 |
|
|
55 |
public void finished(ExportService exportService); |
|
56 |
} |
|
57 |
|
|
58 |
public ExportServiceFactory getFactory(); |
|
59 |
|
|
60 |
public ExportParameters getParameters() ; |
|
61 |
|
|
62 |
public void addFinishListener(ExportFinishListener listener); |
|
63 |
|
|
64 |
// public AttributeNamesTranslator getAttributeNamesTranslator(); |
|
65 |
|
|
66 |
public void export(FeatureSet featureSet) throws ExportException; |
|
67 |
|
|
68 |
public List<OpenDataStoreParameters> getTargetOpenStoreParameters() throws ExportException; |
|
69 |
|
|
70 |
public void setTaskStatus(SimpleTaskStatus taskStatus); |
|
71 |
|
|
72 |
} |
|
0 | 73 |
tags/org.gvsig.desktop-2.0.389/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 | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.export.spi; |
|
7 |
|
|
8 |
import org.cresques.cts.ICoordTrans; |
|
9 |
import org.cresques.cts.IProjection; |
|
10 |
import org.gvsig.export.ExportParameters; |
|
11 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
12 |
import org.gvsig.fmap.geom.GeometryManager; |
|
13 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
14 |
import org.gvsig.export.ExportParametersGeometry; |
|
15 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
16 |
import org.gvsig.fmap.geom.Geometry; |
|
17 |
import org.gvsig.tools.ToolsLocator; |
|
18 |
import org.gvsig.tools.dynobject.DynStruct; |
|
19 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
20 |
import org.gvsig.tools.persistence.PersistentState; |
|
21 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
22 |
|
|
23 |
/** |
|
24 |
* |
|
25 |
* @author jjdelcerro |
|
26 |
*/ |
|
27 |
public abstract class AbstractExportParametersGeometry |
|
28 |
extends AbstractExportParameters |
|
29 |
implements ExportParametersGeometry { |
|
30 |
|
|
31 |
private IProjection contextProjection; |
|
32 |
private IProjection sourceProjection; |
|
33 |
private IProjection targetProjection; |
|
34 |
|
|
35 |
private ICoordTrans sourceTransformation; |
|
36 |
private ICoordTrans targetTransformation; |
|
37 |
|
|
38 |
private int geometryChecks; |
|
39 |
private int geometryChecksAction; |
|
40 |
private boolean tryToFixGeometry; |
|
41 |
private String geometryFieldName; |
|
42 |
private int geometryType; |
|
43 |
private int geometrySubtype; |
|
44 |
|
|
45 |
public AbstractExportParametersGeometry(ExportServiceFactory factory) { |
|
46 |
super(factory); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public boolean needsSelectTargetProjection() { |
|
51 |
return true; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void setContextProjection(IProjection projection) { |
|
56 |
this.contextProjection = projection; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public IProjection getContextProjection() { |
|
61 |
return this.contextProjection; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public void setSourceProjection(IProjection sourceProjection) { |
|
66 |
this.sourceProjection = sourceProjection; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public IProjection getSourceProjection() { |
|
71 |
return sourceProjection; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public ICoordTrans getSourceTransformation() { |
|
76 |
return sourceTransformation; |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public void setSourceTransformation(ICoordTrans contextTransformation) { |
|
81 |
this.sourceTransformation = contextTransformation; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public void setTargetProjection(IProjection targetProjection) { |
|
86 |
this.targetProjection = targetProjection; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public IProjection getTargetProjection() { |
|
91 |
if (this.targetProjection == null) { |
|
92 |
return this.sourceProjection; |
|
93 |
} |
|
94 |
return this.targetProjection; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public void setTargetTransformation(ICoordTrans transformation) { |
|
99 |
this.targetTransformation = transformation; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public ICoordTrans getTargetTransformation() { |
|
104 |
return targetTransformation; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public int getGeometryChecks() { |
|
109 |
return this.geometryChecks; |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public int getGeometryChecksAction() { |
|
114 |
return this.geometryChecksAction; |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
public boolean getTryToFixGeometry() { |
|
119 |
return this.tryToFixGeometry; |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public void setGeometryChecks(int geometryChecks) { |
|
124 |
this.geometryChecks = geometryChecks; |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public void setGeometryChecksAction(int geometryChecksAction) { |
|
129 |
this.geometryChecksAction = geometryChecksAction; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void setTryToFixGeometry(boolean tryToFixGeometry) { |
|
134 |
this.tryToFixGeometry = tryToFixGeometry; |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public String getSourceGeometryFieldName() { |
|
139 |
return this.geometryFieldName; |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
public void setSourceGeometryFieldName(String geometryFieldName) { |
|
144 |
this.geometryFieldName = geometryFieldName; |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public int getTargetGeometryTypeAsInt() { |
|
149 |
return geometryType; |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public int getTargetGeometrySubtype() { |
|
154 |
return geometrySubtype; |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public void setTargetGeometryType(int geometryType) { |
|
159 |
this.geometryType = geometryType; |
|
160 |
} |
|
161 |
|
|
162 |
@Override |
|
163 |
public void setTargetGeometrySubtype(int subtype) { |
|
164 |
this.geometrySubtype = subtype; |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
public void setTargetGeometryType(GeometryType type) { |
|
169 |
this.geometryType = type.getType(); |
|
170 |
this.geometrySubtype = type.getSubType(); |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public GeometryType getTargetGeometryType() { |
|
175 |
try { |
|
176 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
177 |
GeometryType type = geomManager.getGeometryType( |
|
178 |
geometryType, |
|
179 |
geometrySubtype |
|
180 |
); |
|
181 |
return type; |
|
182 |
} catch (Exception ex) { |
|
183 |
throw new RuntimeException("Can't create geoemtry type from type " + geometryType + ", subtype " + geometrySubtype + ".", ex); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public ExportParameters clone() throws CloneNotSupportedException { |
|
189 |
AbstractExportParametersGeometry clone = (AbstractExportParametersGeometry) super.clone(); |
|
190 |
clone.setContextProjection(this.contextProjection); |
|
191 |
clone.setSourceProjection(this.sourceProjection); |
|
192 |
clone.setTargetProjection(this.targetProjection); |
|
193 |
clone.setSourceTransformation(this.sourceTransformation); |
|
194 |
clone.setTargetTransformation(this.targetTransformation); |
|
195 |
clone.setSourceGeometryFieldName(this.geometryFieldName); |
|
196 |
clone.setGeometryChecks(this.geometryChecks); |
|
197 |
clone.setGeometryChecksAction(this.geometryChecksAction); |
|
198 |
clone.setTryToFixGeometry(this.tryToFixGeometry); |
|
199 |
clone.setTargetGeometryType(this.geometryType); |
|
200 |
clone.setTargetGeometrySubtype(this.geometrySubtype); |
|
201 |
return clone; |
|
202 |
} |
|
203 |
|
|
204 |
public static void registerPersistence() { |
|
205 |
|
|
206 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
207 |
if (manager.getDefinition("AbstractExportParametersGeometry") == null) { |
|
208 |
DynStruct definition = manager.addDefinition(AbstractExportParametersGeometry.class, |
|
209 |
"AbstractExportParametersGeometry", "AbstractExportParametersGeometry persistence definition", null, null); |
|
210 |
definition.addDynFieldObject("contextProjection").setClassOfValue(IProjection.class); |
|
211 |
definition.addDynFieldObject("sourceProjection").setClassOfValue(IProjection.class); |
|
212 |
definition.addDynFieldObject("targetProjection").setClassOfValue(IProjection.class); |
|
213 |
definition.addDynFieldObject("sourceTransformation").setClassOfValue(ICoordTrans.class); |
|
214 |
definition.addDynFieldObject("targetTransformation").setClassOfValue(ICoordTrans.class); |
|
215 |
definition.addDynFieldInt("geometryChecks"); |
|
216 |
definition.addDynFieldInt("geometryChecksAction"); |
|
217 |
definition.addDynFieldBoolean("tryToFixGeometry"); |
|
218 |
definition.addDynFieldString("geometryFieldName"); |
|
219 |
definition.addDynFieldInt("geometryType"); |
|
220 |
definition.addDynFieldInt("geometrySubtype"); |
|
221 |
definition.extend(manager.getDefinition("AbstractExportParameters")); |
|
222 |
} |
|
223 |
} |
|
224 |
|
|
225 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
226 |
super.saveToState(state); |
|
227 |
state.set("contextProjection", this.contextProjection); |
|
228 |
state.set("sourceProjection", this.sourceProjection); |
|
229 |
state.set("targetProjection", this.targetProjection); |
|
230 |
state.set("sourceTransformation", this.sourceTransformation); |
|
231 |
state.set("targetTransformation", this.targetTransformation); |
|
232 |
state.set("geometryChecks", this.geometryChecks); |
|
233 |
state.set("geometryChecksAction", this.geometryChecksAction); |
|
234 |
state.set("tryToFixGeometry", this.tryToFixGeometry); |
|
235 |
state.set("geometryFieldName", this.geometryFieldName); |
|
236 |
state.set("geometryType", this.geometryType); |
|
237 |
state.set("geometrySubtype", this.geometrySubtype); |
|
238 |
} |
|
239 |
|
|
240 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
241 |
super.loadFromState(state); |
|
242 |
this.contextProjection = (IProjection) state.get("contextProjection"); |
|
243 |
this.sourceProjection = (IProjection) state.get("sourceProjection"); |
|
244 |
this.targetProjection = (IProjection) state.get("targetProjection"); |
|
245 |
this.sourceTransformation = (ICoordTrans) state.get("sourceTransformation"); |
|
246 |
this.targetTransformation = (ICoordTrans) state.get("targetTransformation"); |
|
247 |
this.geometryChecks = state.getInt("geometryChecks"); |
|
248 |
this.geometryChecksAction = state.getInt("geometryChecksAction"); |
|
249 |
this.tryToFixGeometry = state.getBoolean("tryToFixGeometry"); |
|
250 |
this.geometryFieldName = state.getString("geometryFieldName"); |
|
251 |
this.geometryType = state.getInt("geometryType"); |
|
252 |
this.geometrySubtype = state.getInt("geometrySubtype"); |
|
253 |
} |
|
254 |
|
|
255 |
@Override |
|
256 |
public ICoordTrans getTransformationToUse() { |
|
257 |
FeatureAttributeDescriptor geo_att = this.getSourceFeatureType().getDefaultGeometryAttribute(); |
|
258 |
|
|
259 |
IProjection sourceProjection; |
|
260 |
ICoordTrans coord_trans = null; |
|
261 |
Geometry reproj_geom; |
|
262 |
IProjection targetProjection = this.getTargetProjection(); |
|
263 |
if (geo_att != null) { |
|
264 |
sourceProjection = geo_att.getSRS(); |
|
265 |
// this comparison is perhaps too preventive |
|
266 |
// we could have two instances of same projection |
|
267 |
// so we would do more computations than needed |
|
268 |
if (sourceProjection != null && targetProjection != null && sourceProjection != targetProjection) { |
|
269 |
if (this.getTargetTransformation() != null) { |
|
270 |
coord_trans = this.getTargetTransformation(); |
|
271 |
} else { |
|
272 |
coord_trans = sourceProjection.getCT(targetProjection); |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
} |
|
277 |
return coord_trans; |
|
278 |
} |
|
279 |
} |
tags/org.gvsig.desktop-2.0.389/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/AbstractExportParametersGeometryFile.java | ||
---|---|---|
1 |
package org.gvsig.export.spi; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import org.gvsig.export.ExportParametersFile; |
|
5 |
import org.gvsig.export.spi.AbstractExportParametersFile.ExportParametersFileHelper; |
|
6 |
import org.gvsig.tools.ToolsLocator; |
|
7 |
import org.gvsig.tools.dynobject.DynStruct; |
|
8 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
9 |
import org.gvsig.tools.persistence.PersistentState; |
|
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author jjdelcerro |
|
15 |
*/ |
|
16 |
public abstract class AbstractExportParametersGeometryFile |
|
17 |
extends AbstractExportParametersGeometry |
|
18 |
implements ExportParametersFile |
|
19 |
{ |
|
20 |
protected AbstractExportParametersFile.ExportParametersFileHelper fileHelper; |
|
21 |
|
|
22 |
public AbstractExportParametersGeometryFile(ExportServiceFactory factory) { |
|
23 |
super(factory); |
|
24 |
this.fileHelper = new ExportParametersFileHelper(); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public File getFile() { |
|
29 |
return this.fileHelper.getFile(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public void setFile(File file) { |
|
34 |
this.fileHelper.setFile(file); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public File getEvaluatedFile() { |
|
39 |
return this.fileHelper.getEvaluatedFile(); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
44 |
super.saveToState(state); |
|
45 |
state.set("fileHelper", this.fileHelper); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
50 |
super.loadFromState(state); |
|
51 |
this.fileHelper = (ExportParametersFileHelper) state.get("fileHelper"); |
|
52 |
} |
|
53 |
|
|
54 |
public static void registerPersistence() { |
|
55 |
|
|
56 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
57 |
if (manager.getDefinition("AbstractExportParametersGeometryFile") == null) { |
|
58 |
DynStruct definition = manager.addDefinition(AbstractExportParametersGeometryFile.class, |
|
59 |
"AbstractExportParametersGeometryFile", "AbstractExportParametersGeometryFile persistence definition", null, null); |
|
60 |
definition.addDynFieldObject("fileHelper"); |
|
61 |
definition.extend(manager.getDefinition("AbstractExportParametersGeometry")); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public final String getFileExtension() { |
|
67 |
return this.fileHelper.getFileExtension(); |
|
68 |
} |
|
69 |
|
|
70 |
|
|
71 |
@Override |
|
72 |
public void resetVolatileValues() { |
|
73 |
this.fileHelper.resetVolatileValues(); |
|
74 |
} |
|
75 |
|
|
76 |
} |
tags/org.gvsig.desktop-2.0.389/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 | ||
---|---|---|
1 |
package org.gvsig.export.spi; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashSet; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Set; |
|
7 |
import org.apache.commons.lang3.StringUtils; |
|
8 |
import org.gvsig.export.ExportAttributes; |
|
9 |
import org.gvsig.export.ExportException; |
|
10 |
import org.gvsig.export.ExportLocator; |
|
11 |
import org.gvsig.export.ExportParameters; |
|
12 |
import org.gvsig.export.ExportParametersGeometry; |
|
13 |
import org.gvsig.export.spi.ExportServiceManager.FixGeometryStatus; |
|
14 |
import org.gvsig.fmap.dal.DALLocator; |
|
15 |
import org.gvsig.fmap.dal.DataManager; |
|
16 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
17 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
18 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
19 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
20 |
import org.gvsig.fmap.dal.feature.Feature; |
|
21 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
22 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
23 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
24 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
25 |
import org.gvsig.tools.ToolsLocator; |
|
26 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
27 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
28 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
29 |
import org.slf4j.Logger; |
|
30 |
import org.slf4j.LoggerFactory; |
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @author jjdelcerro |
|
35 |
*/ |
|
36 |
public abstract class AbstractExportService |
|
37 |
implements ExportService { |
|
38 |
|
|
39 |
protected static final Logger LOG = LoggerFactory.getLogger(AbstractExportService.class); |
|
40 |
|
|
41 |
private final ExportParameters parameters; |
|
42 |
private final Set<ExportFinishListener> finishListeners; |
|
43 |
// protected AttributeNamesTranslator attributeNamesTranslator; |
|
44 |
private SimpleTaskStatus taskStatus; |
|
45 |
private final ExportServiceFactory factory; |
|
46 |
|
|
47 |
protected AbstractExportService(ExportServiceFactory factory, ExportParameters parameters) { |
|
48 |
this.factory = factory; |
|
49 |
this.parameters = parameters; |
|
50 |
this.finishListeners = new HashSet<>(); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public ExportParameters getParameters() { |
|
55 |
return this.parameters; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public ExportServiceFactory getFactory() { |
|
60 |
return factory; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public void addFinishListener(ExportFinishListener listener) { |
|
65 |
this.finishListeners.add(listener); |
|
66 |
} |
|
67 |
|
|
68 |
protected void fireFinishedListener() { |
|
69 |
for (ExportFinishListener listener : finishListeners) { |
|
70 |
try { |
|
71 |
listener.finished(this); |
|
72 |
} catch (Exception ex) { |
|
73 |
|
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
protected void fireCancelledListeners() { |
|
79 |
for (ExportFinishListener listener : finishListeners) { |
|
80 |
try { |
|
81 |
listener.cancelled(this); |
|
82 |
} catch (Exception ex) { |
|
83 |
|
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public SimpleTaskStatus getTaskStatus() { |
|
90 |
if (this.taskStatus == null) { |
|
91 |
this.taskStatus = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Export"); |
|
92 |
} |
|
93 |
return this.taskStatus; |
|
94 |
} |
|
95 |
|
|
96 |
@Override |
|
97 |
public void setTaskStatus(SimpleTaskStatus taskStatus) { |
|
98 |
this.taskStatus = taskStatus; |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public boolean isCancellationRequested() { |
|
103 |
return this.getTaskStatus().isCancellationRequested(); |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public void cancelRequest() { |
|
108 |
this.getTaskStatus().cancelRequest(); |
|
109 |
} |
|
110 |
|
|
111 |
// @Override |
|
112 |
// public AttributeNamesTranslator getAttributeNamesTranslator() { |
|
113 |
// if (attributeNamesTranslator == null) { |
|
114 |
// this.attributeNamesTranslator = ExportLocator.getServiceManager().createAttributeNamesTranslator(); |
|
115 |
// } |
|
116 |
// return this.attributeNamesTranslator; |
|
117 |
// } |
|
118 |
@Override |
|
119 |
public List<OpenDataStoreParameters> getTargetOpenStoreParameters() throws ExportException { |
|
120 |
List<OpenDataStoreParameters> r = new ArrayList<>(); |
|
121 |
r.add(this.createTargetOpenStoreParameters()); |
|
122 |
return r; |
|
123 |
} |
|
124 |
|
|
125 |
abstract protected DataServerExplorer createServerExplorer() throws ExportException; |
|
126 |
|
|
127 |
abstract protected NewDataStoreParameters createTargetNewStoreParameters() throws ExportException; |
|
128 |
|
|
129 |
abstract protected OpenDataStoreParameters createTargetOpenStoreParameters() throws ExportException; |
|
130 |
|
|
131 |
protected static class InvalidGeometryException extends ExportException { |
|
132 |
|
|
133 |
public InvalidGeometryException(Feature feature, String checkMessage) { |
|
134 |
super(checkMessage, feature); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
public void export(FeatureSet featureSet) throws ExportException { |
|
140 |
DataServerExplorer explorer = createServerExplorer(); |
|
141 |
NewDataStoreParameters newStoreParameters = createTargetNewStoreParameters(); |
|
142 |
OpenDataStoreParameters openStoreParameters = createTargetOpenStoreParameters(); |
|
143 |
|
|
144 |
String providerName = newStoreParameters.getDataStoreName(); |
|
145 |
String explorerName = explorer.getProviderName(); |
|
146 |
|
|
147 |
DisposableIterator it = null; |
|
148 |
FeatureStore target = null; |
|
149 |
EditableFeature targetFeature = null; |
|
150 |
try { |
|
151 |
this.getTaskStatus().setRangeOfValues(0, featureSet.getSize()); |
|
152 |
|
|
153 |
DataManager dataManager = DALLocator.getDataManager(); |
|
154 |
|
|
155 |
dataManager.newStore(explorerName, providerName, newStoreParameters, true); |
|
156 |
target = (FeatureStore) dataManager.openStore(providerName, openStoreParameters); |
|
157 |
|
|
158 |
FeatureType theTargetFeatureType; |
|
159 |
if (this.getParameters().getExportAttributes().isActive()) { |
|
160 |
theTargetFeatureType = this.getParameters().getExportAttributes().getTargetFeatureType(); |
|
161 |
} else { |
|
162 |
theTargetFeatureType = target.getDefaultFeatureType(); |
|
163 |
} |
|
164 |
FeatureType theSourceFeatureType = featureSet.getDefaultFeatureType(); |
|
165 |
|
|
166 |
ExportGeometryHelper geomHelper = null; |
|
167 |
if (this.getParameters() instanceof ExportParametersGeometry) { |
|
168 |
geomHelper = ExportLocator.getServiceManager().createGeometryHelper( |
|
169 |
(ExportParametersGeometry) this.getParameters(), |
|
170 |
theTargetFeatureType, |
|
171 |
theSourceFeatureType |
|
172 |
); |
|
173 |
if (!geomHelper.canProcessGeometry()) { |
|
174 |
geomHelper = null; |
|
175 |
} |
|
176 |
} |
|
177 |
// ============================================ |
|
178 |
|
|
179 |
target.edit(FeatureStore.MODE_APPEND); |
|
180 |
it = featureSet.fastIterator(); |
|
181 |
|
|
182 |
long featureCount = 1; |
|
183 |
while (it.hasNext()) { |
|
184 |
this.getTaskStatus().setCurValue(featureCount); |
|
185 |
|
|
186 |
Feature sourceFeature = (Feature) it.next(); |
|
187 |
targetFeature = target.createNewFeature(true); //theTargetFeatureType, true); |
|
188 |
copyValues(sourceFeature, targetFeature); |
|
189 |
|
|
190 |
if (geomHelper != null) { |
|
191 |
switch (geomHelper.copyGeometry(sourceFeature, targetFeature)) { |
|
192 |
case FixGeometryStatus.STATE_OK: |
|
193 |
break; |
|
194 |
case FixGeometryStatus.STATE_SKIP: |
|
195 |
continue; |
|
196 |
case FixGeometryStatus.STATE_ABORT: |
|
197 |
throw new InvalidGeometryException(targetFeature, geomHelper.getLastErrorMessage()); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
target.insert(targetFeature); |
|
202 |
|
|
203 |
featureCount++; |
|
204 |
|
|
205 |
if (this.getTaskStatus().isCancellationRequested()) { |
|
206 |
return; |
|
207 |
} |
|
208 |
} |
|
209 |
target.finishEditing(); |
|
210 |
this.getTaskStatus().terminate(); |
|
211 |
this.getTaskStatus().remove(); |
|
212 |
fireFinishedListener(); |
|
213 |
} catch (Exception e) { |
|
214 |
FeatureStore.cancelEditingQuietly(target); |
|
215 |
fireCancelledListeners(); |
|
216 |
throw new ExportException(e, targetFeature); |
|
217 |
} finally { |
|
218 |
DisposeUtils.dispose(it); |
|
219 |
DisposeUtils.dispose(featureSet); |
|
220 |
DisposeUtils.dispose(target); |
|
221 |
} |
|
222 |
} |
|
223 |
|
|
224 |
protected void copyValues(Feature source, EditableFeature target) { |
|
225 |
FeatureType sourceType = source.getType(); |
|
226 |
FeatureType targetType = target.getType(); |
|
227 |
ExportAttributes exp = this.getParameters().getExportAttributes(); |
|
228 |
boolean isActive = exp.isActive(); |
|
229 |
for (FeatureAttributeDescriptor targetAttr : targetType) { |
|
230 |
if (targetAttr.isReadOnly() || targetAttr.isComputed()) { |
|
231 |
continue; |
|
232 |
} |
|
233 |
String targetAttrName = targetAttr.getName(); |
|
234 |
//translate field |
|
235 |
FeatureAttributeDescriptor sourceAttr; |
|
236 |
String sourceAttrName; |
|
237 |
if (isActive) { |
|
238 |
sourceAttrName = exp.getSourceName(targetAttrName); |
|
239 |
for (ExportAttributes.ExportAttribute exportAttribute : exp) { |
|
240 |
if (StringUtils.equals(exportAttribute.getNewName(), targetAttrName)) { |
|
241 |
sourceAttrName = exportAttribute.getName(); |
|
242 |
break; |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
sourceAttr = sourceType.getAttributeDescriptorFromAll(sourceAttrName); |
|
247 |
} else { |
|
248 |
sourceAttrName = targetAttrName; |
|
249 |
sourceAttr = sourceType.getAttributeDescriptorFromAll(targetAttrName); |
|
250 |
} |
|
251 |
if (sourceAttr != null) { |
|
252 |
Object value = source.get(sourceAttrName); |
|
253 |
if (value == null) { |
|
254 |
if (targetAttr.allowNull()) { |
|
255 |
target.set(targetAttrName, null); |
|
256 |
} |
|
257 |
} else { |
|
258 |
target.set(targetAttrName, value); |
|
259 |
} |
|
260 |
} else if (sourceAttr==null && source.hasValue(sourceAttrName)) { |
|
261 |
Object value = source.get(sourceAttrName); |
|
262 |
target.set(targetAttrName, value); |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
|
|
268 |
|
tags/org.gvsig.desktop-2.0.389/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 | ||
---|---|---|
1 |
package org.gvsig.export.spi; |
|
2 |
|
|
3 |
import java.text.DateFormat; |
|
4 |
import java.text.SimpleDateFormat; |
|
5 |
import java.util.Date; |
|
6 |
import org.gvsig.export.ExportAttributes; |
|
7 |
import org.gvsig.export.ExportLocator; |
|
8 |
import org.gvsig.fmap.dal.exception.DataException; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
11 |
import org.gvsig.export.ExportParameters; |
|
12 |
import org.gvsig.expressionevaluator.Expression; |
|
13 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
14 |
import org.gvsig.tools.ToolsLocator; |
|
15 |
import org.gvsig.tools.dynobject.DynStruct; |
|
16 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
17 |
import org.gvsig.tools.persistence.PersistentState; |
|
18 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
19 |
import org.slf4j.Logger; |
|
20 |
import org.slf4j.LoggerFactory; |
|
21 |
|
|
22 |
/** |
|
23 |
* |
|
24 |
* @author jjdelcerro |
|
25 |
*/ |
|
26 |
public abstract class AbstractExportParameters implements ExportParameters { |
|
27 |
|
|
28 |
private FeatureStore sourceFeatureStore; |
|
29 |
private Expression filterExpression; |
|
30 |
private int featuresToUse; |
|
31 |
private Object context; |
|
32 |
protected ExportAttributes exportAttributes = null; |
|
33 |
private Date date = new Date(); |
|
34 |
public ExportServiceFactory factory; |
|
35 |
|
|
36 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractExportParameters.class); |
|
37 |
private FeatureQuery featureQuery; |
|
38 |
|
|
39 |
public AbstractExportParameters(ExportServiceFactory factory) { |
|
40 |
this.factory = factory; |
|
41 |
this.exportAttributes = ExportLocator.getServiceManager().createExportAttributes(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public boolean needsSelectTargetProjection() { |
|
46 |
return false; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public FeatureType getSourceFeatureType() { |
|
51 |
if (!(this.exportAttributes == null)) { |
|
52 |
return this.exportAttributes.getSourceFeatureType(); |
|
53 |
} else { |
|
54 |
return null; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public void setSourceFeatureType(FeatureType sourceFeatureType) { |
|
60 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType, this.featureQuery); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public void setSourceFeatureStore(FeatureStore sourceFeatureStore) { |
|
65 |
this.sourceFeatureStore = sourceFeatureStore; |
|
66 |
try { |
|
67 |
FeatureType sourceFeatureType = sourceFeatureStore.getDefaultFeatureType(); |
|
68 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType, this.featureQuery); |
|
69 |
} catch (DataException ex) { |
|
70 |
throw new RuntimeException("Can't set feature type", ex); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public FeatureStore getSourceFeatureStore() { |
|
76 |
return this.sourceFeatureStore; |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public Expression getFilterExpresion() { |
|
81 |
return this.filterExpression; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public void setFilterExpresion(Expression expression) { |
|
86 |
this.filterExpression = expression; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public FeatureQuery getFeatureQuery() { |
|
91 |
return this.featureQuery; |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public void setFeatureQuery(FeatureQuery query) { |
|
96 |
this.featureQuery = query; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public int getFeaturesToUse() { |
|
101 |
return featuresToUse; |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public void setFeaturesToUse(int featuresToUse) { |
|
106 |
this.featuresToUse = featuresToUse; |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
public Object getContext() { |
Also available in: Unified diff