| | |
| | | } |
| | | } |
| | | |
| | | clearExchangeData(jobContext); |
| | | jobContext.closeOracleConnection(); |
| | | } |
| | | |
| | |
| | | private void logTimeDiff(String message, long tBefore, long tCurrent) { |
| | | logger.warn(message + ":use time = " + ((int) ((tCurrent - tBefore) / 60000.0)) + " min - " + |
| | | (((int) ((tCurrent - tBefore) % 60000.0)) / 1000) + " sec"); |
| | | } |
| | | |
| | | private void clearExchangeData(OracleConvertPostGISJobContext jobContext) throws SQLException, IOException { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | |
| | | ResultSet rsMeta = connection.getMetaData().getTables(null, "CMMS_POSTDB", "GEO_EXCHANGE", |
| | | new String[]{"TABLE"}); |
| | | |
| | | boolean found = false; |
| | | try { |
| | | while (rsMeta.next()) { |
| | | found = true; |
| | | break; |
| | | } |
| | | // } catch (SQLException e) |
| | | } finally { |
| | | if (rsMeta != null) { |
| | | rsMeta.close(); |
| | | rsMeta = null; |
| | | } |
| | | } |
| | | |
| | | if (!found) { |
| | | logger.info("Cannot Found GEO_EXCHANGE in CMMS_POSTDB."); |
| | | return; |
| | | } |
| | | |
| | | Statement stmt = null; |
| | | try { |
| | | stmt = connection.createStatement(); |
| | | int count = stmt.executeUpdate("UPDATE \"CMMS_POSTDB\".\"GEO_EXCHANGE\" SET ISEXCHANGE=1 WHERE ISEXCHANGE=0"); |
| | | logger.info("GEO_EXCHANGE UPDATE SIZE=" + count); |
| | | } finally { |
| | | JDBCUtils.close(stmt); |
| | | } |
| | | } |
| | | |
| | | private void exetcuteConvert(OracleConvertPostGISJobContext jobContext, |
| | |
| | | values[0] = rs.getString("vptname"); |
| | | values[1] = rs.getShort("vptstatus"); |
| | | tmpTablenames.add(values); |
| | | if ((((Short) values[1]) & DataReposVersionManager.VSSTATUS_USING) != 0) { |
| | | if (((Short) values[1]) >= DataReposVersionManager.VSSTATUS_LINKVIEW) { |
| | | current = i; |
| | | } |
| | | i++; |
| | |
| | | Statement stmt = connection.createStatement(); |
| | | ResultSet rs = null; |
| | | try { |
| | | stmt.execute("CREATE TABLE " + tableName +" AS SELECT * FROM " + tempTable); |
| | | boolean found = false; |
| | | rs = connection.getMetaData().getTables(null, _pgSchema, tableName, new String[]{"TABLE"}); |
| | | if (rs.next()) { |
| | | stmt.execute("ALTER TABLE " + encodeSchemaTableName(_pgSchema, tableName) + |
| | | " ADD PRIMARY KEY (tid, oid)"); |
| | | found = true; |
| | | } |
| | | JDBCUtils.close(rs); |
| | | |
| | | if (!found) { |
| | | stmt.execute("CREATE TABLE " + tableName +" AS SELECT * FROM " + tempTable); |
| | | rs = connection.getMetaData().getTables(null, _pgSchema, tableName, new String[]{"TABLE"}); |
| | | if (rs.next()) { |
| | | stmt.execute("ALTER TABLE " + encodeSchemaTableName(_pgSchema, tableName) + |
| | | " ADD PRIMARY KEY (tid, oid)"); |
| | | } |
| | | } else { |
| | | stmt.execute("TRUNCATE "+ tableName + " CASCADE"); |
| | | stmt.execute("SELECT * INTO " + tableName + " FROM " + tempTable); |
| | | } |
| | | stmt.execute("DROP TABLE " + tempTable); |
| | | } finally { |