List of usage examples for java.sql ResultSet getFloat
float getFloat(String columnLabel) throws SQLException;
ResultSet
object as a float
in the Java programming language. From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * Sets a converted value from the old schema to the new schema into the CollectionObjectAttr * object/*from w w w . j a v a 2s . c o m*/ * @param rs the resultset * @param index the index of the column in the resultset * @param type the defined type for the new schema * @param metaData the metat data describing the old schema column * @param colObjAttr the object the data is set into * @return the new data object */ protected void setData(final ResultSet rs, final int index, final AttributeIFace.FieldType type, final FieldMetaData metaData, final CollectionObjectAttr colObjAttr) { // Note: we need to check the old schema once again because the "type" may have been mapped // so now we must map the actual value AttributeIFace.FieldType oldType = getDataType(metaData.getName(), metaData.getType()); try { Object value = rs.getObject(index); if (type == AttributeIFace.FieldType.BooleanType) { if (value == null) { colObjAttr.setDblValue(0.0); // false } else if (oldType == AttributeIFace.FieldType.IntegerType) { colObjAttr.setDblValue(rs.getInt(index) != 0 ? 1.0 : 0.0); } else if (oldType == AttributeIFace.FieldType.FloatType) { colObjAttr.setDblValue(rs.getFloat(index) != 0.0f ? 1.0 : 0.0); } else if (oldType == AttributeIFace.FieldType.DoubleType) { colObjAttr.setDblValue(rs.getDouble(index) != 0.0 ? 1.0 : 0.0); } else if (oldType == AttributeIFace.FieldType.StringType) { colObjAttr.setDblValue(rs.getString(index).equalsIgnoreCase("true") ? 1.0 : 0.0); } else { log.error("Error maping from schema[" + metaData.getType() + "] to [" + type.toString() + "]"); } } else if (type == AttributeIFace.FieldType.IntegerType || type == AttributeIFace.FieldType.DoubleType || type == AttributeIFace.FieldType.FloatType) { if (value == null) { colObjAttr.setDblValue(0.0); } else if (oldType == AttributeIFace.FieldType.IntegerType) { colObjAttr.setDblValue((double) rs.getInt(index)); } else if (oldType == AttributeIFace.FieldType.FloatType) { colObjAttr.setDblValue((double) rs.getFloat(index)); } else if (oldType == AttributeIFace.FieldType.DoubleType) { colObjAttr.setDblValue(rs.getDouble(index)); } else { log.error("Error maping from schema[" + metaData.getType() + "] to [" + type.toString() + "]"); } } else { colObjAttr.setStrValue(rs.getString(index)); } } catch (SQLException ex) { log.error("Error maping from schema[" + metaData.getType() + "] to [" + type.toString() + "]"); log.error(ex); throw new RuntimeException(ex); } }
From source file:uk.ac.ebi.sail.server.data.DataManager.java
private void loadData() { studySummaryCache.clear();/*from ww w . j a va2s.c o m*/ collectionSummaryCache.clear(); data = new ArrayList<Record>(); Connection conn = null; ResultSet rst = null; try { conn = dSrc.getConnection(); Statement stmt = conn.createStatement(); IntMap<Record> recMap = new IntTreeMap<Record>(); rst = stmt.executeQuery("SELECT * FROM " + TBL_RECORD); while (rst.next()) { Record rc = new Record(); rc.setId(rst.getInt(FLD_ID)); rc.setCount(rst.getInt(FLD_COUNT)); rc.setCollectionId(rst.getInt(FLD_COLLECTION_ID)); rc.setCollectionRecordIDs(rst.getString(FLD_COLLECTION_RECORD_ID)); recMap.put(rc.getId(), rc); data.add(rc); } rst.close(); Record cRc = null; rst = stmt.executeQuery("SELECT * FROM " + TBL_RECORD_IN_STUDY + " ORDER BY " + FLD_RECORD_ID); IntList preStds = new ArrayIntList(20); IntList postStds = new ArrayIntList(20); while (rst.next()) { int rcID = rst.getInt(FLD_RECORD_ID); int stID = rst.getInt(FLD_STUDY_ID); boolean postSt = rst.getBoolean(FLD_POST_STUDY); if (cRc == null) cRc = recMap.get(rcID); if (cRc == null) { logger.warn("Invalid recort to study mapping RecordID=" + rcID + " StudyID=" + stID); continue; } if (cRc.getId() != rcID) { if (preStds.size() > 0) { cRc.setPreStudies(preStds.toArray()); Arrays.sort(cRc.getPreStudies()); preStds.clear(); } if (postStds.size() > 0) { cRc.setPostStudies(postStds.toArray()); Arrays.sort(cRc.getPostStudies()); postStds.clear(); } cRc = recMap.get(rcID); if (cRc == null) { logger.warn("Invalid recort to study mapping RecordID=" + rcID + " StudyID=" + stID); continue; } } if (postSt) postStds.add(stID); else preStds.add(stID); } if (preStds.size() > 0) { cRc.setPreStudies(preStds.toArray()); Arrays.sort(cRc.getPreStudies()); } if (postStds.size() > 0) { cRc.setPostStudies(postStds.toArray()); Arrays.sort(cRc.getPostStudies()); } rst.close(); rst = stmt.executeQuery("SELECT * FROM " + TBL_RECORD_CONTENT); Record rc = new Record(); rc.setId(-1); while (rst.next()) { int ptid = rst.getInt(FLD_PART_ID); int rcid = rst.getInt(FLD_RECORD_ID); ParameterPart pp = parts.get(ptid); if (pp == null) { logger.warn("Invalid ParameterPart reference RecordID=" + rcid + " PartID=" + ptid); continue; } if (rc.getId() != rcid) rc = recMap.get(rcid); if (rc == null) { logger.warn("Invalid record reference RecordID=" + rcid + " PartID=" + ptid); continue; } if (pp.isEnum()) { int variID = rst.getInt(FLD_INT_VALUE); short vidx = pp.getVariantIndexByVariantID(variID); VariantPartValue vpv = new VariantPartValue(pp); vpv.setVariant(vidx); rc.addPartValue(vpv); pp.countVariantByIndex(vidx); } else { Variable vrbl = (Variable) pp; if (vrbl.getType() == Type.INTEGER || vrbl.getType() == Type.DATE || vrbl.getType() == Type.BOOLEAN) { int intval = rst.getInt(FLD_INT_VALUE); if (rst.wasNull()) rc.addPartValue(new PartValue(pp)); else { IntPartValue ipv = new IntPartValue(pp); ipv.setIntValue(intval); rc.addPartValue(ipv); } } else if (vrbl.getType() == Type.REAL) { float fltval = rst.getFloat(FLD_REAL_VALUE); if (rst.wasNull()) rc.addPartValue(new PartValue(pp)); else { RealPartValue rpv = new RealPartValue(pp); rpv.setRealValue(fltval); rc.addPartValue(rpv); } } else rc.addPartValue(new PartValue(pp)); } /* PartValue pv = new PartValue(pp); pp.count(); if( pp.isEnum() ) { String variantStr = rst.getString(FLD_ENUM_VALUE); short varid = pp.getVariantID( variantStr ); pv.setVariant(varid); // if( variantStr == null ) // pv.setSecuredVariant(); // else // { // short varid = pp.getVariantID( variantStr ); // pv.setVariant(varid); // } } rc.addPartValue( pv ); */ } rst.close(); for (Record rd : data) rd.completeRecord(); Collections.sort(data, RecordComparator.getIntstance()); } catch (SQLException e) { Log.error("SQL error", e); } finally { if (rst != null) try { rst.close(); } catch (SQLException e) { } if (conn != null) try { conn.close(); } catch (SQLException e) { Log.error("Connection closing error", e); } } }
From source file:org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.java
public float getAverageRating(int apiId) throws APIManagementException { Connection conn = null;//from ww w . ja v a 2 s . c om float avrRating = 0; PreparedStatement ps = null; ResultSet rs = null; try { conn = APIMgtDBUtil.getConnection(); conn.setAutoCommit(false); if (apiId == -1) { String msg = "Invalid APIId : " + apiId; log.error(msg); return Float.NEGATIVE_INFINITY; } //This query to update the AM_API_RATINGS table String sqlQuery = SQLConstants.GET_AVERAGE_RATING_SQL; ps = conn.prepareStatement(sqlQuery); ps.setInt(1, apiId); rs = ps.executeQuery(); while (rs.next()) { avrRating = rs.getFloat("RATING"); } } catch (SQLException e) { if (conn != null) { try { conn.rollback(); } catch (SQLException e1) { log.error("Failed to rollback getting user ratings ", e1); } } handleException("Failed to get user ratings", e); } finally { APIMgtDBUtil.closeAllConnections(ps, conn, rs); } return avrRating; }
From source file:org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.java
/** * @param apiIdentifier API Identifier/*from w ww . j a va 2 s .c o m*/ * @throws APIManagementException if failed to add Application */ public float getAverageRating(APIIdentifier apiIdentifier, Connection conn) throws APIManagementException, SQLException { PreparedStatement ps = null; ResultSet rs = null; float avrRating = 0; try { //Get API Id int apiId; apiId = getAPIID(apiIdentifier, conn); if (apiId == -1) { String msg = "Could not load API record for: " + apiIdentifier.getApiName(); log.error(msg); return Float.NEGATIVE_INFINITY; } //This query to update the AM_API_RATINGS table String sqlQuery = SQLConstants.GET_AVERAGE_RATING_SQL; ps = conn.prepareStatement(sqlQuery); ps.setInt(1, apiId); rs = ps.executeQuery(); while (rs.next()) { avrRating = rs.getFloat("RATING"); } } catch (SQLException e) { handleException("Failed to add Application", e); } finally { APIMgtDBUtil.closeAllConnections(ps, null, rs); } BigDecimal decimal = new BigDecimal(avrRating); return Float.parseFloat(decimal.setScale(1, BigDecimal.ROUND_UP).toString()); }
From source file:talonetl.getproperties_0_2.getProperties.java
public void tMysqlInput_5Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try {/*from w w w . jav a 2 s . c o m*/ String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; getCurrentPropertiesStruct getCurrentProperties = new getCurrentPropertiesStruct(); /** * [tHash_getCurrentProperties begin ] start */ ok_Hash.put("tHash_getCurrentProperties", false); start_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); currentComponent = "tHash_getCurrentProperties"; int tos_count_tHash_getCurrentProperties = 0; java.util.Map<getCurrentPropertiesStruct, getCurrentPropertiesStruct> tHash_getCurrentProperties = new java.util.LinkedHashMap<getCurrentPropertiesStruct, getCurrentPropertiesStruct>(); globalMap.put("tHash_getCurrentProperties", tHash_getCurrentProperties); /** * [tHash_getCurrentProperties begin ] stop */ /** * [tMysqlInput_5 begin ] start */ ok_Hash.put("tMysqlInput_5", false); start_Hash.put("tMysqlInput_5", System.currentTimeMillis()); currentComponent = "tMysqlInput_5"; int tos_count_tMysqlInput_5 = 0; java.util.Calendar calendar_tMysqlInput_5 = java.util.Calendar.getInstance(); calendar_tMysqlInput_5.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_5 = calendar_tMysqlInput_5.getTime(); int nb_line_tMysqlInput_5 = 0; java.sql.Connection conn_tMysqlInput_5 = null; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlInput_5 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlInput_5) { conn_tMysqlInput_5 = dataSources_tMysqlInput_5.get("").getConnection(); } else { java.lang.Class.forName("org.gjt.mm.mysql.Driver"); String url_tMysqlInput_5 = "jdbc:mysql://" + "192.168.1.254" + ":" + "3306" + "/" + "TALONDB" + "?" + "noDatetimeStringSync=true"; String dbUser_tMysqlInput_5 = "dbAdmin"; String dbPwd_tMysqlInput_5 = "1nn0s2013"; conn_tMysqlInput_5 = java.sql.DriverManager.getConnection(url_tMysqlInput_5, dbUser_tMysqlInput_5, dbPwd_tMysqlInput_5); } java.sql.Statement stmt_tMysqlInput_5 = conn_tMysqlInput_5.createStatement(); String dbquery_tMysqlInput_5 = "SELECT `PROPERTY_DATA`.`ID`, `PROPERTY_DATA`.`UUID`, `PROPERTY_DATA`.`PROP_NAME`, `PROPERTY_DATA`.`PRICE`, `PROPERTY_DATA`.`SQFT`, `PROPERTY_DATA`.`DESCRIPTION`, `PROPERTY_DATA`.`NUM_BEDS`, `PROPERTY_DATA`.`NUM_BATHS`, `PROPERTY_DATA`.`TYPE`, `PROPERTY_DATA`.`STATUS`, `PROPERTY_DATA`.`STATE_INFO_ID`, `PROPERTY_DATA`.`DATA_SOURCE_ID` FROM `PROPERTY_DATA`"; globalMap.put("tMysqlInput_5_QUERY", dbquery_tMysqlInput_5); java.sql.ResultSet rs_tMysqlInput_5 = stmt_tMysqlInput_5.executeQuery(dbquery_tMysqlInput_5); java.sql.ResultSetMetaData rsmd_tMysqlInput_5 = rs_tMysqlInput_5.getMetaData(); int colQtyInRs_tMysqlInput_5 = rsmd_tMysqlInput_5.getColumnCount(); String tmpContent_tMysqlInput_5 = null; while (rs_tMysqlInput_5.next()) { nb_line_tMysqlInput_5++; if (colQtyInRs_tMysqlInput_5 < 1) { getCurrentProperties.ID = 0; } else { if (rs_tMysqlInput_5.getObject(1) != null) { getCurrentProperties.ID = rs_tMysqlInput_5.getInt(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 2) { getCurrentProperties.UUID = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(2); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.UUID = tmpContent_tMysqlInput_5; } else { getCurrentProperties.UUID = null; } } if (colQtyInRs_tMysqlInput_5 < 3) { getCurrentProperties.PROP_NAME = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(3); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.PROP_NAME = tmpContent_tMysqlInput_5; } else { getCurrentProperties.PROP_NAME = null; } } if (colQtyInRs_tMysqlInput_5 < 4) { getCurrentProperties.PRICE = 0; } else { if (rs_tMysqlInput_5.getObject(4) != null) { getCurrentProperties.PRICE = rs_tMysqlInput_5.getFloat(4); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 5) { getCurrentProperties.SQFT = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(5); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.SQFT = tmpContent_tMysqlInput_5; } else { getCurrentProperties.SQFT = null; } } if (colQtyInRs_tMysqlInput_5 < 6) { getCurrentProperties.DESCRIPTION = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(6); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.DESCRIPTION = tmpContent_tMysqlInput_5; } else { getCurrentProperties.DESCRIPTION = null; } } if (colQtyInRs_tMysqlInput_5 < 7) { getCurrentProperties.NUM_BEDS = 0; } else { if (rs_tMysqlInput_5.getObject(7) != null) { getCurrentProperties.NUM_BEDS = rs_tMysqlInput_5.getFloat(7); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 8) { getCurrentProperties.NUM_BATHS = 0; } else { if (rs_tMysqlInput_5.getObject(8) != null) { getCurrentProperties.NUM_BATHS = rs_tMysqlInput_5.getFloat(8); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 9) { getCurrentProperties.TYPE = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(9); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.TYPE = tmpContent_tMysqlInput_5; } else { getCurrentProperties.TYPE = null; } } if (colQtyInRs_tMysqlInput_5 < 10) { getCurrentProperties.STATUS = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(10); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.STATUS = tmpContent_tMysqlInput_5; } else { getCurrentProperties.STATUS = null; } } if (colQtyInRs_tMysqlInput_5 < 11) { getCurrentProperties.STATE_INFO_ID = 0; } else { if (rs_tMysqlInput_5.getObject(11) != null) { getCurrentProperties.STATE_INFO_ID = rs_tMysqlInput_5.getInt(11); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 12) { getCurrentProperties.DATA_SOURCE_ID = 0; } else { if (rs_tMysqlInput_5.getObject(12) != null) { getCurrentProperties.DATA_SOURCE_ID = rs_tMysqlInput_5.getInt(12); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_5 begin ] stop */ /** * [tMysqlInput_5 main ] start */ currentComponent = "tMysqlInput_5"; tos_count_tMysqlInput_5++; /** * [tMysqlInput_5 main ] stop */ /** * [tHash_getCurrentProperties main ] start */ currentComponent = "tHash_getCurrentProperties"; getCurrentPropertiesStruct getCurrentProperties_HashRow = new getCurrentPropertiesStruct(); getCurrentProperties_HashRow.ID = getCurrentProperties.ID; getCurrentProperties_HashRow.UUID = getCurrentProperties.UUID; getCurrentProperties_HashRow.PROP_NAME = getCurrentProperties.PROP_NAME; getCurrentProperties_HashRow.PRICE = getCurrentProperties.PRICE; getCurrentProperties_HashRow.SQFT = getCurrentProperties.SQFT; getCurrentProperties_HashRow.DESCRIPTION = getCurrentProperties.DESCRIPTION; getCurrentProperties_HashRow.NUM_BEDS = getCurrentProperties.NUM_BEDS; getCurrentProperties_HashRow.NUM_BATHS = getCurrentProperties.NUM_BATHS; getCurrentProperties_HashRow.TYPE = getCurrentProperties.TYPE; getCurrentProperties_HashRow.STATUS = getCurrentProperties.STATUS; getCurrentProperties_HashRow.STATE_INFO_ID = getCurrentProperties.STATE_INFO_ID; getCurrentProperties_HashRow.DATA_SOURCE_ID = getCurrentProperties.DATA_SOURCE_ID; tHash_getCurrentProperties.put(getCurrentProperties_HashRow, getCurrentProperties_HashRow); tos_count_tHash_getCurrentProperties++; /** * [tHash_getCurrentProperties main ] stop */ /** * [tMysqlInput_5 end ] start */ currentComponent = "tMysqlInput_5"; } rs_tMysqlInput_5.close(); stmt_tMysqlInput_5.close(); conn_tMysqlInput_5.close(); globalMap.put("tMysqlInput_5_NB_LINE", nb_line_tMysqlInput_5); ok_Hash.put("tMysqlInput_5", true); end_Hash.put("tMysqlInput_5", System.currentTimeMillis()); /** * [tMysqlInput_5 end ] stop */ /** * [tHash_getCurrentProperties end ] start */ currentComponent = "tHash_getCurrentProperties"; ok_Hash.put("tHash_getCurrentProperties", true); end_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); /** * [tHash_getCurrentProperties end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 1); }
From source file:talonetl.getproperties_0_4.getProperties.java
public void tMysqlInput_5Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try {/*from ww w .j a va 2 s . co m*/ String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; getCurrentPropertiesStruct getCurrentProperties = new getCurrentPropertiesStruct(); /** * [tHash_getCurrentProperties begin ] start */ ok_Hash.put("tHash_getCurrentProperties", false); start_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); currentComponent = "tHash_getCurrentProperties"; int tos_count_tHash_getCurrentProperties = 0; java.util.Map<getCurrentPropertiesStruct, getCurrentPropertiesStruct> tHash_getCurrentProperties = new java.util.LinkedHashMap<getCurrentPropertiesStruct, getCurrentPropertiesStruct>(); globalMap.put("tHash_getCurrentProperties", tHash_getCurrentProperties); /** * [tHash_getCurrentProperties begin ] stop */ /** * [tMysqlInput_5 begin ] start */ ok_Hash.put("tMysqlInput_5", false); start_Hash.put("tMysqlInput_5", System.currentTimeMillis()); currentComponent = "tMysqlInput_5"; int tos_count_tMysqlInput_5 = 0; java.util.Calendar calendar_tMysqlInput_5 = java.util.Calendar.getInstance(); calendar_tMysqlInput_5.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_5 = calendar_tMysqlInput_5.getTime(); int nb_line_tMysqlInput_5 = 0; java.sql.Connection conn_tMysqlInput_5 = null; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlInput_5 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlInput_5) { conn_tMysqlInput_5 = dataSources_tMysqlInput_5.get("").getConnection(); } else { java.lang.Class.forName("org.gjt.mm.mysql.Driver"); String url_tMysqlInput_5 = "jdbc:mysql://" + "192.168.1.201" + ":" + "3306" + "/" + "TALONDB" + "?" + "noDatetimeStringSync=true"; String dbUser_tMysqlInput_5 = "dbAdmin"; String dbPwd_tMysqlInput_5 = "1nn0s2013"; conn_tMysqlInput_5 = java.sql.DriverManager.getConnection(url_tMysqlInput_5, dbUser_tMysqlInput_5, dbPwd_tMysqlInput_5); } java.sql.Statement stmt_tMysqlInput_5 = conn_tMysqlInput_5.createStatement(); String dbquery_tMysqlInput_5 = "SELECT `PROPERTY_DATA`.`ID`, `PROPERTY_DATA`.`UUID`, `PROPERTY_DATA`.`PROP_NAME`, `PROPERTY_DATA`.`PRICE`, `PROPERTY_DATA`.`SQFT`, `PROPERTY_DATA`.`DESCRIPTION`, `PROPERTY_DATA`.`NUM_BEDS`, `PROPERTY_DATA`.`NUM_BATHS`, `PROPERTY_DATA`.`TYPE`, `PROPERTY_DATA`.`STATUS`, `PROPERTY_DATA`.`STATE_INFO_ID`, `PROPERTY_DATA`.`DATA_SOURCE_ID` FROM `PROPERTY_DATA`"; globalMap.put("tMysqlInput_5_QUERY", dbquery_tMysqlInput_5); java.sql.ResultSet rs_tMysqlInput_5 = stmt_tMysqlInput_5.executeQuery(dbquery_tMysqlInput_5); java.sql.ResultSetMetaData rsmd_tMysqlInput_5 = rs_tMysqlInput_5.getMetaData(); int colQtyInRs_tMysqlInput_5 = rsmd_tMysqlInput_5.getColumnCount(); String tmpContent_tMysqlInput_5 = null; while (rs_tMysqlInput_5.next()) { nb_line_tMysqlInput_5++; if (colQtyInRs_tMysqlInput_5 < 1) { getCurrentProperties.ID = 0; } else { if (rs_tMysqlInput_5.getObject(1) != null) { getCurrentProperties.ID = rs_tMysqlInput_5.getInt(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 2) { getCurrentProperties.UUID = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(2); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.UUID = tmpContent_tMysqlInput_5; } else { getCurrentProperties.UUID = null; } } if (colQtyInRs_tMysqlInput_5 < 3) { getCurrentProperties.PROP_NAME = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(3); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.PROP_NAME = tmpContent_tMysqlInput_5; } else { getCurrentProperties.PROP_NAME = null; } } if (colQtyInRs_tMysqlInput_5 < 4) { getCurrentProperties.PRICE = 0; } else { if (rs_tMysqlInput_5.getObject(4) != null) { getCurrentProperties.PRICE = rs_tMysqlInput_5.getFloat(4); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 5) { getCurrentProperties.SQFT = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(5); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.SQFT = tmpContent_tMysqlInput_5; } else { getCurrentProperties.SQFT = null; } } if (colQtyInRs_tMysqlInput_5 < 6) { getCurrentProperties.DESCRIPTION = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(6); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.DESCRIPTION = tmpContent_tMysqlInput_5; } else { getCurrentProperties.DESCRIPTION = null; } } if (colQtyInRs_tMysqlInput_5 < 7) { getCurrentProperties.NUM_BEDS = 0; } else { if (rs_tMysqlInput_5.getObject(7) != null) { getCurrentProperties.NUM_BEDS = rs_tMysqlInput_5.getFloat(7); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 8) { getCurrentProperties.NUM_BATHS = 0; } else { if (rs_tMysqlInput_5.getObject(8) != null) { getCurrentProperties.NUM_BATHS = rs_tMysqlInput_5.getFloat(8); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 9) { getCurrentProperties.TYPE = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(9); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.TYPE = tmpContent_tMysqlInput_5; } else { getCurrentProperties.TYPE = null; } } if (colQtyInRs_tMysqlInput_5 < 10) { getCurrentProperties.STATUS = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(10); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.STATUS = tmpContent_tMysqlInput_5; } else { getCurrentProperties.STATUS = null; } } if (colQtyInRs_tMysqlInput_5 < 11) { getCurrentProperties.STATE_INFO_ID = 0; } else { if (rs_tMysqlInput_5.getObject(11) != null) { getCurrentProperties.STATE_INFO_ID = rs_tMysqlInput_5.getInt(11); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 12) { getCurrentProperties.DATA_SOURCE_ID = 0; } else { if (rs_tMysqlInput_5.getObject(12) != null) { getCurrentProperties.DATA_SOURCE_ID = rs_tMysqlInput_5.getInt(12); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_5 begin ] stop */ /** * [tMysqlInput_5 main ] start */ currentComponent = "tMysqlInput_5"; tos_count_tMysqlInput_5++; /** * [tMysqlInput_5 main ] stop */ /** * [tHash_getCurrentProperties main ] start */ currentComponent = "tHash_getCurrentProperties"; getCurrentPropertiesStruct getCurrentProperties_HashRow = new getCurrentPropertiesStruct(); getCurrentProperties_HashRow.ID = getCurrentProperties.ID; getCurrentProperties_HashRow.UUID = getCurrentProperties.UUID; getCurrentProperties_HashRow.PROP_NAME = getCurrentProperties.PROP_NAME; getCurrentProperties_HashRow.PRICE = getCurrentProperties.PRICE; getCurrentProperties_HashRow.SQFT = getCurrentProperties.SQFT; getCurrentProperties_HashRow.DESCRIPTION = getCurrentProperties.DESCRIPTION; getCurrentProperties_HashRow.NUM_BEDS = getCurrentProperties.NUM_BEDS; getCurrentProperties_HashRow.NUM_BATHS = getCurrentProperties.NUM_BATHS; getCurrentProperties_HashRow.TYPE = getCurrentProperties.TYPE; getCurrentProperties_HashRow.STATUS = getCurrentProperties.STATUS; getCurrentProperties_HashRow.STATE_INFO_ID = getCurrentProperties.STATE_INFO_ID; getCurrentProperties_HashRow.DATA_SOURCE_ID = getCurrentProperties.DATA_SOURCE_ID; tHash_getCurrentProperties.put(getCurrentProperties_HashRow, getCurrentProperties_HashRow); tos_count_tHash_getCurrentProperties++; /** * [tHash_getCurrentProperties main ] stop */ /** * [tMysqlInput_5 end ] start */ currentComponent = "tMysqlInput_5"; } rs_tMysqlInput_5.close(); stmt_tMysqlInput_5.close(); conn_tMysqlInput_5.close(); globalMap.put("tMysqlInput_5_NB_LINE", nb_line_tMysqlInput_5); ok_Hash.put("tMysqlInput_5", true); end_Hash.put("tMysqlInput_5", System.currentTimeMillis()); /** * [tMysqlInput_5 end ] stop */ /** * [tHash_getCurrentProperties end ] start */ currentComponent = "tHash_getCurrentProperties"; ok_Hash.put("tHash_getCurrentProperties", true); end_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); /** * [tHash_getCurrentProperties end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 1); }
From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * Converts all the CollectionObject and CollectionObjectCatalog Records into the new schema * CollectionObject table. All "logical" records are moved to the CollectionObject table and all * "physical" records are moved to the Preparation table. * @return true if no errors/*from ww w .j a v a2 s. c o m*/ */ @SuppressWarnings("cast") public boolean convertCollectionObjects(final boolean useNumericCatNumbers, final boolean usePrefix) { final String ZEROES = "000000000"; UIFieldFormatterIFace formatter0 = UIFieldFormatterMgr.getInstance().getFormatter("CatalogNumber"); log.debug(formatter0); UIFieldFormatterIFace formatter = UIFieldFormatterMgr.getInstance().getFormatter("CatalogNumberNumeric"); log.debug(formatter); DisciplineType dt; Discipline discipline = (Discipline) AppContextMgr.getInstance().getClassObject(Discipline.class); if (discipline != null) { System.out.println("discipline.getType()[" + discipline.getType() + "]"); dt = DisciplineType.getDiscipline(discipline.getType()); } else { Vector<Object[]> list = query(newDBConn, "SELECT Type FROM discipline"); String typeStr = (String) list.get(0)[0]; System.out.println("typeStr[" + typeStr + "]"); dt = DisciplineType.getDiscipline(typeStr); } Pair<Integer, Boolean> objTypePair = dispToObjTypeHash.get(dt.getDisciplineType()); if (objTypePair == null) { System.out.println("objTypePair is null dt[" + dt.getName() + "][" + dt.getTitle() + "]"); for (STD_DISCIPLINES key : dispToObjTypeHash.keySet()) { Pair<Integer, Boolean> p = dispToObjTypeHash.get(key); System.out.println("[" + key + "] [" + p.first + "][" + p.second + "]"); } } else if (objTypePair.first == null) { System.out.println("objTypePair.first is null dt[" + dt + "]"); for (STD_DISCIPLINES key : dispToObjTypeHash.keySet()) { Pair<Integer, Boolean> p = dispToObjTypeHash.get(key); System.out.println("[" + key + "] [" + p.first + "][" + p.second + "]"); } } //int objTypeId = objTypePair.first; //boolean isEmbedded = objTypePair.second; idMapperMgr.dumpKeys(); IdHashMapper colObjTaxonMapper = (IdHashMapper) idMapperMgr.get("ColObjCatToTaxonType".toLowerCase()); IdHashMapper colObjAttrMapper = (IdHashMapper) idMapperMgr .get("biologicalobjectattributes_BiologicalObjectAttributesID"); IdHashMapper colObjMapper = (IdHashMapper) idMapperMgr .get("collectionobjectcatalog_CollectionObjectCatalogID"); colObjTaxonMapper.setShowLogErrors(false); // NOTE: TURN THIS ON FOR DEBUGGING or running new Databases through it colObjAttrMapper.setShowLogErrors(false); //IdHashMapper stratMapper = (IdHashMapper)idMapperMgr.get("stratigraphy_StratigraphyID"); //IdHashMapper stratGTPMapper = (IdHashMapper)idMapperMgr.get("stratigraphy_GeologicTimePeriodID"); String[] fieldsToSkip = { "ContainerID", "ContainerItemID", "AltCatalogNumber", "GUID", "ContainerOwnerID", "RepositoryAgreementID", "GroupPermittedToView", // this may change when converting Specify 5.x "CollectionObjectID", "VisibilitySetBy", "ContainerOwnerID", "InventoryDate", "ObjectCondition", "Notifications", "ProjectNumber", "Restrictions", "YesNo3", "YesNo4", "YesNo5", "YesNo6", "FieldNotebookPageID", "ColObjAttributesID", "DNASequenceID", "AppraisalID", "TotalValue", "Description", "SGRStatus", "OCR", "ReservedText", "Text3" }; HashSet<String> fieldsToSkipHash = new HashSet<String>(); for (String fName : fieldsToSkip) { fieldsToSkipHash.add(fName); } TableWriter tblWriter = convLogger.getWriter("convertCollectionObjects.html", "Collection Objects"); String msg = "colObjTaxonMapper: " + colObjTaxonMapper.size(); log.info(msg); tblWriter.log(msg); setIdentityInsertONCommandForSQLServer(newDBConn, "collectionobject", BasicSQLUtils.myDestinationServerType); deleteAllRecordsFromTable(newDBConn, "collectionobject", BasicSQLUtils.myDestinationServerType); // automatically closes the connection TreeSet<String> badSubNumberCatNumsSet = new TreeSet<String>(); TimeLogger timeLogger = new TimeLogger(); try { Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); StringBuilder str = new StringBuilder(); List<String> oldFieldNames = new ArrayList<String>(); StringBuilder sql = new StringBuilder("select "); List<String> names = getFieldNamesFromSchema(oldDBConn, "collectionobject"); sql.append(buildSelectFieldList(names, "collectionobject")); sql.append(", "); oldFieldNames.addAll(names); names = getFieldNamesFromSchema(oldDBConn, "collectionobjectcatalog"); sql.append(buildSelectFieldList(names, "collectionobjectcatalog")); oldFieldNames.addAll(names); String fromClause = " FROM collectionobject Inner Join collectionobjectcatalog ON " + "collectionobject.CollectionObjectID = collectionobjectcatalog.CollectionObjectCatalogID " + "WHERE (collectionobject.DerivedFromID IS NULL) AND collectionobjectcatalog.CollectionObjectCatalogID = "; sql.append(fromClause); log.info(sql); String sqlStr = sql.toString(); List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(newDBConn, "collectionobject"); log.info("Number of Fields in New CollectionObject " + newFieldMetaData.size()); Map<String, Integer> oldNameIndex = new Hashtable<String, Integer>(); int inx = 1; log.info("---- Old Names ----"); for (String name : oldFieldNames) { log.info("[" + name + "][" + inx + "]"); oldNameIndex.put(name, inx++); } log.info("---- New Names ----"); for (FieldMetaData fmd : newFieldMetaData) { log.info("[" + fmd.getName() + "]"); } String tableName = "collectionobject"; Statement newStmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); newStmt.setFetchSize(Integer.MIN_VALUE); ResultSet rsLooping = newStmt.executeQuery( "SELECT OldID, NewID FROM collectionobjectcatalog_CollectionObjectCatalogID ORDER BY OldID"); if (hasFrame) { if (rsLooping.last()) { setProcess(0, rsLooping.getRow()); rsLooping.first(); } else { rsLooping.close(); stmt.close(); return true; } } else { if (!rsLooping.first()) { rsLooping.close(); stmt.close(); return true; } } int boaCnt = BasicSQLUtils.getCountAsInt(oldDBConn, "SELECT COUNT(*) FROM biologicalobjectattributes"); // ZZZ PartialDateConv partialDateConv = new PartialDateConv(); Statement stmt2 = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt2.setFetchSize(Integer.MIN_VALUE); int catNumInx = oldNameIndex.get("CatalogNumber"); int catDateInx = oldNameIndex.get("CatalogedDate"); int catSeriesIdInx = oldNameIndex.get("CatalogSeriesID"); int lastEditedByInx = oldNameIndex.get("LastEditedBy"); /*int grpPrmtViewInx = -1; Integer grpPrmtViewInxObj = oldNameIndex.get("GroupPermittedToView"); if (grpPrmtViewInxObj != null) { grpPrmtViewInx = grpPrmtViewInxObj + 1; }*/ Hashtable<Integer, CollectionInfo> oldCatSeriesIDToCollInfo = new Hashtable<Integer, CollectionInfo>(); for (CollectionInfo ci : collectionInfoShortList) { if (ci.getCatSeriesId() != null) { oldCatSeriesIDToCollInfo.put(ci.getCatSeriesId(), ci); } } String insertStmtStr = null; /*String catIdTaxIdStrBase = "SELECT cc.CollectionObjectCatalogID, cc.CatalogSeriesID, ct.TaxonomyTypeID " + "FROM collectionobjectcatalog AS cc " + "Inner Join collectionobject AS co ON cc.CollectionObjectCatalogID = co.CollectionObjectID " + "Inner Join collectiontaxonomytypes as ct ON co.CollectionObjectTypeID = ct.BiologicalObjectTypeID " + "where cc.CollectionObjectCatalogID = ";*/ int colObjAttrsNotMapped = 0; int count = 0; boolean skipRecord = false; do { String catSQL = sqlStr + rsLooping.getInt(1); //log.debug(catSQL); ResultSet rs = stmt.executeQuery(catSQL); if (!rs.next()) { log.error("Couldn't find CO with old id[" + rsLooping.getInt(1) + "] " + catSQL); continue; } partialDateConv.nullAll(); skipRecord = false; CollectionInfo collInfo = oldCatSeriesIDToCollInfo.get(rs.getInt(catSeriesIdInx)); /*String catIdTaxIdStr = catIdTaxIdStrBase + rs.getInt(1); //log.info(catIdTaxIdStr); ResultSet rs2 = stmt2.executeQuery(catIdTaxIdStr); if (!rs2.next()) { log.info("QUERY failed to return results:\n"+catIdTaxIdStr+"\n"); continue; } Integer catalogSeriesID = rs2.getInt(2); Integer taxonomyTypeID = rs2.getInt(3); Integer newCatSeriesId = collectionHash.get(catalogSeriesID + "_" + taxonomyTypeID); String prefix = prefixHash.get(catalogSeriesID + "_" + taxonomyTypeID); rs2.close(); if (newCatSeriesId == null) { msg = "Can't find " + catalogSeriesID + "_" + taxonomyTypeID; log.info(msg); tblWriter.logError(msg); continue; }*/ /*if (false) { String stratGTPIdStr = "SELECT co.CollectionObjectID, ce.CollectingEventID, s.StratigraphyID, g.GeologicTimePeriodID FROM collectionobject co " + "LEFT JOIN collectingevent ce ON co.CollectingEventID = ce.CollectingEventID " + "LEFT JOIN stratigraphy s ON ce.CollectingEventID = s.StratigraphyID " + "LEFT JOIN geologictimeperiod g ON s.GeologicTimePeriodID = g.GeologicTimePeriodID " + "WHERE co.CollectionObjectID = " + rs.getInt(1); log.info(stratGTPIdStr); rs2 = stmt2.executeQuery(stratGTPIdStr); Integer coId = null; Integer ceId = null; Integer stId = null; Integer gtpId = null; if (rs2.next()) { coId = rs2.getInt(1); ceId = rs2.getInt(2); stId = rs2.getInt(3); gtpId = rs2.getInt(4); } rs2.close(); }*/ String catalogNumber = null; String colObjId = null; str.setLength(0); if (insertStmtStr == null) { StringBuffer fieldList = new StringBuffer(); fieldList.append("( "); for (int i = 0; i < newFieldMetaData.size(); i++) { if ((i > 0) && (i < newFieldMetaData.size())) { fieldList.append(", "); } String newFieldName = newFieldMetaData.get(i).getName(); fieldList.append(newFieldName + " "); } fieldList.append(")"); insertStmtStr = "INSERT INTO collectionobject " + fieldList + " VALUES ("; } str.append(insertStmtStr); for (int i = 0; i < newFieldMetaData.size(); i++) { if (i > 0) { str.append(", "); } String newFieldName = newFieldMetaData.get(i).getName(); if (i == 0) { Integer oldColObjId = rs.getInt(1); Integer newColObjId = colObjMapper.get(oldColObjId); if (newColObjId == null) { msg = "Couldn't find new ColObj Id for old [" + oldColObjId + "]"; tblWriter.logError(msg); showError(msg); throw new RuntimeException(msg); } colObjId = getStrValue(newColObjId); if (contains(colObjId, '.')) { String msgStr = String.format("CatalogNumber '%d' contains a decimal point.", colObjId); log.debug(msgStr); tblWriter.logError(msgStr); skipRecord = true; break; } str.append(colObjId); if (useNumericCatNumbers) { catalogNumber = rs.getString(catNumInx); if (catalogNumber != null) { int catNumInt = (int) Math.abs(rs.getDouble(catNumInx)); catalogNumber = Integer.toString(catNumInt); if (catalogNumber.length() > 0 && catalogNumber.length() < ZEROES.length()) { catalogNumber = "\"" + ZEROES.substring(catalogNumber.length()) + catalogNumber + "\""; } else if (catalogNumber.length() > ZEROES.length()) { showError( "Catalog Number[" + catalogNumber + "] is too long for formatter of 9"); } } else { String mssg = "Empty catalog number."; log.debug(mssg); //showError(msg); tblWriter.logError(mssg); } } else { String prefix = collInfo.getCatSeriesPrefix(); float catNum = rs.getFloat(catNumInx); catalogNumber = "\"" + (usePrefix && isNotEmpty(prefix) ? (prefix + "-") : "") + String.format("%9.0f", catNum).trim() + "\""; } int subNumber = rs.getInt(oldNameIndex.get("SubNumber")); if (subNumber < 0 || rs.wasNull()) { badSubNumberCatNumsSet.add(catalogNumber); skipRecord = true; //msg = "Collection Object is being skipped because SubNumber is less than zero CatalogNumber["+ catalogNumber + "]"; //log.error(msg); //tblWriter.logError(msg); //showError(msg); break; } } else if (fieldsToSkipHash.contains(newFieldName)) { str.append("NULL"); } else if (newFieldName.equals("CollectionID")) // User/Security changes { str.append(collInfo.getCollectionId()); } else if (newFieldName.equals("Version")) // User/Security changes { str.append("0"); } else if (newFieldName.equals("CreatedByAgentID")) // User/Security changes { str.append(getCreatorAgentId(null)); } else if (newFieldName.equals("ModifiedByAgentID")) // User/Security changes { String lastEditedByStr = rs.getString(lastEditedByInx); str.append(getModifiedByAgentId(lastEditedByStr)); } else if (newFieldName.equals("CollectionMemberID")) // User/Security changes { str.append(collInfo.getCollectionId()); } else if (newFieldName.equals("PaleoContextID")) { str.append("NULL");// newCatSeriesId); } else if (newFieldName.equals("CollectionObjectAttributeID")) // User/Security changes { Object idObj = rs.getObject(1); if (idObj != null) { Integer coId = rs.getInt(1); Integer newId = colObjAttrMapper.get(coId); if (newId != null) { str.append(getStrValue(newId)); } else { if (boaCnt > 0) colObjAttrsNotMapped++; str.append("NULL"); } } else { str.append("NULL"); } } else if (newFieldName.equals("CatalogedDate")) { if (partialDateConv.getDateStr() == null) { getPartialDate(rs.getObject(catDateInx), partialDateConv); } str.append(partialDateConv.getDateStr()); } else if (newFieldName.equals("CatalogedDatePrecision")) { if (partialDateConv.getDateStr() == null) { getPartialDate(rs.getObject(catDateInx), partialDateConv); } str.append(partialDateConv.getPartial()); } else if (newFieldName.equals("CatalogedDateVerbatim")) { if (partialDateConv.getDateStr() == null) { getPartialDate(rs.getObject(catDateInx), partialDateConv); } str.append(partialDateConv.getVerbatim()); } else if (newFieldName.equals("Availability")) { str.append("NULL"); } else if (newFieldName.equals("CatalogNumber")) { str.append(catalogNumber); } else if (newFieldName.equals("Visibility")) // User/Security changes { //str.append(grpPrmtViewInx > -1 ? rs.getObject(grpPrmtViewInx) : "NULL"); str.append("0"); } else if (newFieldName.equals("VisibilitySetByID")) // User/Security changes { str.append("NULL"); } else if (newFieldName.equals("CountAmt")) { Integer index = oldNameIndex.get("Count1"); if (index == null) { index = oldNameIndex.get("Count"); } Object countObj = rs.getObject(index); if (countObj != null) { str.append(getStrValue(countObj, newFieldMetaData.get(i).getType())); } else { str.append("NULL"); } } else { Integer index = oldNameIndex.get(newFieldName); Object data; if (index == null) { msg = "convertCollectionObjects - Couldn't find new field name[" + newFieldName + "] in old field name in index Map"; log.warn(msg); // tblWriter.logError(msg); // showError(msg); data = null; // for (String key : oldNameIndex.keySet()) // { // log.info("["+key+"]["+oldNameIndex.get(key)+"]"); // } //stmt.close(); //throw new RuntimeException(msg); } else { data = rs.getObject(index); } if (data != null) { int idInx = newFieldName.lastIndexOf("ID"); if (idMapperMgr != null && idInx > -1) { IdMapperIFace idMapper = idMapperMgr.get(tableName, newFieldName); if (idMapper != null) { Integer origValue = rs.getInt(index); data = idMapper.get(origValue); if (data == null) { msg = "No value [" + origValue + "] in map [" + tableName + "][" + newFieldName + "]"; log.error(msg); tblWriter.logError(msg); //showError(msg); } } else { msg = "No Map for [" + tableName + "][" + newFieldName + "]"; log.error(msg); tblWriter.logError(msg); //showError(msg); } } } str.append(getStrValue(data, newFieldMetaData.get(i).getType())); } } if (!skipRecord) { str.append(")"); // log.info("\n"+str.toString()); if (hasFrame) { if (count % 500 == 0) { setProcess(count); } if (count % 5000 == 0) { log.info("CollectionObject Records: " + count); } } else { if (count % 2000 == 0) { log.info("CollectionObject Records: " + count); } } try { Statement updateStatement = newDBConn.createStatement(); if (BasicSQLUtils.myDestinationServerType != BasicSQLUtils.SERVERTYPE.MS_SQLServer) { removeForeignKeyConstraints(newDBConn, BasicSQLUtils.myDestinationServerType); } // updateStatement.executeUpdate("SET FOREIGN_KEY_CHECKS = 0"); //if (count < 50) System.err.println(str.toString()); updateStatement.executeUpdate(str.toString()); updateStatement.clearBatch(); updateStatement.close(); updateStatement = null; } catch (SQLException e) { log.error("Count: " + count); log.error("Key: [" + colObjId + "][" + catalogNumber + "]"); log.error("SQL: " + str.toString()); e.printStackTrace(); log.error(e); showError(e.getMessage()); rs.close(); stmt.close(); throw new RuntimeException(e); } count++; } else { tblWriter.logError("Skipping - CatNo:" + catalogNumber); } // if (count > 10) break; rs.close(); } while (rsLooping.next()); /*if (boaCnt > 0) { msg = "CollectionObjectAttributes not mapped: " + colObjAttrsNotMapped + " out of "+boaCnt; log.info(msg); tblWriter.logError(msg); }*/ stmt2.close(); if (hasFrame) { setProcess(count); } else { log.info("Processed CollectionObject " + count + " records."); } tblWriter.log(String.format("Collection Objects Processing Time: %s", timeLogger.end())); tblWriter.log("Processed CollectionObject " + count + " records."); rsLooping.close(); newStmt.close(); stmt.close(); tblWriter.append( "<br><br><b>Catalog Numbers rejected because the SubNumber was NULL or less than Zero</b><br>"); tblWriter.startTable(); tblWriter.logHdr("Catalog Number"); for (String catNum : badSubNumberCatNumsSet) { tblWriter.log(catNum); } tblWriter.endTable(); } catch (SQLException e) { setIdentityInsertOFFCommandForSQLServer(newDBConn, "collectionobject", BasicSQLUtils.myDestinationServerType); e.printStackTrace(); log.error(e); tblWriter.logError(e.getMessage()); showError(e.getMessage()); throw new RuntimeException(e); } finally { tblWriter.close(); } setIdentityInsertOFFCommandForSQLServer(newDBConn, "collectionobject", BasicSQLUtils.myDestinationServerType); return true; }
From source file:talonetl.getpropfinacials_0_2.getPropFinacials.java
public void tMysqlInput_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_1_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try {//from w w w .j a va 2 s. c o m String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row11Struct row11 = new row11Struct(); /** * [tAdvancedHash_row11 begin ] start */ ok_Hash.put("tAdvancedHash_row11", false); start_Hash.put("tAdvancedHash_row11", System.currentTimeMillis()); currentComponent = "tAdvancedHash_row11"; int tos_count_tAdvancedHash_row11 = 0; // connection name:row11 // source node:tMysqlInput_1 - inputs:() outputs:(row11,row11) | // target node:tAdvancedHash_row11 - inputs:(row11) outputs:() // linked node: tMap_1 - inputs:(row1,row11) // outputs:(financed_net_yield_1__c,monthly_cash_flow_with_financing_2__c,financed_net_yield_2__c,monthly_cash_flow_with_financing_1__c,interest_rate_1__c,interest_rate_2__c,price_per_ft_c,noi_with_financing_1__c,noi_with_financing_2__c,noi__c,monthly_cash_flow__c,est_replacement_cost__c,est_replacement_cost_per_sq_ft__c,cash_net_yield__c,down_payment_1__c,down_payment_2__c,interest_payment_1__c,yearly_interest_payment_1__c,monthly_interest_payment_2__c) org.talend.designer.components.lookup.common.ICommonLookup.MATCHING_MODE matchingModeEnum_row11 = org.talend.designer.components.lookup.common.ICommonLookup.MATCHING_MODE.UNIQUE_MATCH; org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row11Struct> tHash_Lookup_row11 = org.talend.designer.components.lookup.memory.AdvancedMemoryLookup .<row11Struct>getLookup(matchingModeEnum_row11); globalMap.put("tHash_Lookup_row11", tHash_Lookup_row11); /** * [tAdvancedHash_row11 begin ] stop */ /** * [tMysqlInput_1 begin ] start */ ok_Hash.put("tMysqlInput_1", false); start_Hash.put("tMysqlInput_1", System.currentTimeMillis()); currentComponent = "tMysqlInput_1"; int tos_count_tMysqlInput_1 = 0; java.util.Calendar calendar_tMysqlInput_1 = java.util.Calendar.getInstance(); calendar_tMysqlInput_1.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_1 = calendar_tMysqlInput_1.getTime(); int nb_line_tMysqlInput_1 = 0; java.sql.Connection conn_tMysqlInput_1 = null; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlInput_1 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlInput_1) { conn_tMysqlInput_1 = dataSources_tMysqlInput_1.get("").getConnection(); } else { java.lang.Class.forName("org.gjt.mm.mysql.Driver"); String url_tMysqlInput_1 = "jdbc:mysql://" + context.talon_Server + ":" + context.talon_Port + "/" + context.talon_Database + "?" + context.talon_AdditionalParams; String dbUser_tMysqlInput_1 = context.talon_Login; String dbPwd_tMysqlInput_1 = context.talon_Password; conn_tMysqlInput_1 = java.sql.DriverManager.getConnection(url_tMysqlInput_1, dbUser_tMysqlInput_1, dbPwd_tMysqlInput_1); } java.sql.Statement stmt_tMysqlInput_1 = conn_tMysqlInput_1.createStatement(); String dbquery_tMysqlInput_1 = "SELECT `PROPERTY_DATA`.`ID`, `PROPERTY_DATA`.`UUID`, `PROPERTY_DATA`.`PROP_NAME`, `PROPERTY_DATA`.`PRICE`, `PROPERTY_DATA`.`SQFT`, `PROPERTY_DATA`.`DESCRIPTION`, `PROPERTY_DATA`.`NUM_BEDS`, `PROPERTY_DATA`.`NUM_BATHS`, `PROPERTY_DATA`.`TYPE`, `PROPERTY_DATA`.`STATUS`, `PROPERTY_DATA`.`ZIP_CODE`, `PROPERTY_DATA`.`DATA_SOURCE_ID` FROM `PROPERTY_DATA`"; globalMap.put("tMysqlInput_1_QUERY", dbquery_tMysqlInput_1); java.sql.ResultSet rs_tMysqlInput_1 = stmt_tMysqlInput_1.executeQuery(dbquery_tMysqlInput_1); java.sql.ResultSetMetaData rsmd_tMysqlInput_1 = rs_tMysqlInput_1.getMetaData(); int colQtyInRs_tMysqlInput_1 = rsmd_tMysqlInput_1.getColumnCount(); String tmpContent_tMysqlInput_1 = null; while (rs_tMysqlInput_1.next()) { nb_line_tMysqlInput_1++; if (colQtyInRs_tMysqlInput_1 < 1) { row11.ID = 0; } else { if (rs_tMysqlInput_1.getObject(1) != null) { row11.ID = rs_tMysqlInput_1.getInt(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_1 < 2) { row11.UUID = null; } else { tmpContent_tMysqlInput_1 = rs_tMysqlInput_1.getString(2); if (tmpContent_tMysqlInput_1 != null) { row11.UUID = tmpContent_tMysqlInput_1; } else { row11.UUID = null; } } if (colQtyInRs_tMysqlInput_1 < 3) { row11.PROP_NAME = null; } else { tmpContent_tMysqlInput_1 = rs_tMysqlInput_1.getString(3); if (tmpContent_tMysqlInput_1 != null) { row11.PROP_NAME = tmpContent_tMysqlInput_1; } else { row11.PROP_NAME = null; } } if (colQtyInRs_tMysqlInput_1 < 4) { row11.PRICE = 0; } else { if (rs_tMysqlInput_1.getObject(4) != null) { row11.PRICE = rs_tMysqlInput_1.getFloat(4); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_1 < 5) { row11.SQFT = null; } else { tmpContent_tMysqlInput_1 = rs_tMysqlInput_1.getString(5); if (tmpContent_tMysqlInput_1 != null) { row11.SQFT = tmpContent_tMysqlInput_1; } else { row11.SQFT = null; } } if (colQtyInRs_tMysqlInput_1 < 6) { row11.DESCRIPTION = null; } else { tmpContent_tMysqlInput_1 = rs_tMysqlInput_1.getString(6); if (tmpContent_tMysqlInput_1 != null) { row11.DESCRIPTION = tmpContent_tMysqlInput_1; } else { row11.DESCRIPTION = null; } } if (colQtyInRs_tMysqlInput_1 < 7) { row11.NUM_BEDS = 0; } else { if (rs_tMysqlInput_1.getObject(7) != null) { row11.NUM_BEDS = rs_tMysqlInput_1.getFloat(7); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_1 < 8) { row11.NUM_BATHS = 0; } else { if (rs_tMysqlInput_1.getObject(8) != null) { row11.NUM_BATHS = rs_tMysqlInput_1.getFloat(8); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_1 < 9) { row11.TYPE = null; } else { tmpContent_tMysqlInput_1 = rs_tMysqlInput_1.getString(9); if (tmpContent_tMysqlInput_1 != null) { row11.TYPE = tmpContent_tMysqlInput_1; } else { row11.TYPE = null; } } if (colQtyInRs_tMysqlInput_1 < 10) { row11.STATUS = null; } else { tmpContent_tMysqlInput_1 = rs_tMysqlInput_1.getString(10); if (tmpContent_tMysqlInput_1 != null) { row11.STATUS = tmpContent_tMysqlInput_1; } else { row11.STATUS = null; } } if (colQtyInRs_tMysqlInput_1 < 11) { row11.DATA_SOURCE_ID = 0; } else { if (rs_tMysqlInput_1.getObject(11) != null) { row11.DATA_SOURCE_ID = rs_tMysqlInput_1.getInt(11); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_1 < 12) { row11.ZIP_CODE = 0; } else { if (rs_tMysqlInput_1.getObject(12) != null) { row11.ZIP_CODE = rs_tMysqlInput_1.getInt(12); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_1 begin ] stop */ /** * [tMysqlInput_1 main ] start */ currentComponent = "tMysqlInput_1"; tos_count_tMysqlInput_1++; /** * [tMysqlInput_1 main ] stop */ /** * [tAdvancedHash_row11 main ] start */ currentComponent = "tAdvancedHash_row11"; row11Struct row11_HashRow = new row11Struct(); row11_HashRow.ID = row11.ID; row11_HashRow.UUID = row11.UUID; row11_HashRow.PROP_NAME = row11.PROP_NAME; row11_HashRow.PRICE = row11.PRICE; row11_HashRow.SQFT = row11.SQFT; row11_HashRow.DESCRIPTION = row11.DESCRIPTION; row11_HashRow.NUM_BEDS = row11.NUM_BEDS; row11_HashRow.NUM_BATHS = row11.NUM_BATHS; row11_HashRow.TYPE = row11.TYPE; row11_HashRow.STATUS = row11.STATUS; row11_HashRow.DATA_SOURCE_ID = row11.DATA_SOURCE_ID; row11_HashRow.ZIP_CODE = row11.ZIP_CODE; tHash_Lookup_row11.put(row11_HashRow); tos_count_tAdvancedHash_row11++; /** * [tAdvancedHash_row11 main ] stop */ /** * [tMysqlInput_1 end ] start */ currentComponent = "tMysqlInput_1"; } rs_tMysqlInput_1.close(); stmt_tMysqlInput_1.close(); conn_tMysqlInput_1.close(); globalMap.put("tMysqlInput_1_NB_LINE", nb_line_tMysqlInput_1); ok_Hash.put("tMysqlInput_1", true); end_Hash.put("tMysqlInput_1", System.currentTimeMillis()); /** * [tMysqlInput_1 end ] stop */ /** * [tAdvancedHash_row11 end ] start */ currentComponent = "tAdvancedHash_row11"; tHash_Lookup_row11.endPut(); ok_Hash.put("tAdvancedHash_row11", true); end_Hash.put("tAdvancedHash_row11", System.currentTimeMillis()); /** * [tAdvancedHash_row11 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tMysqlInput_1_SUBPROCESS_STATE", 1); }
From source file:talonetl.getproperties_1_2.getProperties.java
public void tMysqlInput_5Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try {// w ww .java 2 s . co m String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; getCurrentPropertiesStruct getCurrentProperties = new getCurrentPropertiesStruct(); /** * [tHash_getCurrentProperties begin ] start */ ok_Hash.put("tHash_getCurrentProperties", false); start_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); currentComponent = "tHash_getCurrentProperties"; int tos_count_tHash_getCurrentProperties = 0; java.util.Map<getCurrentPropertiesStruct, getCurrentPropertiesStruct> tHash_getCurrentProperties = new java.util.LinkedHashMap<getCurrentPropertiesStruct, getCurrentPropertiesStruct>(); globalMap.put("tHash_getCurrentProperties", tHash_getCurrentProperties); /** * [tHash_getCurrentProperties begin ] stop */ /** * [tMysqlInput_5 begin ] start */ ok_Hash.put("tMysqlInput_5", false); start_Hash.put("tMysqlInput_5", System.currentTimeMillis()); currentComponent = "tMysqlInput_5"; int tos_count_tMysqlInput_5 = 0; java.util.Calendar calendar_tMysqlInput_5 = java.util.Calendar.getInstance(); calendar_tMysqlInput_5.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_5 = calendar_tMysqlInput_5.getTime(); int nb_line_tMysqlInput_5 = 0; java.sql.Connection conn_tMysqlInput_5 = null; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlInput_5 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlInput_5) { conn_tMysqlInput_5 = dataSources_tMysqlInput_5.get("").getConnection(); } else { java.lang.Class.forName("org.gjt.mm.mysql.Driver"); String url_tMysqlInput_5 = "jdbc:mysql://" + context.talon_Server + ":" + context.talon_Port + "/" + context.talon_Database + "?" + context.talon_AdditionalParams; String dbUser_tMysqlInput_5 = context.talon_Login; String dbPwd_tMysqlInput_5 = context.talon_Password; conn_tMysqlInput_5 = java.sql.DriverManager.getConnection(url_tMysqlInput_5, dbUser_tMysqlInput_5, dbPwd_tMysqlInput_5); } java.sql.Statement stmt_tMysqlInput_5 = conn_tMysqlInput_5.createStatement(); String dbquery_tMysqlInput_5 = "SELECT `PROPERTY_DATA`.`ID`, `PROPERTY_DATA`.`UUID`, `PROPERTY_DATA`.`PROP_NAME`, `PROPERTY_DATA`.`PRICE`, `PROPERTY_DATA`.`SQFT`, `PROPERTY_DATA`.`DESCRIPTION`, `PROPERTY_DATA`.`NUM_BEDS`, `PROPERTY_DATA`.`NUM_BATHS`, `PROPERTY_DATA`.`TYPE`, `PROPERTY_DATA`.`STATUS`, `PROPERTY_DATA`.`ZIP_CODE`, `PROPERTY_DATA`.`DATA_SOURCE_ID` FROM `PROPERTY_DATA`"; globalMap.put("tMysqlInput_5_QUERY", dbquery_tMysqlInput_5); java.sql.ResultSet rs_tMysqlInput_5 = stmt_tMysqlInput_5.executeQuery(dbquery_tMysqlInput_5); java.sql.ResultSetMetaData rsmd_tMysqlInput_5 = rs_tMysqlInput_5.getMetaData(); int colQtyInRs_tMysqlInput_5 = rsmd_tMysqlInput_5.getColumnCount(); String tmpContent_tMysqlInput_5 = null; while (rs_tMysqlInput_5.next()) { nb_line_tMysqlInput_5++; if (colQtyInRs_tMysqlInput_5 < 1) { getCurrentProperties.ID = 0; } else { if (rs_tMysqlInput_5.getObject(1) != null) { getCurrentProperties.ID = rs_tMysqlInput_5.getInt(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 2) { getCurrentProperties.UUID = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(2); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.UUID = tmpContent_tMysqlInput_5; } else { getCurrentProperties.UUID = null; } } if (colQtyInRs_tMysqlInput_5 < 3) { getCurrentProperties.PROP_NAME = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(3); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.PROP_NAME = tmpContent_tMysqlInput_5; } else { getCurrentProperties.PROP_NAME = null; } } if (colQtyInRs_tMysqlInput_5 < 4) { getCurrentProperties.PRICE = 0; } else { if (rs_tMysqlInput_5.getObject(4) != null) { getCurrentProperties.PRICE = rs_tMysqlInput_5.getFloat(4); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 5) { getCurrentProperties.SQFT = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(5); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.SQFT = tmpContent_tMysqlInput_5; } else { getCurrentProperties.SQFT = null; } } if (colQtyInRs_tMysqlInput_5 < 6) { getCurrentProperties.DESCRIPTION = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(6); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.DESCRIPTION = tmpContent_tMysqlInput_5; } else { getCurrentProperties.DESCRIPTION = null; } } if (colQtyInRs_tMysqlInput_5 < 7) { getCurrentProperties.NUM_BEDS = 0; } else { if (rs_tMysqlInput_5.getObject(7) != null) { getCurrentProperties.NUM_BEDS = rs_tMysqlInput_5.getFloat(7); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 8) { getCurrentProperties.NUM_BATHS = 0; } else { if (rs_tMysqlInput_5.getObject(8) != null) { getCurrentProperties.NUM_BATHS = rs_tMysqlInput_5.getFloat(8); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 9) { getCurrentProperties.TYPE = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(9); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.TYPE = tmpContent_tMysqlInput_5; } else { getCurrentProperties.TYPE = null; } } if (colQtyInRs_tMysqlInput_5 < 10) { getCurrentProperties.STATUS = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(10); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.STATUS = tmpContent_tMysqlInput_5; } else { getCurrentProperties.STATUS = null; } } if (colQtyInRs_tMysqlInput_5 < 11) { getCurrentProperties.DATA_SOURCE_ID = 0; } else { if (rs_tMysqlInput_5.getObject(11) != null) { getCurrentProperties.DATA_SOURCE_ID = rs_tMysqlInput_5.getInt(11); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 12) { getCurrentProperties.ZIP_CODE = 0; } else { if (rs_tMysqlInput_5.getObject(12) != null) { getCurrentProperties.ZIP_CODE = rs_tMysqlInput_5.getInt(12); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_5 begin ] stop */ /** * [tMysqlInput_5 main ] start */ currentComponent = "tMysqlInput_5"; tos_count_tMysqlInput_5++; /** * [tMysqlInput_5 main ] stop */ /** * [tHash_getCurrentProperties main ] start */ currentComponent = "tHash_getCurrentProperties"; getCurrentPropertiesStruct getCurrentProperties_HashRow = new getCurrentPropertiesStruct(); getCurrentProperties_HashRow.ID = getCurrentProperties.ID; getCurrentProperties_HashRow.UUID = getCurrentProperties.UUID; getCurrentProperties_HashRow.PROP_NAME = getCurrentProperties.PROP_NAME; getCurrentProperties_HashRow.PRICE = getCurrentProperties.PRICE; getCurrentProperties_HashRow.SQFT = getCurrentProperties.SQFT; getCurrentProperties_HashRow.DESCRIPTION = getCurrentProperties.DESCRIPTION; getCurrentProperties_HashRow.NUM_BEDS = getCurrentProperties.NUM_BEDS; getCurrentProperties_HashRow.NUM_BATHS = getCurrentProperties.NUM_BATHS; getCurrentProperties_HashRow.TYPE = getCurrentProperties.TYPE; getCurrentProperties_HashRow.STATUS = getCurrentProperties.STATUS; getCurrentProperties_HashRow.DATA_SOURCE_ID = getCurrentProperties.DATA_SOURCE_ID; getCurrentProperties_HashRow.ZIP_CODE = getCurrentProperties.ZIP_CODE; tHash_getCurrentProperties.put(getCurrentProperties_HashRow, getCurrentProperties_HashRow); tos_count_tHash_getCurrentProperties++; /** * [tHash_getCurrentProperties main ] stop */ /** * [tMysqlInput_5 end ] start */ currentComponent = "tMysqlInput_5"; } rs_tMysqlInput_5.close(); stmt_tMysqlInput_5.close(); conn_tMysqlInput_5.close(); globalMap.put("tMysqlInput_5_NB_LINE", nb_line_tMysqlInput_5); ok_Hash.put("tMysqlInput_5", true); end_Hash.put("tMysqlInput_5", System.currentTimeMillis()); /** * [tMysqlInput_5 end ] stop */ /** * [tHash_getCurrentProperties end ] start */ currentComponent = "tHash_getCurrentProperties"; ok_Hash.put("tHash_getCurrentProperties", true); end_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); /** * [tHash_getCurrentProperties end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 1); }
From source file:talonetl.getproperties_1_3.getProperties.java
public void tMysqlInput_5Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try {//from www.j a v a 2 s. co m String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; getCurrentPropertiesStruct getCurrentProperties = new getCurrentPropertiesStruct(); /** * [tHash_getCurrentProperties begin ] start */ ok_Hash.put("tHash_getCurrentProperties", false); start_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); currentComponent = "tHash_getCurrentProperties"; int tos_count_tHash_getCurrentProperties = 0; java.util.Map<getCurrentPropertiesStruct, getCurrentPropertiesStruct> tHash_getCurrentProperties = new java.util.LinkedHashMap<getCurrentPropertiesStruct, getCurrentPropertiesStruct>(); globalMap.put("tHash_getCurrentProperties", tHash_getCurrentProperties); /** * [tHash_getCurrentProperties begin ] stop */ /** * [tMysqlInput_5 begin ] start */ ok_Hash.put("tMysqlInput_5", false); start_Hash.put("tMysqlInput_5", System.currentTimeMillis()); currentComponent = "tMysqlInput_5"; int tos_count_tMysqlInput_5 = 0; java.util.Calendar calendar_tMysqlInput_5 = java.util.Calendar.getInstance(); calendar_tMysqlInput_5.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_5 = calendar_tMysqlInput_5.getTime(); int nb_line_tMysqlInput_5 = 0; java.sql.Connection conn_tMysqlInput_5 = null; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlInput_5 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlInput_5) { conn_tMysqlInput_5 = dataSources_tMysqlInput_5.get("").getConnection(); } else { java.lang.Class.forName("org.gjt.mm.mysql.Driver"); String url_tMysqlInput_5 = "jdbc:mysql://" + context.talon_Server + ":" + context.talon_Port + "/" + context.talon_Database + "?" + context.talon_AdditionalParams; String dbUser_tMysqlInput_5 = context.talon_Login; String dbPwd_tMysqlInput_5 = context.talon_Password; conn_tMysqlInput_5 = java.sql.DriverManager.getConnection(url_tMysqlInput_5, dbUser_tMysqlInput_5, dbPwd_tMysqlInput_5); } java.sql.Statement stmt_tMysqlInput_5 = conn_tMysqlInput_5.createStatement(); String dbquery_tMysqlInput_5 = "SELECT `PROPERTY_DATA`.`ID`, `PROPERTY_DATA`.`UUID`, `PROPERTY_DATA`.`PROP_NAME`, `PROPERTY_DATA`.`PRICE`, `PROPERTY_DATA`.`SQFT`, `PROPERTY_DATA`.`DESCRIPTION`, `PROPERTY_DATA`.`NUM_BEDS`, `PROPERTY_DATA`.`NUM_BATHS`, `PROPERTY_DATA`.`TYPE`, `PROPERTY_DATA`.`STATUS`, `PROPERTY_DATA`.`ZIP_CODE`, `PROPERTY_DATA`.`DATA_SOURCE_ID` FROM `PROPERTY_DATA`"; globalMap.put("tMysqlInput_5_QUERY", dbquery_tMysqlInput_5); java.sql.ResultSet rs_tMysqlInput_5 = stmt_tMysqlInput_5.executeQuery(dbquery_tMysqlInput_5); java.sql.ResultSetMetaData rsmd_tMysqlInput_5 = rs_tMysqlInput_5.getMetaData(); int colQtyInRs_tMysqlInput_5 = rsmd_tMysqlInput_5.getColumnCount(); String tmpContent_tMysqlInput_5 = null; while (rs_tMysqlInput_5.next()) { nb_line_tMysqlInput_5++; if (colQtyInRs_tMysqlInput_5 < 1) { getCurrentProperties.ID = 0; } else { if (rs_tMysqlInput_5.getObject(1) != null) { getCurrentProperties.ID = rs_tMysqlInput_5.getInt(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 2) { getCurrentProperties.UUID = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(2); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.UUID = tmpContent_tMysqlInput_5; } else { getCurrentProperties.UUID = null; } } if (colQtyInRs_tMysqlInput_5 < 3) { getCurrentProperties.PROP_NAME = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(3); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.PROP_NAME = tmpContent_tMysqlInput_5; } else { getCurrentProperties.PROP_NAME = null; } } if (colQtyInRs_tMysqlInput_5 < 4) { getCurrentProperties.PRICE = 0; } else { if (rs_tMysqlInput_5.getObject(4) != null) { getCurrentProperties.PRICE = rs_tMysqlInput_5.getFloat(4); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 5) { getCurrentProperties.SQFT = 0; } else { if (rs_tMysqlInput_5.getObject(5) != null) { getCurrentProperties.SQFT = rs_tMysqlInput_5.getFloat(5); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 6) { getCurrentProperties.DESCRIPTION = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(6); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.DESCRIPTION = tmpContent_tMysqlInput_5; } else { getCurrentProperties.DESCRIPTION = null; } } if (colQtyInRs_tMysqlInput_5 < 7) { getCurrentProperties.NUM_BEDS = 0; } else { if (rs_tMysqlInput_5.getObject(7) != null) { getCurrentProperties.NUM_BEDS = rs_tMysqlInput_5.getFloat(7); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 8) { getCurrentProperties.NUM_BATHS = 0; } else { if (rs_tMysqlInput_5.getObject(8) != null) { getCurrentProperties.NUM_BATHS = rs_tMysqlInput_5.getFloat(8); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 9) { getCurrentProperties.TYPE = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(9); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.TYPE = tmpContent_tMysqlInput_5; } else { getCurrentProperties.TYPE = null; } } if (colQtyInRs_tMysqlInput_5 < 10) { getCurrentProperties.STATUS = null; } else { tmpContent_tMysqlInput_5 = rs_tMysqlInput_5.getString(10); if (tmpContent_tMysqlInput_5 != null) { getCurrentProperties.STATUS = tmpContent_tMysqlInput_5; } else { getCurrentProperties.STATUS = null; } } if (colQtyInRs_tMysqlInput_5 < 11) { getCurrentProperties.DATA_SOURCE_ID = 0; } else { if (rs_tMysqlInput_5.getObject(11) != null) { getCurrentProperties.DATA_SOURCE_ID = rs_tMysqlInput_5.getInt(11); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_5 < 12) { getCurrentProperties.ZIP_CODE = 0; } else { if (rs_tMysqlInput_5.getObject(12) != null) { getCurrentProperties.ZIP_CODE = rs_tMysqlInput_5.getInt(12); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_5 begin ] stop */ /** * [tMysqlInput_5 main ] start */ currentComponent = "tMysqlInput_5"; tos_count_tMysqlInput_5++; /** * [tMysqlInput_5 main ] stop */ /** * [tHash_getCurrentProperties main ] start */ currentComponent = "tHash_getCurrentProperties"; getCurrentPropertiesStruct getCurrentProperties_HashRow = new getCurrentPropertiesStruct(); getCurrentProperties_HashRow.ID = getCurrentProperties.ID; getCurrentProperties_HashRow.UUID = getCurrentProperties.UUID; getCurrentProperties_HashRow.PROP_NAME = getCurrentProperties.PROP_NAME; getCurrentProperties_HashRow.PRICE = getCurrentProperties.PRICE; getCurrentProperties_HashRow.SQFT = getCurrentProperties.SQFT; getCurrentProperties_HashRow.DESCRIPTION = getCurrentProperties.DESCRIPTION; getCurrentProperties_HashRow.NUM_BEDS = getCurrentProperties.NUM_BEDS; getCurrentProperties_HashRow.NUM_BATHS = getCurrentProperties.NUM_BATHS; getCurrentProperties_HashRow.TYPE = getCurrentProperties.TYPE; getCurrentProperties_HashRow.STATUS = getCurrentProperties.STATUS; getCurrentProperties_HashRow.DATA_SOURCE_ID = getCurrentProperties.DATA_SOURCE_ID; getCurrentProperties_HashRow.ZIP_CODE = getCurrentProperties.ZIP_CODE; tHash_getCurrentProperties.put(getCurrentProperties_HashRow, getCurrentProperties_HashRow); tos_count_tHash_getCurrentProperties++; /** * [tHash_getCurrentProperties main ] stop */ /** * [tMysqlInput_5 end ] start */ currentComponent = "tMysqlInput_5"; } rs_tMysqlInput_5.close(); stmt_tMysqlInput_5.close(); conn_tMysqlInput_5.close(); globalMap.put("tMysqlInput_5_NB_LINE", nb_line_tMysqlInput_5); ok_Hash.put("tMysqlInput_5", true); end_Hash.put("tMysqlInput_5", System.currentTimeMillis()); /** * [tMysqlInput_5 end ] stop */ /** * [tHash_getCurrentProperties end ] start */ currentComponent = "tHash_getCurrentProperties"; ok_Hash.put("tHash_getCurrentProperties", true); end_Hash.put("tHash_getCurrentProperties", System.currentTimeMillis()); /** * [tHash_getCurrentProperties end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tMysqlInput_5_SUBPROCESS_STATE", 1); }