EmpireWorkflowMaterialDao extends EmpireDao implements WorkflowMaterialDao { @Override public void addTaskReference(Material m, Task t, Way way) { DBRecord r = new DBRecord(); r.create(db.tableWorkflowMaterialInTask); r.setValue(db.tableWorkflowMaterialInTask.materialId, m.getId()); r.setValue(db.tableWorkflowMaterialInTask.taskId, t.getId()); r.setValue(db.tableWorkflowMaterialInTask.way, way.name()); r.update(getConnection()); } EmpireWorkflowMaterialDao(ProarcDatabase db); @Override T create(MaterialType type); @Override T find(BigDecimal id); @Override Job findJob(Material m); @Override List<MaterialView> view(MaterialFilter filter); @Override void update(Material m); @Override void addTaskReference(Material m, Task t, Way way);  }
@Test public void testAddTaskReference() 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_material.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); Material m1 = dao.find(BigDecimal.ONE); Task t1 = daoTask.find(BigDecimal.ONE); dao.addTaskReference(m1, t1, Way.INPUT); tx.commit(); MaterialFilter filter = new MaterialFilter(); filter.setId(m1.getId()); filter.setTaskId(t1.getId()); filter.setSortBy(schema.tableWorkflowMaterialInTask.way.getBeanPropertyName()); List<MaterialView> result = dao.view(filter); assertEquals(2, result.size()); assertEquals(BigDecimal.ONE, result.get(0).getId()); assertEquals(Way.INPUT, result.get(0).getWay()); assertEquals(BigDecimal.ONE, result.get(1).getId()); assertEquals(Way.OUTPUT, result.get(1).getWay()); }