forked from geodmms/xdgnjobs

?? ?
2008-08-22 af57baed0d81ffaf7ae6b889dd26d9647a8862f0
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TcbElement.java
@@ -39,7 +39,7 @@
        java.nio.charset.Charset.forName("US-ASCII");
        // ASCIIEncoding encode = new ASCIIEncoding();
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        sb.append((char) master[0]);
@@ -54,7 +54,7 @@
        sub[0] = (byte) (raw[561] & 0x00ff);
        sub[1] = (byte) (raw[561] >> 8 & 0x00ff);
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        sb.append((char) sub[0]);
        sb.append((char) sub[0]);
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextElement.java
@@ -164,7 +164,7 @@
    public String getText()
    {
        StringBuffer val = new StringBuffer();
        StringBuilder val = new StringBuilder();
        char[] temp;
        int num = getTextLength();
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/PrintfFormat.java
@@ -635,7 +635,7 @@
        ConversionSpecification cs = null;
        char c = 0;
        int i = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -731,7 +731,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -764,7 +764,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -800,7 +800,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -836,7 +836,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -871,7 +871,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -912,7 +912,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -1223,7 +1223,7 @@
         */
        String getLiteral()
        {
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            int i = 0;
            while (i < fmt.length())
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java
@@ -103,7 +103,7 @@
        {
            TextNodeElement nodeElement = (TextNodeElement) element;
            String[] texts = nodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            for (String text : texts)
            {
                if (sb.length() != 0)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java
@@ -184,7 +184,7 @@
        }
    }
    protected abstract AbstractOracleJobContext prepareJobContext(String filterPath);
    protected abstract AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath);
    protected static byte[] getBytesFromBLOB(BLOB blob) throws SQLException
    {
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.geotools.data.DataStore;
import org.geotools.data.Transaction;
import org.geotools.data.postgis.PostgisDataStore;
import org.geotools.data.postgis.PostgisDataStoreFactory;
import org.geotools.feature.IllegalAttributeException;
@@ -62,6 +63,7 @@
{
    final static Log logger = LogFactory.getLog(OracleConvertDgn2PostGISJob.class);
    private static final String XGVERSION_NAME = "xgversion";
    private static final String PGHOST = "PGHOST";
    private static final String PGDDATBASE = "PGDDATBASE";
    private static final String PGPORT = "PGPORT";
@@ -105,16 +107,9 @@
        return logger;
    }
    protected AbstractOracleJobContext prepareJobContext(String filterPath)
    protected AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath)
    {
        /*
        if (oracleJobContext == null)
        {
            oracleJobContext = new OracleConvertPostGISJobContext(getDataPath(), getTargetDataStore(), filterPath);
        }
        return oracleJobContext;
        */
        return new OracleConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema, filterPath);
        return new OracleConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName, filterPath);
    }
    protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException
