EmpireWorkflowParameterDao extends EmpireDao implements WorkflowParameterDao { @Override public List<TaskParameterView> view(TaskParameterFilter filter) { BeanResult<TaskParameterView> result = new BeanResult<TaskParameterView>( TaskParameterView.class, tableParams); DBCommand cmd = result.getCommand(); cmd.select(tableParams.getColumns()); cmd.select(db.tableWorkflowTask.jobId, db.tableWorkflowTask.typeRef.as("TASK_PROFILE_NAME")); cmd.join(tableParams.taskId, db.tableWorkflowTask.id); if (filter.getTaskId() != null) { cmd.where(tableParams.taskId.is(filter.getTaskId())); } if (filter.getProfileName()!= null) { cmd.where(tableParams.paramRef.is(filter.getProfileName())); } if (filter.getJobId() != null) { cmd.where(db.tableWorkflowTask.jobId.is(filter.getJobId())); } DBReader reader = new DBReader(); try { reader.open(cmd, getConnection()); if (!reader.skipRows(filter.getOffset())) { return Collections.emptyList(); } ArrayList<TaskParameterView> viewItems = new ArrayList<TaskParameterView>(filter.getMaxCount()); for (Iterator<DBRecordData> it = reader.iterator(filter.getMaxCount()); it.hasNext();) { DBRecordData rec = it.next(); TaskParameterView view = new TaskParameterView(); rec.getBeanProperties(view); viewItems.add(view); } return viewItems; } finally { reader.close(); } } EmpireWorkflowParameterDao(ProarcDatabase db); @Override TaskParameter create(); @Override void add(BigDecimal taskId, List<TaskParameter> params); @Override void remove(BigDecimal taskId); @Override List<TaskParameter> find(BigDecimal taskId); Map<String, String> findAsMap(BigDecimal taskId); @Override List<TaskParameterView> view(TaskParameterFilter filter);  }
@Test public void testView() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(getClass(), "user.xml"), support.loadFlatXmlDataStream(getClass(), "wf_job.xml"), support.loadFlatXmlDataStream(getClass(), "wf_task.xml"), support.loadFlatXmlDataStream(getClass(), "wf_param.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); Task task = new Task().addId(BigDecimal.ONE); TaskParameterFilter filter = new TaskParameterFilter(); filter.setTaskId(task.getId()); List<TaskParameterView> params = dao.view(filter); assertEquals(2, params.size()); filter = new TaskParameterFilter(); filter.setTaskId(BigDecimal.TEN); params = dao.view(filter); assertEquals(1, params.size()); filter = new TaskParameterFilter(); filter.setTaskId(BigDecimal.ZERO); params = dao.view(filter); assertEquals(0, params.size()); filter = new TaskParameterFilter(); filter.setJobId(BigDecimal.ONE); params = dao.view(filter); assertEquals(2, params.size()); filter = new TaskParameterFilter(); filter.setProfileName("param.t10.p1"); params = dao.view(filter); assertEquals(1, params.size()); assertEquals(BigDecimal.TEN, params.get(0).getTaskId()); assertEquals("task.id2", params.get(0).getTaskProfileName()); assertEquals(new BigDecimal(2), params.get(0).getJobId()); assertEquals(ValueType.NUMBER, params.get(0).getValueType()); assertEquals("10.1", params.get(0).getValue()); }