List of usage examples for org.apache.commons.dbutils.handlers ArrayHandler ArrayHandler
public ArrayHandler()
BasicRowProcessor
for conversion. From source file:com.rhino.data.db.EquityDao.java
public Date getLastTickerDetails(String equity) throws SQLException { String sql = " select cast(max(date) as date) from EOD where equity='" + equity + "'"; QueryRunner run = new QueryRunner(DataSourceFactory.getDataSource()); ResultSetHandler rsh = new ArrayHandler(); Object[] query = (Object[]) run.query(sql, rsh); if (query == null || query.length == 0) { return null; }/*from ww w . j av a 2 s. c om*/ return (Date) query[0]; }
From source file:com.fluke.database.dataservice.EquityDao.java
public Date getLastTickerDetails(String equity) throws SQLException { String sql = " select cast(max(date) as date) from EOD where equity='" + equity + "'"; QueryRunner run = new QueryRunner(DatabaseProperty.getDataSource()); ResultSetHandler rsh = new ArrayHandler(); Object[] query = (Object[]) run.query(sql, rsh); if (query == null || query.length == 0) { return null; }/*from w ww . ja va 2s . c om*/ return (Date) query[0]; }
From source file:com.fluke.database.dataservice.EODDao.java
public Date getNextTradingDay(String date) throws SQLException { String sql = "select cast(min(date) as date) from intraday where date > '" + date + "'"; QueryRunner run = new QueryRunner(DatabaseProperty.getDataSource()); ResultSetHandler rsh = new ArrayHandler(); Object[] query = (Object[]) run.query(sql, rsh); if (query == null || query.length == 0) { return null; }/* ww w .j a v a 2 s .c om*/ return (java.sql.Date) query[0]; }
From source file:de.iritgo.aktario.jdbc.JDBCIDGenerator.java
/** * Load the last generator state./*from w ww . j a v a 2 s . co m*/ */ public void load() { JDBCManager jdbcManager = (JDBCManager) Engine.instance().getManager("persist.JDBCManager"); DataSource dataSource = jdbcManager.getDefaultDataSource(); try { QueryRunner query = new QueryRunner(dataSource); Object[] res = (Object[]) query.query("select value from IritgoProperties where name=?", "persist.ids.nextvalue", new ArrayHandler()); id = Long.parseLong((String) res[0]); free = 0; Log.logDebug("persist", "JDBCIDGenerator", "Successfully loaded the generator state (id=" + id + ")"); } catch (Exception x) { Log.logError("persist", "JDBCIDGenerator", "Error while loading the generator state: " + x); } }
From source file:info.pancancer.arch3.persistence.PostgreSQL.java
public boolean previouslyRun(String hash) { Object[] runSelectStatement = this.runSelectStatement("select * from job where job_hash = ? and status !='" + JobState.FAILED.toString() + "' and status != '" + JobState.LOST + "'", new ArrayHandler(), hash); return (runSelectStatement.length > 0); }
From source file:net.sourceforge.seqware.pipeline.plugins.AttributeAnnotatorET.java
/** * Toggle just the skip column on a selected table type * * @param type/*ww w . j ava2s .c om*/ * @param accession * @throws IOException */ public void toggleSkipOnly(AttributeType type, int accession) throws IOException { String listCommand = "-p net.sourceforge.seqware.pipeline.plugins.AttributeAnnotator " + "-- --" + type.parameter_prefix + "-accession " + accession + " --skip true"; int expectedReturnValue = type.skippable ? ReturnValue.SUCCESS : ReturnValue.INVALIDPARAMETERS; ITUtility.runSeqWareJar(listCommand, expectedReturnValue, null); if (type.skippable) { Object[] runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT skip FROM " + type.table_name + " WHERE sw_accession=?", accession); Assert.assertTrue("skip value incorrect", runQuery.length == 1 && runQuery[0].equals(true)); } listCommand = "-p net.sourceforge.seqware.pipeline.plugins.AttributeAnnotator " + "-- --" + type.parameter_prefix + "-accession " + accession + " --skip false"; ITUtility.runSeqWareJar(listCommand, expectedReturnValue, null); if (type.skippable) { Object[] runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT skip FROM " + type.table_name + " WHERE sw_accession=?", accession); Assert.assertTrue("skip value incorrect", runQuery.length == 1 && runQuery[0].equals(false)); } }
From source file:net.sourceforge.seqware.pipeline.plugins.AttributeAnnotatorET.java
/** * Annotate skip with an implicit key of "skip" * * @param type/* ww w . ja va2 s.c o m*/ * @param accession * @throws IOException */ public void annotateSkipImplicitly(AttributeType type, int accession) throws IOException { String query = "SELECT t2." + type.table_name + "_attribute_id, t2.tag, t2.value FROM " + type.table_name + "_attribute t2, " + type.table_name + " t1 WHERE " + "t1." + type.table_name + "_id=t2." + type.attribute_id_prefix + "_id AND t1.sw_accession=? ORDER BY " + type.table_name + "_attribute_id"; Log.info(query); String value = "\"Improperly entered into the LIMS\""; String listCommand = "-p net.sourceforge.seqware.pipeline.plugins.AttributeAnnotator " + "-- --" + type.parameter_prefix + "-accession " + accession + " --skip true --value " + value; int expectedReturnValue = type.skippable ? ReturnValue.SUCCESS : ReturnValue.INVALIDPARAMETERS; ITUtility.runSeqWareJar(listCommand, expectedReturnValue, null); if (type.skippable) { Object[] runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT skip FROM " + type.table_name + " WHERE sw_accession=?", accession); Assert.assertTrue("skip value incorrect", runQuery.length == 1 && runQuery[0].equals(true)); List<Object[]> runQuery1 = dbCreator.runQuery(new ArrayListHandler(), query, accession); Assert.assertTrue("first annotation incorrect", runQuery1.size() == 1); Assert.assertTrue("first tag incorrect", runQuery1.get(0)[1].equals("skip")); Assert.assertTrue("first value incorrect", runQuery1.get(0)[2].equals(value)); } }
From source file:net.sourceforge.seqware.pipeline.plugins.DeleteDBET.java
@Test public void testNormalWorkflowRunDelete() throws IOException { unblockWorkflowRuns();// w ww .j a va2s.c o m String listCommand = "-p net.sourceforge.seqware.pipeline.plugins.deletion.DeletionDB " + "-- --r 6698"; String output = ITUtility.runSeqWareJar(listCommand, ReturnValue.SUCCESS, null); File keyFile = getAndCheckForKeyFile(output); Assert.assertTrue("key file is empty", keyFile.exists()); listCommand = "-p net.sourceforge.seqware.pipeline.plugins.deletion.DeletionDB " + "-- --r 6698 -k " + keyFile.getAbsolutePath(); ITUtility.runSeqWareJar(listCommand, ReturnValue.SUCCESS, null); // double check that the workflow run has actually been deleted Object[] runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT * FROM workflow_run WHERE sw_accession=6698"); Assert.assertTrue("workflow run not deleted", runQuery == null); // reset database when testing successful deletes ExtendedTestDatabaseCreator.resetDatabaseWithUsers(); }
From source file:net.sourceforge.seqware.pipeline.plugins.DeleteDBET.java
@Test public void testNormalLaneTargetWorkflowRunDelete() throws IOException { unblockWorkflowRuns();// w w w . j av a 2 s . c o m String listCommand = "-p net.sourceforge.seqware.pipeline.plugins.deletion.DeletionDB " + "-- --r 4764"; String output = ITUtility.runSeqWareJar(listCommand, ReturnValue.SUCCESS, null); File keyFile = getAndCheckForKeyFile(output); Assert.assertTrue("key file is empty", keyFile.exists()); listCommand = "-p net.sourceforge.seqware.pipeline.plugins.deletion.DeletionDB " + "-- --r 4764 -k " + keyFile.getAbsolutePath(); ITUtility.runSeqWareJar(listCommand, ReturnValue.SUCCESS, null); // double check that the workflow run has actually been deleted Object[] runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT * FROM workflow_run WHERE sw_accession=6683 OR sw_accession = 6684"); Assert.assertTrue("workflow run not deleted", runQuery == null); // reset database when testing successful deletes ExtendedTestDatabaseCreator.resetDatabaseWithUsers(); }
From source file:net.sourceforge.seqware.pipeline.plugins.DeleteDBET.java
@Test public void testNormalSequencerRunTargetWorkflowRunDelete() throws IOException { unblockWorkflowRuns();/*from w ww . j ava 2 s. c om*/ String listCommand = "-p net.sourceforge.seqware.pipeline.plugins.deletion.DeletionDB " + "-- --r 4715"; String output = ITUtility.runSeqWareJar(listCommand, ReturnValue.SUCCESS, null); File keyFile = getAndCheckForKeyFile(output); Assert.assertTrue("key file is empty", keyFile.exists()); listCommand = "-p net.sourceforge.seqware.pipeline.plugins.deletion.DeletionDB " + "-- --r 4715 -k " + keyFile.getAbsolutePath(); ITUtility.runSeqWareJar(listCommand, ReturnValue.SUCCESS, null); // double check that the workflow run has actually been deleted Object[] runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT * FROM workflow_run WHERE sw_accession=872 OR sw_accession = 882 OR sw_accession = 5657 OR sw_accession = 6683 OR sw_accession = 6684"); Assert.assertTrue("workflow runs not deleted", runQuery == null); runQuery = dbCreator.runQuery(new ArrayHandler(), "SELECT * FROM file WHERE sw_accession=881 OR sw_accession = 1963 OR sw_accession = 1978 OR sw_accession = 2139 OR sw_accession = 2160"); Assert.assertTrue("files not deleted", runQuery == null); // reset database when testing successful deletes ExtendedTestDatabaseCreator.resetDatabaseWithUsers(); }