From f603c3db4f02b28447c94d8a16dac5cf49999110 Mon Sep 17 00:00:00 2001 From: Dennis Kao <ulysseskao@gmail.com> Date: Fri, 06 Dec 2013 01:33:16 +0800 Subject: [PATCH] themes view --- xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java | 48 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 34 insertions(+), 14 deletions(-) diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java index 2cc9b81..10301d8 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java @@ -29,6 +29,9 @@ import org.apache.commons.collections.OrderedMap; import org.apache.commons.collections.OrderedMapIterator; import org.apache.commons.collections.map.LinkedMap; +import org.apache.commons.dbcp.DelegatingConnection; +import org.apache.commons.dbcp.PoolingConnection; +import org.apache.commons.dbcp.PoolingDataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.geotools.data.DataStore; @@ -247,7 +250,6 @@ long tStepEnd = System.currentTimeMillis(); logTimeDiff("Profile-convertOtherDesignFile", tStep, tStepEnd); } - } OracleConvertPostGISJobContext jobContext = null; @@ -336,6 +338,12 @@ updateRepoStatusToReady(targetSchemaName); if (checkConvertPWThemes()) { + jobContext = (OracleConvertPostGISJobContext) prepareJobContext(targetSchemaName, _filterPath, + isProfileMode(), isTransformed()); + jobContext.setSourceDataStore(getSourceDataStore()); + jobContext.setElementLogging(checkElementLogging()); + jobContext.setExecutionContext(context); + long tStep = System.currentTimeMillis(); if (!convertPowerOwnerThemeWithCopyAPI(jobContext, targetThemeTable)) { convertPowerOwnerTheme(jobContext, targetThemeTable); @@ -351,6 +359,7 @@ long tStepEnd = System.currentTimeMillis(); logTimeDiff("Profile-convertFeatureDesignFile", tStep, tStepEnd); } + jobContext.closeOracleConnection(); } updatePWThemeStatusToReady(targetThemeTable); @@ -1341,6 +1350,8 @@ } public String encodeSchemaTableName(String schemaName, String tableName) { + if (schemaName == null) + return "\"" + tableName + "\""; return "\"" + schemaName + "\".\"" + tableName + "\""; } @@ -1461,7 +1472,7 @@ sbSQL.append(encodeSchemaTableName(_pgSchema, DataReposVersionManager.XPTVERSIONTABLE_NAME)).append(' '); sbSQL.append(" SET vptstatus = "); sbSQL.append(DataReposVersionManager.VSSTATUS_READY); - sbSQL.append(" , vstimestamp = CURRENT_TIMESTAMP WHERE vptname = '"); + sbSQL.append(" , vpttimestamp = CURRENT_TIMESTAMP WHERE vptname = '"); sbSQL.append(targetSchema).append("'"); connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT); @@ -1688,31 +1699,34 @@ } Connection connection = context.getOracleConnection(); Connection connectionPG = targetDataStore.getConnection(Transaction.AUTO_COMMIT); + while (connectionPG instanceof DelegatingConnection) { + connectionPG = ((DelegatingConnection) connectionPG).getDelegate(); + } if (!(connectionPG instanceof PGConnection)) { return false; } + final int MAX_BATCHSIZE = 250; ResultSet rs = null; Statement stmt = null; try { - + // connectionPG.setAutoCommit(false); DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); String targetTableName = targetTableBaseName + FDYNCOLOR_SUFFIX; String targetTempName = "tmp_" + targetTableName; logger.info("target table:" + targetTableName); stmt = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(FETCH_COLORTAB); - rs.setFetchSize(50); + rs.setFetchSize(MAX_BATCHSIZE); createOrClearTempTargetTable(connectionPG, targetTempName, "(tid smallint not null, oid int not null, dyncolor varchar(10) not null)"); StringBuilder sb = new StringBuilder(); CopyManager cpMgr = ((PGConnection) connectionPG).getCopyAPI(); - PushbackReader reader = new PushbackReader(new StringReader(""), 4096); + PushbackReader reader = new PushbackReader(new StringReader(""), 10240); - final int MAX_BATCHSIZE = 50; int count = 0; while (rs.next()) { int cid = rs.getInt(1); @@ -1756,18 +1770,25 @@ } Connection connection = context.getOracleConnection(); Connection connectionPG = targetDataStore.getConnection(Transaction.AUTO_COMMIT); + while (connectionPG instanceof DelegatingConnection) { + connectionPG = ((DelegatingConnection) connectionPG).getDelegate(); + } - boolean found = false; + if (!(connectionPG instanceof PGConnection)) { + return false; + } + + final int MAX_BATCHSIZE = 250; ResultSet rs = null; Statement stmt = null; try { - connectionPG.setAutoCommit(false); + // connectionPG.setAutoCommit(false); String targetTableName = targetTableBaseName + FOWNER_SUFFIX; String targetTempName = "tmp_" + targetTableName; logger.info("target table:" + targetTableName); stmt = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(FETCH_CONNFDR); - rs.setFetchSize(50); + rs.setFetchSize(MAX_BATCHSIZE); createOrClearTempTargetTable(connectionPG, targetTempName, "(tid smallint not null, oid int not null, fowner smallint not null)"); @@ -1775,9 +1796,8 @@ StringBuilder sb = new StringBuilder(); CopyManager cpMgr = ((PGConnection) connectionPG).getCopyAPI(); - PushbackReader reader = new PushbackReader(new StringReader(""), 4096); + PushbackReader reader = new PushbackReader(new StringReader(""), 10240); - final int MAX_BATCHSIZE = 50; int count = 0; while (rs.next()) { int cid = rs.getInt(1); @@ -1816,12 +1836,12 @@ Statement stmt = connection.createStatement(); ResultSet rs = null; try { - rs = connection.getMetaData().getTables(null, _pgSchema, tableName, new String[]{"TABLE"}); + rs = connection.getMetaData().getTables(null, null, tableName, new String[]{"TABLE"}); if (rs.next()) { - stmt.execute("DROP TABLE " + encodeSchemaTableName(_pgSchema, tableName) + "CASCADE"); + stmt.execute("DROP TABLE " + encodeSchemaTableName(null, tableName) + "CASCADE"); } - stmt.executeUpdate("CREATE TEMP TABLE " + encodeSchemaTableName(_pgSchema, tableName) + " " + sql); + stmt.executeUpdate("CREATE TEMP TABLE " + encodeSchemaTableName(null, tableName) + " " + sql); } finally { JDBCUtils.close(rs); JDBCUtils.close(stmt); -- Gitblit v0.0.0-SNAPSHOT