@Override public ProcessorResult process( PipelineConfig pipelineConfig, Processor processorConfig, String inputJson) { ProcessorResult result = new ProcessorResult(Processor.ProcessorType.KETTLE_DATA); // clear the temp table storage.getTempJdbcTemplate().execute("TRUNCATE TABLE KETTLE_DATA"); // get the data from the PCSM_SCORING table String sql = "SELECT " + "ALTERNATIVE_ID," + "COURSE_ID," + "MODEL_RISK_CONFIDENCE " + "FROM " + "PCSM_SCORING"; List<Map<String, Object>> pcsmScoring = storage.getTempJdbcTemplate().queryForList(sql); // insert data from PCSM_SCORING into KETTLE_DATA for CSV output int rowCount = 0; for (Map<String, Object> pcsmScore : pcsmScoring) { Object[] values = new Object[] { pcsmScore.get("ALTERNATIVE_ID"), pcsmScore.get("COURSE_ID"), pcsmScore.get("MODEL_RISK_CONFIDENCE") }; storage .getTempJdbcTemplate() .update( "INSERT INTO KETTLE_DATA (ALTERNATIVE_ID, COURSE_ID, MODEL_RISK_CONFIDENCE) VALUES (?,?,?)", values); rowCount++; } result.done(rowCount, null); return result; }
@PostConstruct public void init() { // create the temp table storage .getTempJdbcTemplate() .execute( "CREATE TABLE IF NOT EXISTS KETTLE_DATA (" + " ID INT(11) NOT NULL AUTO_INCREMENT," + " ALTERNATIVE_ID VARCHAR(255) NOT NULL," + " COURSE_ID VARCHAR(255) NOT NULL," + " MODEL_RISK_CONFIDENCE VARCHAR(255), " + " PRIMARY KEY (ID)," + " UNIQUE KEY KETTLE_DATA_UNIQUE (ALTERNATIVE_ID, COURSE_ID)" + ")"); logger.info("INIT: created temp table KETTLE_DATA"); }