List of usage examples for org.apache.commons.dbutils.handlers ArrayListHandler ArrayListHandler
public ArrayListHandler()
BasicRowProcessor
for conversions. From source file:de.iritgo.aktario.jdbc.LoadAllUsers.java
/** * Perform the command./*from w w w . jav a 2s . c om*/ */ public void perform() { JDBCManager jdbcManager = (JDBCManager) Engine.instance().getManager("persist.JDBCManager"); DataSource dataSource = jdbcManager.getDefaultDataSource(); final UserRegistry userRegistry = Server.instance().getUserRegistry(); try { QueryRunner query = new QueryRunner(dataSource); List userIds = (List) query.query("select id from IritgoUser", new ArrayListHandler()); for (Iterator i = userIds.iterator(); i.hasNext();) { Long userId = (Long) ((Object[]) i.next())[0]; Properties props = new Properties(); props.put("id", userId); CommandTools.performSimple("persist.LoadUser", props); } Log.logVerbose("persist", "LoadAllUsers", "Successfully loaded " + userIds.size() + " users"); } catch (Exception x) { Log.logError("persist", "LoadAllUsers", "Error while loading the users: " + x); } }
From source file:com.aw.core.dao.AWQueryRunner.java
public List findListOfArrays(Connection con, String sql, Object[] filterKeys) { try {// w ww .ja v a 2 s . co m if (logger.isDebugEnabled()) logger.debug("Executing:" + buildSQLLog(sql, filterKeys)); return (List) super.query(con, sql, filterKeys, new ArrayListHandler()); } catch (SQLException e) { throw AWBusinessException.wrapUnhandledException(logger, e); } }
From source file:io.seqware.pipeline.plugins.WorkflowSchedulerTest.java
@Test public void testNormalSchedule() { launchPlugin("--workflow-accession", "2860", "--host", FileTools.getLocalhost(null).hostname); String s = getOut();// w ww. ja v a 2 s . c o m String firstWorkflowRun = getAndCheckSwid(s); BasicTestDatabaseCreator dbCreator = new BasicTestDatabaseCreator(); List<Object[]> runQuery = dbCreator.runQuery(new ArrayListHandler(), "select r.status, r.workflow_id from workflow_run r\n" + "WHERE \n" + "r.sw_accession = ?\n" + "; ", Integer.valueOf(firstWorkflowRun)); Assert.assertTrue( "schedule workflow is incorrect " + runQuery.get(0)[0].toString() + " " + runQuery.get(0)[1].toString(), runQuery.get(0)[0].equals(WorkflowRunStatus.submitted.toString()) && runQuery.get(0)[1].equals(15)); }
From source file:io.seqware.pipeline.plugins.WorkflowSchedulerTest.java
@Test public void testOozieWorkflowEngine() { launchPlugin("--workflow-accession", "2860", "--host", FileTools.getLocalhost(null).hostname, "--workflow-engine", Engines.TYPES.oozie.toString()); String s = getOut();//from ww w .j a va2 s .c om String firstWorkflowRun = getAndCheckSwid(s); BasicTestDatabaseCreator dbCreator = new BasicTestDatabaseCreator(); List<Object[]> runQuery = dbCreator.runQuery(new ArrayListHandler(), "select r.status, r.workflow_id, r.workflow_engine from workflow_run r\n" + "WHERE \n" + "r.sw_accession = ?\n" + "; ", Integer.valueOf(firstWorkflowRun)); Assert.assertTrue( "schedule workflow is incorrect " + runQuery.get(0)[0].toString() + " " + runQuery.get(0)[1].toString(), runQuery.get(0)[0].equals(WorkflowRunStatus.submitted.toString()) && runQuery.get(0)[1].equals(15)); Assert.assertTrue("schedule workflow engine is incorrect " + runQuery.get(0)[2].toString(), runQuery.get(0)[2].equals(Engines.TYPES.oozie.toString())); }
From source file:com.aw.core.dao.DAOSql.java
/** * Helper method used to retrieve a list of Arrays using standard SQL sintaxis * The query must return columns maintaining the ordinal position on the query * * @param sql SQL query/* w ww . j a va 2 s.co m*/ * @param filterKeys key used to restrict the search * @return list of arrays */ public List<Object[]> findListOfArrays(String sql, Object[] filterKeys) { return (List<Object[]>) executeQuery(sql, filterKeys, new ArrayListHandler()); }
From source file:io.seqware.pipeline.plugins.WorkflowSchedulerTest.java
@Test public void testOozieSGEWorkflowEngine() { launchPlugin("--workflow-accession", "2860", "--host", FileTools.getLocalhost(null).hostname, "--workflow-engine", Engines.TYPES.oozie_sge.toString()); String s = getOut();//from w ww. j ava2 s .com String firstWorkflowRun = getAndCheckSwid(s); BasicTestDatabaseCreator dbCreator = new BasicTestDatabaseCreator(); List<Object[]> runQuery = dbCreator.runQuery(new ArrayListHandler(), "select r.status, r.workflow_id, r.workflow_engine from workflow_run r\n" + "WHERE \n" + "r.sw_accession = ?\n" + "; ", Integer.valueOf(firstWorkflowRun)); Assert.assertTrue( "schedule workflow is incorrect " + runQuery.get(0)[0].toString() + " " + runQuery.get(0)[1].toString(), runQuery.get(0)[0].equals(WorkflowRunStatus.submitted.toString()) && runQuery.get(0)[1].equals(15)); Assert.assertTrue("schedule workflow engine is incorrect " + runQuery.get(0)[2].toString(), runQuery.get(0)[2].equals(Engines.TYPES.oozie_sge.toString())); }
From source file:com.che.software.testato.domain.dao.jdbc.impl.SelectionDAO.java
/** * Gets the cost values selectives areas for a given selection type. * // w ww .j a v a2 s . c o m * @author Clement HELIOU (clement.heliou@che-software.com). * @param connection the connection to use. * @param type the selection type. * @return the resulting object list. * @since August, 2011. * @throws SQLException if an error occurs during the search. */ private List<SelectiveArea> getCostValuesAreasFromSelectionType(Connection connection, SelectionTypes type) throws SQLException { LOGGER.debug("getCostValuesAreasFromSelectionType(" + type.name() + ")."); List<SelectiveArea> areas = new ArrayList<SelectiveArea>(); for (Object[] area : getQueryRunner().query(connection, "SELECT selective_area FROM cv_selection_type_area WHERE selection_type = ? ", new ArrayListHandler(), new Object[] { type.name() })) { areas.add(SelectiveArea.valueOf(area[0].toString().toUpperCase())); } return areas; }
From source file:io.seqware.pipeline.plugins.WorkflowSchedulerTest.java
@Test public void testParentAccessions() { launchPlugin("--workflow-accession", "2860", "--host", FileTools.getLocalhost(null).hostname, "--parent-accessions", "4765,4789"); String s = getOut();/*from ww w . j av a2 s . c o m*/ String firstWorkflowRun = getAndCheckSwid(s); BasicTestDatabaseCreator dbCreator = new BasicTestDatabaseCreator(); List<Object[]> runQuery = dbCreator.runQuery(new ArrayListHandler(), "select r.status, r.workflow_id, r.ini_file from workflow_run r\n" + "WHERE \n" + "r.sw_accession = ?\n" + "; ", Integer.valueOf(firstWorkflowRun)); Assert.assertTrue( "schedule workflow is incorrect " + runQuery.get(0)[0].toString() + " " + runQuery.get(0)[1].toString(), runQuery.get(0)[0].equals(WorkflowRunStatus.submitted.toString()) && runQuery.get(0)[1].equals(15)); String iniFile = runQuery.get(0)[2].toString(); Map<String, String> iniMap = MapTools.iniString2Map(iniFile); testIniKey(iniMap, ReservedIniKeys.PARENT_DASH_ACCESSIONS.getKey(), "4765"); testIniKey(iniMap, ReservedIniKeys.PARENT_DASH_ACCESSIONS.getKey(), "4789"); testIniKey(iniMap, ReservedIniKeys.PARENT_ACCESSION.getKey(), "4765"); testIniKey(iniMap, ReservedIniKeys.PARENT_ACCESSION.getKey(), "4789"); testIniKey(iniMap, ReservedIniKeys.PARENT_UNDERSCORE_ACCESSIONS.getKey(), "4765"); testIniKey(iniMap, ReservedIniKeys.PARENT_UNDERSCORE_ACCESSIONS.getKey(), "4789"); }
From source file:com.che.software.testato.domain.dao.jdbc.impl.SelectionDAO.java
/** * Gets the fit risk values selectives areas for a given selection type. * //from w ww . j a va2 s. co m * @author Clement HELIOU (clement.heliou@che-software.com). * @param connection the connection to use. * @param type the selection type. * @return the resulting object list. * @since August, 2011. * @throws SQLException if an error occurs during the search. */ private List<SelectiveArea> getFitRiskAreasFromSelectionType(Connection connection, SelectionTypes type) throws SQLException { LOGGER.debug("getFitRiskAreasFromSelectionType(" + type.name() + ")."); List<SelectiveArea> areas = new ArrayList<SelectiveArea>(); for (Object[] area : getQueryRunner().query(connection, "SELECT selective_area FROM fr_selection_type_area WHERE selection_type = ? ", new ArrayListHandler(), new Object[] { type.name() })) { areas.add(SelectiveArea.valueOf(area[0].toString().toUpperCase())); } return areas; }
From source file:com.che.software.testato.domain.dao.jdbc.impl.UserDAO.java
/** * User search from a bean of criterions. * //from ww w .j a va 2s .c o m * @author Clement HELIOU (clement.heliou@che-software.com). * @param searchBean the criterions to use for the search. * @return the resulting object list. * @since July, 2011. * @throws UserSearchDAOException if an error occurs during the search. */ @Override public List<User> searchUsers(UserSearch searchBean) throws UserSearchDAOException { LOGGER.debug("searchUsers()."); Connection connection = null; try { connection = getDataSource().getConnection(); List<Object> params = new ArrayList<Object>(); List<User> result = getQueryRunner().query(connection, getUserSearchQueryFromCriterion(searchBean, params), new BeanListHandler<User>(User.class), params.toArray()); if (null != result) { // Adding the users roles. for (User user : result) { List<Role> roles = new ArrayList<Role>(); for (Object[] role : getQueryRunner().query(connection, getUserRoleSearchQuery(), new ArrayListHandler(), new Object[] { user.getUserId() })) { roles.add(Role.valueOf(role[0].toString().toUpperCase())); } user.setRoles(roles); } } return result; } catch (SQLException e) { throw new UserSearchDAOException(e); } finally { if (null != connection) { DbUtils.closeQuietly(connection); } } }