From aaf4c6c3a1d50b67b9a7dfd1bc011615ba5d9f57 Mon Sep 17 00:00:00 2001 From: ?? ? <ulysseskao@ximple.com.tw> Date: Fri, 06 Jun 2008 18:44:30 +0800 Subject: [PATCH] update for EOFM-115 --- xdgnjobs/ximple-jobcarrier/pom.xml | 67 + xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java | 95 ++ xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java | 105 - .gitattributes | 31 xdgnjobs/ximple-dgnio/pom.xml | 9 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java | 49 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java | 44 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java | 72 - xdgnjobs/ximple-spatialjob/pom.xml | 63 + xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java | 43 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java | 15 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java | 51 + xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateEllipseShapeStrategy.java | 34 xdgnjobs/pom.xml | 66 - xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateArcLineStringStrategy.java | 34 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java | 31 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java | 4 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java | 51 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java | 74 - xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java | 7 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java | 79 - xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java | 49 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java | 52 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java | 13 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java | 5 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java | 34 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java | 79 + xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java | 34 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java | 26 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java | 51 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java | 80 - xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java | 261 ++++-- xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java | 62 xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml | 4 /dev/null | 16 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java | 4 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java | 167 ++-- xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java | 199 +++++ xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java | 19 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java | 47 + 40 files changed, 1,360 insertions(+), 866 deletions(-) diff --git a/.gitattributes b/.gitattributes index 662bd28..d3076e9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -72,29 +72,30 @@ xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java -text -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToOraSDOJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToPostGISJobContext.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToOraSDOJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToPostGISJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertPostGISJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertPostGISJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertPostGISJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertPostGISJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertOraSDOJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertPostGISJobContext.java svneol=native#text/plain -xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertShapefilesJobContext.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/Base64.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/BinConverter.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/Bits.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ByteArrayCompressor.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java svneol=native#text/plain +xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeomUtil.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/LangUtil.java svneol=native#text/plain xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java svneol=native#text/plain diff --git a/xdgnjobs/pom.xml b/xdgnjobs/pom.xml index ccb025a..e5806d7 100644 --- a/xdgnjobs/pom.xml +++ b/xdgnjobs/pom.xml @@ -206,6 +206,11 @@ </dependency> <dependency> <groupId>org.geotools</groupId> + <artifactId>gt2-jdbc</artifactId> + <version>${gt.version}</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> <artifactId>gt2-oracle-spatial</artifactId> <version>${gt.version}</version> </dependency> @@ -250,8 +255,23 @@ <!-- ORACLE --> <!-- Download and install into your own repo --> <dependency> - <artifactId>ojdbc5</artifactId> <groupId>com.oracle</groupId> + <artifactId>ojdbc5</artifactId> + <version>11.1.0</version> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdoapi</artifactId> + <version>11.1.0</version> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdotype</artifactId> + <version>11.1.0</version> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdoutl</artifactId> <version>11.1.0</version> </dependency> @@ -342,46 +362,6 @@ <dependency> <artifactId>gt2-main</artifactId> <groupId>org.geotools</groupId> - </dependency> - <dependency> - <artifactId>gt2-shapefile</artifactId> - <groupId>org.geotools</groupId> - </dependency> - <dependency> - <artifactId>gt2-sample-data</artifactId> - <groupId>org.geotools</groupId> - <scope>test</scope> - </dependency> - <dependency> - <artifactId>gt2-data</artifactId> - <groupId>org.geotools</groupId> - </dependency> - <dependency> - <groupId>org.geotools</groupId> - <artifactId>gt2-postgis</artifactId> - </dependency> - - <!-- because main and sample-data depend on referencing we need a tie breaker --> - <dependency> - <artifactId>gt2-referencing</artifactId> - <groupId>org.geotools</groupId> - </dependency> - - <dependency> - <artifactId>jdom</artifactId> - <groupId>jdom</groupId> - </dependency> - - <dependency> - <artifactId>velocity</artifactId> - <groupId>velocity</groupId> - </dependency> - - <!-- We need this to make the referencing module useful --> - <dependency> - <artifactId>gt2-epsg-hsql</artifactId> - <groupId>org.geotools</groupId> - <scope>test</scope> </dependency> <dependency> @@ -528,6 +508,7 @@ </pluginManagement> <!-- http://www.ibiblio.org/maven2/org/apache/maven/wagon/ --> + <!-- <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> @@ -535,7 +516,8 @@ <version>1.0-beta-2</version> </extension> </extensions> - + --> + <plugins> <!-- ======================================================= --> <!-- Source reformat --> diff --git a/xdgnjobs/ximple-dgnio/pom.xml b/xdgnjobs/ximple-dgnio/pom.xml index 5c58d1e..5916a17 100644 --- a/xdgnjobs/ximple-dgnio/pom.xml +++ b/xdgnjobs/ximple-dgnio/pom.xml @@ -58,6 +58,15 @@ <!-- Dependencies to be inherited by all modules. --> <!-- =========================================================== --> <dependencies> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-sample-data</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>ojdbc5</artifactId> + </dependency> </dependencies> <!-- =========================================================== --> diff --git a/xdgnjobs/ximple-jobcarrier/pom.xml b/xdgnjobs/ximple-jobcarrier/pom.xml index 2a7c611..ced9097 100644 --- a/xdgnjobs/ximple-jobcarrier/pom.xml +++ b/xdgnjobs/ximple-jobcarrier/pom.xml @@ -69,10 +69,75 @@ <version>1.0.1B</version> </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-shapefile</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-sample-data</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-data</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-jdbc</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-postgis</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-oracle-spatial</artifactId> + </dependency> + + <!-- because main and sample-data depend on referencing we need a tie breaker --> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-referencing</artifactId> + </dependency> + + <!-- We need this to make the referencing module useful --> + <dependency> + <artifactId>gt2-epsg-hsql</artifactId> + <groupId>org.geotools</groupId> + <scope>test</scope> + </dependency> + + <dependency> + <artifactId>jdom</artifactId> + <groupId>jdom</groupId> + </dependency> + + <dependency> + <artifactId>velocity</artifactId> + <groupId>velocity</groupId> + </dependency> + <!-- ORACLE --> <dependency> - <artifactId>ojdbc5</artifactId> <groupId>com.oracle</groupId> + <artifactId>ojdbc5</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>ojdbc5</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdoapi</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdotype</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdoutl</artifactId> </dependency> <dependency> diff --git a/xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml b/xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml index 70a7bdf..3c5b075 100644 --- a/xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml +++ b/xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml @@ -32,7 +32,7 @@ </entry> <entry> <key>PGDDATBASE</key> - <value>nstpc</value> + <value>tctpc</value> </entry> <entry> <key>PGPORT</key> @@ -56,7 +56,7 @@ </entry> <entry> <key>ORAINST</key> - <value>nntpc</value> + <value>tctpc</value> </entry> <entry> <key>ORAPORT</key> diff --git a/xdgnjobs/ximple-spatialjob/pom.xml b/xdgnjobs/ximple-spatialjob/pom.xml index b9350e1..817c643 100644 --- a/xdgnjobs/ximple-spatialjob/pom.xml +++ b/xdgnjobs/ximple-spatialjob/pom.xml @@ -56,10 +56,71 @@ <groupId>opensymphony</groupId> </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-shapefile</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-sample-data</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-data</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-jdbc</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-postgis</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-oracle-spatial</artifactId> + </dependency> + + <!-- because main and sample-data depend on referencing we need a tie breaker --> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt2-referencing</artifactId> + </dependency> + + <!-- We need this to make the referencing module useful --> + <dependency> + <artifactId>gt2-epsg-hsql</artifactId> + <groupId>org.geotools</groupId> + <scope>test</scope> + </dependency> + + <dependency> + <artifactId>jdom</artifactId> + <groupId>jdom</groupId> + </dependency> + + <dependency> + <artifactId>velocity</artifactId> + <groupId>velocity</groupId> + </dependency> + <!-- ORACLE --> <dependency> - <artifactId>ojdbc5</artifactId> <groupId>com.oracle</groupId> + <artifactId>ojdbc5</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdoapi</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdotype</artifactId> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>sdoutl</artifactId> </dependency> <dependency> diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateArcLineStringStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateArcLineStringStrategy.java index 6fc37b6..2be6c13 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateArcLineStringStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateArcLineStringStrategy.java @@ -5,18 +5,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.io.dgn7.ArcElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; @@ -53,16 +52,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createArcFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -72,25 +62,25 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof ArcElement) { ArcElement lineStringElement = (ArcElement) element; convertDecorator.setConverter(lineStringElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - lineStringElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) lineStringElement.getLevelIndex(), colorTable.getColorCode(lineStringElement.getColorIndex()), - lineStringElement.getWeight(), - lineStringElement.getLineStyle() + (short) lineStringElement.getWeight(), + (short) lineStringElement.getLineStyle() }); - return feature; } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateEllipseShapeStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateEllipseShapeStrategy.java index 25b6210..9fd0ed6 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateEllipseShapeStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateEllipseShapeStrategy.java @@ -5,18 +5,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.EllipseElement; import com.ximple.io.dgn7.FrammeAttributeData; @@ -53,16 +52,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createEllipseFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -72,25 +62,25 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof EllipseElement) { EllipseElement shapeElement = (EllipseElement) element; convertDecorator.setConverter(shapeElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - shapeElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) shapeElement.getLevelIndex(), colorTable.getColorCode(shapeElement.getColorIndex()), - shapeElement.getWeight(), - shapeElement.getLineStyle() + (short) shapeElement.getWeight(), + (short) shapeElement.getLineStyle() }); - return feature; } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java index a6fe3c9..65cf4a3 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java @@ -5,25 +5,24 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; +import com.ximple.io.dgn7.ArcElement; import com.ximple.io.dgn7.ComplexChainElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.LineElement; import com.ximple.io.dgn7.LineStringElement; import com.ximple.io.dgn7.UserAttributeData; -import com.ximple.io.dgn7.ArcElement; public class CreateLineStringStrategy implements CreateFeatureTypeStrategy { @@ -56,16 +55,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createLineStringFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -75,73 +65,71 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof LineStringElement) { LineStringElement lineStringElement = (LineStringElement) element; convertDecorator.setConverter(lineStringElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - lineStringElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) lineStringElement.getLevelIndex(), colorTable.getColorCode(lineStringElement.getColorIndex()), - lineStringElement.getWeight(), - lineStringElement.getLineStyle() + (short) lineStringElement.getWeight(), + (short) lineStringElement.getLineStyle() }); - return feature; } else if (element instanceof ComplexChainElement) { ComplexChainElement complexChain = (ComplexChainElement) element; convertDecorator.setConverter(complexChain); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - complexChain.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) complexChain.getLevelIndex(), colorTable.getColorCode(complexChain.getColorIndex()), - complexChain.getWeight(), - complexChain.getLineStyle() + (short) complexChain.getWeight(), + (short) complexChain.getLineStyle() }); - return feature; } else if (element instanceof LineElement) { LineElement lineElement = (LineElement) element; convertDecorator.setConverter(lineElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - lineElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) lineElement.getLevelIndex(), colorTable.getColorCode(lineElement.getColorIndex()), - lineElement.getWeight(), - lineElement.getLineStyle() + (short) lineElement.getWeight(), + (short) lineElement.getLineStyle() }); return feature; } else if (element instanceof ArcElement) { ArcElement lineStringElement = (ArcElement) element; convertDecorator.setConverter(lineStringElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - lineStringElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) lineStringElement.getLevelIndex(), colorTable.getColorCode(lineStringElement.getColorIndex()), - lineStringElement.getWeight(), - lineStringElement.getLineStyle() + (short) lineStringElement.getWeight(), + (short) lineStringElement.getLineStyle() }); - return feature; } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java index 0823ce1..1561e70 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java @@ -5,7 +5,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; @@ -13,12 +12,12 @@ import org.geotools.feature.SchemaException; import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.TWDDatumConverter; import com.ximple.io.dgn7.ComplexChainElement; import com.ximple.io.dgn7.Element; @@ -59,16 +58,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createLineStringFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -78,23 +68,23 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof LineStringElement) { LineStringElement lineStringElement = (LineStringElement) element; convertDecorator.setConverter(lineStringElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - lineStringElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) lineStringElement.getLevelIndex(), colorTable.getColorCode(lineStringElement.getColorIndex()), - lineStringElement.getWeight(), - lineStringElement.getLineStyle() + (short) lineStringElement.getWeight(), + (short) lineStringElement.getLineStyle() }); - return feature; } else if (element instanceof TextElement) { TextElement txtElement = (TextElement) element; @@ -112,53 +102,50 @@ txtElement.getRotationAngle(); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ line, - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - txtElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) txtElement.getLevelIndex(), colorTable.getColorCode(txtElement.getColorIndex()), - txtElement.getWeight(), - txtElement.getLineStyle() + (short) txtElement.getWeight(), + (short) txtElement.getLineStyle() }); - return feature; } else if (element instanceof ComplexChainElement) { ComplexChainElement complexChain = (ComplexChainElement) element; convertDecorator.setConverter(complexChain); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - complexChain.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) complexChain.getLevelIndex(), colorTable.getColorCode(complexChain.getColorIndex()), - complexChain.getWeight(), - complexChain.getLineStyle() + (short) complexChain.getWeight(), + (short) complexChain.getLineStyle() }); - return feature; } else if (element instanceof LineElement) { LineElement lineElement = (LineElement) element; convertDecorator.setConverter(lineElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - lineElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) lineElement.getLevelIndex(), colorTable.getColorCode(lineElement.getColorIndex()), - lineElement.getWeight(), - lineElement.getLineStyle() + (short) lineElement.getWeight(), + (short) lineElement.getLineStyle() }); - return feature; } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java index 44701ef..dbb80a7 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java @@ -5,18 +5,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.io.dgn7.ComplexShapeElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; @@ -54,16 +53,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createPolygonFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -73,40 +63,39 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof ShapeElement) { ShapeElement shapeElement = (ShapeElement) element; convertDecorator.setConverter(shapeElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - shapeElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) shapeElement.getLevelIndex(), colorTable.getColorCode(shapeElement.getColorIndex()), - shapeElement.getWeight(), - shapeElement.getLineStyle() + (short) shapeElement.getWeight(), + (short) shapeElement.getLineStyle() }); - return feature; } else if (element instanceof ComplexShapeElement) { ComplexShapeElement complexShape = (ComplexShapeElement) element; convertDecorator.setConverter(complexShape); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - complexShape.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) complexShape.getLevelIndex(), colorTable.getColorCode(complexShape.getColorIndex()), - complexShape.getWeight(), - complexShape.getLineStyle() + (short) complexShape.getWeight(), + (short) complexShape.getLineStyle() }); - return feature; } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java index b6007a3..6e08a86 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java @@ -1,24 +1,23 @@ package com.ximple.eofms.filter; -import java.util.List; -import java.util.TreeMap; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.List; +import java.util.TreeMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.TextElement; @@ -55,21 +54,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMBOL", String.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createSymbolFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -79,6 +64,7 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof TextElement) { @@ -99,28 +85,27 @@ sb.append(txtElement.getFontIndex()); convertDecorator.setConverter(txtElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - txtElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) txtElement.getLevelIndex(), colorTable.getColorCode(txtElement.getColorIndex()), - txtElement.getWeight(), - txtElement.getLineStyle(), - txtElement.getJustification(), - txtElement.getTextHeight(), - txtElement.getTextWidth(), - angle, + (short) txtElement.getWeight(), + (short) txtElement.getLineStyle(), + (short) txtElement.getJustification(), + (float) txtElement.getTextHeight(), + (float) txtElement.getTextWidth(), + (float) angle, sb.toString() }); - return feature; } else { logger.info("CreateSymbolStrategy cannot conver " + element.toString() + "to Feature"); } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java index 229373a..a8ba4c8 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java @@ -1,24 +1,23 @@ package com.ximple.eofms.filter; -import java.util.List; -import java.util.TreeMap; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.List; +import java.util.TreeMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; -import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.TextElement; @@ -56,21 +55,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createPointFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -80,6 +65,7 @@ { DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); FrammeAttributeData fLinkage = getFeatureLinkage(element); + Feature feature = null; if (fLinkage == null) return null; if (element instanceof TextElement) { @@ -87,23 +73,22 @@ double angle = txtElement.getRotationAngle(); angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); convertDecorator.setConverter(txtElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - txtElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) txtElement.getLevelIndex(), colorTable.getColorCode(txtElement.getColorIndex()), - txtElement.getWeight(), - txtElement.getLineStyle(), - txtElement.getJustification(), - txtElement.getTextHeight(), - txtElement.getTextWidth(), - angle, + (short) txtElement.getWeight(), + (short) txtElement.getLineStyle(), + (short) txtElement.getJustification(), + (float) txtElement.getTextHeight(), + (float) txtElement.getTextWidth(), + (float) angle, txtElement.getText() }); - return feature; } else if (element instanceof TextNodeElement) { TextNodeElement nodeElement = (TextNodeElement) element; @@ -119,24 +104,23 @@ double angle = nodeElement.getRotationAngle(); angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); convertDecorator.setConverter(nodeElement); - Feature feature = featureType.create(new Object[]{ + feature = featureType.create(new Object[]{ convertDecorator.toGeometry(geometryFactory), - (int) fLinkage.getFsc(), + fLinkage.getFsc(), (long) fLinkage.getUfid(), - (int) fLinkage.getComponentID(), - 0, - nodeElement.getLevelIndex(), + (short) fLinkage.getComponentID(), + (short) 0, + (short) nodeElement.getLevelIndex(), colorTable.getColorCode(nodeElement.getColorIndex()), - nodeElement.getWeight(), - nodeElement.getLineStyle(), - nodeElement.getJustification(), - nodeElement.getTextNodeHeight(), - nodeElement.getTextNodeLength(), - angle, + (short) nodeElement.getWeight(), + (short) nodeElement.getLineStyle(), + (short) nodeElement.getJustification(), + (float) nodeElement.getTextNodeHeight(), + (float) nodeElement.getTextNodeLength(), + (float) angle, sb.toString() }); - return feature; } - return null; + return feature; } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java index 3e68794..532d267 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java @@ -6,23 +6,35 @@ import java.nio.ByteBuffer; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Map; import java.util.StringTokenizer; +import java.util.TreeMap; + +import com.vividsolutions.jts.util.Assert; +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; import org.apache.commons.logging.Log; +import org.geotools.data.DataStore; +import org.geotools.data.jdbc.ConnectionPoolManager; +import org.geotools.data.oracle.OracleDataStore; +import org.geotools.data.oracle.OracleDataStoreFactory; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; -import com.vividsolutions.jts.util.Assert; - import oracle.sql.BLOB; - -import com.ximple.eofms.jobs.context.AbstractOracleJobContext; public abstract class AbstractOracleDatabaseJob implements Job { + /** The Oracle driver class name */ + private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver"; + + private static final String ORACLE_URL = "jdbc:oracle:thin:@"; + private static final String PROPUsrKey = "user"; + private static final String PROPPassKey = "password"; + private static final String JOBDATA_DIR = "JOBDATA_DIR"; private static final String CONFELMSFILTER = "ELMSFILTER_CONF"; private static final String SPATAILSCHEMA = "ORGSCHEMA"; @@ -39,6 +51,8 @@ private static final String TESTMODE = "TESTMODE"; private static final String TESTCOUNT = "TESTCOUNT"; + protected static OracleDataStoreFactory dataStoreFactory = new OracleDataStoreFactory(); + protected String _dataPath; protected String _filterPath; protected String _oracleHost; @@ -54,10 +68,22 @@ protected ArrayList<String> _orgSchema = new ArrayList<String>(); protected boolean _testMode = false; protected int _testCount = -1; + protected OracleDataStore sourceDataStore; + private boolean driverFound = true; + + protected AbstractOracleDatabaseJob() + { + try { + Class.forName(JDBC_DRIVER); + } catch (Throwable t) { + // must be running off dummy jar! + driverFound = false; + } + } public abstract void execute(JobExecutionContext context) throws JobExecutionException; - public Log getLogger() { return null; } + public abstract Log getLogger(); protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException { @@ -77,6 +103,7 @@ _createDummy = dataMap.getString(CREATEDUMMY); Log logger = getLogger(); + /* logger.info("JOBDATA_DIR=" + _dataPath); logger.info("CONFELMSFILTER=" + _filterPath); logger.info("ORAHOST=" + _oracleHost); @@ -88,6 +115,7 @@ logger.info("CONVERTFILE=" + _convertFile); logger.info("CONVERTELEMIN=" + _convertElementIn); logger.info("ELEMLOG=" + _elementLogging); + */ String strSchema = dataMap.getString(SPATAILSCHEMA); StringTokenizer st = new StringTokenizer(strSchema, ","); @@ -123,22 +151,27 @@ if (_oracleHost == null) { + logger.warn("OracleHOST is null"); throw new JobExecutionException("Unknown Oracle Host."); } if (_oracleInstance == null) { + logger.warn("OracleINSTANCE is null"); throw new JobExecutionException("Unknown Oracle Instance."); } if (_username == null) { + logger.warn("OracleUSER is null"); throw new JobExecutionException("Unknown Oracle Username."); } if (_password == null) { + logger.warn("OraclePASS is null"); throw new JobExecutionException("Unknown Oracle Password."); } if (_orgSchema == null) { + logger.warn("OracleSchema is null"); throw new JobExecutionException("Unknown Spatial Database Schema."); } } @@ -183,6 +216,11 @@ } return raw; + } + + public boolean isDriverFound() + { + return driverFound; } public String getDataPath() @@ -304,4 +342,51 @@ return _createDummy != null && !_createDummy.equalsIgnoreCase("false") && !_createDummy.equalsIgnoreCase("no") && !_createDummy.equalsIgnoreCase("0"); } + + public DataStore getSourceDataStore() + { + return sourceDataStore; + } + + protected void createSourceDataStore() throws JobExecutionException + { + if (sourceDataStore != null) + { + sourceDataStore.dispose(); + sourceDataStore = null; + } + + if (!isDriverFound()) + { + throw new JobExecutionException("Oracle JDBC Driver not found.-" + JDBC_DRIVER); + } + Map<String, String> map = new TreeMap<String, String>(); + map.put("host", _oracleHost); + map.put("port", _oraclePort); + map.put("instance", _oracleInstance); + map.put("user", _username); + map.put("passwd", _password); + map.put("dbtype", "oracle"); + map.put("alias", _oracleInstance); + map.put("namespace", null); + if (!dataStoreFactory.canProcess(map)) + { + getLogger().warn("cannot process properties-"); + throw new JobExecutionException("cannot process properties-"); + } + try + { + sourceDataStore = (OracleDataStore) dataStoreFactory.createDataStore(map); + } catch (IOException e) + { + getLogger().warn(e.getMessage(), e); + throw new JobExecutionException(e.getMessage(), e); + } + } + + protected void disconnect() + { + ConnectionPoolManager manager = ConnectionPoolManager.getInstance(); + manager.closeAll(); + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java index 19ec40d..ba6584d 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java @@ -1,46 +1,46 @@ package com.ximple.eofms.jobs; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.io.IOException; -import java.nio.charset.Charset; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.transaction.util.LoggerFacade; -import org.apache.commons.transaction.util.CommonsLoggingLogger; -import org.apache.commons.transaction.memory.PessimisticMapWrapper; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; -import org.geotools.feature.Feature; -import org.geotools.feature.IllegalAttributeException; -import org.geotools.feature.SchemaException; -import org.geotools.feature.FeatureType; -import org.geotools.feature.SimpleFeature; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.transaction.memory.PessimisticMapWrapper; +import org.apache.commons.transaction.util.CommonsLoggingLogger; +import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; +import org.geotools.feature.Feature; +import org.geotools.feature.FeatureType; +import org.geotools.feature.IllegalAttributeException; +import org.geotools.feature.SchemaException; +import org.geotools.feature.SimpleFeature; import org.xml.sax.SAXException; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.ElementDispatchableFilter; +import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.TypeCompIdDispatchableFilter; import com.ximple.eofms.filter.TypeCompLevelIdDispatchableFilter; import com.ximple.eofms.filter.TypeIdDispatchableFilter; import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; -import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.UserAttributeData; public class DummyFeatureConvertJobContext extends AbstractDgnFileJobContext @@ -158,7 +158,7 @@ } else if (filter instanceof TypeCompLevelIdDispatchableFilter) { ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); - } else if(filter instanceof TypeIdDispatchableFilter) + } else if (filter instanceof TypeIdDispatchableFilter) { ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); } @@ -221,7 +221,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { ShapefileDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(), null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8")); writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), @@ -270,7 +271,8 @@ return dataOut; } - public void closeFeatureWriter() throws IOException { + public void closeFeatureWriter() throws IOException + { for (FeatureWriter featureWriter : this.featuresWriterContext.values()) { @@ -295,4 +297,9 @@ } return null; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java index 1e9a236..9a3f93d 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java @@ -1,61 +1,63 @@ package com.ximple.eofms.jobs; -import java.util.Date; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.ResultSet; -import java.sql.Types; -import java.io.IOException; import java.io.File; -import java.io.FilenameFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FilenameFilter; +import java.io.IOException; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; +import java.util.Date; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.commons.collections.OrderedMap; import org.apache.commons.collections.OrderedMapIterator; import org.apache.commons.collections.map.LinkedMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.JobDetail; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; +import org.quartz.JobDetail; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; import com.vividsolutions.jts.geom.GeometryFactory; import oracle.jdbc.OracleConnection; import oracle.jdbc.OracleResultSet; -import oracle.sql.BLOB; import oracle.sql.ARRAY; +import oracle.sql.BLOB; -import com.ximple.util.PrintfFormat; -import com.ximple.io.dgn7.Element; -import com.ximple.io.dgn7.Dgn7fileException; -import com.ximple.io.dgn7.ElementType; -import com.ximple.io.dgn7.IElementHandler; -import com.ximple.io.dgn7.ComplexElement; -import com.ximple.io.dgn7.Dgn7fileReader; -import com.ximple.io.dgn7.Lock; -import com.ximple.io.dgn7.TextElement; +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; +import com.ximple.eofms.jobs.context.shapefile.FeatureDgnConvertShpJobContext; +import com.ximple.eofms.jobs.context.shapefile.GeneralDgnConvertShpJobContext; +import com.ximple.eofms.jobs.context.shapefile.IndexDgnConvertShpJobContext; +import com.ximple.eofms.jobs.context.shapefile.OracleConvertShapefilesJobContext; import com.ximple.eofms.util.BinConverter; import com.ximple.eofms.util.ByteArrayCompressor; import com.ximple.eofms.util.StringUtils; -import com.ximple.eofms.jobs.context.AbstractOracleJobContext; -import com.ximple.eofms.jobs.context.FeatureDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.GeneralDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.IndexDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.OracleConvertShapefilesJobContext; +import com.ximple.io.dgn7.ComplexElement; +import com.ximple.io.dgn7.Dgn7fileException; +import com.ximple.io.dgn7.Dgn7fileReader; +import com.ximple.io.dgn7.Element; +import com.ximple.io.dgn7.ElementType; +import com.ximple.io.dgn7.IElementHandler; +import com.ximple.io.dgn7.Lock; +import com.ximple.io.dgn7.TextElement; +import com.ximple.util.PrintfFormat; public class OracleConvertDgn2OraSDOJob extends AbstractOracleDatabaseJob { final static Log logger = LogFactory.getLog(OracleConvertDgn2OraSDOJob.class); - /** The Oracle driver class name */ + /** + * The Oracle driver class name + */ private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver"; private static final int FETCHSIZE = 30; @@ -136,7 +138,7 @@ FeatureStore fs = (FeatureStore) dstore.getFeatureSource("ORA_TEST_POINTS"); fs.addFeatures(DataUtilities.collection(feature)); */ - + protected AbstractOracleJobContext prepareJobContext(String filterPath) { return new OracleConvertShapefilesJobContext(filterPath); @@ -153,6 +155,11 @@ // Log the time the job started logger.info(jobName + " fired at " + new Date()); extractJobConfiguration(jobDetail); + createSourceDataStore(); + if (getSourceDataStore() == null) + { + throw new JobExecutionException("Cannot connect source oracle database."); + } try { @@ -166,11 +173,7 @@ for (String orgSchema : _orgSchema) { OracleConvertShapefilesJobContext jobContext = (OracleConvertShapefilesJobContext) prepareJobContext(_filterPath); - jobContext.setConnectionInfo(_oracleHost, _oraclePort, _oracleInstance); - jobContext.setLogin(_username, _password); - jobContext.setShapeData(_dataPath); - jobContext.setConvertDB(_convertDB); - jobContext.setConvertFile(_convertFile); + jobContext.setSourceDataStore(getSourceDataStore()); jobContext.setConvertElementIn(_convertElementIn); jobContext.setElementLogging(checkElementLogging()); jobContext.setExecutionContext(context); @@ -207,6 +210,8 @@ logger.info("-- step:createDummyFeatureFile --"); createDummyFeatureFile(context); } + + disconnect(); } catch (SQLException e) { logger.warn(e.getMessage(), e); @@ -536,7 +541,8 @@ * �����ഫ���޹��ɪ��u�@ * * @param context �u�@�������� - * @throws org.quartz.JobExecutionException exception + * @throws org.quartz.JobExecutionException + * exception */ private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException { @@ -665,7 +671,8 @@ * �����ഫ��L�]�p���ɪ��u�@ * * @param context jobContext - * @throws org.quartz.JobExecutionException exception + * @throws org.quartz.JobExecutionException + * exception */ private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException { diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java index e2d0c90..058a7b8 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java @@ -1,56 +1,62 @@ package com.ximple.eofms.jobs; -import java.util.Date; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.ResultSet; -import java.sql.Types; -import java.io.IOException; import java.io.File; -import java.io.FilenameFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FilenameFilter; +import java.io.IOException; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.collections.OrderedMap; -import org.apache.commons.collections.OrderedMapIterator; -import org.apache.commons.collections.map.LinkedMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.JobDetail; -import org.quartz.JobDataMap; -import org.geotools.feature.IllegalAttributeException; -import org.geotools.feature.SchemaException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import java.util.TreeMap; import com.vividsolutions.jts.geom.GeometryFactory; - -import oracle.jdbc.OracleConnection; -import oracle.jdbc.OracleResultSet; -import oracle.sql.BLOB; -import oracle.sql.ARRAY; - -import com.ximple.util.PrintfFormat; -import com.ximple.io.dgn7.Element; -import com.ximple.io.dgn7.Dgn7fileException; -import com.ximple.io.dgn7.ElementType; -import com.ximple.io.dgn7.IElementHandler; -import com.ximple.io.dgn7.ComplexElement; -import com.ximple.io.dgn7.Dgn7fileReader; -import com.ximple.io.dgn7.Lock; -import com.ximple.io.dgn7.TextElement; +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; +import com.ximple.eofms.jobs.context.postgis.FeatureDgnConvertPostGISJobContext; +import com.ximple.eofms.jobs.context.postgis.GeneralDgnConvertPostGISJobContext; +import com.ximple.eofms.jobs.context.postgis.IndexDgnConvertPostGISJobContext; +import com.ximple.eofms.jobs.context.postgis.OracleConvertPostGISJobContext; import com.ximple.eofms.util.BinConverter; import com.ximple.eofms.util.ByteArrayCompressor; import com.ximple.eofms.util.StringUtils; -import com.ximple.eofms.jobs.context.AbstractOracleJobContext; -import com.ximple.eofms.jobs.context.FeatureDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.GeneralDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.IndexDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.OracleConvertShapefilesJobContext; +import com.ximple.io.dgn7.ComplexElement; +import com.ximple.io.dgn7.Dgn7fileException; +import com.ximple.io.dgn7.Dgn7fileReader; +import com.ximple.io.dgn7.Element; +import com.ximple.io.dgn7.ElementType; +import com.ximple.io.dgn7.IElementHandler; +import com.ximple.io.dgn7.Lock; +import com.ximple.io.dgn7.TextElement; +import com.ximple.util.PrintfFormat; + +import org.apache.commons.collections.OrderedMap; +import org.apache.commons.collections.OrderedMapIterator; +import org.apache.commons.collections.map.LinkedMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.geotools.data.DataStore; +import org.geotools.data.oracle.OracleDataStore; +import org.geotools.data.postgis.PostgisDataStore; +import org.geotools.data.postgis.PostgisDataStoreFactory; +import org.geotools.feature.IllegalAttributeException; +import org.geotools.feature.SchemaException; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import oracle.jdbc.OracleConnection; +import oracle.jdbc.OracleResultSet; +import oracle.sql.ARRAY; +import oracle.sql.BLOB; public class OracleConvertDgn2PostGISJob extends AbstractOracleDatabaseJob { @@ -61,7 +67,7 @@ private static final String PGPORT = "PGPORT"; private static final String PGSCHEMA = "PGSCHEMA"; private static final String PGUSER = "PGUSER"; - private static final String PGPASS = " PGPASS"; + private static final String PGPASS = "PGPASS"; private static final String USEWKB = "USEWKB"; private static final int FETCHSIZE = 30; @@ -80,6 +86,8 @@ } } + protected static PostgisDataStoreFactory dataStoreFactory = new PostgisDataStoreFactory(); + GeometryFactory _geomFactory = new GeometryFactory(); protected String _pgHost; protected String _pgDatabase; @@ -89,30 +97,20 @@ protected String _pgPassword; protected String _pgUseWKB; - // static PostgisDataStoreFactory factory = new PostgisDataStoreFactory(); + protected Map pgProperties; + protected PostgisDataStore targetDataStore; + /* - f = PostgisTests.newFixture(); - remote = new HashMap(); - remote.put("dbtype", "postgis"); - remote.put("charset", ""); - remote.put("host", f.host); - remote.put("port", f.port); - remote.put("database", f.database); - remote.put("user", f.user); - remote.put("passwd", f.password); - remote.put("namespace", f.namespace); - */ - /* - PostgisDataStore pg = new PostgisDataStore(pool, f.schema, getName(), - PostgisDataStore.OPTIMIZE_SQL); - pg.setWKBEnabled(WKB_ENABLED); - pg.setEstimatedExtent(true); - pg.setFIDMapper("road", new TypedFIDMapper(new BasicFIDMapper("fid", 255, false), "road")); - pg.setFIDMapper("river", new TypedFIDMapper(new BasicFIDMapper("fid", 255, false), "river")); - pg.setFIDMapper("testset", - new TypedFIDMapper(new BasicFIDMapper("gid", 255, true), "testset")); - - */ + PostgisDataStore pg = new PostgisDataStore(pool, f.schema, getName(), + PostgisDataStore.OPTIMIZE_SQL); + pg.setWKBEnabled(WKB_ENABLED); + pg.setEstimatedExtent(true); + pg.setFIDMapper("road", new TypedFIDMapper(new BasicFIDMapper("fid", 255, false), "road")); + pg.setFIDMapper("river", new TypedFIDMapper(new BasicFIDMapper("fid", 255, false), "river")); + pg.setFIDMapper("testset", + new TypedFIDMapper(new BasicFIDMapper("gid", 255, true), "testset")); + + */ /* Transaction transaction = new DefaultTransaction("attemptWriteFW"); FeatureWriter writer = ds.getFeatureWriter(table, transaction); @@ -139,7 +137,7 @@ protected AbstractOracleJobContext prepareJobContext(String filterPath) { - return new OracleConvertShapefilesJobContext(filterPath); + return new OracleConvertPostGISJobContext(getDataPath(), getTargetDataStore(), filterPath); } protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException @@ -155,6 +153,7 @@ _pgUseWKB = dataMap.getString(USEWKB); Log logger = getLogger(); + /* logger.info("PGHOST=" + _pgHost); logger.info("PGDDATBASE=" + _pgDatabase); logger.info("PGPORT=" + _pgPort); @@ -162,31 +161,49 @@ logger.info("PGUSER=" + _pgUsername); logger.info("PGPASS=" + _pgPassword); logger.info("USEWKB=" + _pgUseWKB); + */ if (_pgHost == null) { + logger.warn("PGHOST is null"); throw new JobExecutionException("Unknown PostGIS host."); } if (_pgDatabase == null) { + logger.warn("PGDATABASE is null"); throw new JobExecutionException("Unknown PostGIS database."); } if (_pgPort == null) { + logger.warn("PGPORT is null"); throw new JobExecutionException("Unknown PostGIS port."); } if (_pgSchema == null) { + logger.warn("PGSCHEMA is null"); throw new JobExecutionException("Unknown PostGIS schema."); } if (_pgUsername == null) { + logger.warn("PGUSERNAME is null"); throw new JobExecutionException("Unknown PostGIS username."); } if (_pgPassword == null) { + logger.warn("PGPASSWORD is null"); throw new JobExecutionException("Unknown PostGIS password."); } + + Map<String, String> remote = new TreeMap<String, String>(); + remote.put("dbtype", "postgis"); + remote.put("charset", "UTF-8"); + remote.put("host", _pgHost); + remote.put("port", _pgPort); + remote.put("database", _pgDatabase); + remote.put("user", _pgUsername); + remote.put("passwd", _pgPassword); + remote.put("namespace", null); + pgProperties = remote; } public void execute(JobExecutionContext context) throws JobExecutionException @@ -200,11 +217,26 @@ // Log the time the job started logger.info(jobName + " fired at " + new Date()); extractJobConfiguration(jobDetail); + createSourceDataStore(); + createTargetDataStore(); + if (getSourceDataStore() == null) + { + logger.warn("Cannot connect source oracle database."); + throw new JobExecutionException("Cannot connect source oracle database."); + } + if (getTargetDataStore() == null) + { + logger.warn("Cannot connect source postgreSQL database."); + throw new JobExecutionException("Cannot connect source postgreSQL database."); + } + + Calendar cal = Calendar.getInstance(); + Date startTime = cal.getTime(); try { - logger.info("-- step:clearOutputDirectory --"); - clearOutputDirectory(); + logger.info("-- step:clearOutputDatabase --"); + clearOutputDatabase(); boolean bFirst = true; if (checkConvertDB()) { @@ -212,12 +244,9 @@ for (String orgSchema : _orgSchema) { - OracleConvertShapefilesJobContext jobContext = (OracleConvertShapefilesJobContext) prepareJobContext(_filterPath); - jobContext.setConnectionInfo(_oracleHost, _oraclePort, _oracleInstance); - jobContext.setLogin(_username, _password); - jobContext.setShapeData(_dataPath); - jobContext.setConvertDB(_convertDB); - jobContext.setConvertFile(_convertFile); + OracleConvertPostGISJobContext jobContext = + (OracleConvertPostGISJobContext) prepareJobContext(_filterPath); + jobContext.setSourceDataStore(getSourceDataStore()); jobContext.setConvertElementIn(_convertElementIn); jobContext.setElementLogging(checkElementLogging()); jobContext.setExecutionContext(context); @@ -254,6 +283,13 @@ logger.info("-- step:createDummyFeatureFile --"); createDummyFeatureFile(context); } + + disconnect(); + Date endTime = cal.getTime(); + Date time = new Date(endTime.getTime() - startTime.getTime()); + // public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; + // SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); + logger.warn("use time = " + time); } catch (SQLException e) { logger.warn(e.getMessage(), e); @@ -272,15 +308,15 @@ * @param jobContext job context * @throws SQLException sql exception */ - private void copyConnectivity(OracleConvertShapefilesJobContext jobContext) throws SQLException + private void copyConnectivity(OracleConvertPostGISJobContext jobContext) throws SQLException { OracleConnection connection = jobContext.getOracleConnection(); Statement stmt = connection.createStatement(); - stmt.execute(OracleConvertShapefilesJobContext.TRUNCATE_CONNECTIVITY_WEBCHECK); - stmt.execute(OracleConvertShapefilesJobContext.COPY_CONNECTIVITY_TO_WEBCHECK); + stmt.execute(AbstractOracleJobContext.TRUNCATE_CONNECTIVITY_WEBCHECK); + stmt.execute(AbstractOracleJobContext.COPY_CONNECTIVITY_TO_WEBCHECK); } - private void exetcuteConvert(OracleConvertShapefilesJobContext jobContext, + private void exetcuteConvert(OracleConvertPostGISJobContext jobContext, String querySchema, String dataPath) throws SQLException { int order = 0; @@ -429,7 +465,7 @@ return orderedMap; } - protected void queryIgsetElement(OracleConvertShapefilesJobContext jobContext, + protected void queryIgsetElement(OracleConvertPostGISJobContext jobContext, String srcschema, String srctable) throws SQLException { OracleConnection connection = jobContext.getOracleConnection(); @@ -471,7 +507,7 @@ stmtSrc.close(); } - protected void queryRawElement(OracleConvertShapefilesJobContext jobContext, + protected void queryRawElement(OracleConvertPostGISJobContext jobContext, String srcschema, String srctable) throws SQLException { OracleConnection connection = jobContext.getOracleConnection(); @@ -583,7 +619,8 @@ * �����ഫ���޹��ɪ��u�@ * * @param context �u�@�������� - * @throws org.quartz.JobExecutionException exception + * @throws org.quartz.JobExecutionException + * exception */ private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException { @@ -609,7 +646,8 @@ for (File dgnFile : dgnFiles) { - IndexDgnConvertShpJobContext convertContext = new IndexDgnConvertShpJobContext(getDataPath()); + IndexDgnConvertPostGISJobContext convertContext = + new IndexDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore()); logger.debug("--- start dgnfile-" + dgnFile.toString() + " ---"); try { @@ -656,7 +694,7 @@ } } - protected void scanIndexDgnElement(IndexDgnConvertShpJobContext convertContext) + protected void scanIndexDgnElement(IndexDgnConvertPostGISJobContext convertContext) throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException { Dgn7fileReader reader = convertContext.getReader(); @@ -699,7 +737,8 @@ logger.debug("ElementRecord Count=" + count); } - private void processIndexElement(Element element, IndexDgnConvertShpJobContext convertContext) throws IllegalAttributeException, SchemaException + private void processIndexElement(Element element, IndexDgnConvertPostGISJobContext convertContext) + throws IllegalAttributeException, SchemaException { if (element instanceof TextElement) { @@ -712,7 +751,8 @@ * �����ഫ��L�]�p���ɪ��u�@ * * @param context jobContext - * @throws org.quartz.JobExecutionException exception + * @throws org.quartz.JobExecutionException + * exception */ private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException { @@ -738,7 +778,8 @@ for (File dgnFile : dgnFiles) { - GeneralDgnConvertShpJobContext convertContext = new GeneralDgnConvertShpJobContext(getDataPath()); + GeneralDgnConvertPostGISJobContext convertContext = + new GeneralDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore()); logger.info("--- start dgnfile-" + dgnFile.toString() + " ---"); try { @@ -785,7 +826,7 @@ } } - public void scanOtherDgnElement(GeneralDgnConvertShpJobContext convertContext) + public void scanOtherDgnElement(GeneralDgnConvertPostGISJobContext convertContext) throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException { Dgn7fileReader reader = convertContext.getReader(); @@ -828,15 +869,16 @@ logger.debug("ElementRecord Count=" + count); } - private void processOtherElement(Element element, GeneralDgnConvertShpJobContext convertContext) + private void processOtherElement(Element element, GeneralDgnConvertPostGISJobContext convertContext) throws IllegalAttributeException, SchemaException { convertContext.putFeatureCollection(element); } - private void clearOutputDirectory() + private void clearOutputDatabase() { - File outDataPath = new File(getDataPath(), OracleConvertShapefilesJobContext.SHPOUTPATH); + /* + File outDataPath = new File(getDataPath(), OracleConvertPostGISJobContext.SHPOUTPATH); if (outDataPath.exists() && outDataPath.isDirectory()) { deleteFilesInPath(outDataPath); @@ -851,6 +893,7 @@ { deleteFilesInPath(outDataPath); } + */ } private void deleteFilesInPath(File outDataPath) @@ -911,7 +954,8 @@ for (File dgnFile : dgnFiles) { - FeatureDgnConvertShpJobContext convertContext = new FeatureDgnConvertShpJobContext(getDataPath(), _filterPath); + FeatureDgnConvertPostGISJobContext convertContext = + new FeatureDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _filterPath); logger.info("--- start dgnfile-" + dgnFile.toString() + " ---"); try { @@ -958,7 +1002,7 @@ } } - public void scanFeatureDgnElement(FeatureDgnConvertShpJobContext convertContext) + public void scanFeatureDgnElement(FeatureDgnConvertPostGISJobContext convertContext) throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException { Dgn7fileReader reader = convertContext.getReader(); @@ -1001,7 +1045,7 @@ logger.debug("ElementRecord Count=" + count); } - private void processFeatureElement(Element element, FeatureDgnConvertShpJobContext convertContext) + private void processFeatureElement(Element element, FeatureDgnConvertPostGISJobContext convertContext) throws IllegalAttributeException, SchemaException { convertContext.putFeatureCollection(element); @@ -1022,4 +1066,39 @@ } */ } + + public DataStore getTargetDataStore() + { + return targetDataStore; + } + + protected void createTargetDataStore() throws JobExecutionException + { + if (targetDataStore != null) + { + targetDataStore.dispose(); + targetDataStore = null; + } + + /* + if (!isDriverFound()) + { + throw new JobExecutionException("Oracle JDBC Driver not found.-" + JDBC_DRIVER); + } + */ + + if (!dataStoreFactory.canProcess(pgProperties)) + { + getLogger().warn("cannot process properties-"); + throw new JobExecutionException("cannot process properties-"); + } + try + { + targetDataStore = (PostgisDataStore) dataStoreFactory.createDataStore(pgProperties); + } catch (IOException e) + { + getLogger().warn(e.getMessage(), e); + throw new JobExecutionException(e.getMessage(), e); + } + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java index d3de309..384b6d9 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java @@ -22,6 +22,10 @@ import org.apache.commons.logging.LogFactory; import org.geotools.feature.IllegalAttributeException; import org.geotools.feature.SchemaException; +import org.geotools.data.oracle.OracleDataStore; +import org.geotools.data.jdbc.ConnectionPoolManager; +import org.geotools.data.jdbc.datasource.DataSourceUtil; +import org.geotools.data.jdbc.datasource.DataSourceFinder; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -33,14 +37,14 @@ import oracle.sql.ARRAY; import oracle.sql.BLOB; +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; +import com.ximple.eofms.jobs.context.shapefile.FeatureDgnConvertShpJobContext; +import com.ximple.eofms.jobs.context.shapefile.GeneralDgnConvertShpJobContext; +import com.ximple.eofms.jobs.context.shapefile.IndexDgnConvertShpJobContext; +import com.ximple.eofms.jobs.context.shapefile.OracleConvertShapefilesJobContext; import com.ximple.eofms.util.BinConverter; import com.ximple.eofms.util.ByteArrayCompressor; import com.ximple.eofms.util.StringUtils; -import com.ximple.eofms.jobs.context.AbstractOracleJobContext; -import com.ximple.eofms.jobs.context.FeatureDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.GeneralDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.IndexDgnConvertShpJobContext; -import com.ximple.eofms.jobs.context.OracleConvertShapefilesJobContext; import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Dgn7fileException; import com.ximple.io.dgn7.Dgn7fileReader; @@ -102,6 +106,11 @@ // Log the time the job started logger.info(jobName + " fired at " + new Date()); extractJobConfiguration(jobDetail); + createSourceDataStore(); + if (getSourceDataStore() == null) + { + throw new JobExecutionException("Cannot connect source oracle database."); + } try { @@ -115,11 +124,8 @@ for (String orgSchema : _orgSchema) { OracleConvertShapefilesJobContext jobContext = (OracleConvertShapefilesJobContext) prepareJobContext(_filterPath); - jobContext.setConnectionInfo(_oracleHost, _oraclePort, _oracleInstance); - jobContext.setLogin(_username, _password); - jobContext.setShapeData(_dataPath); - jobContext.setConvertDB(_convertDB); - jobContext.setConvertFile(_convertFile); + jobContext.setSourceDataStore(getSourceDataStore()); + jobContext.setDataPath(_dataPath); jobContext.setConvertElementIn(_convertElementIn); jobContext.setElementLogging(checkElementLogging()); jobContext.setExecutionContext(context); @@ -156,6 +162,8 @@ logger.info("-- step:createDummyFeatureFile --"); createDummyFeatureFile(context); } + + disconnect(); } catch (SQLException e) { logger.warn(e.getMessage(), e); @@ -485,7 +493,8 @@ * �����ഫ���޹��ɪ��u�@ * * @param context �u�@�������� - * @throws org.quartz.JobExecutionException exception + * @throws org.quartz.JobExecutionException + * exception */ private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException { @@ -614,7 +623,8 @@ * �����ഫ��L�]�p���ɪ��u�@ * * @param context jobContext - * @throws org.quartz.JobExecutionException exception + * @throws org.quartz.JobExecutionException + * exception */ private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException { diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java index 2ff257c..328ef87 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java @@ -81,7 +81,7 @@ public void logElement(Element element, String currentSchema) { if ((this.currentSchema == null) || - (!this.currentSchema.equalsIgnoreCase(currentSchema))) + (!this.currentSchema.equalsIgnoreCase(currentSchema))) { schemaChanged = true; this.currentSchema = currentSchema; @@ -199,7 +199,7 @@ while (logFile.exists()) { logFile = new File(getDataOutPath(), this.currentSchema + "-" - + (++logCount) +".dgn"); + + (++logCount) + ".dgn"); } logger.warn("Create Dgn Logging File:" + logFile.toString()); @@ -286,6 +286,7 @@ } is.close(); + assert buffer != null; buffer.position(0); raw = buffer.array(); } catch (IOException e) diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java index adb35c2..cbeb488 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java @@ -31,10 +31,14 @@ // Log the time the job started logger.info(jobName + " fired at " + new Date()); extractJobConfiguration(jobDetail); + createSourceDataStore(); + if (getSourceDataStore() == null) + { + throw new JobExecutionException("Cannot connect source oracle database."); + } AbstractOracleJobContext jobContext = prepareJobContext(_filterPath); - jobContext.setConnectionInfo(_oracleHost, _oraclePort, _oracleInstance); - jobContext.setLogin(_username, _password); + jobContext.setSourceDataStore(getSourceDataStore()); try { @@ -48,6 +52,11 @@ } } + public Log getLogger() + { + return logger; + } + protected AbstractOracleJobContext prepareJobContext(String filterPath) { return new OracleUpgradeJobContext(); diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java index db4655e..0cb5325 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java @@ -1,82 +1,85 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Map; - -import org.quartz.JobExecutionContext; - -import com.ximple.io.dgn7.Dgn7fileReader; - -public abstract class AbstractDgnFileJobContext -{ - /** - * Encoding of URL path. - */ - protected static final String ENCODING = "UTF-8"; - - private JobExecutionContext executionContext = null; - - protected String _dataPath = null; - protected Map properties = null; - - private Dgn7fileReader reader = null; - private String filename = null; - private boolean _elementLogging; - - public AbstractDgnFileJobContext(String dataPath) - { - _dataPath = dataPath; - } - - public String getDataPath() - { - return _dataPath; - } - - public JobExecutionContext getExecutionContext() - { - return executionContext; - } - - public void setExecutionContext(JobExecutionContext context) - { - executionContext = context; - } - - public abstract void startTransaction(); - - public abstract void commitTransaction(); - - public abstract void rollbackTransaction(); - - public abstract String getDataOutPath(); - - public Dgn7fileReader getReader() - { - return this.reader; - } - - public void setReader(Dgn7fileReader reader) - { - this.reader = reader; - } - - public String getFilename() - { - return filename; - } - - public void setFilename(String filename) - { - this.filename = filename; - } - - public boolean getElementLogging() - { - return _elementLogging; - } - - public void setElementLogging(boolean elementLogging) - { - this._elementLogging = elementLogging; - } -} +package com.ximple.eofms.jobs.context; + +import java.util.Map; + +import org.quartz.JobExecutionContext; +import org.apache.commons.logging.Log; + +import com.ximple.io.dgn7.Dgn7fileReader; + +public abstract class AbstractDgnFileJobContext +{ + /** + * Encoding of URL path. + */ + protected static final String ENCODING = "UTF-8"; + + private JobExecutionContext executionContext = null; + + protected String _dataPath = null; + protected Map properties = null; + + private Dgn7fileReader reader = null; + private String filename = null; + private boolean _elementLogging; + + public AbstractDgnFileJobContext(String dataPath) + { + _dataPath = dataPath; + } + + public String getDataPath() + { + return _dataPath; + } + + public JobExecutionContext getExecutionContext() + { + return executionContext; + } + + public void setExecutionContext(JobExecutionContext context) + { + executionContext = context; + } + + public abstract void startTransaction(); + + public abstract void commitTransaction(); + + public abstract void rollbackTransaction(); + + public abstract String getDataOutPath(); + + public Dgn7fileReader getReader() + { + return this.reader; + } + + public void setReader(Dgn7fileReader reader) + { + this.reader = reader; + } + + public String getFilename() + { + return filename; + } + + public void setFilename(String filename) + { + this.filename = filename; + } + + public boolean getElementLogging() + { + return _elementLogging; + } + + public void setElementLogging(boolean elementLogging) + { + this._elementLogging = elementLogging; + } + + public abstract Log getLogger(); +} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToPostGISJobContext.java deleted file mode 100644 index 035b499..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToPostGISJobContext.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Properties; - -public abstract class AbstractDgnToPostGISJobContext extends AbstractDgnFileJobContext -{ - public AbstractDgnToPostGISJobContext(String dataPath, Properties properties) - { - super(dataPath); - this.properties = properties; - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java index 5895786..82081c2 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java @@ -3,16 +3,19 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.geotools.data.oracle.OracleDataStore; +import org.geotools.data.Transaction; +import org.geotools.data.DataStore; import oracle.jdbc.OracleConnection; -import com.ximple.eofms.jobs.context.OracleConvertShapefilesJobContext; +import com.ximple.eofms.jobs.context.shapefile.OracleConvertShapefilesJobContext; public abstract class AbstractOracleJobContext { - private static final String ORACLE_URL = "jdbc:oracle:thin:@"; - private static final String PROPUsrKey = "user"; - private static final String PROPPassKey = "password"; /** * Table Prefiex */ @@ -196,9 +199,9 @@ "PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT )\n" + "LOGGING NOCOMPRESS NOCACHE NOPARALLEL MONITORING;"; - public static final String COPY_CONNECTIVITY_TO_WEBCHECK = "INSERT /*+ APPEND */ INTO BASEDB.CONNECTIVITY_WEBCHECK\n" + - "(FSC, UFID, N1, N2, FDR1, FDR2, DIR, OHUG,OSTATUS, PHASE, X, Y)\n" + - "SELECT FSC, UFID, N1, N2, FDR1, FDR2, DIR, OHUG, OSTATUS, PHASE, X, Y FROM BASEDB.CONNECTIVITY "; + public static final String COPY_CONNECTIVITY_TO_WEBCHECK = "INSERT /*+ APPEND */ INTO BASEDB.CONNECTIVITY_WEBCHECK\n" + + "(FSC, UFID, N1, N2, FDR1, FDR2, DIR, OHUG,OSTATUS, PHASE, X, Y)\n" + + "SELECT FSC, UFID, N1, N2, FDR1, FDR2, DIR, OHUG, OSTATUS, PHASE, X, Y FROM BASEDB.CONNECTIVITY "; /** @@ -213,101 +216,55 @@ * Encoding of URL path. */ protected static final String ENCODING = "UTF-8"; - private String _oracleHost; - private String _oracleInstance; - private String _oraclePort; + protected OracleDataStore sourceDataStore; + protected String _dataPath; - private OracleConnection oracleConnection = null; protected Properties properties; protected boolean _elementLogging; - public static String getCurrentURL(String oracleHost, String oraclePort, String oracleInstance) + public OracleDataStore getSourceDataStore() { - StringBuilder builder = new StringBuilder(); - - builder.append(ORACLE_URL); - builder.append(oracleHost); - builder.append(":"); - builder.append(oraclePort); - builder.append(":"); - builder.append(oracleInstance); - - return builder.toString(); + return sourceDataStore; } - public void setLogin(String userName, String password) + public void setSourceDataStore(DataStore sourceDataStore) { - properties.put(PROPUsrKey, userName); - properties.put(PROPPassKey, password); - } - - public void setShapeData(String dataPath) - { - _dataPath = dataPath; + if ((sourceDataStore != null) && (sourceDataStore instanceof OracleDataStore)) + { + this.sourceDataStore = (OracleDataStore) sourceDataStore; + } else + { + assert sourceDataStore != null; + getLogger().warn("setSourceDataStore(datastore) need OracleDataStore but got " + + sourceDataStore.getClass().getName()); + } } public OracleConnection getOracleConnection() { try { - if (oracleConnection == null) + if (sourceDataStore != null) { - oracleConnection = (OracleConnection) DriverManager.getConnection( - getCurrentURL(_oracleHost, _oraclePort, _oracleInstance), - properties); + return (OracleConnection) sourceDataStore.getConnection(Transaction.AUTO_COMMIT); } - return oracleConnection; - } catch (SQLException e) + } catch (IOException e) { - OracleConvertShapefilesJobContext.logger.warn(e.getMessage(), e); + getLogger().warn(e.getMessage(), e); } - - oracleConnection = null; return null; } - public void closeConnection() + public void setDataPath(String dataPath) { - try - { - if (oracleConnection != null) - { - oracleConnection.close(); - oracleConnection = null; - } - } catch (SQLException e) - { - OracleConvertShapefilesJobContext.logger.warn(e.getMessage(), e); - } - } - - public void setConnectionInfo(String oracleHost, String oraclePort, String oracleInstance) - { - _oracleHost = oracleHost; - _oracleInstance = oracleInstance; - _oraclePort = oraclePort; + _dataPath = dataPath; } public String getDataPath() { return _dataPath; - } - - public String getOracleHost() - { - return _oracleHost; - } - - public String getOracleInstance() - { - return _oracleInstance; - } - - public String getOraclePort() - { - return _oraclePort; } public boolean getElementLogging() @@ -325,4 +282,6 @@ public abstract void commitTransaction(); public abstract void rollbackTransaction(); + + protected abstract Log getLogger(); } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToPostGISJobContext.java deleted file mode 100644 index 74386f9..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToPostGISJobContext.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Properties; - -public abstract class AbstractOracleToPostGISJobContext extends AbstractOracleJobContext -{ - public AbstractOracleToPostGISJobContext(String dataPath, Properties properties) - { - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertPostGISJobContext.java deleted file mode 100644 index 98d27c8..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertPostGISJobContext.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Properties; - -public class DummyFeatureConvertPostGISJobContext extends AbstractDgnToPostGISJobContext -{ - public DummyFeatureConvertPostGISJobContext(String dataPath, Properties properties) - { - super(dataPath, properties); - } - - public void startTransaction() - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void commitTransaction() - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void rollbackTransaction() - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getDataOutPath() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertPostGISJobContext.java deleted file mode 100644 index 2edb464..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertPostGISJobContext.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Properties; - -public class FeatureDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext -{ - public FeatureDgnConvertPostGISJobContext(String dataPath, Properties properties) - { - super(dataPath, properties); - } - - public void startTransaction() - { - } - - public void commitTransaction() - { - } - - public void rollbackTransaction() - { - } - - public String getDataOutPath() - { - return null; - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertPostGISJobContext.java deleted file mode 100644 index aad1861..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertPostGISJobContext.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Properties; - -public class GeneralDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext -{ - public GeneralDgnConvertPostGISJobContext(String dataPath, Properties properties) - { - super(dataPath, properties); - } - - public void startTransaction() - { - } - - public void commitTransaction() - { - } - - public void rollbackTransaction() - { - } - - public String getDataOutPath() - { - return null; - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertPostGISJobContext.java deleted file mode 100644 index 2a4626c..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertPostGISJobContext.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ximple.eofms.jobs.context; - -import java.util.Properties; - -public class IndexDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext -{ - public IndexDgnConvertPostGISJobContext(String dataPath, Properties properties) - { - super(dataPath, properties); - } - - public void startTransaction() - { - } - - public void commitTransaction() - { - } - - public void rollbackTransaction() - { - } - - public String getDataOutPath() - { - return null; - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertOraSDOJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertOraSDOJobContext.java deleted file mode 100644 index 97ea7f6..0000000 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertOraSDOJobContext.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ximple.eofms.jobs.context; - -public class OracleConvertOraSDOJobContext extends AbstractOracleJobContext -{ - public void startTransaction() - { - } - - public void commitTransaction() - { - } - - public void rollbackTransaction() - { - } -} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java index 66a97a6..29e1acf 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java @@ -1,6 +1,6 @@ package com.ximple.eofms.jobs.context; -import com.ximple.eofms.jobs.context.AbstractOracleJobContext; +import org.apache.commons.logging.Log; public class OracleUpgradeJobContext extends AbstractOracleJobContext { @@ -15,4 +15,9 @@ public void rollbackTransaction() { } + + protected Log getLogger() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToOraSDOJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java similarity index 71% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToOraSDOJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java index 863dc38..71dd629 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnToOraSDOJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java @@ -1,7 +1,9 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.orasdo; import java.util.Properties; +import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; + public abstract class AbstractDgnToOraSDOJobContext extends AbstractDgnFileJobContext { public AbstractDgnToOraSDOJobContext(String dataPath, Properties properties) diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToOraSDOJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java similarity index 66% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToOraSDOJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java index 251c6a7..2c0c7a1 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleToOraSDOJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java @@ -1,7 +1,9 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.orasdo; import java.util.Properties; +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; + public abstract class AbstractOracleToOraSDOJobContext extends AbstractOracleJobContext { public AbstractOracleToOraSDOJobContext(String dataPath, Properties properties) diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java new file mode 100644 index 0000000..b027a76 --- /dev/null +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java @@ -0,0 +1,31 @@ +package com.ximple.eofms.jobs.context.orasdo; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.transaction.util.LoggerFacade; +import org.apache.commons.transaction.util.CommonsLoggingLogger; + +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; + +public class OracleConvertOraSDOJobContext extends AbstractOracleJobContext +{ + static Log logger = LogFactory.getLog(OracleConvertOraSDOJobContext.class); + static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); + + public void startTransaction() + { + } + + public void commitTransaction() + { + } + + public void rollbackTransaction() + { + } + + protected Log getLogger() + { + return logger; + } +} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java new file mode 100644 index 0000000..3b09bcc --- /dev/null +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java @@ -0,0 +1,47 @@ +package com.ximple.eofms.jobs.context.postgis; + +import java.util.Map; +import java.sql.Connection; +import java.io.IOException; + +import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; + +import org.geotools.data.postgis.PostgisDataStore; +import org.geotools.data.Transaction; +import org.geotools.data.DataStore; + +public abstract class AbstractDgnToPostGISJobContext extends AbstractDgnFileJobContext +{ + protected PostgisDataStore targetDataStore; + + public AbstractDgnToPostGISJobContext(String dataPath, DataStore targetDataStore) + { + super(dataPath); + this.targetDataStore = (PostgisDataStore) targetDataStore; + } + + public PostgisDataStore getTargetDataStore() + { + return targetDataStore; + } + + public void setTargetDataStore(PostgisDataStore targetDataStore) + { + this.targetDataStore = targetDataStore; + } + + public Connection getConnection() + { + if (targetDataStore != null) + { + try + { + return targetDataStore.getConnection(Transaction.AUTO_COMMIT); + } catch (IOException e) + { + getLogger().warn(e.getMessage(), e); + } + } + return null; + } +} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java new file mode 100644 index 0000000..e36a820 --- /dev/null +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java @@ -0,0 +1,51 @@ +package com.ximple.eofms.jobs.context.postgis; + +import java.sql.Connection; +import java.io.IOException; + +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; + +import org.geotools.data.postgis.PostgisDataStore; +import org.geotools.data.Transaction; +import org.geotools.data.DataStore; + +public abstract class AbstractOracleToPostGISJobContext extends AbstractOracleJobContext +{ + protected PostgisDataStore targetDataStore; + + public AbstractOracleToPostGISJobContext(String dataPath, DataStore targetDataStore) + { + if ((targetDataStore != null) && (targetDataStore instanceof PostgisDataStore)) + { + this.targetDataStore = (PostgisDataStore) targetDataStore; + } else { + getLogger().info("targetDataStore has wrong."); + } + setDataPath(dataPath); + } + + public PostgisDataStore getTargetDataStore() + { + return targetDataStore; + } + + public void setTargetDataStore(PostgisDataStore targetDataStore) + { + this.targetDataStore = targetDataStore; + } + + public Connection getConnection() + { + if (targetDataStore != null) + { + try + { + return targetDataStore.getConnection(Transaction.AUTO_COMMIT); + } catch (IOException e) + { + getLogger().warn(e.getMessage(), e); + } + } + return null; + } +} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java similarity index 93% copy from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java copy to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java index 37f5305..bf42829 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java @@ -1,50 +1,53 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.postgis; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.io.IOException; -import java.nio.charset.Charset; +import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.transaction.util.LoggerFacade; -import org.apache.commons.transaction.util.CommonsLoggingLogger; -import org.apache.commons.transaction.memory.PessimisticMapWrapper; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; -import org.geotools.feature.Feature; -import org.geotools.feature.IllegalAttributeException; -import org.geotools.feature.SchemaException; -import org.geotools.feature.FeatureType; -import org.geotools.feature.SimpleFeature; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.transaction.memory.PessimisticMapWrapper; +import org.apache.commons.transaction.util.CommonsLoggingLogger; +import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; +import org.geotools.data.DataStore; +import org.geotools.data.postgis.PostgisDataStore; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; +import org.geotools.feature.Feature; +import org.geotools.feature.FeatureType; +import org.geotools.feature.IllegalAttributeException; +import org.geotools.feature.SchemaException; +import org.geotools.feature.SimpleFeature; import org.xml.sax.SAXException; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.ElementDispatchableFilter; +import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.TypeCompIdDispatchableFilter; import com.ximple.eofms.filter.TypeCompLevelIdDispatchableFilter; import com.ximple.eofms.filter.TypeIdDispatchableFilter; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; -import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.UserAttributeData; -public class DummyFeatureConvertShpJobContext extends AbstractDgnFileJobContext +public class DummyFeatureConvertPostGISJobContext extends AbstractDgnToPostGISJobContext { - static final Log logger = LogFactory.getLog(DummyFeatureConvertShpJobContext.class); + static final Log logger = LogFactory.getLog(DummyFeatureConvertPostGISJobContext.class); static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); static final GeometryFactory geometryFactory = new GeometryFactory(); static final String SHPOUTPATH = "shpout"; @@ -60,9 +63,9 @@ private String _filterConfig; private boolean withIndex = false; - public DummyFeatureConvertShpJobContext(String dataPath, String filterConfig) + public DummyFeatureConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String filterConfig) { - super(dataPath); + super(dataPath, targetDataStore); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); _filterConfig = filterConfig; elementDispatcher = createElementDispatcher(); @@ -158,7 +161,7 @@ } else if (filter instanceof TypeCompLevelIdDispatchableFilter) { ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); - } else if(filter instanceof TypeIdDispatchableFilter) + } else if (filter instanceof TypeIdDispatchableFilter) { ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); } @@ -227,7 +230,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -274,7 +278,8 @@ return dataOut; } - public void closeFeatureWriter() throws IOException { + public void closeFeatureWriter() throws IOException + { for (FeatureWriter featureWriter : this.featuresWriterContext.values()) { @@ -310,4 +315,9 @@ { this.withIndex = withIndex; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java similarity index 93% copy from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java copy to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java index 1acd9d6..3f55622 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java @@ -1,4 +1,4 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.postgis; import java.io.File; import java.io.IOException; @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; @@ -20,6 +21,7 @@ import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; +import org.geotools.data.DataStore; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; import org.geotools.feature.Feature; @@ -33,13 +35,13 @@ import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.ElementDispatcher; -import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.eofms.jobs.context.shapefile.FeatureDgnConvertShpJobContext; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.UserAttributeData; -import com.ximple.io.dgn7.ComplexElement; -public class FeatureDgnConvertShpJobContext extends AbstractDgnFileJobContext +public class FeatureDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext { static final Log logger = LogFactory.getLog(FeatureDgnConvertShpJobContext.class); static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); @@ -57,9 +59,9 @@ private String _filterConfig; private boolean withIndex = false; - public FeatureDgnConvertShpJobContext(String dataPath, String filterConfig) + public FeatureDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String filterConfig) { - super(dataPath); + super(dataPath, targetDataStore); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); _filterConfig = filterConfig; elementDispatcher = createElementDispatcher(); @@ -210,7 +212,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -257,7 +260,8 @@ return dataOut; } - public void closeFeatureWriter() throws IOException { + public void closeFeatureWriter() throws IOException + { for (FeatureWriter featureWriter : this.featuresWriterContext.values()) { @@ -293,5 +297,9 @@ { this.withIndex = withIndex; } -} + public Log getLogger() + { + return logger; + } +} diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java similarity index 88% copy from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java copy to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java index 2dd494f..49fcf69 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java @@ -1,4 +1,4 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.postgis; import java.io.File; import java.io.IOException; @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.TreeMap; import org.apache.commons.logging.Log; @@ -19,9 +20,9 @@ import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; +import org.geotools.data.DataStore; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; @@ -33,8 +34,8 @@ import com.vividsolutions.jts.geom.GeometryFactory; import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; import com.ximple.eofms.util.TWD97GeometryConverterDecorator; -import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; import com.ximple.io.dgn7.ArcElement; import com.ximple.io.dgn7.ComplexChainElement; import com.ximple.io.dgn7.Element; @@ -47,9 +48,9 @@ import com.ximple.io.dgn7.TextNodeElement; import com.ximple.io.dgn7.UserAttributeData; -public class GeneralDgnConvertShpJobContext extends AbstractDgnFileJobContext +public class GeneralDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext { - static final Log logger = LogFactory.getLog(GeneralDgnConvertShpJobContext.class); + static final Log logger = LogFactory.getLog(GeneralDgnConvertPostGISJobContext.class); static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); static final GeometryFactory geometryFactory = new GeometryFactory(); public static final String SHPOUTPATH = "shpout"; @@ -67,9 +68,9 @@ private String featureBaseName = null; private boolean withIndex = false; - public GeneralDgnConvertShpJobContext(String dataPath) + public GeneralDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore) { - super(dataPath); + super(dataPath, targetDataStore); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); convertDecorator = new TWD97GeometryConverterDecorator(); } @@ -179,7 +180,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -241,15 +243,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalPointFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -259,11 +253,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalLineFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -273,11 +263,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalArcFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -287,11 +273,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalEllipseFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -568,4 +550,9 @@ { this.withIndex = withIndex; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java similarity index 83% copy from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java copy to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java index 4d99ad9..15b5245 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java @@ -1,4 +1,4 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.postgis; import java.io.File; import java.io.IOException; @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -18,6 +19,7 @@ import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; +import org.geotools.data.DataStore; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; import org.geotools.feature.AttributeTypeFactory; @@ -35,17 +37,17 @@ import com.ximple.eofms.util.DefaultColorTable; import com.ximple.eofms.util.TPCLIDConverter; -import com.ximple.eofms.util.TWDDatumConverter; import com.ximple.eofms.util.TWD97GeometryConverterDecorator; -import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.eofms.util.TWDDatumConverter; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.TextElement; import com.ximple.io.dgn7.UserAttributeData; -public class IndexDgnConvertShpJobContext extends AbstractDgnFileJobContext +public class IndexDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext { - static final Log logger = LogFactory.getLog(IndexDgnConvertShpJobContext.class); + static final Log logger = LogFactory.getLog(IndexDgnConvertPostGISJobContext.class); static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); static final GeometryFactory geometryFactory = new GeometryFactory(); TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); @@ -62,9 +64,9 @@ private FeatureType featureType = null; private FeatureType featureType2 = null; - public IndexDgnConvertShpJobContext(String dataPath) + public IndexDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore) { - super(dataPath); + super(dataPath, targetDataStore); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); } @@ -218,16 +220,7 @@ { if (typeBuilderRect == null) { - typeBuilderRect = FeatureTypeBuilder.newInstance(featureName); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("X1", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("Y1", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("X2", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("Y2", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("TPCID", String.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexFeatureTypeBuilder(featureName); } return typeBuilderRect.getFeatureType(); } @@ -236,16 +229,7 @@ { if (typeBuilderPnt == null) { - typeBuilderPnt = FeatureTypeBuilder.newInstance(featureName); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("TPCID", String.class)); + typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexTextFeatureTypeBuilder(featureName); } return typeBuilderPnt.getFeatureType(); } @@ -354,4 +338,9 @@ } return null; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java similarity index 92% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertPostGISJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java index 2ee594c..58708ac 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertPostGISJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java @@ -1,53 +1,51 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.postgis; -import java.util.Properties; -import java.util.HashMap; -import java.util.ArrayList; -import java.util.Iterator; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; import java.sql.DriverManager; import java.sql.SQLException; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.io.IOException; -import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.transaction.util.LoggerFacade; -import org.apache.commons.transaction.util.CommonsLoggingLogger; -import org.apache.commons.transaction.memory.PessimisticMapWrapper; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.transaction.memory.PessimisticMapWrapper; +import org.apache.commons.transaction.util.CommonsLoggingLogger; +import org.apache.commons.transaction.util.LoggerFacade; +import org.geotools.data.DataStore; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; -import org.geotools.data.DataStore; import org.geotools.data.postgis.PostgisDataStoreFactory; -import org.geotools.data.shapefile.ShapefileDataStore; -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; +import org.geotools.data.postgis.PostgisDataStore; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; -import org.geotools.feature.SimpleFeature; import org.geotools.feature.IllegalAttributeException; +import org.geotools.feature.SimpleFeature; import org.quartz.JobExecutionContext; import org.xml.sax.SAXException; import com.vividsolutions.jts.util.Assert; -import com.ximple.eofms.jobs.OracleElementLogger; -import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; +import com.ximple.eofms.filter.ElementDispatcher; +import com.ximple.eofms.jobs.OracleElementLogger; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; -import com.ximple.io.dgn7.ComplexElement; public class OracleConvertPostGISJobContext extends AbstractOracleToPostGISJobContext { - static Log logger = LogFactory.getLog(OracleConvertShapefilesJobContext.class); + static Log logger = LogFactory.getLog(OracleConvertPostGISJobContext.class); static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); - static PostgisDataStoreFactory dataStoreFactory = new PostgisDataStoreFactory(); + static PostgisDataStoreFactory dataStoreFactory = new PostgisDataStoreFactory(); private OracleElementLogger elmLogger = null; @@ -73,16 +71,14 @@ private JobExecutionContext executionContext; private String dataOut = null; - private String _convertDB = null; - private String _convertFile = null; private String currentSchema = null; private String pgCurrentSchema = null; private boolean schemaChanged = false; private String _convertElementIn = null; - public OracleConvertPostGISJobContext(String dataPath, Properties properties, String filterConfig) + public OracleConvertPostGISJobContext(String dataPath, DataStore pgDS, String filterConfig) { - super(dataPath, properties); + super(dataPath, pgDS); _filterConfig = filterConfig; elementDispatcher = createElementDispatcher(); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); @@ -227,7 +223,8 @@ postGisDataStore.createSchema(featureType); writer = postGisDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = postGisDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -289,16 +286,6 @@ this.featuresWriterContext.clear(); } - public void setConvertDB(String convertDB) - { - _convertDB = convertDB; - } - - public void setConvertFile(String convertFile) - { - _convertFile = convertFile; - } - protected OracleElementLogger getElementLogger() { if (elmLogger == null) @@ -324,4 +311,9 @@ { _convertElementIn = convertElementIn; } + + protected Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java similarity index 96% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java index 37f5305..bb4983c 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/DummyFeatureConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java @@ -1,45 +1,46 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.shapefile; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.io.IOException; -import java.nio.charset.Charset; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.transaction.util.LoggerFacade; -import org.apache.commons.transaction.util.CommonsLoggingLogger; -import org.apache.commons.transaction.memory.PessimisticMapWrapper; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; -import org.geotools.feature.Feature; -import org.geotools.feature.IllegalAttributeException; -import org.geotools.feature.SchemaException; -import org.geotools.feature.FeatureType; -import org.geotools.feature.SimpleFeature; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.transaction.memory.PessimisticMapWrapper; +import org.apache.commons.transaction.util.CommonsLoggingLogger; +import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; +import org.geotools.feature.Feature; +import org.geotools.feature.FeatureType; +import org.geotools.feature.IllegalAttributeException; +import org.geotools.feature.SchemaException; +import org.geotools.feature.SimpleFeature; import org.xml.sax.SAXException; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.ElementDispatchableFilter; +import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.filter.TypeCompIdDispatchableFilter; import com.ximple.eofms.filter.TypeCompLevelIdDispatchableFilter; import com.ximple.eofms.filter.TypeIdDispatchableFilter; +import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; -import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.UserAttributeData; public class DummyFeatureConvertShpJobContext extends AbstractDgnFileJobContext @@ -158,7 +159,7 @@ } else if (filter instanceof TypeCompLevelIdDispatchableFilter) { ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); - } else if(filter instanceof TypeIdDispatchableFilter) + } else if (filter instanceof TypeIdDispatchableFilter) { ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); } @@ -227,7 +228,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -274,7 +276,8 @@ return dataOut; } - public void closeFeatureWriter() throws IOException { + public void closeFeatureWriter() throws IOException + { for (FeatureWriter featureWriter : this.featuresWriterContext.values()) { @@ -310,4 +313,9 @@ { this.withIndex = withIndex; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java similarity index 97% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java index 1acd9d6..4dbd691 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/FeatureDgnConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java @@ -1,4 +1,4 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.shapefile; import java.io.File; import java.io.IOException; @@ -34,10 +34,10 @@ import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.ElementDispatcher; import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.UserAttributeData; -import com.ximple.io.dgn7.ComplexElement; public class FeatureDgnConvertShpJobContext extends AbstractDgnFileJobContext { @@ -210,7 +210,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -257,7 +258,8 @@ return dataOut; } - public void closeFeatureWriter() throws IOException { + public void closeFeatureWriter() throws IOException + { for (FeatureWriter featureWriter : this.featuresWriterContext.values()) { @@ -293,5 +295,10 @@ { this.withIndex = withIndex; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java similarity index 89% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java index 2dd494f..546fa00 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/GeneralDgnConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java @@ -1,4 +1,4 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.shapefile; import java.io.File; import java.io.IOException; @@ -21,7 +21,6 @@ import org.geotools.data.Transaction; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; -import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Feature; import org.geotools.feature.FeatureType; import org.geotools.feature.FeatureTypeBuilder; @@ -32,9 +31,10 @@ import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import com.ximple.eofms.util.DefaultColorTable; -import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.eofms.util.DefaultColorTable; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; +import com.ximple.eofms.util.TWD97GeometryConverterDecorator; import com.ximple.io.dgn7.ArcElement; import com.ximple.io.dgn7.ComplexChainElement; import com.ximple.io.dgn7.Element; @@ -179,7 +179,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -241,15 +242,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalPointFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -259,11 +252,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalLineFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -273,11 +262,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalArcFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -287,11 +272,7 @@ { if (!typeBuilders.containsKey(featureName)) { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalEllipseFeatureTypeBuilder(featureName); typeBuilders.put(featureName, typeBuilder); } return typeBuilders.get(featureName).getFeatureType(); @@ -568,4 +549,9 @@ { this.withIndex = withIndex; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java similarity index 85% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java index 4d99ad9..e602224 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/IndexDgnConvertShpJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java @@ -1,4 +1,4 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.shapefile; import java.io.File; import java.io.IOException; @@ -33,11 +33,12 @@ import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; +import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; import com.ximple.eofms.util.DefaultColorTable; import com.ximple.eofms.util.TPCLIDConverter; -import com.ximple.eofms.util.TWDDatumConverter; import com.ximple.eofms.util.TWD97GeometryConverterDecorator; -import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; +import com.ximple.eofms.util.TWDDatumConverter; +import com.ximple.eofms.util.FeatureTypeBuilderUtil; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.TextElement; @@ -218,16 +219,7 @@ { if (typeBuilderRect == null) { - typeBuilderRect = FeatureTypeBuilder.newInstance(featureName); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("X1", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("Y1", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("X2", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("Y2", Double.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("TPCID", String.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilderRect.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); + typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexFeatureTypeBuilder(featureName); } return typeBuilderRect.getFeatureType(); } @@ -236,16 +228,7 @@ { if (typeBuilderPnt == null) { - typeBuilderPnt = FeatureTypeBuilder.newInstance(featureName); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - typeBuilderPnt.addType(AttributeTypeFactory.newAttributeType("TPCID", String.class)); + typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexTextFeatureTypeBuilder(featureName); } return typeBuilderPnt.getFeatureType(); } @@ -354,4 +337,9 @@ } return null; } + + public Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertShapefilesJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java similarity index 97% rename from xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertShapefilesJobContext.java rename to xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java index fbb6be6..42bcbc0 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleConvertShapefilesJobContext.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java @@ -1,17 +1,17 @@ -package com.ximple.eofms.jobs.context; +package com.ximple.eofms.jobs.context.shapefile; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.Charset; import java.sql.DriverManager; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Properties; -import java.nio.charset.Charset; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; @@ -22,6 +22,7 @@ import org.apache.commons.transaction.util.LoggerFacade; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; +import org.geotools.data.oracle.OracleDataStore; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; import org.geotools.feature.Feature; @@ -35,11 +36,11 @@ import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.ElementDispatcher; -import com.ximple.eofms.jobs.context.AbstractOracleJobContext; import com.ximple.eofms.jobs.OracleElementLogger; +import com.ximple.eofms.jobs.context.AbstractOracleJobContext; +import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; -import com.ximple.io.dgn7.ComplexElement; public class OracleConvertShapefilesJobContext extends AbstractOracleJobContext @@ -75,9 +76,9 @@ private String dataOut = null; private String _convertDB = null; private String _convertFile = null; + private String _convertElementIn = null; private String currentSchema = null; private boolean schemaChanged = false; - private String _convertElementIn = null; private boolean withIndex = false; public OracleConvertShapefilesJobContext(String filterConfig) @@ -238,7 +239,8 @@ shapefileDataStore.createSchema(featureType); writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); - } else { + } else + { writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT); } @@ -362,4 +364,9 @@ { this.withIndex = withIndex; } + + protected Log getLogger() + { + return logger; + } } diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java new file mode 100644 index 0000000..e07bbab --- /dev/null +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java @@ -0,0 +1,199 @@ +package com.ximple.eofms.util; + +import org.geotools.feature.FeatureTypeBuilder; +import org.geotools.feature.AttributeTypeFactory; + +import com.vividsolutions.jts.geom.Geometry; + +public final class FeatureTypeBuilderUtil +{ + public static FeatureTypeBuilder createNormalPointFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class, false, 254)); + return typeBuilder; + } + + public static FeatureTypeBuilder createNormalLineFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + } + + public static FeatureTypeBuilder createNormalArcFeatureTypeBuilder(String featureName) + { + return createNormalLineFeatureTypeBuilder(featureName); + /* + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + */ + } + + public static FeatureTypeBuilder createNormalEllipseFeatureTypeBuilder(String featureName) + { + return createNormalLineFeatureTypeBuilder(featureName); + /* + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + */ + } + + public static FeatureTypeBuilder createNormalIndexFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("X1", Double.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("Y1", Double.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("X2", Double.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("Y2", Double.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TPCID", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + } + + public static FeatureTypeBuilder createNormalIndexTextFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TPCID", String.class, false, 12)); + return typeBuilder; + } + + public static FeatureTypeBuilder createPointFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CONTEXT", String.class, false, 254)); + return typeBuilder; + } + + public static FeatureTypeBuilder createSymbolFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Float.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMBOL", String.class, false, 20)); + return typeBuilder; + } + + public static FeatureTypeBuilder createPolygonFeatureTypeBuilder(String featureName) + { + return createLineStringFeatureTypeBuilder(featureName); + /* + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + */ + } + + public static FeatureTypeBuilder createLineStringFeatureTypeBuilder(String featureName) + { + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + } + + public static FeatureTypeBuilder createEllipseFeatureTypeBuilder(String featureName) + { + return createLineStringFeatureTypeBuilder(featureName); + /* + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + */ + } + + public static FeatureTypeBuilder createArcFeatureTypeBuilder(String featureName) + { + return createLineStringFeatureTypeBuilder(featureName); + /* + FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", String.class, false, 12)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Short.class, false)); + typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Short.class, false)); + return typeBuilder; + */ + } +} -- Gitblit v0.0.0-SNAPSHOT