List of usage examples for org.apache.commons.dbutils.handlers BeanListHandler BeanListHandler
public BeanListHandler(Class<T> type)
From source file:com.pinterest.deployservice.db.DBTagDAOImpl.java
@Override public List<TagBean> getByTargetIdAndType(String target_id, TagTargetType target_type) throws Exception { ResultSetHandler<List<TagBean>> h = new BeanListHandler<TagBean>(TagBean.class); return new QueryRunner(basicDataSource).query(GET_TAG_BY_TARGET_ID_AND_TYPE_TEMPLATE, h, target_id, target_type.toString());//from w ww . j av a 2s . co m }
From source file:com.pinterest.arcee.db.DBGroupMappingDAOImpl.java
@Override public Collection<GroupMappingBean> getGroupMappingsByCluster(String clusterName) throws Exception { ResultSetHandler<List<GroupMappingBean>> h = new BeanListHandler<>(GroupMappingBean.class); return new QueryRunner(dataSource).query(GET_GROUP_MAPPING_BY_CLUSTER, h, clusterName); }
From source file:com.pinterest.deployservice.db.DBHotfixDAOImpl.java
@Override public List<HotfixBean> getHotfixes(String envName, int pageIndex, int pageSize) throws Exception { ResultSetHandler<List<HotfixBean>> h = new BeanListHandler<>(HotfixBean.class); QueryRunner run = new QueryRunner(this.dataSource); return run.query(GET_HOTFIXES, h, envName, (pageIndex - 1) * pageSize, pageSize); }
From source file:com.che.software.testato.domain.dao.jdbc.impl.SelectionDAO.java
/** * Selection search from a bean of criterions. * /*from w w w . ja v a2 s . c om*/ * @author Clement HELIOU (clement.heliou@che-software.com). * @param searchBean the criterions to use for the search. * @return the resulting object list. * @since August, 2011. * @throws SelectionSearchDAOException if an error occurs during the search. */ @Override public List<Selection> searchSelection(SelectionSearch searchBean) throws SelectionSearchDAOException { LOGGER.debug("searchSelection()."); Connection connection = null; try { connection = getDataSource().getConnection(); List<Object> params = new ArrayList<Object>(); List<Selection> selections = getQueryRunner().query(connection, getSelectionSearchQueryFromCriterion(searchBean, params), new BeanListHandler<Selection>(Selection.class), params.toArray()); for (Selection selection : selections) { selection.setOperator(Operator.valueOf(selection.getOperatorString())); selection.setSelectionType(SelectionTypes.valueOf(selection.getSelectionTypeString())); selection.setCostValueAreas( getCostValuesAreasFromSelectionType(connection, selection.getSelectionType())); selection.setFitRiskAreas( getFitRiskAreasFromSelectionType(connection, selection.getSelectionType())); } return selections; } catch (SQLException e) { throw new SelectionSearchDAOException(e); } finally { if (null != connection) { DbUtils.closeQuietly(connection); } } }
From source file:com.che.software.testato.domain.dao.jdbc.impl.TestCaseDAO.java
/** * Test cases variants to generate search. * /*ww w .ja v a 2 s .co m*/ * @author Clement HELIOU (clement.heliou@che-software.com). * @return the resulting object list. * @since July, 2011. * @throws TestCaseSearchDAOException if an error occurs during the search. */ @Override public List<TestCase> searchTestCasesVariantsToGenerate() throws TestCaseSearchDAOException { LOGGER.debug("searchTestCasesVariantsToGenerate()."); Connection connection = null; try { connection = getDataSource().getConnection(); return getQueryRunner().query(connection, "SELECT test_case_id AS testCaseId, item.label AS label, ve.version_id AS versionId, project.project_id AS projectId, ve.name AS versionName, project.name AS projectName FROM test_case JOIN item USING(test_case_id) LEFT JOIN action_inclusive_item aii ON(aii.item_id = item.item_id) LEFT JOIN action_exclusive_item aei ON(aei.item_id = item.item_id) JOIN action a ON(a.action_id = COALESCE(aei.action_id, aii.action_id)) JOIN hierarchy_action_plan h ON(h.action_plan_id = a.action_plan_id) JOIN hierarchy_version v ON(v.hierarchy_id = h.hierarchy_id) JOIN version ve ON(ve.version_id = v.version_id) JOIN project ON(project.project_id = ve.project_id) WHERE NOT EXISTS( SELECT variant_id FROM variant va WHERE va.test_case_id = test_case_id ) ", new BeanListHandler<TestCase>(TestCase.class)); } catch (SQLException e) { throw new TestCaseSearchDAOException(e); } finally { if (null != connection) { DbUtils.closeQuietly(connection); } } }
From source file:magrathea.marvin.desktop.user.dao.DerbyDAO.DerbyUserDAO.java
@Override public List<User> findAll() { try {/* www .j a v a 2s .c om*/ return dbAccess.query(con, "SELECT * FROM \"User\"", new BeanListHandler<User>(User.class)); } catch (Exception e) { e.printStackTrace(); } return EMPTY; }
From source file:com.pinterest.deployservice.db.DBTagDAOImpl.java
@Override public List<TagBean> getByValue(TagValue value) throws Exception { ResultSetHandler<List<TagBean>> h = new BeanListHandler<TagBean>(TagBean.class); return new QueryRunner(basicDataSource).query(GET_TAG_BY_VALUE, h, value.toString()); }
From source file:com.pinterest.deployservice.db.DBUserRolesDAOImpl.java
@Override public List<UserRolesBean> getByResource(String resourceId, Resource.Type resourceType) throws Exception { ResultSetHandler<List<UserRolesBean>> h = new BeanListHandler<>(UserRolesBean.class); return new QueryRunner(dataSource).query(GET_BY_RESOURCE, h, resourceId, resourceType.toString()); }
From source file:com.pinterest.deployservice.db.DBGroupRolesDAOImpl.java
@Override public List<GroupRolesBean> getByResource(String resourceId, Resource.Type resourceType) throws Exception { ResultSetHandler<List<GroupRolesBean>> h = new BeanListHandler<>(GroupRolesBean.class); return new QueryRunner(dataSource).query(GET_BY_RESOURCE, h, resourceId, resourceType.toString()); }
From source file:com.che.software.testato.domain.dao.jdbc.impl.MatrixResultDAO.java
/** * Creates the matrix results for a given iteration assignment. The related * matrix must be completed before calling this method. * //from w w w . j a va 2s. co m * @author Clement HELIOU (clement.heliou@che-software.com). * @param iterationId the given iteration id. * @since August, 2011. * @throws MatrixResultCreationDAOException if an error occurs during the * creation. */ @Override public void createMatrixResults(int iterationId) throws MatrixResultCreationDAOException { LOGGER.debug("createMatrixResults(" + iterationId + ")."); Connection connection = null; try { connection = getDataSource().getConnection(); connection.setAutoCommit(false); for (MatrixResult result : getQueryRunner().query(connection, "SELECT first_script AS scriptId, iteration_assignment_id AS iterationAssignmentId, ((SUM((value/( SELECT SUM(value) FROM comparisonMatrixItem WHERE iteration_assignment_id = ? AND second_script = base.second_script GROUP BY second_script ORDER BY second_script ))))/COUNT(*))::numeric(15,2) AS percentage FROM comparisonMatrixItem base WHERE iteration_assignment_id = ? GROUP BY first_script,iteration_assignment_id ORDER BY first_script ", new BeanListHandler<MatrixResult>(MatrixResult.class), new Object[] { iterationId, iterationId })) { getQueryRunner().update(connection, "INSERT INTO iteration_assignment_source_script(script_id, iteration_assignment_id, percentage) VALUES(?, ?, ?) ", new Object[] { result.getScriptId(), result.getIterationAssignmentId(), result.getPercentage() }); } connection.commit(); } catch (SQLException e) { try { connection.rollback(); } catch (SQLException e1) { throw new MatrixResultCreationDAOException(e1); } throw new MatrixResultCreationDAOException(e); } finally { if (null != connection) { DbUtils.closeQuietly(connection); } } }