forked from geodmms/xdgnjobs

Dennis Kao
2013-08-06 daf48e225fc4323cb986a5f5a18be279fb1a40a7
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
@@ -115,7 +115,7 @@
                                                         boolean profileMode,
                                                         boolean useTransform) {
        return new OracleConvertPostGISJobContext(getDataPath(),
                                                  getTargetDataStore(), targetSchemaName, filterPath, profileMode, useTransform);
            getTargetDataStore(), targetSchemaName, filterPath, profileMode, useTransform);
    }
    protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException {
@@ -187,6 +187,11 @@
        // Log the time the job started
        logger.info(jobName + " fired at " + new Date());
        extractJobConfiguration(jobDetail);
        if (isIgnoreDBETL()) {
            return;
        }
        createSourceDataStore();
        createTargetDataStore();
        if (getSourceDataStore() == null) {
@@ -234,18 +239,17 @@
                OracleConvertPostGISJobContext jobContext =
                    (OracleConvertPostGISJobContext) prepareJobContext(targetSchemaName, _filterPath,
                                                                       isProfileMode(), isTransformed());
                        isProfileMode(), isTransformed());
                jobContext.setSourceDataStore(getSourceDataStore());
                // jobContext.setConvertElementIn(_convertElementIn);
                jobContext.setElementLogging(checkElementLogging());
                jobContext.setExecutionContext(context);
                createHibernateSequence(jobContext);
                long tStep = System.currentTimeMillis();
                if (isCopyConnectivityMode())
                {
                if (isCopyConnectivityMode()) {
                    copyConnectivity(jobContext);
                }
@@ -344,8 +348,8 @@
    private void copyConnectivity(OracleConvertPostGISJobContext jobContext) throws SQLException {
        Connection connection = jobContext.getOracleConnection();
        ResultSet rsMeta = connection.getMetaData().getTables(null, "BASEDB",
                                                              AbstractOracleJobContext.CONNECTIVITY_WEBCHECK_NAME + "%",
                                                              new String[]{"TABLE"});
            AbstractOracleJobContext.CONNECTIVITY_WEBCHECK_NAME + "%",
            new String[]{"TABLE"});
        boolean found = false;
        try {
@@ -384,16 +388,15 @@
    }
        private void createHibernateSequence(OracleConvertPostGISJobContext jobContext) throws SQLException {
    private void createHibernateSequence(OracleConvertPostGISJobContext jobContext) throws SQLException {
        Connection connection = jobContext.getOracleConnection();
        try {
            Statement stmt = connection.createStatement();
            stmt.execute(AbstractOracleJobContext.CREATE_HIBERNATE_SEQUENCE);
            stmt.close();
        } catch (SQLException e)
        {
            logger.warn("HIBERNATE_SEQUENCE is already exist.");
        } catch (SQLException e) {
            logger.warn("HIBERNATE_SEQUENCE is already exist.");
        }
    }
@@ -401,7 +404,7 @@
                                 String querySchema, String targetSchemaName) throws SQLException {
        int order = 0;
        OrderedMap map = getBlobStorageList(jobContext.getOracleConnection(),
                                            querySchema, "SD$SPACENODES", null);
            querySchema, "SD$SPACENODES", null);
        logger.info("begin convert job:[" + map.size() + "]:testmode=" + _testMode);
@@ -409,16 +412,16 @@
        int step = total / 100;
        int current = 0;
        if (total == 0)  {
        if (total == 0) {
            logger.warn("SELECT COUNT FROM " + querySchema + ".SD$SPACENODES is zero.");
            return;
        }
            logger.warn("SELECT COUNT FROM " + querySchema + ".SD$SPACENODES is " + map.size() );
        logger.warn("SELECT COUNT FROM " + querySchema + ".SD$SPACENODES is " + map.size());
        //jobContext.startTransaction();
        jobContext.setCurrentSchema(querySchema);
        jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", 0);
        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();) {
        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext(); ) {
            it.next();
            Pair pair = (Pair) it.getValue();
@@ -444,16 +447,14 @@
                System.runFinalization();
            }
            if( step != 0)
            {
            if (step != 0) {
                int now = order % step;
                if (now != current) {
                    current = now;
                    jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", current);
                }
            }else
            {
            } else {
                jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", current);
                current++;
            }
@@ -727,7 +728,7 @@
            if (dgnFile.isDirectory()) continue;
            IndexDgnConvertPostGISJobContext convertContext =
                new IndexDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName,
                                                     isProfileMode(), isTransformed());
                    isProfileMode(), isTransformed());
            logger.info("--- start index dgnfile-" + dgnFile.toString() + " ---");
            FileInputStream fs = null;
            FileChannel fc = null;
@@ -774,8 +775,7 @@
            } finally {
                convertContext.closeFeatureWriter();
                if (reader != null)
                {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e) {
@@ -851,7 +851,7 @@
        //    }
        //} else {
        //    if (element instanceof ShapeElement) {
                convertContext.putFeatureCollection(element);
        convertContext.putFeatureCollection(element);
        //    }
        //}
    }
@@ -886,7 +886,7 @@
            GeneralDgnConvertPostGISJobContext convertContext =
                new GeneralDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName,
                                                       isProfileMode(), isTransformed());
                    isProfileMode(), isTransformed());
            logger.info("--- start other dgnfile-" + dgnFile.toString() + " ---");
            FileInputStream fs = null;
            FileChannel fc;
@@ -932,8 +932,7 @@
            } finally {
                convertContext.closeFeatureWriter();
                if (reader != null)
                {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e) {
@@ -1069,7 +1068,7 @@
        for (File dgnFile : dgnFiles) {
            FeatureDgnConvertPostGISJobContext convertContext =
                new FeatureDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), targetSchemaName, _filterPath,
                                                       isProfileMode(), isTransformed());
                    isProfileMode(), isTransformed());
            logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
            try {
                convertContext.setExecutionContext(context);