From 7c489a7b30ed09100ad58fedb7e40281f823e91d Mon Sep 17 00:00:00 2001
From: Dennis Kao <ulysseskao@gmail.com>
Date: Thu, 26 Sep 2013 18:51:16 +0800
Subject: [PATCH] update for dist id

---
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2EdbGeoJob.java |  100 +++++++++-----------------------------------------
 1 files changed, 18 insertions(+), 82 deletions(-)

diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2EdbGeoJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2EdbGeoJob.java
index dee8809..48edd57 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2EdbGeoJob.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2EdbGeoJob.java
@@ -113,7 +113,7 @@
                                                          boolean profileMode,
                                                          boolean useTransform) {
         return new OracleConvertEdbGeoJobContext(getDataPath(),
-                                                  getTargetDataStore(), targetSchemaName, filterPath, profileMode, useTransform);
+            getTargetDataStore(), targetSchemaName, filterPath, profileMode, useTransform);
     }
 
     protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException {
@@ -232,18 +232,20 @@
 
                 OracleConvertEdbGeoJobContext jobContext =
                     (OracleConvertEdbGeoJobContext) prepareJobContext(targetSchemaName, _filterPath,
-                                                                       isProfileMode(), isTransformed());
+                        isProfileMode(), isTransformed());
                 jobContext.setSourceDataStore(getSourceDataStore());
                 // jobContext.setConvertElementIn(_convertElementIn);
                 jobContext.setElementLogging(checkElementLogging());
                 jobContext.setExecutionContext(context);
 
                 createHibernateSequence(jobContext);
+                fetchTPData(jobContext);
+                logger.info("TPC DIST:" + jobContext.getDistId() + ":" +
+                    ((jobContext.getDistName() == null) ? "NULL" : jobContext.getDistName()));
 
                 long tStep = System.currentTimeMillis();
 
-                if (isCopyConnectivityMode())
-                {
+                if (isCopyConnectivityMode()) {
                     copyConnectivity(jobContext);
                 }
 
@@ -333,73 +335,11 @@
             (((int) ((tCurrent - tBefore) % 60000.0)) / 1000) + " sec");
     }
 
-    /**
-     * Connectivity�ƻs�@�Ӫ����A�b�d�߹q�y��V�ɥΨӤ��OMS��Ʈw���q���s����(Connectivity)
-     *
-     * @param jobContext job context
-     * @throws SQLException sql exception
-     */
-    private void copyConnectivity(OracleConvertEdbGeoJobContext jobContext) throws SQLException {
-        Connection connection = jobContext.getOracleConnection();
-        ResultSet rsMeta = connection.getMetaData().getTables(null, "BASEDB",
-                                                              AbstractOracleJobContext.CONNECTIVITY_WEBCHECK_NAME + "%",
-                                                              new String[]{"TABLE"});
-
-        boolean found = false;
-        try {
-            while (rsMeta.next()) {
-                String tablename = rsMeta.getString(3);
-                if (AbstractOracleJobContext.CONNECTIVITY_WEBCHECK_NAME.equalsIgnoreCase(tablename)) {
-                    found = true;
-                    break;
-                }
-            }
-            // } catch (SQLException e)
-        } finally {
-            if (rsMeta != null) {
-                rsMeta.close();
-                rsMeta = null;
-            }
-        }
-        Statement stmt = connection.createStatement();
-        if (found) {
-            stmt.execute(AbstractOracleJobContext.TRUNCATE_CONNECTIVITY_WEBCHECK);
-        } else {
-            logger.info("Create CONNECTIVITY_WEBCHECK table.");
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK);
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_1);
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_2);
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_3);
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_4);
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_5);
-            stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_6);
-            stmt.execute(AbstractOracleJobContext.ALTER_CONNECTIVITY_WEBCHECK_1);
-            stmt.execute(AbstractOracleJobContext.ALTER_CONNECTIVITY_WEBCHECK_2);
-        }
-
-        stmt.execute(AbstractOracleJobContext.COPY_CONNECTIVITY_TO_WEBCHECK);
-        stmt.close();
-    }
-
-
-        private void createHibernateSequence(OracleConvertEdbGeoJobContext 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.");
-        }
-    }
-
     private void exetcuteConvert(OracleConvertEdbGeoJobContext jobContext,
                                  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);
 
@@ -407,16 +347,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("ConvertDgn2EdbGeoJobProgress", 0);
-        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();) {
+        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext(); ) {
             it.next();
 
             Pair pair = (Pair) it.getValue();
@@ -442,16 +382,14 @@
                 System.runFinalization();
             }
 
-            if( step != 0)
-            {
+            if (step != 0) {
                 int now = order % step;
                 if (now != current) {
                     current = now;
                     jobContext.getExecutionContext().put("ConvertDgn2EdbGeoSpatialJob", current);
 
                 }
-            }else
-            {
+            } else {
                 jobContext.getExecutionContext().put("ConvertDgn2EdbGeoSpatialJob", current);
                 current++;
             }
@@ -725,7 +663,7 @@
             if (dgnFile.isDirectory()) continue;
             IndexDgnConvertEdbGeoJobContext convertContext =
                 new IndexDgnConvertEdbGeoJobContext(getDataPath(), getTargetDataStore(), targetSchemaName,
-                                                     isProfileMode(), isTransformed());
+                    isProfileMode(), isTransformed());
             logger.info("--- start index dgnfile-" + dgnFile.toString() + " ---");
             FileInputStream fs = null;
             FileChannel fc = null;
@@ -772,8 +710,7 @@
             } finally {
                 convertContext.closeFeatureWriter();
 
-                if (reader != null)
-                {
+                if (reader != null) {
                     try {
                         reader.close();
                     } catch (IOException e) {
@@ -849,7 +786,7 @@
         //    }
         //} else {
         //    if (element instanceof ShapeElement) {
-                convertContext.putFeatureCollection(element);
+        convertContext.putFeatureCollection(element);
         //    }
         //}
     }
@@ -884,7 +821,7 @@
 
             GeneralDgnConvertEdbGeoJobContext convertContext =
                 new GeneralDgnConvertEdbGeoJobContext(getDataPath(), getTargetDataStore(), targetSchemaName,
-                                                       isProfileMode(), isTransformed());
+                    isProfileMode(), isTransformed());
             logger.info("--- start other dgnfile-" + dgnFile.toString() + " ---");
             FileInputStream fs = null;
             FileChannel fc;
@@ -930,8 +867,7 @@
             } finally {
                 convertContext.closeFeatureWriter();
 
-                if (reader != null)
-                {
+                if (reader != null) {
                     try {
                         reader.close();
                     } catch (IOException e) {
@@ -1067,7 +1003,7 @@
         for (File dgnFile : dgnFiles) {
             FeatureDgnConvertEdbGeoJobContext convertContext =
                 new FeatureDgnConvertEdbGeoJobContext(getDataPath(), getTargetDataStore(), targetSchemaName, _filterPath,
-                                                       isProfileMode(), isTransformed());
+                    isProfileMode(), isTransformed());
             logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
             try {
                 convertContext.setExecutionContext(context);

--
Gitblit v0.0.0-SNAPSHOT