@@ -209,22 +204,26 @@
        }
        long t1 = System.currentTimeMillis();
        String targetSchemaName = null;
        try
        {
            logger.info("-- step:clearOutputDatabase --");
            clearOutputDatabase();
            targetSchemaName = determineTargetSchemaName();
            if (checkConvertDB())
            {
                logger.info("-- step:convertOracleDB --");
                OracleConvertPostGISJobContext jobContext =
                        (OracleConvertPostGISJobContext) prepareJobContext(_filterPath);
                        (OracleConvertPostGISJobContext) prepareJobContext(targetSchemaName, _filterPath);
                jobContext.setSourceDataStore(getSourceDataStore());
                // jobContext.setConvertElementIn(_convertElementIn);
                jobContext.setElementLogging(checkElementLogging());
                jobContext.setExecutionContext(context);
                if (isCopyConnectivityMode())
                    copyConnectivity(jobContext);
                for (String orgSchema : _orgSchema)
                {
@@ -239,15 +238,15 @@
            if (checkConvertFile())
            {
                logger.info("-- step:convertIndexDesignFile --");
                convertIndexDesignFile(context);
                convertIndexDesignFile(context, targetSchemaName);
                logger.info("-- step:convertOtherDesignFile --");
                convertOtherDesignFile(context);
                convertOtherDesignFile(context, targetSchemaName);
            }
            if (checkConvertElementIn())
            {
                logger.info("-- step:convertFeatureDesignFile --");
                convertFeatureDesignFile(context);
                convertFeatureDesignFile(context, targetSchemaName);
            }
            if (checkCreateDummy())
@@ -330,7 +329,7 @@
    }
    private void exetcuteConvert(OracleConvertPostGISJobContext jobContext,
                                 String querySchema, String dataPath) throws SQLException
                                 String querySchema, String targetSchemaName) throws SQLException
    {
        int order = 0;
        OrderedMap map = getBlobStorageList(jobContext.getOracleConnection(),
@@ -638,7 +637,7 @@
     * @throws org.quartz.JobExecutionException
     *          exception
     */
    private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException
    private void convertIndexDesignFile(JobExecutionContext context, String targetSchemaName) throws JobExecutionException
    {
        File indexDir = new File(getDataPath(), "index");
        if (!indexDir.exists())
@@ -663,7 +662,7 @@
        for (File dgnFile : dgnFiles)
        {
            IndexDgnConvertPostGISJobContext convertContext =
                    new IndexDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema);
                    new IndexDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName);
            logger.debug("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
@@ -778,7 +777,7 @@
     * @throws org.quartz.JobExecutionException
     *          exception
     */
    private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException
    private void convertOtherDesignFile(JobExecutionContext context, String targetSchemaName) throws JobExecutionException
    {
        File otherDir = new File(getDataPath(), "other");
        if (!otherDir.exists())
@@ -803,7 +802,7 @@
        for (File dgnFile : dgnFiles)
        {
            GeneralDgnConvertPostGISJobContext convertContext =
                    new GeneralDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema);
                    new GeneralDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName);
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
@@ -961,7 +960,7 @@
        }
    }
    private void convertFeatureDesignFile(JobExecutionContext context) throws JobExecutionException
    private void convertFeatureDesignFile(JobExecutionContext context, String targetSchemaName) throws JobExecutionException
    {
        File elminDir = new File(getDataPath(), "elmin");
        if (!elminDir.exists())
@@ -986,7 +985,7 @@
        for (File dgnFile : dgnFiles)
        {
            FeatureDgnConvertPostGISJobContext convertContext =
                    new FeatureDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema, _filterPath);
                    new FeatureDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName, _filterPath);
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try
            {
@@ -1155,4 +1154,72 @@
        }
    }
    private String determineTargetSchemaName() throws IOException
    {
        if (targetDataStore == null) return null;
        Connection connection = null;
        ResultSet rs = null;
        String targetSchema = null;
        boolean needCreate = false;
        try
        {
            connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT);
            rs = connection.getMetaData().getTables(null, _pgSchema, XGVERSION_NAME, new String[] {"TABLE"});
            if (!rs.next()) needCreate = true;
            if (needCreate)
                createXGeosVersionTable(connection, _pgSchema);
            StringBuilder sbSQL = new StringBuilder();
        } catch (SQLException e) {
            logger.warn(e.getMessage(), e);
        } finally {
        if (connection != null) try { connection.close(); } catch (SQLException e) {};
        }
        return targetSchema;
    }
    public String encodeSchemaTableName(String schemaName, String tableName)
    {
        return "\"" + schemaName + "\".\"" + tableName + "\"";
    }
    private void createXGeosVersionTable(Connection connection, String pgSchema) throws SQLException
    {
        Statement stmt = null;
        StringBuilder sql = new StringBuilder("CREATE TABLE ");
        sql.append(encodeSchemaTableName(pgSchema, XGVERSION_NAME));
        sql.append(" ( vsid serial PRIMARY KEY, ");
        sql.append(" vsschema character varying(64) NOT NULL, ");
        sql.append(" vsstatus smallint NOT NULL, ");
        sql.append(" vstimestamp timestamp with time zone ) ");
        try
        {
            stmt = connection.createStatement();
            stmt.executeUpdate(sql.toString());
            sql = new StringBuilder("ALTER TABLE ");
            sql.append(encodeSchemaTableName(pgSchema, XGVERSION_NAME));
            sql.append(" OWNER TO spatialdb");
            stmt.executeUpdate(sql.toString());
            sql = new StringBuilder("GRANT ALL ON TABLE ");
            sql.append(encodeSchemaTableName(pgSchema, XGVERSION_NAME));
            sql.append(" TO public");
            stmt.executeUpdate(sql.toString());
            sql = new StringBuilder("INSERT INTO ");
            sql.append(encodeSchemaTableName(pgSchema, XGVERSION_NAME));
            sql.append(" ('vsschema', 'vsstatus' ) VALUES (");
            sql.append("'gisrepo1', 0 ");
            stmt.executeUpdate(sql.toString());
            sql = new StringBuilder("INSERT INTO ");
            sql.append(encodeSchemaTableName(pgSchema, XGVERSION_NAME));
            sql.append(" ('vsschema', 'vsstatus' ) VALUES (");
            sql.append("'gisrepo2', 0 ");
            stmt.executeUpdate(sql.toString());
        } finally {
            if (stmt != null) stmt.close();
        }
    }
}
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/GeneralDgnConvertMySQLJobContext.java
@@ -280,7 +280,7 @@
            double angle = textNodeElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            String[] texts = textNodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            for (String text : texts)
            {
                if (sb.length() != 0)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/GeneralDgnConvertOraSDOJobContext.java
@@ -280,7 +280,7 @@
            double angle = textNodeElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            String[] texts = textNodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            for (String text : texts)
            {
                if (sb.length() != 0)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java
@@ -321,7 +321,7 @@
            result.add(sqlStr);
        }
        StringBuffer sql = new StringBuffer("CREATE TABLE ");
        StringBuilder sql = new StringBuilder("CREATE TABLE ");
        sql.append(encodeSchemaTableName(tableName));
        sql.append(" ( gid serial PRIMARY KEY, ");
        sql.append(makeNonGeomSqlCreate(attributeType));
@@ -349,7 +349,7 @@
            String indexName = tableName.replace('-', '_');
            //also build a spatial index on each geometry column.
            sql = new StringBuffer("CREATE INDEX \"spatial_");
            sql = new StringBuilder("CREATE INDEX \"spatial_");
            sql.append(indexName);
            sql.append("_");
            sql.append(anAttributeType.getLocalName().toLowerCase());
@@ -449,10 +449,10 @@
    }
    private StringBuffer makeNonGeomSqlCreate(AttributeType[] attributeType)
    private StringBuilder makeNonGeomSqlCreate(AttributeType[] attributeType)
            throws IOException
    {
        StringBuffer buf = new StringBuffer("");
        StringBuilder buf = new StringBuilder("");
        for (AttributeType anAttributeType : attributeType)
        {
@@ -587,7 +587,7 @@
        String attrValue;
        StringBuffer statementSQL = new StringBuffer("INSERT INTO " + tableName + " (");
        StringBuilder statementSQL = new StringBuilder("INSERT INTO " + tableName + " (");
        // encode insertion for attributes, but remember to avoid auto-increment ones,
        // they may be included in the feature type as well
@@ -650,7 +650,7 @@
        String attrValue;
        StringBuffer statementSQL = new StringBuffer("INSERT INTO " + tableName + " (");
        StringBuilder statementSQL = new StringBuilder("INSERT INTO " + tableName + " (");
        // encode insertion for attributes, but remember to avoid auto-increment ones,
        // they may be included in the feature type as well
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java
@@ -322,7 +322,7 @@
            result.add(sqlStr);
        }
        StringBuffer sql = new StringBuffer("CREATE TABLE ");
        StringBuilder sql = new StringBuilder("CREATE TABLE ");
        sql.append(encodeSchemaTableName(tableName));
        sql.append(" ( gid serial PRIMARY KEY, ");
        sql.append(makeNonGeomSqlCreate(attributeType));
@@ -350,7 +350,7 @@
            String indexName = tableName.replace('-', '_');
            //also build a spatial index on each geometry column.
            sql = new StringBuffer("CREATE INDEX \"");
            sql = new StringBuilder("CREATE INDEX \"");
            sql.append("spatial_");
            sql.append(indexName);
            sql.append("_");
@@ -651,7 +651,7 @@
        String attrValue;
        StringBuffer statementSQL = new StringBuffer("INSERT INTO " + tableName + " (");
        StringBuilder statementSQL = new StringBuilder("INSERT INTO " + tableName + " (");
        // encode insertion for attributes, but remember to avoid auto-increment ones,
        // they may be included in the feature type as well
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java
@@ -321,7 +321,7 @@
            double angle = textNodeElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            String[] texts = textNodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            for (String text : texts)
            {
                if (sb.length() != 0)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java
@@ -315,7 +315,7 @@
            double angle = textNodeElement.getRotationAngle();
            angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue();
            String[] texts = textNodeElement.getTextArray();
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            for (String text : texts)
            {
                if (sb.length() != 0)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java
@@ -635,7 +635,7 @@
        ConversionSpecification cs = null;
        char c = 0;
        int i = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -731,7 +731,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -764,7 +764,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -800,7 +800,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -836,7 +836,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -871,7 +871,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -912,7 +912,7 @@
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char c = 0;
        StringBuffer sb = new StringBuffer();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements())
        {
@@ -1223,7 +1223,7 @@
         */
        String getLiteral()
        {
            StringBuffer sb = new StringBuffer();
            StringBuilder sb = new StringBuilder();
            int i = 0;
            while (i < fmt.length())