WorkflowManager { public TaskManager tasks() { return new TaskManager(daoFactory, wp, this); } WorkflowManager(WorkflowProfiles wp, DaoFactory daoFactory, UserManager users); static WorkflowManager getInstance(); static void setInstance(WorkflowManager instance); Job getJob(BigDecimal id); List<JobView> findJob(JobFilter filter); List<MaterialView> findMaterial(MaterialFilter filter); MaterialView createDigitalMaterialFromPhysical(DigitalObjectManager.CreateHandler handler, MaterialView view); Material updateMaterial(MaterialView view); Job getJobs(BigDecimal id); List<TaskParameterView> findParameter(TaskParameterFilter filter); Job updateJob(Job job); TaskManager tasks(); Job addJob(JobDefinition jobProfile, String xml,
            CatalogConfiguration catalog, BigDecimal rdczId, UserProfile defaultUser, AppConfiguration appConfiguration
    ); Job addSubjob(JobDefinition jobProfile, BigDecimal parentId,
            UserProfile defaultUser, WorkflowDefinition profiles, AppConfiguration appConfiguration
    );  }
@Test public void testUpdateTaskState() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(EmpireWorkflowJobDaoTest.class, "user.xml"), support.loadFlatXmlDataStream(WorkflowManagerTest.class, "WorkflowManagerUpdateTaskState.xml") ); final IDatabaseConnection dbcon = support.getConnection(); support.cleanInsert(dbcon, db); dbcon.getConnection().commit(); dbcon.close(); WorkflowManager wm = initWorkflowManager("WorkflowManagerUpdateTaskStateProfile.xml"); TaskManager tm = wm.tasks(); WorkflowDefinition workflow = wp.getProfiles(); assertNotNull(workflow); JobDefinition jobProfile = wp.getProfile(workflow, "job1"); assertNotNull(jobProfile); Map<String, Object> params = null; TaskFilter taskFilter = new TaskFilter(); taskFilter.setId(new BigDecimal(3)); taskFilter.setLocale(Locale.ENGLISH); List<TaskView> tasks = tm.findTask(taskFilter, workflow); TaskView task = tasks.get(0); assertEquals(Task.State.WAITING, task.getState()); task.setState(State.READY); try { Task update = tm.updateTask(task, params, workflow); fail("Cannot update blocked state! " + update.getStateAsString()); } catch (WorkflowException ex) { assertEquals("Task is blocked by other tasks!", ex.getMessage()); } taskFilter.setId(new BigDecimal(2)); tasks = tm.findTask(taskFilter, workflow); task = tasks.get(0); assertEquals(Task.State.WAITING, tm.findTask(taskFilter, workflow).get(0).getState()); task.setState(State.READY); Task update = tm.updateTask(task, params, workflow); assertEquals(Task.State.READY, update.getState()); taskFilter.setId(new BigDecimal(3)); assertEquals(Task.State.WAITING, tm.findTask(taskFilter, workflow).get(0).getState()); taskFilter.setId(new BigDecimal(2)); tasks = tm.findTask(taskFilter, workflow); task = tasks.get(0); assertEquals(Task.State.READY, tm.findTask(taskFilter, workflow).get(0).getState()); task.setState(State.FINISHED); update = tm.updateTask(task, params, workflow); assertEquals(Task.State.FINISHED, update.getState()); taskFilter.setId(new BigDecimal(4)); assertEquals(Task.State.READY, tm.findTask(taskFilter, workflow).get(0).getState()); taskFilter.setId(new BigDecimal(12)); assertEquals(Task.State.WAITING, tm.findTask(taskFilter, workflow).get(0).getState()); taskFilter.setId(new BigDecimal(13)); assertEquals(Task.State.WAITING, tm.findTask(taskFilter, workflow).get(0).getState()); }