forked from geodmms/xdgnjobs

?? ?
2008-06-09 bd210ee7438fd203c19d3e8080ea12b79fe56159
update for EOFM-117
58 files modified
12 files added
5944 ■■■■■ changed files
.gitattributes 12 ●●●●● patch | view | raw | blame | history
xdgnjobs/pom.xml 6 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ComplexShapeElement.java 8 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7OracleReader.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileHeader.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileReader.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ElementType.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/FrammeAttributeData.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/LineElement.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/LineStringElement.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Lock.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/NIOUtilities.java 47 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/StreamLogging.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextElement.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextNodeElement.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/UserAttributeData.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/DgnUtility.java patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/PrintfFormat.java 194 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7OracleReaderTest.java 4 ●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7TextElementReaderTest.java 2 ●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7fileReaderTest.java 3 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/OracleTarget.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-jobcarrier/pom.xml 9 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/pom.xml 9 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompIdDispatchableFilter.java patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompLevelIdDispatchableFilter.java patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeIdDispatchableFilter.java patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java 18 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2MySQLJob.java 1089 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java 284 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java 58 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java 4 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java 2 ●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java 10 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractDgnToMySQLJobContext.java 47 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractOracleToMySQLJobContext.java 52 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/DummyFeatureConvertMySQlJobContext.java 304 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/FeatureDgnConvertMySQLJobContext.java 268 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/GeneralDgnConvertMySQLJobContext.java 521 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/IndexDgnConvertMySQLJobContext.java 320 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/OracleConvertMySQLJobContext.java 319 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java 38 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java 44 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/DummyFeatureConvertOraSDOJobContext.java 303 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/FeatureDgnConvertOraSDOJobContext.java 267 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/GeneralDgnConvertOraSDOJobContext.java 522 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/IndexDgnConvertOraSDOJobContext.java 320 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java 294 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java 11 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java 13 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java 35 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java 53 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java 7 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java 46 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java 19 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java 4 ●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java 3 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java 25 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java 2 ●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeomUtil.java patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java 194 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/StringUtils.java 146 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TPCLIDConverter.java patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWD97GeometryConverterDecorator.java 1 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWDDatumConverter.java 1 ●●●● patch | view | raw | blame | history
.gitattributes
@@ -66,6 +66,7 @@
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeIdDispatchableFilter.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2MySQLJob.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java svneol=native#text/plain
@@ -74,8 +75,19 @@
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/AbstractOracleJobContext.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/mysql/AbstractDgnToMySQLJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractOracleToMySQLJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/DummyFeatureConvertMySQlJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/FeatureDgnConvertMySQLJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/GeneralDgnConvertMySQLJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/IndexDgnConvertMySQLJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/OracleConvertMySQLJobContext.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/DummyFeatureConvertOraSDOJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/FeatureDgnConvertOraSDOJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/GeneralDgnConvertOraSDOJobContext.java svneol=native#text/plain
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/IndexDgnConvertOraSDOJobContext.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/pom.xml
@@ -286,6 +286,12 @@
        <version>1.3.2</version>
      </dependency>
        
      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
      </dependency>
      <!-- opensymphony -->
      <dependency>
        <groupId>opensymphony</groupId>
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ComplexShapeElement.java
@@ -10,10 +10,9 @@
import org.apache.log4j.Logger;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.CoordinateList;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
/**
 * ComplexShapeElement
@@ -162,8 +161,7 @@
                {
                  list.add(((ShapeElement) element).toGeometry(factory));
                }
            }
            else if (element instanceof LineStringElement)
            } else if (element instanceof LineStringElement)
            {
               if( ((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1)
               {
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7OracleReader.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileHeader.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileReader.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ElementType.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/FrammeAttributeData.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/LineElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/LineStringElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Lock.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/NIOUtilities.java
@@ -17,6 +17,7 @@
 */
// J2SE dependencies
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.security.AccessController;
@@ -28,12 +29,13 @@
/**
 * Utility class for managing memory mapped buffers.
 *
 * @since 2.0
 * @source $URL$
 * @version $Id$
 * @author Andres Aimes
 * @version $Id$
 * @source $URL$
 * @since 2.0
 */
