Package me.kafeitu.demo.activiti.entity.oa

Examples of me.kafeitu.demo.activiti.entity.oa.Leave


   * 测试全部审批通过的情况
   * @throws Exception
   */
  @Test
  public void testAllPass() throws Exception {
    Leave leave = new Leave();
    leave.setApplyTime(new Date());
    leave.setStartTime(new jodd.datetime.JDateTime("2012-05-22 12:00").convertToDate());
    leave.setEndTime(new jodd.datetime.JDateTime("2012-05-23 09:00").convertToDate());
    leave.setLeaveType("公休");
    leave.setUserId("kafeitu");
    leave.setReason("no reason");

    Map<String, Object> variables = new HashMap<String, Object>();
    leaveWorkflowService.startWorkflow(leave, variables);
    assertNotNull(leave.getProcessInstanceId());

    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
        .processInstanceBusinessKey(leave.getId().toString()).singleResult();
    assertNotNull(processInstance);
   
    // 部门领导
    Task task = taskService.createTaskQuery().taskCandidateGroup("deptLeader").singleResult();
    assertNotNull(task);
    taskService.claim(task.getId(), "leaderuser");
   
    variables = new HashMap<String, Object>();
    variables.put("deptLeaderPass", true);
    taskService.complete(task.getId(), variables);
   
    // HR
    task = taskService.createTaskQuery().taskCandidateGroup("hr").singleResult();
    assertNotNull(task);
    taskService.claim(task.getId(), "hruser");
   
    variables = new HashMap<String, Object>();
    variables.put("hrPass", true);
    taskService.complete(task.getId(), variables);
   
    // 销假
    task = taskService.createTaskQuery().taskAssignee(leave.getUserId()).singleResult();
    variables = new HashMap<String, Object>();
    variables.put("realityStartTime", new jodd.datetime.JDateTime("2012-05-22 13:00").convertToDate());
    variables.put("realityEndTime", new jodd.datetime.JDateTime("2012-05-24 09:00").convertToDate());
    taskService.complete(task.getId(), variables);
   
    em.flush();
   
    leave = leaveManager.getLeave(leave.getId());
    assertNotNull(leave.getRealityStartTime());
    assertNotNull(leave.getRealityEndTime());
   
    // 验证已结束流程
    long count = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("leave").finished().count();
    assertEquals(1, count);
  }
View Full Code Here


        List<HistoricProcessInstance> list = query.listPage(pageParams[0], pageParams[1]);

        // 关联业务实体
        for (HistoricProcessInstance historicProcessInstance : list) {
            String businessKey = historicProcessInstance.getBusinessKey();
            Leave leave = leaveManager.getLeave(new Long(businessKey));
            leave.setProcessDefinition(getProcessDefinition(historicProcessInstance.getProcessDefinitionId()));
            leave.setHistoricProcessInstance(historicProcessInstance);
            results.add(leave);
        }
        page.setTotalCount(query.count());
        page.setResult(results);
        return results;
View Full Code Here

     * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
     */
    public void notify(DelegateTask delegateTask) {
        String processInstanceId = delegateTask.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        Leave leave = leaveManager.getLeave(new Long(processInstance.getBusinessKey()));

        leave.setLeaveType((String) delegateTask.getVariable("leaveType"));
        leave.setStartTime((Date) delegateTask.getVariable("startTime"));
        leave.setEndTime((Date) delegateTask.getVariable("endTime"));
        leave.setReason((String) delegateTask.getVariable("reason"));

        leaveManager.saveLeave(leave);
    }
View Full Code Here

     * @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
     */
    public void notify(DelegateTask delegateTask) {
        String processInstanceId = delegateTask.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        Leave leave = leaveManager.getLeave(new Long(processInstance.getBusinessKey()));

        Object realityStartTime = delegateTask.getVariable("realityStartTime");
        leave.setRealityStartTime((Date) realityStartTime);
        Object realityEndTime = delegateTask.getVariable("realityEndTime");
        leave.setRealityEndTime((Date) realityEndTime);

        leaveManager.saveLeave(leave);
    }
View Full Code Here

            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
            String businessKey = processInstance.getBusinessKey();
            if (businessKey == null) {
                continue;
            }
            Leave leave = leaveManager.getLeave(new Long(businessKey));
            leave.setTask(task);
            leave.setProcessInstance(processInstance);
            leave.setProcessDefinition(getProcessDefinition(processInstance.getProcessDefinitionId()));
            results.add(leave);
        }

        page.setTotalCount(taskQuery.count());
        page.setResult(results);
View Full Code Here

        for (ProcessInstance processInstance : list) {
            String businessKey = processInstance.getBusinessKey();
            if (businessKey == null) {
                continue;
            }
            Leave leave = leaveManager.getLeave(new Long(businessKey));
            leave.setProcessInstance(processInstance);
            leave.setProcessDefinition(getProcessDefinition(processInstance.getProcessDefinitionId()));
            results.add(leave);

            // 设置当前任务信息
            List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).active().orderByTaskCreateTime().desc().listPage(0, 1);
            leave.setTask(tasks.get(0));
        }

        page.setTotalCount(query.count());
        page.setResult(results);
        return results;
View Full Code Here

    @Autowired
    protected TaskService taskService;

    @RequestMapping(value = {"apply", ""})
    public String createForm(Model model) {
        model.addAttribute("leave", new Leave());
        return "/oa/leave/leaveApply";
    }
View Full Code Here

     * @return
     */
    @RequestMapping(value = "detail/{id}")
    @ResponseBody
    public Leave getLeave(@PathVariable("id") Long id) {
        Leave leave = leaveManager.getLeave(id);
        return leave;
    }
View Full Code Here

     * @return
     */
    @RequestMapping(value = "detail-with-vars/{id}/{taskId}")
    @ResponseBody
    public Leave getLeaveWithVars(@PathVariable("id") Long id, @PathVariable("taskId") String taskId) {
        Leave leave = leaveManager.getLeave(id);
        Map<String, Object> variables = taskService.getVariables(taskId);
        leave.setVariables(variables);
        return leave;
    }
View Full Code Here

  public void setUp() throws Exception {
  }

  @Test
  public void testSave() {
    Leave leave = new Leave();
    leave.setApplyTime(new Date());
    leave.setStartTime(new jodd.datetime.JDateTime("2012-05-22").convertToSqlDate());
    leave.setEndTime(new jodd.datetime.JDateTime("2012-05-23").convertToSqlDate());
    leave.setLeaveType("公休");
    leave.setUserId("kafeitu");
    leave.setReason("no reason");
    leaveManager.saveLeave(leave);
   
    assertNotNull(leave.getId());
   
    Leave newLeave = leaveManager.getLeave(leave.getId());
    assertNotNull(newLeave);
  }
View Full Code Here

TOP

Related Classes of me.kafeitu.demo.activiti.entity.oa.Leave

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.