public class NIOUtilities {
public class NIOUtilities
{
    /**
     * {@code true} if a warning has already been logged.
     */
@@ -45,7 +47,8 @@
     * @todo This constructor will become private when {@code NIOBufferUtils}
     *       will have been removed.
     */
    protected NIOUtilities() {
    protected NIOUtilities()
    {
    }
    /**
@@ -56,26 +59,32 @@
     *
     * @param  buffer The buffer to close.
     * @return true if the operation was successful, false otherwise.
     *
     * @see java.nio.MappedByteBuffer
     */
    public static boolean clean(final ByteBuffer buffer) {
        if (buffer == null || ! buffer.isDirect() ) {
    public static boolean clean(final ByteBuffer buffer)
    {
        if (buffer == null || !buffer.isDirect())
        {
            return false;
        }
        Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
        Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction()
        {
            public Object run()
            {
                Boolean success = Boolean.FALSE;
                try {
                try
                {
                    Method getCleanerMethod = buffer.getClass().getMethod("cleaner", (Class[])null);
                    getCleanerMethod.setAccessible(true);
                    Object cleaner = getCleanerMethod.invoke(buffer,  (Object[])null);
                    Method clean = cleaner.getClass().getMethod("clean", (Class[])null);
                    clean.invoke(cleaner, (Object[])null);
                    success = Boolean.TRUE;
                } catch (Exception e) {
                } catch (Exception e)
                {
                    // This really is a show stopper on windows
                    if (isLoggable()) {
                    if (isLoggable())
                    {
                        log(e, buffer);
                    }
                }
@@ -89,12 +98,15 @@
    /**
     * Check if a warning message should be logged.
     */
    private static synchronized boolean isLoggable() {
        try {
    private static synchronized boolean isLoggable()
    {
        try
        {
            return !warned && (
                    System.getProperty("org.geotools.io.debugBuffer", "false").equalsIgnoreCase("true") ||
                    System.getProperty("os.name").indexOf("Windows") >= 0 );
        } catch (SecurityException exception) {
        } catch (SecurityException exception)
        {
            // The utilities may be running in an Applet, in which case we
            // can't read properties. Assumes we are not in debugging mode.
            return false;
@@ -104,7 +116,8 @@
    /**
     * Log a warning message.
     */
    private static synchronized void log(final Exception e, final ByteBuffer buffer) {
    private static synchronized void log(final Exception e, final ByteBuffer buffer)
    {
        warned = true;
        String message = "Error attempting to close a mapped byte buffer : " + buffer.getClass().getName()
                       + "\n JVM : " + System.getProperty("java.version")
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/StreamLogging.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextElement.java
@@ -2,7 +2,6 @@
import java.awt.geom.AffineTransform;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextNodeElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/UserAttributeData.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/DgnUtility.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/PrintfFormat.java
@@ -90,7 +90,7 @@
 * In format strings containing the %<code>n</code>$
 * form of conversion specifications, each argument
 * in the argument list is used exactly once.</p>
 *
 * <p/>
 * <h4>Escape Sequences</h4>
 * <p>
 * The following table lists escape sequences and
@@ -206,7 +206,7 @@
 * be mixed with the %<code>n</code>$ form.  The
 * results of mixing numbered and unnumbered argument
 * specifications in a format string are undefined.</p>
 *
 * <p/>
 * <h4>Flag Characters</h4>
 * <p>
 * The flags and their meanings are:</p>
@@ -254,7 +254,7 @@
 *      0 flag will be ignored. For c conversions,
 *      the flag is ignored.
 * </dl>
 *
 * <p/>
 * <h4>Conversion Characters</h4>
 * <p>
 * Each conversion character results in fetching zero
@@ -263,7 +263,7 @@
 * Usually, an unchecked exception will be thrown.
 * If the format is exhausted while arguments remain,
 * the excess arguments are ignored.</p>
 *
 * <p/>
 * <p>
 * The conversion characters and their meanings are:
 * </p>
@@ -349,7 +349,7 @@
 *        followed by a digit.
 * <dt>c,C<dd>The integer argument is converted to a
 *        char and the result is written.
 *
 * <p/>
 * <dt>s,S<dd>The argument is taken to be a string and
 *        bytes from the string are written until the
 *        end of the string or the number of bytes
@@ -443,13 +443,19 @@
 */
public final class PrintfFormat
{
    /** Vector of control strings and format literals. */
    /**
     * Vector of control strings and format literals.
     */
    private Vector vFmt = new Vector();
    /** Character position.  Used by the constructor. */
    /**
     * Character position.  Used by the constructor.
     */
    private int cPos = 0;
    /** Character position.  Used by the constructor. */
    /**
     * Character position.  Used by the constructor.
     */
    private DecimalFormatSymbols dfs = null;
    /**
@@ -459,8 +465,9 @@
     * unpaired percent signs.  A pair of successive
     * percent signs designates a single percent sign in
     * the format.
     *
     * @param fmtArg  Control string.
     * @exception IllegalArgumentException if the control
     * @throws IllegalArgumentException if the control
     * string is null, zero length, or otherwise
     * malformed.
     */
@@ -476,8 +483,9 @@
     * unpaired percent signs.  A pair of successive
     * percent signs designates a single percent sign in
     * the format.
     *
     * @param fmtArg  Control string.
     * @exception IllegalArgumentException if the control
     * @throws IllegalArgumentException if the control
     * string is null, zero length, or otherwise
     * malformed.
     */
@@ -590,6 +598,7 @@
     * of the String <code>s</code>, the next unpaired
     * percent sign, or at the end of the String if the
     * last character is a percent sign.
     *
     * @param s  Control string.
     * @param start Position in the string
     *     <code>s</code> to begin looking for the start
@@ -616,6 +625,7 @@
     * Integer, Long, Float, Double, and Character
     * arguments are treated as wrappers for primitive
     * types.
     *
     * @param o The array of objects to format.
     * @return  The formatted String.
     */
@@ -713,6 +723,7 @@
    /**
     * Format nothing.  Just use the control string.
     *
     * @return  the formatted String.
     */
    public String sprintf()
@@ -741,9 +752,10 @@
    /**
     * Format an int.
     *
     * @param x The int to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *     conversion character is f, e, E, g, G, s,
     *     or S.
     */
@@ -776,9 +788,10 @@
    /**
     * Format an long.
     *
     * @param x The long to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *     conversion character is f, e, E, g, G, s,
     *     or S.
     */
@@ -811,9 +824,10 @@
    /**
     * Format a double.
     *
     * @param x The double to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *     conversion character is c, C, s, S,
     *     d, d, x, X, or o.
     */
@@ -846,9 +860,10 @@
    /**
     * Format a String.
     *
     * @param x The String to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *   conversion character is neither s nor S.
     */
    public String sprintf(String x) throws IllegalArgumentException
@@ -885,9 +900,10 @@
     * Strings using an internal formatting method for
     * Strings. Otherwise use the default formatter
     * (use toString).
     *
     * @param x the Object to format.
     * @return  the formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *    conversion character is inappropriate for
     *    formatting an unwrapped value.
     */
@@ -946,13 +962,13 @@
    }
    /**
     * <p>
     * <p/>
     * ConversionSpecification allows the formatting of
     * a single primitive or object embedded within a
     * string.  The formatting is controlled by a
     * format string.  Only one Java primitive or
     * object can be formatted at a time.
     * <p>
     * <p/>
     * A format string is a Java string that contains
     * a control string.  The control string starts at
     * the first percent sign (%) in the string,
@@ -964,12 +980,12 @@
     * <li>precedes a sequence of characters that parses
     *     as a valid control string.
     * </ol>
     * <p>
     * <p/>
     * A control string takes the form:
     * <pre> % ['-+ #0]* [0..9]* { . [0..9]* }+
     *                { [hlL] }+ [idfgGoxXeEcs]
     * </pre>
     * <p>
     * <p/>
     * The behavior is like printf.  One (hopefully the
     * only) exception is that the minimum number of
     * exponent digits is 3 instead of 2 for e and E
@@ -980,7 +996,9 @@
     */
    private class ConversionSpecification
    {
        /** Default precision. */
        /**
         * Default precision.
         */
        private final static int defaultDigits = 6;
        /**
@@ -1098,7 +1116,9 @@
         */
        private boolean optionalL = false;
        /** Control string type. */
        /**
         * Control string type.
         */
        private char conversionCharacter = '\0';
        /**
@@ -1107,7 +1127,9 @@
         */
        private int pos = 0;
        /** Literal or control format string. */
        /**
         * Literal or control format string.
         */
        private String fmt;
        /**
@@ -1123,9 +1145,10 @@
         * The argument must begin with a % and end
         * with the conversion character for the
         * conversion specification.
         *
         *  @param fmtArg  String specifying the
         *     conversion specification.
         *  @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     input string is null, zero length, or
         *     otherwise malformed.
         */
@@ -1184,6 +1207,7 @@
        /**
         * Set the String for this instance.
         *
         * @param s the String to store.
         */
        void setLiteral(String s)
@@ -1284,6 +1308,7 @@
         * Check whether the specifier has a variable
         * field width that is going to be set by an
         * argument.
         *
         * @return <code>true</code> if the conversion
         *   uses an * field width; otherwise
         *   <code>false</code>.
@@ -1297,6 +1322,7 @@
         * Set the field width with an argument.  A
         * negative field width is taken as a - flag
         * followed by a positive field width.
         *
         * @param fw the field width.
         */
        void setFieldWidthWithArg(int fw)
@@ -1314,6 +1340,7 @@
         * Check whether the specifier has a variable
         * precision that is going to be set by an
         * argument.
         *
         * @return <code>true</code> if the conversion
         *   uses an * precision; otherwise
         *   <code>false</code>.
@@ -1326,6 +1353,7 @@
        /**
         * Set the precision with an argument.  A
         * negative precision will be changed to zero.
         *
         * @param pr the precision.
         */
        void setPrecisionWithArg(int pr)
@@ -1337,9 +1365,10 @@
        /**
         * Format an int argument using this conversion
         *  specification.
         *
         * @param s the int to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         */
        String internalsprintf(int s) throws IllegalArgumentException
@@ -1409,9 +1438,10 @@
        /**
         * Format a long argument using this conversion
         * specification.
         *
         * @param s the long to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         */
        String internalsprintf(long s) throws IllegalArgumentException
@@ -1481,9 +1511,10 @@
        /**
         * Format a double argument using this conversion
         * specification.
         *
         * @param s the double to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is c, C, s, S, i, d,
         *     x, X, or o.
         */
@@ -1521,9 +1552,10 @@
        /**
         * Format a String argument using this conversion
         * specification.
         *
         * @param s the String to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *   conversion character is neither s nor S.
         */
        String internalsprintf(String s) throws IllegalArgumentException
@@ -1545,9 +1577,10 @@
        /**
         * Format an Object argument using this conversion
         * specification.
         *
         * @param s the Object to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is neither s nor S.
         */
        String internalsprintf(Object s)
@@ -1578,12 +1611,12 @@
         * is ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the number of digits
         * to appear after the radix character.  Padding is
         * with trailing 0s.
@@ -1974,6 +2007,7 @@
         * the input double value is an infinity,
         * not-a-number, or a finite double and formats
         * each type of input appropriately.
         *
         * @param x the double value to be formatted.
         * @return the converted double value.
         */
@@ -2038,16 +2072,16 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear after the radix character.
         * Padding is with trailing 0s.
         *
         * <p/>
         * The behavior is like printf.  One (hopefully the
         * only) exception is that the minimum number of
         * exponent digits is 3 instead of 2 for e and E
@@ -2614,6 +2648,7 @@
         * Check to see if the digits that are going to
         * be truncated because of the precision should
         * force a round in the preceding digits.
         *
         * @param ca1 the array of digits
         * @param icarry the index of the first digit that
         *     is to be truncated from the print
@@ -2659,6 +2694,7 @@
         * is not quite finished because the symbolic
         * carry may change the length of the string and
         * change the exponent (in e format).
         *
         * @param cLast index of the last digit changed
         *     by the round
         * @param cFirst index of the first digit allowed
@@ -2739,6 +2775,7 @@
         * the input double value is an infinity,
         * not-a-number, or a finite double and formats
         * each type of input appropriately.
         *
         * @param x the double value to be formatted.
         * @param eChar an 'e' or 'E' to use in the
         *     converted double value.
@@ -2795,6 +2832,7 @@
        /**
         * Apply zero or blank, left or right padding.
         *
         * @param ca4 array of characters before padding is
         *     finished
         * @param noDigits NaN or signed Inf
@@ -2879,6 +2917,7 @@
        /**
         * Format method for the f conversion character.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -2890,6 +2929,7 @@
        /**
         * Format method for the e or E conversion
         * character.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -2906,7 +2946,7 @@
        /**
         * Format method for the g conversion character.
         *
         * <p/>
         * For g format, the flag character '-', means that
         *  the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -2918,15 +2958,16 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear after the radix character.
         * Padding is with trailing 0s.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -3115,7 +3156,7 @@
        /**
         * Format method for the d conversion specifer and
         * short argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3127,14 +3168,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3146,7 +3188,7 @@
        /**
         * Format method for the d conversion character and
         * long argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3158,14 +3200,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3177,7 +3220,7 @@
        /**
         * Format method for the d conversion character and
         * int argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3189,14 +3232,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -3208,6 +3252,7 @@
        /**
         * Utility method for formatting using the d
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
@@ -3369,20 +3414,21 @@
        /**
         * Format method for the x conversion character and
         * short argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3479,20 +3525,21 @@
        /**
         * Format method for the x conversion character and
         * long argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3636,20 +3683,21 @@
        /**
         * Format method for the x conversion character and
         * int argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -3753,6 +3801,7 @@
        /**
         * Utility method for formatting using the x
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
@@ -3881,21 +3930,22 @@
        /**
         * Format method for the o conversion character and
         * short argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3948,21 +3998,22 @@
        /**
         * Format method for the o conversion character and
         * long argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -4095,21 +4146,22 @@
        /**
         * Format method for the o conversion character and
         * int argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -4192,6 +4244,7 @@
        /**
         * Utility method for formatting using the o
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
@@ -4289,17 +4342,18 @@
        /**
         * Format method for the c conversion character and
         * char argument.
         *
         * <p/>
         * The only flag character that affects c format is
         * the '-', meaning that the output should be left
         * justified within the field.  The default is to
         * pad with blanks on the left.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  Padding is with
         * blanks by default.  The default width is 1.
         *
         * <p/>
         * The precision, if set, is ignored.
         *
         * @param x the char to format.
         * @return the formatted String.
         */
@@ -4340,23 +4394,24 @@
        /**
         * Format method for the s conversion character and
         * String argument.
         *
         * <p/>
         * The only flag character that affects s format is
         * the '-', meaning that the output should be left
         * justified within the field.  The default is to
         * pad with blanks on the left.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is the
         * smaller of the number of characters in the the
         * input and the precision.  Padding is with blanks
         * by default.
         *
         * <p/>
         * The precision, if set, specifies the maximum
         * number of characters to be printed from the
         * string.  A null digit string is treated
         * as a 0.  The default is not to set a maximum
         * number of characters to be printed.
         *
         * @param x the String to format.
         * @return the formatted String.
         */
@@ -4449,6 +4504,7 @@
        /**
         * Check for a conversion character.  If it is
         * there, store it.
         *
         * @return <code>true</code> if the conversion
         *     character is there, and
         *     <code>false</code> otherwise.
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7OracleReaderTest.java
@@ -8,9 +8,11 @@
import org.testng.annotations.Test;
import com.vividsolutions.jts.geom.Coordinate;
import com.ximple.util.PrintfFormat;
import oracle.jdbc.OracleConnection;
import com.ximple.util.PrintfFormat;
/**
 * Dgn7OracleReaderTest
 * User: Ulysses
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7TextElementReaderTest.java
@@ -9,9 +9,9 @@
import java.util.List;
import org.apache.log4j.Logger;
import org.geotools.TestData;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.geotools.TestData;
/**
 * Dgn7TextElementReaderTest
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7fileReaderTest.java
@@ -2,14 +2,13 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;
import org.apache.log4j.Logger;
import org.geotools.TestData;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.geotools.TestData;
/**
 * Dgn7fileReaderTest
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/OracleTarget.java
@@ -9,6 +9,7 @@
import org.apache.log4j.Logger;
import com.vividsolutions.jts.util.Assert;
import oracle.jdbc.OracleConnection;
/**
xdgnjobs/ximple-jobcarrier/pom.xml
@@ -94,6 +94,10 @@
      <groupId>org.geotools</groupId>
      <artifactId>gt2-oracle-spatial</artifactId>
    </dependency>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt2-mysql</artifactId>
    </dependency>
    <!-- because main and sample-data depend on referencing we need a tie breaker -->
    <dependency>
@@ -149,6 +153,11 @@
      <artifactId>postgis-driver</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <!-- Ximple Library -->
    <dependency>
      <artifactId>ximple-dgnio</artifactId>
xdgnjobs/ximple-spatialjob/pom.xml
@@ -81,6 +81,10 @@
      <groupId>org.geotools</groupId>
      <artifactId>gt2-oracle-spatial</artifactId>
    </dependency>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt2-mysql</artifactId>
    </dependency>
    <!-- because main and sample-data depend on referencing we need a tie breaker -->
    <dependency>
@@ -132,6 +136,11 @@
      <artifactId>postgis-driver</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <!-- Ximple Library -->
    <dependency>
      <groupId>com.ximple.eofms</groupId>
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompIdDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompLevelIdDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeIdDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java
@@ -10,12 +10,8 @@
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.postgis.PostgisDataStoreFactory;
import org.geotools.data.jdbc.ConnectionPoolManager;
import org.geotools.data.oracle.OracleDataStore;
import org.geotools.data.oracle.OracleDataStoreFactory;
@@ -25,11 +21,17 @@
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 */
    /**
     * The Oracle driver class name
     */
    private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
    
    private static final String ORACLE_URL = "jdbc:oracle:thin:@";
@@ -74,9 +76,11 @@
    protected AbstractOracleDatabaseJob()
    {
        try {
        try
        {
            Class.forName(JDBC_DRIVER);
        } catch (Throwable t) {
        } catch (Throwable t)
        {
            // must be running off dummy jar!
            driverFound = false;
        }
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2MySQLJob.java
New file
@@ -0,0 +1,1089 @@
package com.ximple.eofms.jobs;
import java.io.File;
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.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
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.mysql.MySQLDataStore;
import org.geotools.data.mysql.MySQLDataStoreFactory;
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 com.vividsolutions.jts.geom.GeometryFactory;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleResultSet;
import oracle.sql.ARRAY;
import oracle.sql.BLOB;
import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
import com.ximple.eofms.jobs.context.mysql.OracleConvertMySQLJobContext;
import com.ximple.eofms.jobs.context.mysql.IndexDgnConvertMySQLJobContext;
import com.ximple.eofms.jobs.context.mysql.GeneralDgnConvertMySQLJobContext;
import com.ximple.eofms.jobs.context.mysql.FeatureDgnConvertMySQLJobContext;
import com.ximple.eofms.util.BinConverter;
import com.ximple.eofms.util.ByteArrayCompressor;
import com.ximple.eofms.util.StringUtils;
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 OracleConvertDgn2MySQLJob extends AbstractOracleDatabaseJob
{
    final static Log logger = LogFactory.getLog(OracleConvertDgn2PostGISJob.class);
    private static final String MYHOST = "MYHOST";
    private static final String MYDATBASE = "MYDATBASE";
    private static final String MYPORT = "MYPORT";
    private static final String MYSCHEMA = "MYSCHEMA";
    private static final String MYUSER = "MYUSER";
    private static final String MYPASS = "MYPASS";
    private static final String USEWKB = "USEWKB";
    private static final int FETCHSIZE = 30;
    private static final int BATCHSIZE = 25;
    private static final int COMMITSIZE = 20;
    class Pair
    {
        Object first;
        Object second;
        public Pair(Object first, Object second)
        {
            this.first = first;
            this.second = second;
        }
    }
    protected static MySQLDataStoreFactory dataStoreFactory = new MySQLDataStoreFactory();
    GeometryFactory _geomFactory = new GeometryFactory();
    protected String _myHost;
    protected String _myDatabase;
    protected String _myPort;
    protected String _mySchema;
    protected String _myUsername;
    protected String _myPassword;
    protected String _myUseWKB;
    protected Map<String, String> myProperties;
    protected MySQLDataStore targetDataStore;
    public Log getLogger()
    {
        return logger;
    }
    protected AbstractOracleJobContext prepareJobContext(String filterPath)
    {
        return new OracleConvertMySQLJobContext(getDataPath(), getTargetDataStore(), filterPath);
    }
    protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException
    {
        super.extractJobConfiguration(jobDetail);
        JobDataMap dataMap = jobDetail.getJobDataMap();
        _myHost = dataMap.getString(MYHOST);
        _myDatabase = dataMap.getString(MYDATBASE);
        _myPort = dataMap.getString(MYPORT);
        _mySchema = dataMap.getString(MYSCHEMA);
        _myUsername = dataMap.getString(MYUSER);
        _myPassword = dataMap.getString(MYPASS);
        _myUseWKB = dataMap.getString(USEWKB);
        Log logger = getLogger();
        /*
        logger.info("MYHOST=" + _myHost);
        logger.info("MYDATBASE=" + _myDatabase);
        logger.info("MYPORT=" + _myPort);
        logger.info("MYSCHEMA=" + _mySchema);
        logger.info("MYUSER=" + _myUsername);
        logger.info("MYPASS=" + _myPassword);
        logger.info("USEWKB=" + _myUseWKB);
        */
        if (_myHost == null)
        {
            logger.warn("MYHOST is null");
            throw new JobExecutionException("Unknown PostGIS host.");
        }
        if (_myDatabase == null)
        {
            logger.warn("PGDATABASE is null");
            throw new JobExecutionException("Unknown PostGIS database.");
        }
        if (_myPort == null)
        {
            logger.warn("MYPORT is null");
            throw new JobExecutionException("Unknown PostGIS port.");
        }
        if (_mySchema == null)
        {
            logger.warn("MYSCHEMA is null");
            throw new JobExecutionException("Unknown PostGIS schema.");
        }
        if (_myUsername == null)
        {
            logger.warn("PGUSERNAME is null");
            throw new JobExecutionException("Unknown PostGIS username.");
        }
        if (_myPassword == 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", _myHost);
        remote.put("port", _myPort);
        remote.put("database", _myDatabase);
        remote.put("user", _myUsername);
        remote.put("passwd", _myPassword);
        remote.put("namespace", null);
        myProperties = remote;
    }
    public void execute(JobExecutionContext context) throws JobExecutionException
    {
        // Every job has its own job detail
        JobDetail jobDetail = context.getJobDetail();
        // The name is defined in the job definition
        String jobName = jobDetail.getName();
        // 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:clearOutputDatabase --");
            clearOutputDatabase();
            boolean bFirst = true;
            if (checkConvertDB())
            {
                logger.info("-- step:convertOracleDB --");
                for (String orgSchema : _orgSchema)
                {
                    OracleConvertMySQLJobContext jobContext =
                            (OracleConvertMySQLJobContext) prepareJobContext(_filterPath);
                    jobContext.setSourceDataStore(getSourceDataStore());
                    // jobContext.setConvertElementIn(_convertElementIn);
                    jobContext.setElementLogging(checkElementLogging());
                    jobContext.setExecutionContext(context);
                    if (bFirst)
                        copyConnectivity(jobContext);
                    else
                        bFirst = false;
                    logger.info("----- start schema:" + orgSchema + " -----");
                    exetcuteConvert(jobContext, orgSchema, _dataPath);
                    //close all open filewriter instance
                    jobContext.closeFeatureWriter();
                }
            }
            if (checkConvertFile())
            {
                logger.info("-- step:convertIndexDesignFile --");
                convertIndexDesignFile(context);
                logger.info("-- step:convertOtherDesignFile --");
                convertOtherDesignFile(context);
            }
            if (checkConvertElementIn())
            {
                logger.info("-- step:convertFeatureDesignFile --");
                convertFeatureDesignFile(context);
            }
            if (checkCreateDummy())
            {
                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);
            throw new JobExecutionException("Database error. " + e.getMessage(), e);
        } catch (IOException ex)
        {
            logger.warn(ex.getMessage(), ex);
            throw new JobExecutionException("IO error. " + ex.getMessage(), ex);
        }
        logger.info(jobName + " end at " + new Date());
    }
    /**
     * Connectivity½Æ»s¤@­Óª©¥»¡A¦b¬d¸ß¹q¬y¤è¦V®É¥Î¨Ó¤ñ¹ïOMS¸ê®Æ®wªº¹q¾¹³s±µ©Ê(Connectivity)
     *
     * @param jobContext job context
     * @throws SQLException sql exception
     */
    private void copyConnectivity(OracleConvertMySQLJobContext jobContext) throws SQLException
    {
        OracleConnection connection = jobContext.getOracleConnection();
        Statement stmt = connection.createStatement();
        stmt.execute(AbstractOracleJobContext.TRUNCATE_CONNECTIVITY_WEBCHECK);
        stmt.execute(AbstractOracleJobContext.COPY_CONNECTIVITY_TO_WEBCHECK);
    }
    private void exetcuteConvert(OracleConvertMySQLJobContext jobContext,
                                 String querySchema, String dataPath) throws SQLException
    {
        int order = 0;
        OrderedMap map = getBlobStorageList(jobContext.getOracleConnection(), querySchema, "SD$SPACENODES"
                , null);
        logger.info("begin convert job:[" + map.size() + "]:testmode=" + _testMode);
        int total = map.size(); //spacenodes count
        int step = total / 100;
        int current = 0;
        //jobContext.startTransaction();
        jobContext.setCurrentSchema(querySchema);
        jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", 0);
        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();)
        {
            it.next();
            Pair pair = (Pair) it.getValue();
            String tableSrc = (String) pair.first;
            logger.info("begin convert:[" + order + "]-" + tableSrc);
            queryIgsetElement(jobContext, querySchema, tableSrc);
            order++;
            if (_testMode)
            {
                if ((_testCount < 0) || (order >= _testCount))
                    break;
            }
            if ((order % COMMITSIZE) == 0)
            {
                // OracleConnection connection = jobContext.getOracleConnection();
                // connection.commitTransaction();
                jobContext.commitTransaction();
                //jobContext.startTransaction();
                System.gc();
            }
            int now = order % step;
            if (now != current)
            {
                current = now;
                jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", current);
            }
        }
        jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", 100);
        jobContext.commitTransaction();
        logger.info("end convert job:[" + order + "]");
        System.gc();
    }
    protected OrderedMap getBlobStorageList(OracleConnection connection, String schemaSrc, String tableSrc,
                                            OrderedMap orderedMap) throws SQLException
    {
        if (orderedMap == null)
            orderedMap = new LinkedMap(99);
        String fetchStmtFmt = "SELECT SNID, SPACETABLE FROM \"%s\".\"%s\"";
        PrintfFormat spf = new PrintfFormat(fetchStmtFmt);
        String fetchStmt = spf.sprintf(new Object[]{schemaSrc, tableSrc});
        Statement stmt = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet rs = null;
        stmt.setFetchSize(FETCHSIZE);
        try
        {
            rs = stmt.executeQuery(fetchStmt);
            while (rs.next())
            {
                int size = rs.getMetaData().getColumnCount();
                Object[] values = new Object[size];
                for (int i = 0; i < size; i++)
                {
                    values[i] = rs.getObject(i + 1);
                }
                Integer key = ((BigDecimal) values[0]).intValue();
                String name = (String) values[1];
                Pair pair = (Pair) orderedMap.get(key);
                if (pair == null)
                    orderedMap.put(key, new Pair(name, null));
                else
                    pair.first = name;
            }
        } catch (SQLException e)
        {
            logger.error(e.toString(), e);
            logger.error("stmt=" + fetchStmt);
            throw e;
        } finally
        {
            if (rs != null) rs.close();
            stmt.close();
        }
        return orderedMap;
    }
    protected OrderedMap getRawFormatStorageList(OracleConnection connection, String schemaSrc, String tableSrc,
                                                 OrderedMap orderedMap) throws SQLException
    {
        if (orderedMap == null)
            orderedMap = new LinkedMap(99);
        String fetchStmtFmt = "SELECT RNID, SPACETABLE FROM \"%s\".\"%s\"";
        PrintfFormat spf = new PrintfFormat(fetchStmtFmt);
        String fetchStmt = spf.sprintf(new Object[]{schemaSrc, tableSrc});
        Statement stmt = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(FETCHSIZE);
        ResultSet rs = stmt.executeQuery(fetchStmt);
        while (rs.next())
        {
            int size = rs.getMetaData().getColumnCount();
            Object[] values = new Object[size];
            for (int i = 0; i < size; i++)
            {
                values[i] = rs.getObject(i + 1);
            }
            Integer key = ((BigDecimal) values[0]).intValue();
            String name = (String) values[1];
            Pair pair = (Pair) orderedMap.get(key);
            if (pair == null)
                orderedMap.put(key, new Pair(null, name));
            else
                pair.second = name;
        }
        rs.close();
        stmt.close();
        return orderedMap;
    }
    protected void queryIgsetElement(OracleConvertMySQLJobContext jobContext,
                                     String srcschema, String srctable) throws SQLException
    {
        OracleConnection connection = jobContext.getOracleConnection();
        String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" ORDER BY ROWID";
        PrintfFormat spf = new PrintfFormat(fetchSrcStmtFmt);
        String fetchSrcStmt = spf.sprintf(new Object[]{srcschema, srctable});
        Statement stmtSrc = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        stmtSrc.setFetchSize(FETCHSIZE);
        ResultSet rsSrc = stmtSrc.executeQuery(fetchSrcStmt);
        while (rsSrc.next())
        {
            byte[] raw = null;
            if (rsSrc.getMetaData().getColumnType(1) == Types.BLOB)
            {
                BLOB blob = (BLOB) rsSrc.getBlob(1);
                raw = getBytesFromBLOB(blob);
                blob.close();
            } else
            {
                raw = rsSrc.getBytes(1);
            }
            try
            {
                Element element = fetchBinaryElement(raw);
                jobContext.putFeatureCollection(element);
            } catch (Dgn7fileException e)
            {
                logger.warn("Dgn7Exception", e);
            }
        }
        rsSrc.close();
        stmtSrc.close();
    }
    protected void queryRawElement(OracleConvertMySQLJobContext jobContext,
                                   String srcschema, String srctable) throws SQLException
    {
        OracleConnection connection = jobContext.getOracleConnection();
        String fetchDestStmtFmt = "SELECT ELEMENT FROM \"%s\".\"%s\" ORDER BY ROWID";
        PrintfFormat spf = new PrintfFormat(fetchDestStmtFmt);
        String fetchDestStmt = spf.sprintf(new Object[]{srcschema, srctable});
        Statement stmtDest = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        stmtDest.setFetchSize(FETCHSIZE);
        ResultSet rsDest = stmtDest.executeQuery(fetchDestStmt);
        while (rsDest.next())
        {
            ARRAY rawsValue = ((OracleResultSet) rsDest).getARRAY(1);
            long[] rawData = rawsValue.getLongArray();
            byte[] comparessedValue;
            /*
            if (dataMode == TransferTask.DataMode.Normal)
            {
                comparessedValue = BinConverter.unmarshalByteArray(rawData, true);
            } else
            {
                comparessedValue = BinConverter.unmarshalCompactByteArray(rawData);
            }
            */
            comparessedValue = BinConverter.unmarshalByteArray(rawData, true);
            byte[] rawDest = ByteArrayCompressor.decompressByteArray(comparessedValue);
            try
            {
                Element element = fetchBinaryElement(rawDest);
                jobContext.putFeatureCollection(element);
            } catch (Dgn7fileException e)
            {
                logger.warn("Dgn7Exception:" + e.getMessage(), e);
            }
        }
        rsDest.close();
        stmtDest.close();
    }
    // Binary to Element
    private Element fetchBinaryElement(byte[] raws) throws Dgn7fileException
    {
        ByteBuffer buffer = ByteBuffer.wrap(raws);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        short signature = buffer.getShort();
        // byte type = (byte) (buffer.get() & 0x7f);
        byte type = (byte) ((signature >>> 8) & 0x007f);
        // silly Bentley say contentLength is in 2-byte words
        // and ByteByffer uses raws.
        // track the record location
        int elementLength = (buffer.getShort() * 2) + 4;
        ElementType recordType = ElementType.forID(type);
        IElementHandler handler;
        handler = recordType.getElementHandler();
        Element dgnElement = (Element) handler.read(buffer, signature, elementLength);
        if (recordType.isComplexElement() && (elementLength < raws.length))
        {
            int offset = elementLength;
            while (offset < (raws.length - 4))
            {
                buffer.position(offset);
                signature = buffer.getShort();
                type = (byte) ((signature >>> 8) & 0x007f);
                elementLength = (buffer.getShort() * 2) + 4;
                if (raws.length < (offset + elementLength))
                {
                    System.out.println("Length not match:" + offset + ":" + buffer.position() + ":" + buffer.limit());
                    break;
                }
                recordType = ElementType.forID(type);
                handler = recordType.getElementHandler();
                if (handler != null)
                {
                    Element subElement = (Element) handler.read(buffer, signature, elementLength);
                    ((ComplexElement) dgnElement).add(subElement);
                    offset += elementLength;
                } else
                {
                    byte[] remain = new byte[buffer.remaining()];
                    System.arraycopy(raws, offset, remain, 0, buffer.remaining());
                    for (int i = 0; i < remain.length; i++)
                    {
                        if (remain[i] != 0)
                        {
                            logger.info("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]);
                            System.out.println("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]);
                        }
                    }
                    break;
                }
            }
        }
        return dgnElement;
    }
    /**
     * °õ¦æÂà´«¯Á¤Þ¹ÏÀɪº¤u§@
     *
     * @param context ¤u§@°õ¦æÀô¹Ò
     * @throws org.quartz.JobExecutionException
     *          exception
     */
    private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException
    {
        File indexDir = new File(getDataPath(), "index");
        if (!indexDir.exists())
        {
            logger.info("index dir=" + indexDir + " not exist.");
            return;
        }
        if (!indexDir.isDirectory())
        {
            logger.info("index dir=" + indexDir + " is not a directory.");
        }
        File[] dgnFiles = indexDir.listFiles(new FilenameFilter()
        {
            public boolean accept(File dir, String name)
            {
                return name.toLowerCase().endsWith(".dgn");
            }
        });
        for (File dgnFile : dgnFiles)
        {
            IndexDgnConvertMySQLJobContext convertContext =
                    new IndexDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore());
            logger.debug("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
                convertContext.setExecutionContext(context);
                String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator);
                convertContext.setFilename(dgnPaths[dgnPaths.length - 1]);
                FileInputStream fs = new FileInputStream(dgnFile);
                FileChannel fc = fs.getChannel();
                Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
                convertContext.setReader(reader);
                scanIndexDgnElement(convertContext);
                convertContext.commitTransaction();
                convertContext.closeFeatureWriter();
                System.gc();
            } catch (FileNotFoundException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (Dgn7fileException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (IOException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (IllegalAttributeException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (SchemaException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            }
        }
    }
    protected void scanIndexDgnElement(IndexDgnConvertMySQLJobContext convertContext)
            throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException
    {
        Dgn7fileReader reader = convertContext.getReader();
        int count = 0;
        Element lastComplex = null;
        while (reader.hasNext())
        {
            Dgn7fileReader.Record record = reader.nextElement();
            if (record.element() != null)
            {
                Element element = (Element) record.element();
                ElementType type = element.getElementType();
                if ((!type.isComplexElement()) && (!element.isComponentElement()))
                {
                    lastComplex = null;
                    processIndexElement(element, convertContext);
                } else if (element.isComponentElement())
                {
                    if (lastComplex != null)
                    {
                        ((ComplexElement) lastComplex).add(element);
                    }
                } else if (type.isComplexElement())
                {
                    if (lastComplex == null)
                    {
                        lastComplex = element;
                    } else
                    {
                        processIndexElement(element, convertContext);
                        lastComplex = element;
                    }
                }
            }
            count++;
        }
        logger.debug("ElementRecord Count=" + count);
    }
    private void processIndexElement(Element element, IndexDgnConvertMySQLJobContext convertContext)
            throws IllegalAttributeException, SchemaException
    {
        if (element instanceof TextElement)
        {
            convertContext.putFeatureCollection(element);
        }
    }
    /**
     * °õ¦æÂà´«¨ä¥L³]­p¹ÏÀɪº¤u§@
     *
     * @param context jobContext
     * @throws org.quartz.JobExecutionException
     *          exception
     */
    private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException
    {
        File otherDir = new File(getDataPath(), "other");
        if (!otherDir.exists())
        {
            logger.info("other dir=" + otherDir + " not exist.");
            return;
        }
        if (!otherDir.isDirectory())
        {
            logger.info("other dir=" + otherDir + " is not a directory.");
        }
        File[] dgnFiles = otherDir.listFiles(new FilenameFilter()
        {
            public boolean accept(File dir, String name)
            {
                return name.toLowerCase().endsWith(".dgn");
            }
        });
        for (File dgnFile : dgnFiles)
        {
            GeneralDgnConvertMySQLJobContext convertContext =
                    new GeneralDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore());
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
                convertContext.setExecutionContext(context);
                String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator);
                convertContext.setFilename(dgnPaths[dgnPaths.length - 1]);
                FileInputStream fs = new FileInputStream(dgnFile);
                FileChannel fc = fs.getChannel();
                Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
                convertContext.setReader(reader);
                scanOtherDgnElement(convertContext);
                convertContext.commitTransaction();
                convertContext.closeFeatureWriter();
                System.gc();
            } catch (FileNotFoundException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (Dgn7fileException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (IOException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (IllegalAttributeException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (SchemaException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            }
        }
    }
    public void scanOtherDgnElement(GeneralDgnConvertMySQLJobContext convertContext)
            throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException
    {
        Dgn7fileReader reader = convertContext.getReader();
        int count = 0;
        Element lastComplex = null;
        while (reader.hasNext())
        {
            Dgn7fileReader.Record record = reader.nextElement();
            if (record.element() != null)
            {
                Element element = (Element) record.element();
                ElementType type = element.getElementType();
                if ((!type.isComplexElement()) && (!element.isComponentElement()))
                {
                    lastComplex = null;
                    processOtherElement(element, convertContext);
                } else if (element.isComponentElement())
                {
                    if (lastComplex != null)
                    {
                        ((ComplexElement) lastComplex).add(element);
                    }
                } else if (type.isComplexElement())
                {
                    if (lastComplex == null)
                    {
                        lastComplex = element;
                    } else
                    {
                        processOtherElement(element, convertContext);
                        lastComplex = element;
                    }
                }
            }
            count++;
        }
        logger.debug("ElementRecord Count=" + count);
    }
    private void processOtherElement(Element element, GeneralDgnConvertMySQLJobContext convertContext)
            throws IllegalAttributeException, SchemaException
    {
        convertContext.putFeatureCollection(element);
    }
    private void clearOutputDatabase()
    {
        /*
        File outDataPath = new File(getDataPath(), OracleConvertPostGISJobContext.SHPOUTPATH);
        if (outDataPath.exists() && outDataPath.isDirectory())
        {
            deleteFilesInPath(outDataPath);
        }
        outDataPath = new File(getDataPath(), IndexDgnConvertShpJobContext.SHPOUTPATH);
        if (outDataPath.exists() && outDataPath.isDirectory())
        {
            deleteFilesInPath(outDataPath);
        }
        outDataPath = new File(getDataPath(), GeneralDgnConvertShpJobContext.SHPOUTPATH);
        if (outDataPath.exists() && outDataPath.isDirectory())
        {
            deleteFilesInPath(outDataPath);
        }
        */
    }
    private void deleteFilesInPath(File outDataPath)
    {
        deleteFilesInPath(outDataPath, true);
    }
    private void deleteFilesInPath(File outDataPath, boolean removeSubDir)
    {
        if (!outDataPath.isDirectory())
        {
            return;
        }
        File[] files = outDataPath.listFiles();
        for (File file : files)
        {
            if (file.isFile())
            {
                if (!file.delete())
                {
                    logger.info("Cannot delete file-" + file.toString());
                }
            } else if (file.isDirectory())
            {
                deleteFilesInPath(file, removeSubDir);
                if (removeSubDir)
                {
                    if (file.delete())
                    {
                        logger.info("Cannot delete dir-" + file.toString());
                    }
                }
            }
        }
    }
    private void convertFeatureDesignFile(JobExecutionContext context) throws JobExecutionException
    {
        File elminDir = new File(getDataPath(), "elmin");
        if (!elminDir.exists())
        {
            logger.info("elmin dir=" + elminDir + " not exist.");
            return;
        }
        if (!elminDir.isDirectory())
        {
            logger.info("elmin dir=" + elminDir + " is not a directory.");
        }
        File[] dgnFiles = elminDir.listFiles(new FilenameFilter()
        {
            public boolean accept(File dir, String name)
            {
                return name.toLowerCase().endsWith(".dgn");
            }
        });
        for (File dgnFile : dgnFiles)
        {
            FeatureDgnConvertMySQLJobContext convertContext =
                    new FeatureDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore(), _filterPath);
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
                convertContext.setExecutionContext(context);
                String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator);
                convertContext.setFilename(dgnPaths[dgnPaths.length - 1]);
                FileInputStream fs = new FileInputStream(dgnFile);
                FileChannel fc = fs.getChannel();
                Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
                convertContext.setReader(reader);
                scanFeatureDgnElement(convertContext);
                convertContext.commitTransaction();
                convertContext.closeFeatureWriter();
                System.gc();
            } catch (FileNotFoundException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (Dgn7fileException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (IOException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (IllegalAttributeException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            } catch (SchemaException e)
            {
                convertContext.rollbackTransaction();
                logger.warn(e.getMessage(), e);
                throw new JobExecutionException(e.getMessage(), e);
            }
        }
    }
    public void scanFeatureDgnElement(FeatureDgnConvertMySQLJobContext convertContext)
            throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException
    {
        Dgn7fileReader reader = convertContext.getReader();
        int count = 0;
        Element lastComplex = null;
        while (reader.hasNext())
        {
            Dgn7fileReader.Record record = reader.nextElement();
            if (record.element() != null)
            {
                Element element = (Element) record.element();
                ElementType type = element.getElementType();
                if ((!type.isComplexElement()) && (!element.isComponentElement()))
                {
                    lastComplex = null;
                    processFeatureElement(element, convertContext);
                } else if (element.isComponentElement())
                {
                    if (lastComplex != null)
                    {
                        ((ComplexElement) lastComplex).add(element);
                    }
                } else if (type.isComplexElement())
                {
                    if (lastComplex == null)
                    {
                        lastComplex = element;
                    } else
                    {
                        processFeatureElement(element, convertContext);
                        lastComplex = element;
                    }
                }
            }
            count++;
        }
        logger.debug("ElementRecord Count=" + count);
    }
    private void processFeatureElement(Element element, FeatureDgnConvertMySQLJobContext convertContext)
            throws IllegalAttributeException, SchemaException
    {
        convertContext.putFeatureCollection(element);
    }
    private void createDummyFeatureFile(JobExecutionContext context) throws JobExecutionException
    {
        /*
        DummyFeatureConvertShpJobContext convertContext = new DummyFeatureConvertShpJobContext(getDataPath(), _filterPath);
        try {
            convertContext.startTransaction();
            convertContext.commitTransaction();
            convertContext.closeFeatureWriter();
        } catch (IOException e)
        {
            logger.warn(e.getMessage(), e);
            throw new JobExecutionException(e.getMessage(), e);
        }
        */
    }
    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 (!myProperties.containsKey("max connections" /*MySQLDataStoreFactory.MAXCONN.key */))
        {
            myProperties.put("max connections", "2");
        }
        if (!myProperties.containsKey("min connections" /* MySQLDataStoreFactory.MINCONN.key */))
        {
            myProperties.put("min connections", "1");
        }
        if (!myProperties.containsKey(MySQLDataStoreFactory.WKBENABLED.key))
        {
            myProperties.put(MySQLDataStoreFactory.WKBENABLED.key, "true");
        }
        if (!dataStoreFactory.canProcess(myProperties))
        {
            getLogger().warn("cannot process properties-");
            throw new JobExecutionException("cannot process properties-");
        }
        try
        {
            targetDataStore = (MySQLDataStore) dataStoreFactory.createDataStore(myProperties);
        } catch (IOException e)
        {
            getLogger().warn(e.getMessage(), e);
            throw new JobExecutionException(e.getMessage(), e);
        }
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java
@@ -13,15 +13,22 @@
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 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.oracle.OracleDataStoreFactory;
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;
@@ -34,10 +41,10 @@
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.jobs.context.orasdo.FeatureDgnConvertOraSDOJobContext;
import com.ximple.eofms.jobs.context.orasdo.GeneralDgnConvertOraSDOJobContext;
import com.ximple.eofms.jobs.context.orasdo.IndexDgnConvertOraSDOJobContext;
import com.ximple.eofms.jobs.context.orasdo.OracleConvertOraSDOJobContext;
import com.ximple.eofms.util.BinConverter;
import com.ximple.eofms.util.ByteArrayCompressor;
import com.ximple.eofms.util.StringUtils;
@@ -55,10 +62,13 @@
{
    final static Log logger = LogFactory.getLog(OracleConvertDgn2OraSDOJob.class);
    /**
     * The Oracle driver class name
     */
    private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
    private static final String SDOHOST = "SDOHOST";
    private static final String SDODDATBASE = "SDODDATBASE";
    private static final String SDOPORT = "SDOPORT";
    private static final String SDOSCHEMA = "SDOSCHEMA";
    private static final String SDOUSER = "SDOUSER";
    private static final String SDOPASS = "SDOPASS";
    private static final String USEWKB = "USEWKB";
    private static final int FETCHSIZE = 30;
    private static final int BATCHSIZE = 25;
@@ -76,72 +86,94 @@
        }
    }
    protected static OracleDataStoreFactory dataStoreFactory = new OracleDataStoreFactory();
    GeometryFactory _geomFactory = new GeometryFactory();
    protected String _sdoHost;
    protected String _sdoDatabase;
    protected String _sdoPort;
    protected String _sdoSchema;
    protected String _sdoUsername;
    protected String _sdoPassword;
    protected String _sdoUseWKB;
    protected Map<String, String> sdoProperties;
    protected OracleDataStore targetDataStore;
    public Log getLogger()
    {
        return logger;
    }
    // OracleDataStoreFactory factory = new OracleDataStoreFactory();
    /*
        Map map = new HashMap();
        map.put("host", fixture.getProperty("host"));
        map.put("port", fixture.getProperty("port"));
        map.put("instance", fixture.getProperty("instance"));
        map.put("user", fixture.getProperty("user"));
        map.put("passwd", fixture.getProperty("passwd"));
        map.put("dbtype", "oracle");
        map.put("alias", fixture.getProperty("instance"));
        map.put("namespace", null);
        assertTrue(factory.canProcess(map));
        OracleDataStore store = (OracleDataStore) factory.createDataStore(map);
        assertNull(store.getNameSpace());
        map.put("schema", fixture.getProperty("user").toUpperCase());
        store = (OracleDataStore) factory.createDataStore(map);
        assertNull(store.getNameSpace());
        map.put("namespace", "topp");
        store = (OracleDataStore) factory.createDataStore(map);
        assertEquals(new URI("topp"), store.getNameSpace());
     */
    /*
        FeatureWriter writer = dstore.getFeatureWriter("ORA_TEST_POINTS", Filter.INCLUDE,
                Transaction.AUTO_COMMIT);
        assertNotNull(writer);
        Feature feature = writer.next();
        System.out.println(feature);
        feature.setAttribute(0, "Changed Feature");
        System.out.println(feature);
        writer.write();
        writer.close();
     */
    /*
        Map fidGen = new HashMap();
        fidGen.put("ORA_TEST_POINTS", JDBCDataStoreConfig.FID_GEN_MANUAL_INC);
        JDBCDataStoreConfig config = JDBCDataStoreConfig.createWithSchemaNameAndFIDGenMap(schemaName,
                fidGen);
        String name = "add_name";
        BigDecimal intval = new BigDecimal(70);
        Point point = jtsFactory.createPoint(new Coordinate(-15.0, -25));
        Feature feature = dstore.getSchema("ORA_TEST_POINTS")
                                .create(new Object[] { name, intval, point });
        FeatureStore fs = (FeatureStore) dstore.getFeatureSource("ORA_TEST_POINTS");
        fs.addFeatures(DataUtilities.collection(feature));
     */
    protected AbstractOracleJobContext prepareJobContext(String filterPath)
    {
        return new OracleConvertShapefilesJobContext(filterPath);
        return new OracleConvertOraSDOJobContext(getDataPath(), getTargetDataStore(), filterPath);
    }
    protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException
    {
        super.extractJobConfiguration(jobDetail);
        JobDataMap dataMap = jobDetail.getJobDataMap();
        _sdoHost = dataMap.getString(SDOHOST);
        _sdoDatabase = dataMap.getString(SDODDATBASE);
        _sdoPort = dataMap.getString(SDOPORT);
        _sdoSchema = dataMap.getString(SDOSCHEMA);
        _sdoUsername = dataMap.getString(SDOUSER);
        _sdoPassword = dataMap.getString(SDOPASS);
        _sdoUseWKB = dataMap.getString(USEWKB);
        Log logger = getLogger();
        /*
        logger.info("SDOHOST=" + _myHost);
        logger.info("SDODDATBASE=" + _myDatabase);
        logger.info("SDOPORT=" + _myPort);
        logger.info("SDOSCHEMA=" + _mySchema);
        logger.info("SDOUSER=" + _myUsername);
        logger.info("SDOPASS=" + _myPassword);
        logger.info("USEWKB=" + _myUseWKB);
        */
        if (_sdoHost == null)
        {
            logger.warn("SDOHOST is null");
            throw new JobExecutionException("Unknown OraSDO host.");
        }
        if (_sdoDatabase == null)
        {
            logger.warn("PGDATABASE is null");
            throw new JobExecutionException("Unknown OraSDO database.");
        }
        if (_sdoPort == null)
        {
            logger.warn("SDOPORT is null");
            throw new JobExecutionException("Unknown OraSDO port.");
        }
        if (_sdoSchema == null)
        {
            logger.warn("SDOSCHEMA is null");
            throw new JobExecutionException("Unknown OraSDO schema.");
        }
        if (_sdoUsername == null)
        {
            logger.warn("PGUSERNAME is null");
            throw new JobExecutionException("Unknown OraSDO username.");
        }
        if (_sdoPassword == null)
        {
            logger.warn("PGPASSWORD is null");
            throw new JobExecutionException("Unknown OraSDO password.");
        }
        Map<String, String> remote = new TreeMap<String, String>();
        remote.put("dbtype", "OraSDO");
        remote.put("charset", "UTF-8");
        remote.put("host", _sdoHost);
        remote.put("port", _sdoPort);
        remote.put("database", _sdoDatabase);
        remote.put("user", _sdoUsername);
        remote.put("passwd", _sdoPassword);
        remote.put("namespace", null);
        sdoProperties = remote;
    }
    public void execute(JobExecutionContext context) throws JobExecutionException
@@ -156,15 +188,25 @@
        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())
            {
@@ -172,9 +214,10 @@
                for (String orgSchema : _orgSchema)
                {
                    OracleConvertShapefilesJobContext jobContext = (OracleConvertShapefilesJobContext) prepareJobContext(_filterPath);
                    OracleConvertOraSDOJobContext jobContext =
                            (OracleConvertOraSDOJobContext) prepareJobContext(_filterPath);
                    jobContext.setSourceDataStore(getSourceDataStore());
                    jobContext.setConvertElementIn(_convertElementIn);
                    // jobContext.setConvertElementIn(_convertElementIn);
                    jobContext.setElementLogging(checkElementLogging());
                    jobContext.setExecutionContext(context);
@@ -212,6 +255,11 @@
            }
            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);
@@ -230,15 +278,15 @@
     * @param jobContext job context
     * @throws SQLException sql exception
     */
    private void copyConnectivity(OracleConvertShapefilesJobContext jobContext) throws SQLException
    private void copyConnectivity(OracleConvertOraSDOJobContext 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(OracleConvertOraSDOJobContext jobContext,
                                 String querySchema, String dataPath) throws SQLException
    {
        int order = 0;
@@ -253,7 +301,7 @@
        //jobContext.startTransaction();
        jobContext.setCurrentSchema(querySchema);
        jobContext.getExecutionContext().put("ConvertDgn2ShpJobProgress", 0);
        jobContext.getExecutionContext().put("ConvertDgn2OraSDOJobProgress", 0);
        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();)
        {
            it.next();
@@ -285,11 +333,11 @@
            if (now != current)
            {
                current = now;
                jobContext.getExecutionContext().put("ConvertDgn2ShpJobProgress", current);
                jobContext.getExecutionContext().put("ConvertDgn2OraSDOJobProgress", current);
            }
        }
        jobContext.getExecutionContext().put("ConvertDgn2ShpJobProgress", 100);
        jobContext.getExecutionContext().put("ConvertDgn2OraSDOJobProgress", 100);
        jobContext.commitTransaction();
@@ -387,7 +435,7 @@
        return orderedMap;
    }
    protected void queryIgsetElement(OracleConvertShapefilesJobContext jobContext,
    protected void queryIgsetElement(OracleConvertOraSDOJobContext jobContext,
                                     String srcschema, String srctable) throws SQLException
    {
        OracleConnection connection = jobContext.getOracleConnection();
@@ -429,7 +477,7 @@
        stmtSrc.close();
    }
    protected void queryRawElement(OracleConvertShapefilesJobContext jobContext,
    protected void queryRawElement(OracleConvertOraSDOJobContext jobContext,
                                   String srcschema, String srctable) throws SQLException
    {
        OracleConnection connection = jobContext.getOracleConnection();
@@ -568,7 +616,8 @@
        for (File dgnFile : dgnFiles)
        {
            IndexDgnConvertShpJobContext convertContext = new IndexDgnConvertShpJobContext(getDataPath());
            IndexDgnConvertOraSDOJobContext convertContext =
                    new IndexDgnConvertOraSDOJobContext(getDataPath(), getTargetDataStore());
            logger.debug("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
@@ -615,7 +664,7 @@
        }
    }
    protected void scanIndexDgnElement(IndexDgnConvertShpJobContext convertContext)
    protected void scanIndexDgnElement(IndexDgnConvertOraSDOJobContext convertContext)
            throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException
    {
        Dgn7fileReader reader = convertContext.getReader();
@@ -658,7 +707,8 @@
        logger.debug("ElementRecord Count=" + count);
    }
    private void processIndexElement(Element element, IndexDgnConvertShpJobContext convertContext) throws IllegalAttributeException, SchemaException
    private void processIndexElement(Element element, IndexDgnConvertOraSDOJobContext convertContext)
            throws IllegalAttributeException, SchemaException
    {
        if (element instanceof TextElement)
        {
@@ -698,7 +748,8 @@
        for (File dgnFile : dgnFiles)
        {
            GeneralDgnConvertShpJobContext convertContext = new GeneralDgnConvertShpJobContext(getDataPath());
            GeneralDgnConvertOraSDOJobContext convertContext =
                    new GeneralDgnConvertOraSDOJobContext(getDataPath(), getTargetDataStore());
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
@@ -745,7 +796,7 @@
        }
    }
    public void scanOtherDgnElement(GeneralDgnConvertShpJobContext convertContext)
    public void scanOtherDgnElement(GeneralDgnConvertOraSDOJobContext convertContext)
            throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException
    {
        Dgn7fileReader reader = convertContext.getReader();
@@ -788,15 +839,16 @@
        logger.debug("ElementRecord Count=" + count);
    }
    private void processOtherElement(Element element, GeneralDgnConvertShpJobContext convertContext)
    private void processOtherElement(Element element, GeneralDgnConvertOraSDOJobContext 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(), OracleConvertOraSDOJobContext.SHPOUTPATH);
        if (outDataPath.exists() && outDataPath.isDirectory())
        {
            deleteFilesInPath(outDataPath);
@@ -811,6 +863,7 @@
        {
            deleteFilesInPath(outDataPath);
        }
        */
    }
    private void deleteFilesInPath(File outDataPath)
@@ -871,7 +924,8 @@
        for (File dgnFile : dgnFiles)
        {
            FeatureDgnConvertShpJobContext convertContext = new FeatureDgnConvertShpJobContext(getDataPath(), _filterPath);
            FeatureDgnConvertOraSDOJobContext convertContext =
                    new FeatureDgnConvertOraSDOJobContext(getDataPath(), getTargetDataStore(), _filterPath);
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
@@ -918,7 +972,7 @@
        }
    }
    public void scanFeatureDgnElement(FeatureDgnConvertShpJobContext convertContext)
    public void scanFeatureDgnElement(FeatureDgnConvertOraSDOJobContext convertContext)
            throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException
    {
        Dgn7fileReader reader = convertContext.getReader();
@@ -961,7 +1015,7 @@
        logger.debug("ElementRecord Count=" + count);
    }
    private void processFeatureElement(Element element, FeatureDgnConvertShpJobContext convertContext)
    private void processFeatureElement(Element element, FeatureDgnConvertOraSDOJobContext convertContext)
            throws IllegalAttributeException, SchemaException
    {
        convertContext.putFeatureCollection(element);
@@ -982,4 +1036,56 @@
        }
        */
    }
    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 (!sdoProperties.containsKey(OracleDataStoreFactory.MAXCONN.key))
        {
            sdoProperties.put(OracleDataStoreFactory.MAXCONN.key, "2");
        }
        if (!sdoProperties.containsKey(OracleDataStoreFactory.MINCONN.key))
        {
            sdoProperties.put(OracleDataStoreFactory.MINCONN.key, "1");
        }
        /*
        if (!sdoProperties.containsKey(OracleDataStoreFactory.WKBENABLED.key))
        {
            sdoProperties.put(OracleDataStoreFactory.WKBENABLED.key, "true");
        }
        */
        if (!dataStoreFactory.canProcess(sdoProperties))
        {
            getLogger().warn("cannot process properties-");
            throw new JobExecutionException("cannot process properties-");
        }
        try
        {
            targetDataStore = (OracleDataStore) dataStoreFactory.createDataStore(sdoProperties);
        } catch (IOException e)
        {
            getLogger().warn(e.getMessage(), e);
            throw new JobExecutionException(e.getMessage(), e);
        }
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
@@ -18,7 +18,28 @@
import java.util.Map;
import java.util.TreeMap;
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.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 com.vividsolutions.jts.geom.GeometryFactory;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleResultSet;
import oracle.sql.ARRAY;
import oracle.sql.BLOB;
import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
import com.ximple.eofms.jobs.context.postgis.FeatureDgnConvertPostGISJobContext;
import com.ximple.eofms.jobs.context.postgis.GeneralDgnConvertPostGISJobContext;
@@ -36,27 +57,6 @@
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
{
@@ -154,13 +154,13 @@
        Log logger = getLogger();
        /*
        logger.info("PGHOST=" + _pgHost);
        logger.info("PGDDATBASE=" + _pgDatabase);
        logger.info("PGPORT=" + _pgPort);
        logger.info("PGSCHEMA=" + _pgSchema);
        logger.info("PGUSER=" + _pgUsername);
        logger.info("PGPASS=" + _pgPassword);
        logger.info("USEWKB=" + _pgUseWKB);
        logger.info("PGHOST=" + _myHost);
        logger.info("PGDDATBASE=" + _myDatabase);
        logger.info("PGPORT=" + _myPort);
        logger.info("PGSCHEMA=" + _mySchema);
        logger.info("PGUSER=" + _myUsername);
        logger.info("PGPASS=" + _myPassword);
        logger.info("USEWKB=" + _myUseWKB);
        */
        if (_pgHost == null)
@@ -247,7 +247,7 @@
                    OracleConvertPostGISJobContext jobContext =
                            (OracleConvertPostGISJobContext) prepareJobContext(_filterPath);
                    jobContext.setSourceDataStore(getSourceDataStore());
                    jobContext.setConvertElementIn(_convertElementIn);
                    // jobContext.setConvertElementIn(_convertElementIn);
                    jobContext.setElementLogging(checkElementLogging());
                    jobContext.setExecutionContext(context);
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
@@ -22,10 +22,6 @@
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;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java
@@ -2,8 +2,8 @@
import java.util.Map;
import org.quartz.JobExecutionContext;
import org.apache.commons.logging.Log;
import org.quartz.JobExecutionContext;
import com.ximple.io.dgn7.Dgn7fileReader;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java
@@ -1,18 +1,14 @@
package com.ximple.eofms.jobs.context;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.io.IOException;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.geotools.data.oracle.OracleDataStore;
import org.geotools.data.Transaction;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.oracle.OracleDataStore;
import oracle.jdbc.OracleConnection;
import com.ximple.eofms.jobs.context.shapefile.OracleConvertShapefilesJobContext;
public abstract class AbstractOracleJobContext
{
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractDgnToMySQLJobContext.java
New file
@@ -0,0 +1,47 @@
package com.ximple.eofms.jobs.context.mysql;
import java.io.IOException;
import java.sql.Connection;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.mysql.MySQLDataStore;
import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext;
public abstract class AbstractDgnToMySQLJobContext extends AbstractDgnFileJobContext
{
    protected MySQLDataStore targetDataStore;
    public AbstractDgnToMySQLJobContext(String dataPath, DataStore targetDataStore)
    {
        super(dataPath);
        this.targetDataStore = (MySQLDataStore) targetDataStore;
    }
    public MySQLDataStore getTargetDataStore()
    {
        return targetDataStore;
    }
    public void setTargetDataStore(MySQLDataStore 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;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractOracleToMySQLJobContext.java
New file
@@ -0,0 +1,52 @@
package com.ximple.eofms.jobs.context.mysql;
import java.io.IOException;
import java.sql.Connection;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.mysql.MySQLDataStore;
import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
public abstract class AbstractOracleToMySQLJobContext extends AbstractOracleJobContext
{
    protected MySQLDataStore targetDataStore;
    public AbstractOracleToMySQLJobContext(String dataPath, DataStore targetDataStore)
    {
        if ((targetDataStore != null) && (targetDataStore instanceof MySQLDataStore))
        {
            this.targetDataStore = (MySQLDataStore) targetDataStore;
        } else
        {
            getLogger().info("targetDataStore has wrong.");
        }
        setDataPath(dataPath);
    }
    public MySQLDataStore getTargetDataStore()
    {
        return targetDataStore;
    }
    public void setTargetDataStore(MySQLDataStore 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;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/DummyFeatureConvertMySQlJobContext.java
New file
@@ -0,0 +1,304 @@
package com.ximple.eofms.jobs.context.mysql;
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 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.geotools.data.FeatureWriter;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.xml.sax.SAXException;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.ximple.eofms.jobs.context.orasdo.AbstractDgnToOraSDOJobContext;
import com.ximple.eofms.filter.ElementDispatcher;
import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter;
import com.ximple.eofms.filter.ElementDispatchableFilter;
import com.ximple.eofms.filter.TypeCompIdDispatchableFilter;
import com.ximple.eofms.filter.TypeCompLevelIdDispatchableFilter;
import com.ximple.eofms.filter.TypeIdDispatchableFilter;
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 DummyFeatureConvertMySQlJobContext extends AbstractDgnToMySQLJobContext
{
    static final Log logger = LogFactory.getLog(DummyFeatureConvertMySQlJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    static final String SHPOUTPATH = "shpout";
    private String dataOut = null;
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private ElementDispatcher elementDispatcher;
    private String _filterConfig;
    private boolean withIndex = false;
    public DummyFeatureConvertMySQlJobContext(String dataPath, DataStore targetDataStore, String filterConfig)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
        _filterConfig = filterConfig;
        elementDispatcher = createElementDispatcher();
    }
    private ElementDispatcher createElementDispatcher()
    {
        try
        {
            URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml");
            assert rulesURL != null;
            Digester digester = DigesterLoader.createDigester(rulesURL);
            URL filterURL = null;
            if (_filterConfig != null)
            {
                File config = new File(_filterConfig);
                if (config.exists())
                {
                    filterURL = config.toURI().toURL();
                }
            }
            if (filterURL == null)
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
        } catch (UnsupportedEncodingException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (MalformedURLException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (SAXException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        assert elementDispatcher != null;
        if (element == null)
        {
            logger.warn("Unknown Element:" + null);
            return;
        }
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element);
        if (feature == null)
        {
            FrammeAttributeData linkage =
                    AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
            logger.warn("Unknown Element:" + element.getElementType().toString() +
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            if (element instanceof ComplexElement)
            {
                ComplexElement complex = (ComplexElement) element;
                logger.warn("----Complex Element size=" + complex.size());
            }
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
        assert elementDispatcher != null;
        for (ElementDispatchableFilter filter : elementDispatcher.getRules())
        {
            if (filter instanceof TypeCompIdDispatchableFilter)
            {
                ((TypeCompIdDispatchableFilter) filter).getCreateStrategy();
            } else if (filter instanceof TypeCompLevelIdDispatchableFilter)
            {
                ((TypeCompIdDispatchableFilter) filter).getCreateStrategy();
            } else if (filter instanceof TypeIdDispatchableFilter)
            {
                ((TypeCompIdDispatchableFilter) filter).getCreateStrategy();
            }
        }
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public String getDataOutPath()
    {
        if (dataOut == null)
        {
            File outPath = new File(getDataPath(), SHPOUTPATH);
            if (!outPath.exists())
            {
                outPath.mkdir();
            } else if (!outPath.isDirectory())
            {
                outPath.mkdir();
            }
            dataOut = outPath.toString();
        }
        return dataOut;
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public boolean isWithIndex()
    {
        return withIndex;
    }
    public void setWithIndex(boolean withIndex)
    {
        this.withIndex = withIndex;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/FeatureDgnConvertMySQLJobContext.java
New file
@@ -0,0 +1,268 @@
package com.ximple.eofms.jobs.context.mysql;
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 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.geotools.data.FeatureWriter;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
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.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.ComplexElement;
import com.ximple.io.dgn7.UserAttributeData;
public class FeatureDgnConvertMySQLJobContext extends AbstractDgnToMySQLJobContext
{
    static final Log logger = LogFactory.getLog(FeatureDgnConvertMySQLJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private ElementDispatcher elementDispatcher;
    private String _filterConfig;
    private boolean withIndex = false;
    public FeatureDgnConvertMySQLJobContext(String dataPath, DataStore targetDataStore, String filterConfig)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
        _filterConfig = filterConfig;
        elementDispatcher = createElementDispatcher();
    }
    private ElementDispatcher createElementDispatcher()
    {
        try
        {
            URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml");
            assert rulesURL != null;
            Digester digester = DigesterLoader.createDigester(rulesURL);
            URL filterURL = null;
            if (_filterConfig != null)
            {
                File config = new File(_filterConfig);
                if (config.exists())
                {
                    filterURL = config.toURI().toURL();
                }
            }
            if (filterURL == null)
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
        } catch (UnsupportedEncodingException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (MalformedURLException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (SAXException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        assert elementDispatcher != null;
        if (element == null)
        {
            logger.warn("Unknown Element:" + null);
            return;
        }
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element);
        if (feature == null)
        {
            FrammeAttributeData linkage =
                    AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
            logger.warn("Unknown Element:" + element.getElementType().toString() +
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            if (element instanceof ComplexElement)
            {
                ComplexElement complex = (ComplexElement) element;
                logger.warn("----Complex Element size=" + complex.size());
            }
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public boolean isWithIndex()
    {
        return withIndex;
    }
    public void setWithIndex(boolean withIndex)
    {
        this.withIndex = withIndex;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/GeneralDgnConvertMySQLJobContext.java
New file
@@ -0,0 +1,521 @@
package com.ximple.eofms.jobs.context.mysql;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Iterator;
import java.util.List;
import java.net.MalformedURLException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
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.geotools.feature.Feature;
import org.geotools.feature.FeatureTypeBuilder;
import org.geotools.feature.FeatureType;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.feature.SimpleFeature;
import org.geotools.data.FeatureWriter;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Geometry;
import com.ximple.eofms.util.TWD97GeometryConverterDecorator;
import com.ximple.eofms.util.FeatureTypeBuilderUtil;
import com.ximple.eofms.util.DefaultColorTable;
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.TextElement;
import com.ximple.io.dgn7.ShapeElement;
import com.ximple.io.dgn7.LineStringElement;
import com.ximple.io.dgn7.ArcElement;
import com.ximple.io.dgn7.TextNodeElement;
import com.ximple.io.dgn7.LineElement;
import com.ximple.io.dgn7.EllipseElement;
import com.ximple.io.dgn7.ComplexChainElement;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.UserAttributeData;
public class GeneralDgnConvertMySQLJobContext  extends AbstractDgnToMySQLJobContext
{
    static final Log logger = LogFactory.getLog(GeneralDgnConvertMySQLJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    private String dataOut = null;
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>();
    private TreeMap<String, FeatureType> featureTypes = new TreeMap<String, FeatureType>();
    private TWD97GeometryConverterDecorator convertDecorator = null;
    private String featureBaseName = null;
    private boolean withIndex = false;
    public GeneralDgnConvertMySQLJobContext(String dataPath, DataStore targetDataStore)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
        convertDecorator = new TWD97GeometryConverterDecorator();
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        FeatureType ft = lookupFeatureType(element);
        if (ft != null)
        {
            Feature feature = createFeature(ft, element);
            if (feature == null)
            {
                if (element instanceof TextElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((TextElement) element).getText() + "'");
                else if (element instanceof ShapeElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((ShapeElement) element).getVerticeSize() + "'" +
                            ((ShapeElement) element).getStartPoint());
                else if (element instanceof LineStringElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((LineStringElement) element).getVerticeSize() + "'" +
                            ((LineStringElement) element).getStartPoint());
                else if (element instanceof ArcElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((ArcElement) element).getOrigin().toString() + "'" +
                            ((ArcElement) element).getRotationAngle());
                return;
            }
            if (!txFeaturesContext.containsKey(feature.getFeatureType()))
            {
                txFeaturesContext.put(feature.getFeatureType(), new ArrayList<Feature>());
            }
            ArrayList<Feature> arrayList = (ArrayList<Feature>) txFeaturesContext.get(feature.getFeatureType());
            arrayList.add(feature);
        } else
        {
            logger.info("Unknown Element :" + element.getType() + ", lv=" + element.getLevelIndex());
        }
    }
    public void startTransaction()
    {
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save into OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) != null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save into OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    public FeatureType createPointFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalPointFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public FeatureType createLineFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalLineFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public FeatureType createArcFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalArcFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public FeatureType createEllipseFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalEllipseFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException
    {
        DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance();
        if (element instanceof TextElement)
        {
            TextElement textElement = (TextElement) element;
            convertDecorator.setConverter(textElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            double angle = textElement.getRotationAngle();
            String content = textElement.getText();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            if (geom != null)
            {
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(textElement.getColorIndex()),
                        textElement.getFontIndex(),
                        textElement.getJustification(),
                        textElement.getTextHeight(),
                        textElement.getTextWidth(),
                        angle,
                        content
                });
            } else
            {
                logger.info("geometry is null." + element.toString());
            }
            return null;
        } else if (element instanceof TextNodeElement)
        {
            TextNodeElement textNodeElement = (TextNodeElement) element;
            convertDecorator.setConverter(textNodeElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            double angle = textNodeElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            String[] texts = textNodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            for (String text : texts)
            {
                if (sb.length() != 0)
                    sb.append("\n");
                sb.append(text);
            }
            if (geom != null)
            {
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(textNodeElement.getColorIndex()),
                        textNodeElement.getFontIndex(),
                        textNodeElement.getJustification(),
                        textNodeElement.getTextNodeHeight(),
                        textNodeElement.getTextNodeLength(),
                        angle,
                        sb.toString()
                });
            } else
            {
                logger.info("geometry is null." + element.toString());
            }
            return null;
        } else if (element instanceof ShapeElement)
        {
            ShapeElement shapeElement = (ShapeElement) element;
            convertDecorator.setConverter(shapeElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
            {
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(shapeElement.getColorIndex()),
                        shapeElement.getWeight(),
                        shapeElement.getLineStyle()
                });
            } else
            {
                logger.info("geometry is null." + element.toString());
            }
            return null;
        } else if (element instanceof LineStringElement)
        {
            LineStringElement linestring = (LineStringElement) element;
            convertDecorator.setConverter(linestring);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(linestring.getColorIndex()),
                        linestring.getWeight(),
                        linestring.getLineStyle()
                });
            return null;
        } else if (element instanceof LineElement)
        {
            LineElement line = (LineElement) element;
            convertDecorator.setConverter(line);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(line.getColorIndex()),
                        line.getWeight(),
                        line.getLineStyle()
                });
            return null;
        } else if (element instanceof ArcElement)
        {
            ArcElement arcElement = (ArcElement) element;
            /*
            logger.fatal("" + arcElement.getPrimary() + ":" + arcElement.getSecondary() +
                    "-" + arcElement.getStartAngle() + ":" + arcElement.getSweepAngle() + ":" +
            arcElement.getRotationAngle() + ":" + arcElement.getOrigin());
            */
            convertDecorator.setConverter(arcElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(arcElement.getColorIndex()),
                        arcElement.getWeight(),
                        arcElement.getLineStyle()
                });
            return null;
        } else if (element instanceof EllipseElement)
        {
            EllipseElement arcElement = (EllipseElement) element;
            convertDecorator.setConverter(arcElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(arcElement.getColorIndex()),
                        arcElement.getWeight(),
                        arcElement.getLineStyle()
                });
            return null;
        } else if (element instanceof ComplexChainElement)
        {
            ComplexChainElement complexChainElement = (ComplexChainElement) element;
            convertDecorator.setConverter(complexChainElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(complexChainElement.getColorIndex()),
                        complexChainElement.getWeight(),
                        complexChainElement.getLineStyle()
                });
            return null;
        }
        return null;
    }
    private String getFeatureBaseName()
    {
        if (featureBaseName == null)
        {
            String dgnname = getFilename().toLowerCase();
            int i = dgnname.lastIndexOf(".");
            if (i != -1)
            {
                dgnname = dgnname.substring(0, i);
            }
            featureBaseName = dgnname;
        }
        return featureBaseName;
    }
    private FeatureType lookupFeatureType(Element element) throws SchemaException, IllegalAttributeException
    {
        String typeName;
        if (element instanceof TextElement)
        {
            typeName = getFeatureBaseName() + "P";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createPointFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof TextNodeElement)
        {
            typeName = getFeatureBaseName() + "P";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createPointFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof LineStringElement)
        {
            if (element instanceof ShapeElement)
            {
                typeName = getFeatureBaseName() + "R";
                if (!featureTypes.containsKey(typeName))
                {
                    featureTypes.put(typeName, createLineFeatureElement(typeName));
                }
                return featureTypes.get(typeName);
            } else
            {
                typeName = getFeatureBaseName() + "L";
                if (!featureTypes.containsKey(typeName))
                {
                    featureTypes.put(typeName, createLineFeatureElement(typeName));
                }
                return featureTypes.get(typeName);
            }
        } else if (element instanceof LineElement)
        {
            typeName = getFeatureBaseName() + "L";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createLineFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof ComplexChainElement)
        {
            typeName = getFeatureBaseName() + "L";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createLineFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof ArcElement)
        {
            typeName = getFeatureBaseName() + "A";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createArcFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof EllipseElement)
        {
            typeName = getFeatureBaseName() + "R";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createEllipseFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        }
        return null;
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public boolean isWithIndex()
    {
        return withIndex;
    }
    public void setWithIndex(boolean withIndex)
    {
        this.withIndex = withIndex;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/IndexDgnConvertMySQLJobContext.java
New file
@@ -0,0 +1,320 @@
package com.ximple.eofms.jobs.context.mysql;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.net.MalformedURLException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
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.geotools.feature.Feature;
import org.geotools.feature.FeatureTypeBuilder;
import org.geotools.feature.FeatureType;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.feature.SimpleFeature;
import org.geotools.data.FeatureWriter;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Coordinate;
import com.ximple.eofms.util.TWD97GeometryConverterDecorator;
import com.ximple.eofms.util.FeatureTypeBuilderUtil;
import com.ximple.eofms.util.DefaultColorTable;
import com.ximple.eofms.util.TPCLIDConverter;
import com.ximple.eofms.util.TWDDatumConverter;
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.TextElement;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.UserAttributeData;
public class IndexDgnConvertMySQLJobContext extends AbstractDgnToMySQLJobContext
{
    static final Log logger = LogFactory.getLog(IndexDgnConvertMySQLJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator();
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private FeatureTypeBuilder typeBuilderPnt = null;
    private FeatureTypeBuilder typeBuilderRect = null;
    private FeatureType featureType = null;
    private FeatureType featureType2 = null;
    public IndexDgnConvertMySQLJobContext(String dataPath, DataStore targetDataStore)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        if (!(element instanceof TextElement))
        {
            return;
        }
        Feature feature = createFeature((TextElement) element);
        if (feature == null)
        {
            logger.info("cannot craete feature." + element.toString() + "'" +
                    ((TextElement) element).getText() + "'");
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
        feature = createFeature2((TextElement) element);
        if (feature == null)
        {
            logger.info("cannot craete feature2." + element.toString() + "'" +
                    ((TextElement) element).getText() + "'");
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                for (Feature feature1 : features)
                {
                    ((SimpleFeature) writer.next()).setAttributes(feature1.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    public FeatureType createFeatureElement(String featureName) throws SchemaException
    {
        if (typeBuilderRect == null)
        {
            typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexFeatureTypeBuilder(featureName);
        }
        return typeBuilderRect.getFeatureType();
    }
    public FeatureType createFeatureElement2(String featureName) throws SchemaException
    {
        if (typeBuilderPnt == null)
        {
            typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexTextFeatureTypeBuilder(featureName);
        }
        return typeBuilderPnt.getFeatureType();
    }
    public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException
    {
        DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance();
        if (element instanceof TextElement)
        {
            TextElement textElement = (TextElement) element;
            String tpclid = textElement.getText();
            Envelope extent = TPCLIDConverter.convertTpclIdToEnvelope(tpclid);
            Geometry geom = geometryFactory.createLinearRing(new Coordinate[]
                    {
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMaxX(), extent.getMinY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMaxX(), extent.getMaxY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMaxY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())),
                    });
            return featureType.create(new Object[]{
                    geom,
                    extent.getMinX(),
                    extent.getMinY(),
                    extent.getMaxX(),
                    extent.getMaxY(),
                    tpclid,
                    colorTable.getColorCode(textElement.getColorIndex()),
                    textElement.getWeight(),
                    textElement.getLineStyle()
            });
        }
        return null;
    }
    public Feature createFeature2(FeatureType featureType, Element element) throws IllegalAttributeException
    {
        DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance();
        if (element instanceof TextElement)
        {
            TextElement txtElement = (TextElement) element;
            double angle = txtElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            convertDecorator.setConverter(txtElement);
            Feature feature = featureType.create(new Object[]{
                    convertDecorator.toGeometry(geometryFactory),
                    colorTable.getColorCode(txtElement.getColorIndex()),
                    txtElement.getWeight(),
                    txtElement.getLineStyle(),
                    txtElement.getJustification(),
                    txtElement.getTextHeight(),
                    txtElement.getTextWidth(),
                    angle,
                    txtElement.getText()
            });
            return feature;
        }
        return null;
    }
    private Feature createFeature(TextElement element) throws SchemaException, IllegalAttributeException
    {
        if (featureType == null)
        {
            String dgnname = getFilename().toLowerCase();
            int i = dgnname.lastIndexOf(".");
            if (i != -1)
            {
                dgnname = dgnname.substring(0, i);
            }
            featureType = createFeatureElement(dgnname);
        }
        return createFeature(featureType, element);
    }
    private Feature createFeature2(TextElement element) throws SchemaException, IllegalAttributeException
    {
        if (featureType2 == null)
        {
            String dgnname = getFilename().toLowerCase();
            int i = dgnname.lastIndexOf(".");
            if (i != -1)
            {
                dgnname = dgnname.substring(0, i);
            }
            dgnname = dgnname + "P";
            featureType2 = createFeatureElement2(dgnname);
        }
        return createFeature2(featureType2, element);
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/OracleConvertMySQLJobContext.java
New file
@@ -0,0 +1,319 @@
package com.ximple.eofms.jobs.context.mysql;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
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.data.FeatureWriter;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.mysql.MySQLDataStoreFactory;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.SimpleFeature;
import org.geotools.feature.IllegalAttributeException;
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.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.ComplexElement;
public class OracleConvertMySQLJobContext extends AbstractOracleToMySQLJobContext
{
    static Log logger = LogFactory.getLog(OracleConvertMySQLJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static MySQLDataStoreFactory dataStoreFactory = new MySQLDataStoreFactory();
    private OracleElementLogger elmLogger = null;
    static
    {
        try
        {
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        } catch (SQLException e)
        {
            Assert.shouldNeverReachHere(e.getMessage());
        }
    }
    private String _filterConfig;
    private ElementDispatcher elementDispatcher;
    private HashMap featuresContext = new HashMap();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private JobExecutionContext executionContext;
    private String currentSchema = null;
    private String pgCurrentSchema = null;
    private boolean schemaChanged = false;
    // private String _convertElementIn = null;
    public OracleConvertMySQLJobContext(String dataPath, DataStore oraDS, String filterConfig)
    {
        super(dataPath, oraDS);
        _filterConfig = filterConfig;
        elementDispatcher = createElementDispatcher();
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
    }
    private ElementDispatcher createElementDispatcher()
    {
        try
        {
            URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml");
            assert rulesURL != null;
            Digester digester = DigesterLoader.createDigester(rulesURL);
            URL filterURL = null;
            if (_filterConfig != null)
            {
                File config = new File(_filterConfig);
                if (config.exists())
                {
                    filterURL = config.toURI().toURL();
                }
            }
            if (filterURL == null)
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
        } catch (UnsupportedEncodingException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (MalformedURLException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (SAXException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    public void putFeatureCollection(Element element)
    {
        assert elementDispatcher != null;
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element);
        if (feature == null)
        {
            boolean isEmptySize = false;
            FrammeAttributeData linkage =
                    AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
            logger.warn("Unknown Element:" + element.getElementType().toString() +
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            if (element instanceof ComplexElement)
            {
                ComplexElement complex = (ComplexElement) element;
                logger.warn("----Complex Element size=" + complex.size() + ":" +
                        (linkage == null ? "NULL" : (linkage.getUfid())));
                isEmptySize = true;
            }
            if (getElementLogging() && (!isEmptySize))
            {
                getElementLogger().logElement(element, getCurrentSchema());
            }
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
        //txFeaturesContext.startTransaction();
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
        if (this.getElementLogger() != null)
            this.getElementLogger().flashLogging();
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                FeatureWriter writer = null;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    DataStore postGisDataStore = null;
                    postGisDataStore = dataStoreFactory.createDataStore(properties);
                    boolean existTable = isExistFeature(featureType);
                    if (!existTable)
                    {
                        postGisDataStore.createSchema(featureType);
                        writer = postGisDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = postGisDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList features = (ArrayList) featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    private boolean isExistFeature(FeatureType featureType)
    {
        try
        {
            FeatureType existFeatureType = targetDataStore.getSchema(featureType.getTypeName());
            return existFeatureType != null && existFeatureType.equals(featureType);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            return false;
        }
    }
    public JobExecutionContext getExecutionContext()
    {
        return executionContext;
    }
    public void setExecutionContext(JobExecutionContext context)
    {
        executionContext = context;
    }
    /**
     * Ãö³¬³]³Æ¼g¤J¾¹
     *
     * @throws IOException IOµo¥Í¿ù»~
     */
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    protected OracleElementLogger getElementLogger()
    {
        if (elmLogger == null)
        {
            elmLogger = new OracleElementLogger(getOracleConnection());
            elmLogger.setDataPath(this.getDataPath());
        }
        return elmLogger;
    }
    public String getCurrentSchema()
    {
        return currentSchema;
    }
    public void setCurrentSchema(String querySchema)
    {
        this.currentSchema = querySchema;
        this.schemaChanged = true;
    }
    protected Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java
@@ -1,14 +1,46 @@
package com.ximple.eofms.jobs.context.orasdo;
import java.util.Properties;
import java.io.IOException;
import java.sql.Connection;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.oracle.OracleDataStore;
import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext;
public abstract class AbstractDgnToOraSDOJobContext extends AbstractDgnFileJobContext
{
    public AbstractDgnToOraSDOJobContext(String dataPath, Properties properties)
    protected OracleDataStore targetDataStore;
    public AbstractDgnToOraSDOJobContext(String dataPath, DataStore targetDataStore)
    {
        super(dataPath);
        this.properties = properties;
        this.targetDataStore = (OracleDataStore) targetDataStore;
    }
    public OracleDataStore getTargetDataStore()
    {
        return targetDataStore;
    }
    public void setTargetDataStore(OracleDataStore 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;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java
@@ -1,12 +1,52 @@
package com.ximple.eofms.jobs.context.orasdo;
import java.util.Properties;
import java.io.IOException;
import java.sql.Connection;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.oracle.OracleDataStore;
import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
public abstract class AbstractOracleToOraSDOJobContext extends AbstractOracleJobContext
{
    public AbstractOracleToOraSDOJobContext(String dataPath, Properties properties)
    protected OracleDataStore targetDataStore;
    public AbstractOracleToOraSDOJobContext(String dataPath, DataStore targetDataStore)
    {
        if ((targetDataStore != null) && (targetDataStore instanceof OracleDataStore))
        {
            this.targetDataStore = (OracleDataStore) targetDataStore;
        } else
        {
            getLogger().info("targetDataStore has wrong.");
        }
        setDataPath(dataPath);
    }
    public OracleDataStore getTargetDataStore()
    {
        return targetDataStore;
    }
    public void setTargetDataStore(OracleDataStore 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;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/DummyFeatureConvertOraSDOJobContext.java
New file
@@ -0,0 +1,303 @@
package com.ximple.eofms.jobs.context.orasdo;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
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.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.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.UserAttributeData;
public class DummyFeatureConvertOraSDOJobContext extends AbstractDgnToOraSDOJobContext
{
    static final Log logger = LogFactory.getLog(DummyFeatureConvertOraSDOJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    static final String SHPOUTPATH = "shpout";
    private String dataOut = null;
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private ElementDispatcher elementDispatcher;
    private String _filterConfig;
    private boolean withIndex = false;
    public DummyFeatureConvertOraSDOJobContext(String dataPath, DataStore targetDataStore, String filterConfig)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
        _filterConfig = filterConfig;
        elementDispatcher = createElementDispatcher();
    }
    private ElementDispatcher createElementDispatcher()
    {
        try
        {
            URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml");
            assert rulesURL != null;
            Digester digester = DigesterLoader.createDigester(rulesURL);
            URL filterURL = null;
            if (_filterConfig != null)
            {
                File config = new File(_filterConfig);
                if (config.exists())
                {
                    filterURL = config.toURI().toURL();
                }
            }
            if (filterURL == null)
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
        } catch (UnsupportedEncodingException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (MalformedURLException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (SAXException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        assert elementDispatcher != null;
        if (element == null)
        {
            logger.warn("Unknown Element:" + null);
            return;
        }
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element);
        if (feature == null)
        {
            FrammeAttributeData linkage =
                    AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
            logger.warn("Unknown Element:" + element.getElementType().toString() +
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            if (element instanceof ComplexElement)
            {
                ComplexElement complex = (ComplexElement) element;
                logger.warn("----Complex Element size=" + complex.size());
            }
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
        assert elementDispatcher != null;
        for (ElementDispatchableFilter filter : elementDispatcher.getRules())
        {
            if (filter instanceof TypeCompIdDispatchableFilter)
            {
                ((TypeCompIdDispatchableFilter) filter).getCreateStrategy();
            } else if (filter instanceof TypeCompLevelIdDispatchableFilter)
            {
                ((TypeCompIdDispatchableFilter) filter).getCreateStrategy();
            } else if (filter instanceof TypeIdDispatchableFilter)
            {
                ((TypeCompIdDispatchableFilter) filter).getCreateStrategy();
            }
        }
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public String getDataOutPath()
    {
        if (dataOut == null)
        {
            File outPath = new File(getDataPath(), SHPOUTPATH);
            if (!outPath.exists())
            {
                outPath.mkdir();
            } else if (!outPath.isDirectory())
            {
                outPath.mkdir();
            }
            dataOut = outPath.toString();
        }
        return dataOut;
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public boolean isWithIndex()
    {
        return withIndex;
    }
    public void setWithIndex(boolean withIndex)
    {
        this.withIndex = withIndex;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/FeatureDgnConvertOraSDOJobContext.java
New file
@@ -0,0 +1,267 @@
package com.ximple.eofms.jobs.context.orasdo;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
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.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.AbstractFLinkageDispatchableFilter;
import com.ximple.eofms.filter.ElementDispatcher;
import com.ximple.io.dgn7.ComplexElement;
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.UserAttributeData;
public class FeatureDgnConvertOraSDOJobContext extends AbstractDgnToOraSDOJobContext
{
    static final Log logger = LogFactory.getLog(FeatureDgnConvertOraSDOJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private ElementDispatcher elementDispatcher;
    private String _filterConfig;
    private boolean withIndex = false;
    public FeatureDgnConvertOraSDOJobContext(String dataPath, DataStore targetDataStore, String filterConfig)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
        _filterConfig = filterConfig;
        elementDispatcher = createElementDispatcher();
    }
    private ElementDispatcher createElementDispatcher()
    {
        try
        {
            URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml");
            assert rulesURL != null;
            Digester digester = DigesterLoader.createDigester(rulesURL);
            URL filterURL = null;
            if (_filterConfig != null)
            {
                File config = new File(_filterConfig);
                if (config.exists())
                {
                    filterURL = config.toURI().toURL();
                }
            }
            if (filterURL == null)
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
        } catch (UnsupportedEncodingException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (MalformedURLException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (SAXException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        assert elementDispatcher != null;
        if (element == null)
        {
            logger.warn("Unknown Element:" + null);
            return;
        }
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element);
        if (feature == null)
        {
            FrammeAttributeData linkage =
                    AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
            logger.warn("Unknown Element:" + element.getElementType().toString() +
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            if (element instanceof ComplexElement)
            {
                ComplexElement complex = (ComplexElement) element;
                logger.warn("----Complex Element size=" + complex.size());
            }
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public boolean isWithIndex()
    {
        return withIndex;
    }
    public void setWithIndex(boolean withIndex)
    {
        this.withIndex = withIndex;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/GeneralDgnConvertOraSDOJobContext.java
New file
@@ -0,0 +1,522 @@
package com.ximple.eofms.jobs.context.orasdo;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
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.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.FeatureTypeBuilder;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.feature.SimpleFeature;
import com.vividsolutions.jts.geom.Geometry;
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.io.dgn7.ArcElement;
import com.ximple.io.dgn7.ComplexChainElement;
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.EllipseElement;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.LineElement;
import com.ximple.io.dgn7.LineStringElement;
import com.ximple.io.dgn7.ShapeElement;
import com.ximple.io.dgn7.TextElement;
import com.ximple.io.dgn7.TextNodeElement;
import com.ximple.io.dgn7.UserAttributeData;
public class GeneralDgnConvertOraSDOJobContext extends AbstractDgnToOraSDOJobContext
{
    static final Log logger = LogFactory.getLog(GeneralDgnConvertOraSDOJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    private String dataOut = null;
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>();
    private TreeMap<String, FeatureType> featureTypes = new TreeMap<String, FeatureType>();
    private TWD97GeometryConverterDecorator convertDecorator = null;
    private String featureBaseName = null;
    private boolean withIndex = false;
    public GeneralDgnConvertOraSDOJobContext(String dataPath, DataStore targetDataStore)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
        convertDecorator = new TWD97GeometryConverterDecorator();
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        FeatureType ft = lookupFeatureType(element);
        if (ft != null)
        {
            Feature feature = createFeature(ft, element);
            if (feature == null)
            {
                if (element instanceof TextElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((TextElement) element).getText() + "'");
                else if (element instanceof ShapeElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((ShapeElement) element).getVerticeSize() + "'" +
                            ((ShapeElement) element).getStartPoint());
                else if (element instanceof LineStringElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((LineStringElement) element).getVerticeSize() + "'" +
                            ((LineStringElement) element).getStartPoint());
                else if (element instanceof ArcElement)
                    logger.info("cannot craete feature." + element.toString() + "'" +
                            ((ArcElement) element).getOrigin().toString() + "'" +
                            ((ArcElement) element).getRotationAngle());
                return;
            }
            if (!txFeaturesContext.containsKey(feature.getFeatureType()))
            {
                txFeaturesContext.put(feature.getFeatureType(), new ArrayList<Feature>());
            }
            ArrayList<Feature> arrayList = (ArrayList<Feature>) txFeaturesContext.get(feature.getFeatureType());
            arrayList.add(feature);
        } else
        {
            logger.info("Unknown Element :" + element.getType() + ", lv=" + element.getLevelIndex());
        }
    }
    public void startTransaction()
    {
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save into OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) != null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save into OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    public FeatureType createPointFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalPointFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public FeatureType createLineFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalLineFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public FeatureType createArcFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalArcFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public FeatureType createEllipseFeatureElement(String featureName) throws SchemaException
    {
        if (!typeBuilders.containsKey(featureName))
        {
            FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createNormalEllipseFeatureTypeBuilder(featureName);
            typeBuilders.put(featureName, typeBuilder);
        }
        return typeBuilders.get(featureName).getFeatureType();
    }
    public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException
    {
        DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance();
        if (element instanceof TextElement)
        {
            TextElement textElement = (TextElement) element;
            convertDecorator.setConverter(textElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            double angle = textElement.getRotationAngle();
            String content = textElement.getText();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            if (geom != null)
            {
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(textElement.getColorIndex()),
                        textElement.getFontIndex(),
                        textElement.getJustification(),
                        textElement.getTextHeight(),
                        textElement.getTextWidth(),
                        angle,
                        content
                });
            } else
            {
                logger.info("geometry is null." + element.toString());
            }
            return null;
        } else if (element instanceof TextNodeElement)
        {
            TextNodeElement textNodeElement = (TextNodeElement) element;
            convertDecorator.setConverter(textNodeElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            double angle = textNodeElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            String[] texts = textNodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            for (String text : texts)
            {
                if (sb.length() != 0)
                    sb.append("\n");
                sb.append(text);
            }
            if (geom != null)
            {
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(textNodeElement.getColorIndex()),
                        textNodeElement.getFontIndex(),
                        textNodeElement.getJustification(),
                        textNodeElement.getTextNodeHeight(),
                        textNodeElement.getTextNodeLength(),
                        angle,
                        sb.toString()
                });
            } else
            {
                logger.info("geometry is null." + element.toString());
            }
            return null;
        } else if (element instanceof ShapeElement)
        {
            ShapeElement shapeElement = (ShapeElement) element;
            convertDecorator.setConverter(shapeElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
            {
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(shapeElement.getColorIndex()),
                        shapeElement.getWeight(),
                        shapeElement.getLineStyle()
                });
            } else
            {
                logger.info("geometry is null." + element.toString());
            }
            return null;
        } else if (element instanceof LineStringElement)
        {
            LineStringElement linestring = (LineStringElement) element;
            convertDecorator.setConverter(linestring);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(linestring.getColorIndex()),
                        linestring.getWeight(),
                        linestring.getLineStyle()
                });
            return null;
        } else if (element instanceof LineElement)
        {
            LineElement line = (LineElement) element;
            convertDecorator.setConverter(line);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(line.getColorIndex()),
                        line.getWeight(),
                        line.getLineStyle()
                });
            return null;
        } else if (element instanceof ArcElement)
        {
            ArcElement arcElement = (ArcElement) element;
            /*
            logger.fatal("" + arcElement.getPrimary() + ":" + arcElement.getSecondary() +
                    "-" + arcElement.getStartAngle() + ":" + arcElement.getSweepAngle() + ":" +
            arcElement.getRotationAngle() + ":" + arcElement.getOrigin());
            */
            convertDecorator.setConverter(arcElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(arcElement.getColorIndex()),
                        arcElement.getWeight(),
                        arcElement.getLineStyle()
                });
            return null;
        } else if (element instanceof EllipseElement)
        {
            EllipseElement arcElement = (EllipseElement) element;
            convertDecorator.setConverter(arcElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(arcElement.getColorIndex()),
                        arcElement.getWeight(),
                        arcElement.getLineStyle()
                });
            return null;
        } else if (element instanceof ComplexChainElement)
        {
            ComplexChainElement complexChainElement = (ComplexChainElement) element;
            convertDecorator.setConverter(complexChainElement);
            Geometry geom = convertDecorator.toGeometry(geometryFactory);
            if (geom != null)
                return featureType.create(new Object[]{
                        geom,
                        colorTable.getColorCode(complexChainElement.getColorIndex()),
                        complexChainElement.getWeight(),
                        complexChainElement.getLineStyle()
                });
            return null;
        }
        return null;
    }
    private String getFeatureBaseName()
    {
        if (featureBaseName == null)
        {
            String dgnname = getFilename().toLowerCase();
            int i = dgnname.lastIndexOf(".");
            if (i != -1)
            {
                dgnname = dgnname.substring(0, i);
            }
            featureBaseName = dgnname;
        }
        return featureBaseName;
    }
    private FeatureType lookupFeatureType(Element element) throws SchemaException, IllegalAttributeException
    {
        String typeName;
        if (element instanceof TextElement)
        {
            typeName = getFeatureBaseName() + "P";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createPointFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof TextNodeElement)
        {
            typeName = getFeatureBaseName() + "P";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createPointFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof LineStringElement)
        {
            if (element instanceof ShapeElement)
            {
                typeName = getFeatureBaseName() + "R";
                if (!featureTypes.containsKey(typeName))
                {
                    featureTypes.put(typeName, createLineFeatureElement(typeName));
                }
                return featureTypes.get(typeName);
            } else
            {
                typeName = getFeatureBaseName() + "L";
                if (!featureTypes.containsKey(typeName))
                {
                    featureTypes.put(typeName, createLineFeatureElement(typeName));
                }
                return featureTypes.get(typeName);
            }
        } else if (element instanceof LineElement)
        {
            typeName = getFeatureBaseName() + "L";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createLineFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof ComplexChainElement)
        {
            typeName = getFeatureBaseName() + "L";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createLineFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof ArcElement)
        {
            typeName = getFeatureBaseName() + "A";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createArcFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        } else if (element instanceof EllipseElement)
        {
            typeName = getFeatureBaseName() + "R";
            if (!featureTypes.containsKey(typeName))
            {
                featureTypes.put(typeName, createEllipseFeatureElement(typeName));
            }
            return featureTypes.get(typeName);
        }
        return null;
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public boolean isWithIndex()
    {
        return withIndex;
    }
    public void setWithIndex(boolean withIndex)
    {
        this.withIndex = withIndex;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/IndexDgnConvertOraSDOJobContext.java
New file
@@ -0,0 +1,320 @@
package com.ximple.eofms.jobs.context.orasdo;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
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.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.FeatureTypeBuilder;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.feature.SimpleFeature;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.ximple.eofms.util.DefaultColorTable;
import com.ximple.eofms.util.FeatureTypeBuilderUtil;
import com.ximple.eofms.util.TPCLIDConverter;
import com.ximple.eofms.util.TWD97GeometryConverterDecorator;
import com.ximple.eofms.util.TWDDatumConverter;
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 IndexDgnConvertOraSDOJobContext extends AbstractDgnToOraSDOJobContext
{
    static final Log logger = LogFactory.getLog(IndexDgnConvertOraSDOJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator();
    private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private FeatureTypeBuilder typeBuilderPnt = null;
    private FeatureTypeBuilder typeBuilderRect = null;
    private FeatureType featureType = null;
    private FeatureType featureType2 = null;
    public IndexDgnConvertOraSDOJobContext(String dataPath, DataStore targetDataStore)
    {
        super(dataPath, targetDataStore);
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
    }
    public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException
    {
        if (!(element instanceof TextElement))
        {
            return;
        }
        Feature feature = createFeature((TextElement) element);
        if (feature == null)
        {
            logger.info("cannot craete feature." + element.toString() + "'" +
                    ((TextElement) element).getText() + "'");
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
        feature = createFeature2((TextElement) element);
        if (feature == null)
        {
            logger.info("cannot craete feature2." + element.toString() + "'" +
                    ((TextElement) element).getText() + "'");
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                logger.debug("Begin Save OracleSDO:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList<Feature> features = featuresContext.get(featureType);
                for (Feature feature1 : features)
                {
                    ((SimpleFeature) writer.next()).setAttributes(feature1.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    public FeatureType createFeatureElement(String featureName) throws SchemaException
    {
        if (typeBuilderRect == null)
        {
            typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexFeatureTypeBuilder(featureName);
        }
        return typeBuilderRect.getFeatureType();
    }
    public FeatureType createFeatureElement2(String featureName) throws SchemaException
    {
        if (typeBuilderPnt == null)
        {
            typeBuilderRect = FeatureTypeBuilderUtil.createNormalIndexTextFeatureTypeBuilder(featureName);
        }
        return typeBuilderPnt.getFeatureType();
    }
    public Feature createFeature(FeatureType featureType, Element element) throws IllegalAttributeException
    {
        DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance();
        if (element instanceof TextElement)
        {
            TextElement textElement = (TextElement) element;
            String tpclid = textElement.getText();
            Envelope extent = TPCLIDConverter.convertTpclIdToEnvelope(tpclid);
            Geometry geom = geometryFactory.createLinearRing(new Coordinate[]
                    {
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMaxX(), extent.getMinY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMaxX(), extent.getMaxY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMaxY())),
                            TWDDatumConverter.fromTM2ToTWD97(new Coordinate(extent.getMinX(), extent.getMinY())),
                    });
            return featureType.create(new Object[]{
                    geom,
                    extent.getMinX(),
                    extent.getMinY(),
                    extent.getMaxX(),
                    extent.getMaxY(),
                    tpclid,
                    colorTable.getColorCode(textElement.getColorIndex()),
                    textElement.getWeight(),
                    textElement.getLineStyle()
            });
        }
        return null;
    }
    public Feature createFeature2(FeatureType featureType, Element element) throws IllegalAttributeException
    {
        DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance();
        if (element instanceof TextElement)
        {
            TextElement txtElement = (TextElement) element;
            double angle = txtElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            convertDecorator.setConverter(txtElement);
            Feature feature = featureType.create(new Object[]{
                    convertDecorator.toGeometry(geometryFactory),
                    colorTable.getColorCode(txtElement.getColorIndex()),
                    txtElement.getWeight(),
                    txtElement.getLineStyle(),
                    txtElement.getJustification(),
                    txtElement.getTextHeight(),
                    txtElement.getTextWidth(),
                    angle,
                    txtElement.getText()
            });
            return feature;
        }
        return null;
    }
    private Feature createFeature(TextElement element) throws SchemaException, IllegalAttributeException
    {
        if (featureType == null)
        {
            String dgnname = getFilename().toLowerCase();
            int i = dgnname.lastIndexOf(".");
            if (i != -1)
            {
                dgnname = dgnname.substring(0, i);
            }
            featureType = createFeatureElement(dgnname);
        }
        return createFeature(featureType, element);
    }
    private Feature createFeature2(TextElement element) throws SchemaException, IllegalAttributeException
    {
        if (featureType2 == null)
        {
            String dgnname = getFilename().toLowerCase();
            int i = dgnname.lastIndexOf(".");
            if (i != -1)
            {
                dgnname = dgnname.substring(0, i);
            }
            dgnname = dgnname + "P";
            featureType2 = createFeatureElement2(dgnname);
        }
        return createFeature2(featureType2, element);
    }
    protected FrammeAttributeData getFeatureLinkage(Element element)
    {
        if (!element.hasUserAttributeData())
            return null;
        List<UserAttributeData> usrDatas = element.getUserAttributeData();
        for (UserAttributeData anUsrData : usrDatas)
        {
            if (anUsrData instanceof FrammeAttributeData)
            {
                return (FrammeAttributeData) anUsrData;
            }
        }
        return null;
    }
    public Log getLogger()
    {
        return logger;
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java
@@ -1,27 +1,315 @@
package com.ximple.eofms.jobs.context.orasdo;
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.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
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.util.LoggerFacade;
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.oracle.OracleDataStoreFactory;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SimpleFeature;
import org.quartz.JobExecutionContext;
import org.xml.sax.SAXException;
import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
import com.vividsolutions.jts.util.Assert;
public class OracleConvertOraSDOJobContext extends AbstractOracleJobContext
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;
public class OracleConvertOraSDOJobContext extends AbstractOracleToOraSDOJobContext
{
    static Log logger = LogFactory.getLog(OracleConvertOraSDOJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static OracleDataStoreFactory dataStoreFactory = new OracleDataStoreFactory();
    private OracleElementLogger elmLogger = null;
    static
    {
        try
        {
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        } catch (SQLException e)
        {
            Assert.shouldNeverReachHere(e.getMessage());
        }
    }
    private String _filterConfig;
    private ElementDispatcher elementDispatcher;
    private HashMap featuresContext = new HashMap();
    private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>();
    private PessimisticMapWrapper txFeaturesContext;
    private JobExecutionContext executionContext;
    private String currentSchema = null;
    private String pgCurrentSchema = null;
    private boolean schemaChanged = false;
    // private String _convertElementIn = null;
    public OracleConvertOraSDOJobContext(String dataPath, DataStore oraDS, String filterConfig)
    {
        super(dataPath, oraDS);
        _filterConfig = filterConfig;
        elementDispatcher = createElementDispatcher();
        txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger);
    }
    private ElementDispatcher createElementDispatcher()
    {
        try
        {
            URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml");
            assert rulesURL != null;
            Digester digester = DigesterLoader.createDigester(rulesURL);
            URL filterURL = null;
            if (_filterConfig != null)
            {
                File config = new File(_filterConfig);
                if (config.exists())
                {
                    filterURL = config.toURI().toURL();
                }
            }
            if (filterURL == null)
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
        } catch (UnsupportedEncodingException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (MalformedURLException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        } catch (SAXException e)
        {
            logger.info(e.getMessage(), e);
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    public void putFeatureCollection(Element element)
    {
        assert elementDispatcher != null;
        // §PÂ_¬O§_²Å©M±ø¥ó
        Feature feature = elementDispatcher.execute(element);
        if (feature == null)
        {
            boolean isEmptySize = false;
            FrammeAttributeData linkage =
                    AbstractFLinkageDispatchableFilter.getFeatureLinkage(element);
            logger.warn("Unknown Element:" + element.getElementType().toString() +
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            if (element instanceof ComplexElement)
            {
                ComplexElement complex = (ComplexElement) element;
                logger.warn("----Complex Element size=" + complex.size() + ":" +
                        (linkage == null ? "NULL" : (linkage.getUfid())));
                isEmptySize = true;
            }
            if (getElementLogging() && (!isEmptySize))
            {
                getElementLogger().logElement(element, getCurrentSchema());
            }
            return;
        }
        if (!txFeaturesContext.containsKey(feature.getFeatureType()))
        {
            txFeaturesContext.put(feature.getFeatureType(), new ArrayList());
        }
        ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType());
        arrayList.add(feature);
    }
    public void startTransaction()
    {
        //txFeaturesContext.startTransaction();
    }
    public void commitTransaction()
    {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
        if (this.getElementLogger() != null)
            this.getElementLogger().flashLogging();
    }
    public void rollbackTransaction()
    {
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
        }
    }
    private void updateDataStore()
    {
        Iterator it = featuresContext.keySet().iterator();
        try
        {
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                FeatureWriter writer = null;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    DataStore postGisDataStore = null;
                    postGisDataStore = dataStoreFactory.createDataStore(properties);
                    boolean existTable = isExistFeature(featureType);
                    if (!existTable)
                    {
                        postGisDataStore.createSchema(featureType);
                        writer = postGisDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = postGisDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList features = (ArrayList) featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
                {
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save OracleSDO:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IllegalAttributeException e)
        {
            logger.error(e.getMessage(), e);
        } catch (IOException e)
        {
            logger.error(e.getMessage(), e);
        }
    }
    private boolean isExistFeature(FeatureType featureType)
    {
        try
        {
            FeatureType existFeatureType = targetDataStore.getSchema(featureType.getTypeName());
            return existFeatureType != null && existFeatureType.equals(featureType);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
            return false;
        }
    }
    public JobExecutionContext getExecutionContext()
    {
        return executionContext;
    }
    public void setExecutionContext(JobExecutionContext context)
    {
        executionContext = context;
    }
    /**
     * Ãö³¬³]³Æ¼g¤J¾¹
     *
     * @throws IOException IOµo¥Í¿ù»~
     */
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
            featureWriter.close();
        }
        this.featuresWriterContext.clear();
    }
    protected OracleElementLogger getElementLogger()
    {
        if (elmLogger == null)
        {
            elmLogger = new OracleElementLogger(getOracleConnection());
            elmLogger.setDataPath(this.getDataPath());
        }
        return elmLogger;
    }
    public String getCurrentSchema()
    {
        return currentSchema;
    }
    public void setCurrentSchema(String querySchema)
    {
        this.currentSchema = querySchema;
        this.schemaChanged = true;
    }
    protected Log getLogger()
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java
@@ -1,14 +1,13 @@
package com.ximple.eofms.jobs.context.postgis;
import java.util.Map;
import java.sql.Connection;
import java.io.IOException;
import java.sql.Connection;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.postgis.PostgisDataStore;
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
{
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java
@@ -1,13 +1,13 @@
package com.ximple.eofms.jobs.context.postgis;
import java.sql.Connection;
import java.io.IOException;
import java.sql.Connection;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.postgis.PostgisDataStore;
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
{
@@ -18,7 +18,8 @@
        if ((targetDataStore != null) && (targetDataStore instanceof PostgisDataStore))
        {
            this.targetDataStore = (PostgisDataStore) targetDataStore;
        } else {
        } else
        {
            getLogger().info("targetDataStore has wrong.");
        }
        setDataPath(dataPath);
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java
@@ -5,12 +5,10 @@
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.util.Map;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.xmlrules.DigesterLoader;
@@ -19,12 +17,9 @@
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.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;
@@ -203,8 +198,7 @@
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                File sfile = new File(getDataOutPath() + File.separator + featureType.getTypeName());
                logger.debug("Begin Save shapefile:" + sfile.toURI());
                logger.debug("Begin Save PostGIS:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
@@ -212,28 +206,13 @@
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    ShapefileDataStore shapefileDataStore = null;
                    boolean existFile = sfile.exists();
                    if (!withIndex)
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL(),
                                true, Charset.forName("UTF-8"));
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    } else
                    {
                        shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(),
                                null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8"));
                    }
                    if (!existFile)
                    {
                        shapefileDataStore.createSchema(featureType);
                        writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
@@ -246,7 +225,7 @@
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save shapefile:" + sfile.toURI());
                logger.debug("End Save PostGIS:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java
@@ -5,12 +5,10 @@
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.util.Map;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.xmlrules.DigesterLoader;
@@ -19,11 +17,9 @@
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.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.IllegalAttributeException;
@@ -35,7 +31,6 @@
import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter;
import com.ximple.eofms.filter.ElementDispatcher;
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;
@@ -43,10 +38,9 @@
public class FeatureDgnConvertPostGISJobContext extends AbstractDgnToPostGISJobContext
{
    static final Log logger = LogFactory.getLog(FeatureDgnConvertShpJobContext.class);
    static final Log logger = LogFactory.getLog(FeatureDgnConvertPostGISJobContext.class);
    static final LoggerFacade sLogger = new CommonsLoggingLogger(logger);
    static final GeometryFactory geometryFactory = new GeometryFactory();
    static final String SHPOUTPATH = "shpout";
    private String dataOut = null;
@@ -185,8 +179,7 @@
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                File sfile = new File(getDataOutPath() + File.separator + featureType.getTypeName());
                logger.debug("Begin Save shapefile:" + sfile.toURI());
                logger.debug("Begin Save PostGIS:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
@@ -194,27 +187,14 @@
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    ShapefileDataStore shapefileDataStore = null;
                    boolean existFile = sfile.exists();
                    if (!withIndex)
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL(),
                                true, Charset.forName("UTF-8"));
                    } else
                    {
                        shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(),
                                null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8"));
                    }
                    if (!existFile)
                    {
                        shapefileDataStore.createSchema(featureType);
                        writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(),
                        targetDataStore.createSchema(featureType);
                        writer = targetDataStore.getFeatureWriter(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(),
                                Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
@@ -228,7 +208,7 @@
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save shapefile:" + sfile.toURI());
                logger.debug("End Save PostGIS:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
@@ -241,23 +221,6 @@
        {
            logger.error(e.getMessage(), e);
        }
    }
    public String getDataOutPath()
    {
        if (dataOut == null)
        {
            File outPath = new File(getDataPath(), SHPOUTPATH);
            if (!outPath.exists())
            {
                outPath.mkdir();
            } else if (!outPath.isDirectory())
            {
                outPath.mkdir();
            }
            dataOut = outPath.toString();
        }
        return dataOut;
    }
    public void closeFeatureWriter() throws IOException
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java
@@ -1,16 +1,13 @@
package com.ximple.eofms.jobs.context.postgis;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.util.ArrayList;
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;
@@ -18,11 +15,9 @@
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.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.FeatureTypeBuilder;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java
@@ -1,29 +1,22 @@
package com.ximple.eofms.jobs.context.postgis;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.util.ArrayList;
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;
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.PostgisDataStore;
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;
@@ -37,10 +30,10 @@
import com.vividsolutions.jts.geom.GeometryFactory;
import com.ximple.eofms.util.DefaultColorTable;
import com.ximple.eofms.util.FeatureTypeBuilderUtil;
import com.ximple.eofms.util.TPCLIDConverter;
import com.ximple.eofms.util.TWD97GeometryConverterDecorator;
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;
@@ -148,8 +141,7 @@
            while (it.hasNext())
            {
                FeatureType featureType = (FeatureType) it.next();
                File sfile = new File(getDataOutPath() + File.separator + featureType.getTypeName());
                logger.debug("Begin Save shapefile:" + sfile.toURI());
                logger.debug("Begin Save PostGIS:" + featureType.getTypeName());
                FeatureWriter writer;
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
@@ -157,17 +149,14 @@
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                    /*
                    ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL(),
                            true, Charset.forName("UTF-8"));
                    PostgisDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(),
                            null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8"));
                    */
                    if (targetDataStore.getSchema(featureType.getTypeName()) != null)
                    if (targetDataStore.getSchema(featureType.getTypeName()) == null)
                    {
                        targetDataStore.createSchema(featureType);
                    }
                    writer = targetDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    } else
                    {
                        writer = targetDataStore.getFeatureWriterAppend(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    }
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
@@ -177,7 +166,7 @@
                    ((SimpleFeature) writer.next()).setAttributes(feature1.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save shapefile:" + sfile.toURI());
                logger.debug("End Save PostGIS:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
@@ -190,23 +179,6 @@
        {
            logger.error(e.getMessage(), e);
        }
    }
    public String getDataOutPath()
    {
        if (dataOut == null)
        {
            File outPath = new File(getDataPath(), SHPOUTPATH);
            if (!outPath.exists())
            {
                outPath.mkdir();
            } else if (!outPath.isDirectory())
            {
                outPath.mkdir();
            }
            dataOut = outPath.toString();
        }
        return dataOut;
    }
    public void closeFeatureWriter() throws IOException
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
@@ -10,7 +10,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.xmlrules.DigesterLoader;
@@ -23,7 +22,6 @@
import org.geotools.data.FeatureWriter;
import org.geotools.data.Transaction;
import org.geotools.data.postgis.PostgisDataStoreFactory;
import org.geotools.data.postgis.PostgisDataStore;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.IllegalAttributeException;
@@ -70,11 +68,9 @@
    private JobExecutionContext executionContext;
    private String dataOut = null;
    private String currentSchema = null;
    private String pgCurrentSchema = null;
    private boolean schemaChanged = false;
    private String _convertElementIn = null;
    public OracleConvertPostGISJobContext(String dataPath, DataStore pgDS, String filterConfig)
    {
@@ -239,7 +235,7 @@
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                //writer.close();
                logger.debug("End Save posgis:");
                logger.debug("End Save PostGIS:" + featureType.getTypeName());
            }
            featuresContext.clear();
        } catch (MalformedURLException e)
@@ -257,7 +253,15 @@
    private boolean isExistFeature(FeatureType featureType)
    {
        try
        {
            FeatureType existFeatureType = targetDataStore.getSchema(featureType.getTypeName());
            return existFeatureType != null && existFeatureType.equals(featureType);
        } catch (IOException e)
        {
            logger.info(e.getMessage(), e);
        return false;
        }
    }
    public JobExecutionContext getExecutionContext()
@@ -305,11 +309,6 @@
    {
        this.currentSchema = querySchema;
        this.schemaChanged = true;
    }
    public void setConvertElementIn(String convertElementIn)
    {
        _convertElementIn = convertElementIn;
    }
    protected Log getLogger()
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java
@@ -37,7 +37,6 @@
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;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java
@@ -33,7 +33,6 @@
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;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java
@@ -31,7 +31,6 @@
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.FeatureTypeBuilderUtil;
import com.ximple.eofms.util.TWD97GeometryConverterDecorator;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java
@@ -20,7 +20,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;
@@ -33,12 +32,11 @@
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.FeatureTypeBuilderUtil;
import com.ximple.eofms.util.TPCLIDConverter;
import com.ximple.eofms.util.TWD97GeometryConverterDecorator;
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;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java
@@ -22,7 +22,6 @@
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;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java
@@ -6,7 +6,10 @@
public interface ColorTableMapping
{
    boolean contain(Color color);
    List findId(Color color);
    Color getColor(int value);
    String getColorCode(int i);
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java
@@ -19,6 +19,7 @@
    }
    private ArrayList<Color> colortable = null;
    private DefaultColorTable()
    {
        initializeColorTable();
@@ -328,33 +329,37 @@
        return false;
    }
    private static String colorToString(Color c) {
    private static String colorToString(Color c)
    {
        char[] buf = new char[7];
        buf[0] = '#';
        String s = Integer.toHexString(c.getRed());
        if (s.length() == 1) {
        if (s.length() == 1)
        {
            buf[1] = '0';
            buf[2] = s.charAt(0);
        }
        else {
        } else
        {
            buf[1] = s.charAt(0);
            buf[2] = s.charAt(1);
        }
        s = Integer.toHexString(c.getGreen());
        if (s.length() == 1) {
        if (s.length() == 1)
        {
            buf[3] = '0';
            buf[4] = s.charAt(0);
        }
        else {
        } else
        {
            buf[3] = s.charAt(0);
            buf[4] = s.charAt(1);
        }
        s = Integer.toHexString(c.getBlue());
        if (s.length() == 1) {
        if (s.length() == 1)
        {
            buf[5] = '0';
            buf[6] = s.charAt(0);
        }
        else {
        } else
        {
            buf[5] = s.charAt(0);
            buf[6] = s.charAt(1);
        }
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java
@@ -1,7 +1,7 @@
package com.ximple.eofms.util;
import org.geotools.feature.FeatureTypeBuilder;
import org.geotools.feature.AttributeTypeFactory;
import org.geotools.feature.FeatureTypeBuilder;
import com.vividsolutions.jts.geom.Geometry;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeomUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java
@@ -90,7 +90,7 @@
 * In format strings containing the %<code>n</code>$
 * form of conversion specifications, each argument
 * in the argument list is used exactly once.</p>
 *
 * <p/>
 * <h4>Escape Sequences</h4>
 * <p>
 * The following table lists escape sequences and
@@ -206,7 +206,7 @@
 * be mixed with the %<code>n</code>$ form.  The
 * results of mixing numbered and unnumbered argument
 * specifications in a format string are undefined.</p>
 *
 * <p/>
 * <h4>Flag Characters</h4>
 * <p>
 * The flags and their meanings are:</p>
@@ -254,7 +254,7 @@
 *      0 flag will be ignored. For c conversions,
 *      the flag is ignored.
 * </dl>
 *
 * <p/>
 * <h4>Conversion Characters</h4>
 * <p>
 * Each conversion character results in fetching zero
@@ -263,7 +263,7 @@
 * Usually, an unchecked exception will be thrown.
 * If the format is exhausted while arguments remain,
 * the excess arguments are ignored.</p>
 *
 * <p/>
 * <p>
 * The conversion characters and their meanings are:
 * </p>
@@ -349,7 +349,7 @@
 *        followed by a digit.
 * <dt>c,C<dd>The integer argument is converted to a
 *        char and the result is written.
 *
 * <p/>
 * <dt>s,S<dd>The argument is taken to be a string and
 *        bytes from the string are written until the
 *        end of the string or the number of bytes
@@ -443,13 +443,19 @@
 */
public final class PrintfFormat
{
    /** Vector of control strings and format literals. */
    /**
     * Vector of control strings and format literals.
     */
    private Vector vFmt = new Vector();
    /** Character position.  Used by the constructor. */
    /**
     * Character position.  Used by the constructor.
     */
    private int cPos = 0;
    /** Character position.  Used by the constructor. */
    /**
     * Character position.  Used by the constructor.
     */
    private DecimalFormatSymbols dfs = null;
    /**
@@ -459,8 +465,9 @@
     * unpaired percent signs.  A pair of successive
     * percent signs designates a single percent sign in
     * the format.
     *
     * @param fmtArg  Control string.
     * @exception IllegalArgumentException if the control
     * @throws IllegalArgumentException if the control
     * string is null, zero length, or otherwise
     * malformed.
     */
@@ -476,8 +483,9 @@
     * unpaired percent signs.  A pair of successive
     * percent signs designates a single percent sign in
     * the format.
     *
     * @param fmtArg  Control string.
     * @exception IllegalArgumentException if the control
     * @throws IllegalArgumentException if the control
     * string is null, zero length, or otherwise
     * malformed.
     */
@@ -590,6 +598,7 @@
     * of the String <code>s</code>, the next unpaired
     * percent sign, or at the end of the String if the
     * last character is a percent sign.
     *
     * @param s  Control string.
     * @param start Position in the string
     *     <code>s</code> to begin looking for the start
@@ -616,6 +625,7 @@
     * Integer, Long, Float, Double, and Character
     * arguments are treated as wrappers for primitive
     * types.
     *
     * @param o The array of objects to format.
     * @return  The formatted String.
     */
@@ -713,6 +723,7 @@
    /**
     * Format nothing.  Just use the control string.
     *
     * @return  the formatted String.
     */
    public String sprintf()
@@ -741,9 +752,10 @@
    /**
     * Format an int.
     *
     * @param x The int to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *     conversion character is f, e, E, g, G, s,
     *     or S.
     */
@@ -776,9 +788,10 @@
    /**
     * Format an long.
     *
     * @param x The long to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *     conversion character is f, e, E, g, G, s,
     *     or S.
     */
@@ -811,9 +824,10 @@
    /**
     * Format a double.
     *
     * @param x The double to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *     conversion character is c, C, s, S,
     *     d, d, x, X, or o.
     */
@@ -846,9 +860,10 @@
    /**
     * Format a String.
     *
     * @param x The String to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *   conversion character is neither s nor S.
     */
    public String sprintf(String x) throws IllegalArgumentException
@@ -885,9 +900,10 @@
     * Strings using an internal formatting method for
     * Strings. Otherwise use the default formatter
     * (use toString).
     *
     * @param x the Object to format.
     * @return  the formatted String.
     * @exception IllegalArgumentException if the
     * @throws IllegalArgumentException if the
     *    conversion character is inappropriate for
     *    formatting an unwrapped value.
     */
@@ -946,13 +962,13 @@
    }
    /**
     * <p>
     * <p/>
     * ConversionSpecification allows the formatting of
     * a single primitive or object embedded within a
     * string.  The formatting is controlled by a
     * format string.  Only one Java primitive or
     * object can be formatted at a time.
     * <p>
     * <p/>
     * A format string is a Java string that contains
     * a control string.  The control string starts at
     * the first percent sign (%) in the string,
@@ -964,12 +980,12 @@
     * <li>precedes a sequence of characters that parses
     *     as a valid control string.
     * </ol>
     * <p>
     * <p/>
     * A control string takes the form:
     * <pre> % ['-+ #0]* [0..9]* { . [0..9]* }+
     *                { [hlL] }+ [idfgGoxXeEcs]
     * </pre>
     * <p>
     * <p/>
     * The behavior is like printf.  One (hopefully the
     * only) exception is that the minimum number of
     * exponent digits is 3 instead of 2 for e and E
@@ -980,7 +996,9 @@
     */
    private class ConversionSpecification
    {
        /** Default precision. */
        /**
         * Default precision.
         */
        private final static int defaultDigits = 6;
        /**
@@ -1098,7 +1116,9 @@
         */
        private boolean optionalL = false;
        /** Control string type. */
        /**
         * Control string type.
         */
        private char conversionCharacter = '\0';
        /**
@@ -1107,7 +1127,9 @@
         */
        private int pos = 0;
        /** Literal or control format string. */
        /**
         * Literal or control format string.
         */
        private String fmt;
        /**
@@ -1123,9 +1145,10 @@
         * The argument must begin with a % and end
         * with the conversion character for the
         * conversion specification.
         *
         *  @param fmtArg  String specifying the
         *     conversion specification.
         *  @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     input string is null, zero length, or
         *     otherwise malformed.
         */
@@ -1184,6 +1207,7 @@
        /**
         * Set the String for this instance.
         *
         * @param s the String to store.
         */
        void setLiteral(String s)
@@ -1284,6 +1308,7 @@
         * Check whether the specifier has a variable
         * field width that is going to be set by an
         * argument.
         *
         * @return <code>true</code> if the conversion
         *   uses an * field width; otherwise
         *   <code>false</code>.
@@ -1297,6 +1322,7 @@
         * Set the field width with an argument.  A
         * negative field width is taken as a - flag
         * followed by a positive field width.
         *
         * @param fw the field width.
         */
        void setFieldWidthWithArg(int fw)
@@ -1314,6 +1340,7 @@
         * Check whether the specifier has a variable
         * precision that is going to be set by an
         * argument.
         *
         * @return <code>true</code> if the conversion
         *   uses an * precision; otherwise
         *   <code>false</code>.
@@ -1326,6 +1353,7 @@
        /**
         * Set the precision with an argument.  A
         * negative precision will be changed to zero.
         *
         * @param pr the precision.
         */
        void setPrecisionWithArg(int pr)
@@ -1337,9 +1365,10 @@
        /**
         * Format an int argument using this conversion
         *  specification.
         *
         * @param s the int to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         */
        String internalsprintf(int s) throws IllegalArgumentException
@@ -1409,9 +1438,10 @@
        /**
         * Format a long argument using this conversion
         * specification.
         *
         * @param s the long to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         */
        String internalsprintf(long s) throws IllegalArgumentException
@@ -1481,9 +1511,10 @@
        /**
         * Format a double argument using this conversion
         * specification.
         *
         * @param s the double to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is c, C, s, S, i, d,
         *     x, X, or o.
         */
@@ -1521,9 +1552,10 @@
        /**
         * Format a String argument using this conversion
         * specification.
         *
         * @param s the String to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *   conversion character is neither s nor S.
         */
        String internalsprintf(String s) throws IllegalArgumentException
@@ -1545,9 +1577,10 @@
        /**
         * Format an Object argument using this conversion
         * specification.
         *
         * @param s the Object to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         * @throws IllegalArgumentException if the
         *     conversion character is neither s nor S.
         */
        String internalsprintf(Object s)
@@ -1578,12 +1611,12 @@
         * is ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the number of digits
         * to appear after the radix character.  Padding is
         * with trailing 0s.
@@ -1974,6 +2007,7 @@
         * the input double value is an infinity,
         * not-a-number, or a finite double and formats
         * each type of input appropriately.
         *
         * @param x the double value to be formatted.
         * @return the converted double value.
         */
@@ -2038,16 +2072,16 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear after the radix character.
         * Padding is with trailing 0s.
         *
         * <p/>
         * The behavior is like printf.  One (hopefully the
         * only) exception is that the minimum number of
         * exponent digits is 3 instead of 2 for e and E
@@ -2614,6 +2648,7 @@
         * Check to see if the digits that are going to
         * be truncated because of the precision should
         * force a round in the preceding digits.
         *
         * @param ca1 the array of digits
         * @param icarry the index of the first digit that
         *     is to be truncated from the print
@@ -2659,6 +2694,7 @@
         * is not quite finished because the symbolic
         * carry may change the length of the string and
         * change the exponent (in e format).
         *
         * @param cLast index of the last digit changed
         *     by the round
         * @param cFirst index of the first digit allowed
@@ -2739,6 +2775,7 @@
         * the input double value is an infinity,
         * not-a-number, or a finite double and formats
         * each type of input appropriately.
         *
         * @param x the double value to be formatted.
         * @param eChar an 'e' or 'E' to use in the
         *     converted double value.
@@ -2795,6 +2832,7 @@
        /**
         * Apply zero or blank, left or right padding.
         *
         * @param ca4 array of characters before padding is
         *     finished
         * @param noDigits NaN or signed Inf
@@ -2879,6 +2917,7 @@
        /**
         * Format method for the f conversion character.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -2890,6 +2929,7 @@
        /**
         * Format method for the e or E conversion
         * character.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -2906,7 +2946,7 @@
        /**
         * Format method for the g conversion character.
         *
         * <p/>
         * For g format, the flag character '-', means that
         *  the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -2918,15 +2958,16 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear after the radix character.
         * Padding is with trailing 0s.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -3115,7 +3156,7 @@
        /**
         * Format method for the d conversion specifer and
         * short argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3127,14 +3168,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3146,7 +3188,7 @@
        /**
         * Format method for the d conversion character and
         * long argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3158,14 +3200,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3177,7 +3220,7 @@
        /**
         * Format method for the d conversion character and
         * int argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3189,14 +3232,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -3208,6 +3252,7 @@
        /**
         * Utility method for formatting using the d
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
@@ -3369,20 +3414,21 @@
        /**
         * Format method for the x conversion character and
         * short argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3479,20 +3525,21 @@
        /**
         * Format method for the x conversion character and
         * long argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3636,20 +3683,21 @@
        /**
         * Format method for the x conversion character and
         * int argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -3753,6 +3801,7 @@
        /**
         * Utility method for formatting using the x
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
@@ -3881,21 +3930,22 @@
        /**
         * Format method for the o conversion character and
         * short argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3948,21 +3998,22 @@
        /**
         * Format method for the o conversion character and
         * long argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -4095,21 +4146,22 @@
        /**
         * Format method for the o conversion character and
         * int argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -4192,6 +4244,7 @@
        /**
         * Utility method for formatting using the o
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
@@ -4289,17 +4342,18 @@
        /**
         * Format method for the c conversion character and
         * char argument.
         *
         * <p/>
         * The only flag character that affects c format is
         * the '-', meaning that the output should be left
         * justified within the field.  The default is to
         * pad with blanks on the left.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  Padding is with
         * blanks by default.  The default width is 1.
         *
         * <p/>
         * The precision, if set, is ignored.
         *
         * @param x the char to format.
         * @return the formatted String.
         */
@@ -4340,23 +4394,24 @@
        /**
         * Format method for the s conversion character and
         * String argument.
         *
         * <p/>
         * The only flag character that affects s format is
         * the '-', meaning that the output should be left
         * justified within the field.  The default is to
         * pad with blanks on the left.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is the
         * smaller of the number of characters in the the
         * input and the precision.  Padding is with blanks
         * by default.
         *
         * <p/>
         * The precision, if set, specifies the maximum
         * number of characters to be printed from the
         * string.  A null digit string is treated
         * as a 0.  The default is not to set a maximum
         * number of characters to be printed.
         *
         * @param x the String to format.
         * @return the formatted String.
         */
@@ -4449,6 +4504,7 @@
        /**
         * Check for a conversion character.  If it is
         * there, store it.
         *
         * @return <code>true</code> if the conversion
         *     character is there, and
         *     <code>false</code> otherwise.
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/StringUtils.java
@@ -1,22 +1,22 @@
package com.ximple.eofms.util;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Collection;
import java.util.Locale;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.net.URLEncoder;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharacterCodingException;
import java.nio.CharBuffer;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.lang.reflect.Array;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public abstract class StringUtils
{
@@ -601,8 +601,7 @@
            if (null == decoded)
            {
                return null;
            }
            else
            } else
            {
                return new String(decoded, StringUtils.ENCODING_UTF_8);
            }
@@ -668,7 +667,6 @@
    }
    /**
     *
     * @since 1.6
     */
    public static String decodeHtml(String source)
@@ -731,8 +729,7 @@
                        {
                            result.append(entity);
                        }
                    }
                    else
                    } else
                    {
                        // try to decode the entity as a literal
                        Character decoded = HTML_DECODE_MAP.get(entity);
@@ -746,13 +743,11 @@
                            result.append(entity);
                        }
                    }
                }
                else
                } else
                {
                    break;
                }
            }
            else
            } else
            {
                break;
            }
@@ -761,8 +756,7 @@
        if (null == result)
        {
            return source;
        }
        else if (current_index < source.length())
        } else if (current_index < source.length())
        {
            result.append(source.substring(current_index));
        }
@@ -1021,8 +1015,7 @@
        if (null == encoded_string)
        {
            return source;
        }
        else
        } else
        {
            int difference = string_to_encode_array.length-(last_match+1);
            if (difference > 0)
@@ -1052,6 +1045,7 @@
    private static interface EncoderFallbackHandler
    {
        abstract boolean hasFallback(char character);
        abstract void appendFallback(StringBuilder encodedBuffer, char character);
    }
@@ -1177,8 +1171,7 @@
            if (-1 == substring_index)
            {
                break;
            }
            else
            } else
            {
                current_index = substring_index + substring.length();
                count++;
@@ -1243,8 +1236,7 @@
        {
            source_lookup_reference = source.toLowerCase();
            seperator = seperator.toLowerCase();
        }
        else
        } else
        {
            source_lookup_reference = source;
        }
@@ -1258,8 +1250,7 @@
                element = new String(source.substring(current_index, source.length()));
                substrings.add(element);
                current_index = source.length() + 1;
            }
            else
            } else
            {
                element = new String(source.substring(current_index, delimiter_index));
                substrings.add(element);
@@ -1484,8 +1475,7 @@
        {
            source_lookup_reference = source.toLowerCase();
            stringToStrip = stringToStrip.toLowerCase();
        }
        else
        } else
        {
            source_lookup_reference = source;
        }
@@ -1502,8 +1492,7 @@
                   new_index == last_index+strip_length);
            return source.substring(last_index+strip_length);
        }
        else
        } else
        {
            return source;
        }
@@ -1554,8 +1543,7 @@
        {
            source_lookup_reference = source.toLowerCase();
            stringToStrip = stringToStrip.toLowerCase();
        }
        else
        } else
        {
            source_lookup_reference = source;
        }
@@ -1573,8 +1561,7 @@
                   new_index == last_index-strip_length);
            return source.substring(0, last_index);
        }
        else
        } else
        {
            return source;
        }
@@ -1753,8 +1740,7 @@
        if (0 == collection.size())
        {
            return "";
        }
        else
        } else
        {
            StringBuilder result = new StringBuilder();
            for (Object element : collection)
@@ -1829,8 +1815,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int                current_index = 0;
            String            array_value = null;
@@ -1840,8 +1825,7 @@
                if (null == array[current_index])
                {
                    result.append("null");
                }
                else
                } else
                {
                    array_value = String.valueOf(array[current_index]);
                    if (encodeStrings)
@@ -1859,8 +1843,7 @@
            if (null == array[current_index])
            {
                result.append("null");
            }
            else
            } else
            {
                array_value = String.valueOf(array[current_index]);
                if (encodeStrings)
@@ -1899,8 +1882,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -1939,8 +1921,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -1979,8 +1960,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -2019,8 +1999,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -2059,8 +2038,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -2099,8 +2077,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -2139,8 +2116,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            String result = "";
@@ -2199,8 +2175,7 @@
        if (0 == array.length)
        {
            return "";
        }
        else
        } else
        {
            int current_index = 0;
            StringBuilder    result = new StringBuilder();
@@ -2261,8 +2236,7 @@
        {
            source_lookup_reference = source.toLowerCase();
            substring = substring.toLowerCase();
        }
        else
        } else
        {
            source_lookup_reference = source;
        }
@@ -2280,8 +2254,7 @@
            if (-1 == substring_index)
            {
                break;
            }
            else
            } else
            {
                current_index = substring_index + substring.length();
                indices[counter] = substring_index;
@@ -2408,8 +2381,7 @@
        if (null == included)
        {
            accepted = true;
        }
        else
        } else
        {
            for (Pattern pattern : included)
            {
@@ -2510,8 +2482,7 @@
                if (url_matcher.groupCount() > 1)
                {
                    visual_url = url_matcher.group(2);
                }
                else
                } else
                {
                    visual_url = actual_url;
                }
@@ -2532,8 +2503,7 @@
                if (pattern.equals(BBCODE_BAREURL))
                {
                    sb.append(source.substring(last, url_matcher.start(1)));
                }
                else
                } else
                {
                    sb.append(source.substring(last, url_matcher.start(0)));
                }
@@ -2553,8 +2523,7 @@
                if (visual_url.length() <= max_length || !shorten)
                {
                    sb.append(visual_url);
                }
                else
                } else
                {
                    String ellipsis = "...";
                    int query_index = visual_url.indexOf("?");
@@ -2584,8 +2553,7 @@
                if (pattern.equals(BBCODE_BAREURL))
                {
                    last = url_matcher.end(1);
                }
                else
                } else
                {
                    last = url_matcher.end(0);
                }
@@ -2643,16 +2611,13 @@
            if (next < begin && next < end)
            {
                endIndex = next;
            }
            else if (begin < next && begin < end)
            } else if (begin < next && begin < end)
            {
                endIndex = begin;
            }
            else if (end < next && end < begin)
            } else if (end < next && end < begin)
            {
                endIndex = end;
            }
            else
            } else
            {
                endIndex = resultLowerCopy.length();
            }
@@ -2768,8 +2733,7 @@
        if (0 == last_tab_index)
        {
            return line;
        }
        else
        } else
        {
            result.append(line.substring(last_tab_index));
        }
@@ -2800,7 +2764,7 @@
     * are split apart at the earliest wordbreak or at maxLength, whichever is
     * sooner. If the width specified is less than 5 or greater than the input
     * Strings length the string will be returned as is.
     * <p>
     * <p/>
     * Please note that this method can be lossy - trailing spaces on wrapped
     * lines may be trimmed.
     *
@@ -2814,12 +2778,10 @@
        if (input == null)
        {
            return "";
        }
        else if (width < 5)
        } else if (width < 5)
        {
            return input;
        }
        else if (width >= input.length())
        } else if (width >= input.length())
        {
            return input;
        }
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TPCLIDConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWD97GeometryConverterDecorator.java
@@ -7,7 +7,6 @@
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.util.Assert;
import com.ximple.eofms.util.TWDDatumConverter;
import com.ximple.io.dgn7.GeometryConverter;
public class TWD97GeometryConverterDecorator implements GeometryConverter
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWDDatumConverter.java
@@ -492,6 +492,7 @@
    /**
     * ¥ÑTM2®y¼ÐÂà´«¦ÜTWD97®y¼Ð
     *
     * @param pt TM2¦ì¸m
     * @return ·sªºTWD97®y¼Ð
     */