Package com.defaultcompany.external.repository

Examples of com.defaultcompany.external.repository.ApproverDAO


    if (initiatorHumanActivity instanceof ExternalApprovalActivity) {
     
      pm.executeProcess(instanceId);
     
      // 결재선 정보 가져오기
      ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
      ApprovalLineDAO approvalLineDAO = new ApprovalLineDAO(DefaultConnectionFactory.create().getDataSource());
      ApprovalLine al = approvalLineDAO.get(psMsg.getApprovalKey());
      al.setLineStatus(ExternalApprovalActivity.SIGN_DRAFT);
      al.setInstanceId(Integer.parseInt(instanceId));
     
      List<Approver> approverList = approverDAO.list(psMsg.getApprovalKey());
      List<HumanActivity> approvalActs = new ArrayList<HumanActivity>();
     
      // 결재선 다이나믹 체인지 Start
      ProcessDefinition tempPd = (ProcessDefinition) instance.getProcessDefinition().clone();
      HumanActivity draftAct = (HumanActivity) tempPd.getInitiatorHumanActivityReference(instance.getProcessTransactionContext()).getActivity();
      if (StringUtils.hasText(psMsg.getMainParam())) {
        draftAct.setExtValue1(psMsg.getMainParam());
      }
      if (StringUtils.hasText(psMsg.getSubParam())) {
        draftAct.setExtValue2(psMsg.getSubParam());
      }
      Activity approvalLineAct = draftAct.getParentActivity();
      while (!(approvalLineAct instanceof ExternalApprovalLineActivity)) {
        approvalLineAct = approvalLineAct.getParentActivity();
      }
     
      ComplexActivity parent = (ComplexActivity) approvalLineAct;
      if (parent.getChildActivities().size() > 1) {
        parent.getChildActivities().clear();
        parent.addChildActivity(draftAct);
      }
     
      String preApprovalType = null;
      for (Approver approver : approverList) {
        if (ExternalApprovalActivity.APPROVAL_TYPE_DRAFT.equalsIgnoreCase(approver.getType())) {
          approver.setTracingTag(draftAct.getTracingTag());
          approver.setTaskId(draftAct.getTaskIds(instance)[0]);
          approver.setTruthEmpCode(approver.getEmpCode());
          approver.setStatus(ExternalApprovalActivity.SIGN_DRAFT);
          approver.setEndDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
          approver.setComment(psMsg.getComment());
          approvalActs.add(draftAct);
          continue;
        }
        ExternalApprovalActivity childAct = (ExternalApprovalActivity) draftAct.clone();
        childAct.setName("결재");
        childAct.setTracingTag(null);
        childAct.setRole(null);
        childAct.setApprovalTypeByString(approver.getType());
       
        RoleMapping rm = RoleMapping.create();
        rm.setEndpoint(approver.getEmpCode());
        rm.fill(instance);
       
        // 결재 -> 합의
        if (!ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
          AllActivity allAct = new AllActivity();
          allAct.setTracingTag(null);
         
          parent.addChildActivity(allAct);
          parent = allAct;
        // 합의 -> 결재
        } else if (ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && !ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
          parent = (ComplexActivity) approvalLineAct;
        }
       
        parent.addChildActivity(childAct);
        childAct.setApprover(instance, rm);
       
        approver.setTracingTag(childAct.getTracingTag());
       
        preApprovalType = approver.getType();
        approvalActs.add(childAct);
      }
     
//      tempPd.registerToProcessDefinition(false, false);
      pm.changeProcessDefinition(instanceId, tempPd);
      // 결재선 다이나믹 체인지 End
     
      instance.setProperty(approvalLineAct.getTracingTag(), ExternalApprovalLineActivity.KEY_APPR_KEY, psMsg.getApprovalKey());
      approvalLineDAO.update(al);
      approverDAO.update(approverList);
     
      if (psMsg.isFirstTaskCompleted()) {
        pm.completeWorkitem(instanceId, draftAct.getTracingTag(), null, new org.uengine.kernel.ResultPayload());
      }
     
View Full Code Here


   
    ProcessInstance instance = pm.getProcessInstance(adacMsg.getInstanceId());
    this.bindProcessInfo(instance, adacMsg);
   
    // 결재선 다이나믹 체인지 Start
    ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
    List<Approver> approverList = approverDAO.list(adacMsg.getApprovalKey());
   
    ApprovalLineDAO approvalLineDAO = new ApprovalLineDAO(DefaultConnectionFactory.create().getDataSource());
    ApprovalLine approvalLine = approvalLineDAO.get(adacMsg.getApprovalKey());
    approvalLine.setLineStatus(ExternalApprovalActivity.SIGN_DRAFT);
   
   
    ProcessDefinition tempPd = (ProcessDefinition) instance.getProcessDefinition().clone();
    HumanActivity draftAct = (HumanActivity) tempPd.getActivity(adacMsg.getTracingTag());
    if (StringUtils.hasText(adacMsg.getMainParam())) {
      draftAct.setExtValue1(adacMsg.getMainParam());
    }
    if (StringUtils.hasText(adacMsg.getSubParam())) {
      draftAct.setExtValue2(adacMsg.getSubParam());
    }
    Activity approvalLineAct = draftAct.getParentActivity();
    while (!(approvalLineAct instanceof ExternalApprovalLineActivity)) {
      approvalLineAct = approvalLineAct.getParentActivity();
    }
   
    ComplexActivity parent = (ComplexActivity) approvalLineAct;
    if (parent.getChildActivities().size() > 1) {
      parent.getChildActivities().clear();
      parent.addChildActivity(draftAct);
    }
   
    String preApprovalType = null;
    for (Approver approver : approverList) {
      if (ExternalApprovalActivity.APPROVAL_TYPE_DRAFT.equalsIgnoreCase(approver.getType())) {
        approver.setTracingTag(draftAct.getTracingTag());
        approver.setTaskId(adacMsg.getTaskId());
        approver.setTruthEmpCode(approver.getEmpCode());
        approver.setStatus(ExternalApprovalActivity.SIGN_DRAFT);
        approver.setEndDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
        approver.setComment(adacMsg.getComment());
        continue;
      }
      ExternalApprovalActivity childAct = (ExternalApprovalActivity) draftAct.clone();
      childAct.setName("결재");
      childAct.setTracingTag(null);
      childAct.setRole(null);
      childAct.setApprovalTypeByString(approver.getType());
     
      RoleMapping rm = RoleMapping.create();
      rm.setEndpoint(approver.getEmpCode());
      rm.fill(instance);
     
      // 결재 -> 합의
      if (!ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
        AllActivity allAct = new AllActivity();
        allAct.setTracingTag(null);
       
        parent.addChildActivity(allAct);
        parent = allAct;
      // 합의 -> 결재
      } else if (ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && !ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
        parent = (ComplexActivity) approvalLineAct;
      }
     
      parent.addChildActivity(childAct);
      childAct.setApprover(instance, rm);
     
      approver.setTracingTag(childAct.getTracingTag());
     
      preApprovalType = approver.getType();
    }
   
    pm.changeProcessDefinition(adacMsg.getInstanceId(), tempPd);
    // 결재선 다이나믹 체인지 End
   
    instance.setProperty(approvalLineAct.getTracingTag(), ExternalApprovalLineActivity.KEY_APPR_KEY, adacMsg.getApprovalKey());
    approvalLineDAO.update(approvalLine);
    approverDAO.update(approverList);
   
    pm.completeWorkitem(adacMsg.getInstanceId(), adacMsg.getTracingTag(), adacMsg.getTaskId(), new org.uengine.kernel.ResultPayload());
  }
View Full Code Here

      instance.getWorkList().completeWorkItem(aacMsg.getTaskId(), new KeyedParameter[]{}, instance.getProcessTransactionContext());
     
      //반려시에는 ExternalApprovalActivity 의 afterComplete 를 타지 않는다.(바로 윗줄에 보면 worklist 테이블만 update 시킨다.) 따라서 수동 update
      Calendar endTime = GlobalContext.getNow(instance.getProcessTransactionContext());
     
      ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
      Approver approver = approverDAO.getByInstanceIdAndTracingTag(aacMsg.getApprovalKey(), Integer.parseInt(instance.getInstanceId()), aacMsg.getTracingTag());
      approver.setTruthEmpCode(aacMsg.getEndpoint());
      approver.setTaskId(approvalAct.getTaskIds(instance)[0]);
      approver.setStatus(ExternalApprovalActivity.SIGN_REJECT);
      approver.setEndDate(new Timestamp(endTime.getTimeInMillis()));
      approver.setComment(aacMsg.getComment());
      approverDAO.update(approver);
     
     
      //반려 로직
      ExternalApprovalLineActivity approvalLineAct = approvalAct.getApprovalLineActivity();
      int rejectOption = approvalLineAct.getRejectOption();
     
      // 기안 단계로 반려
      if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_BACK_TO_DRAFT) {
        approvalLineAct.getDraftActivity().compensateToThis(instance);
       
        // 결재 DB update
        List<Approver> _approverList = approverDAO.list(aacMsg.getApprovalKey());
        int version = _approverList.get(0).getVersion() + 1;
        for (int i = 0; i < _approverList.size(); i++) {
          Approver _approver = _approverList.get(i);
          _approver.setVersion(version);
          _approver.setComment(null);
          _approver.setEndDate(null);
          _approver.setTruthEmpCode(null);
          _approver.setStatus(null);
         
          if (i > 0) {
            _approver.setTracingTag(null);
            _approver.setTaskId(null);
          }
        }
        approvalLine.setVersion(version);
        approvalLineDAO.update(approvalLine);
        approverDAO.add(_approverList);
     
      // 바로 이전 결재로 반려
      } else if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_BACK_TO_PREV) {
        Vector<? extends Activity> childActs = approvalLineAct.getChildActivities();
        Activity currentAct = instance.getProcessDefinition().getActivity(aacMsg.getTracingTag());
        int prevIndex = 0;
        if (currentAct.getParentActivity() instanceof AllActivity) {
          prevIndex = childActs.indexOf(currentAct.getParentActivity()) - 1
        } else {
          prevIndex = childActs.indexOf(approvalAct) - 1;
        }
       
        Activity prevAct = childActs.get(prevIndex);
       
        Approver prevApprover = approverDAO.getByInstanceIdAndTracingTag(aacMsg.getApprovalKey(), Integer.parseInt(instance.getInstanceId()), prevAct.getTracingTag());
       
        prevAct.compensateToThis(instance);
       
        // ExternalApprovalActivity 의 afterExecute() 를 타기 때문에 강제로 다시 update
        approverDAO.update(prevApprover);
       
       
        // 결재 DB update
        List<Approver> _approverList = approverDAO.list(aacMsg.getApprovalKey());
        int version = _approverList.get(0).getVersion() + 1;
        for (int i = 0; i < _approverList.size(); i++) {
          Approver _approver = _approverList.get(i);
          _approver.setVersion(version);
         
          if ( aacMsg.getTracingTag().equalsIgnoreCase(_approver.getTracingTag()) &&
              _approver.getTaskId().equalsIgnoreCase(aacMsg.getTaskId()) ) {
           
            // 현재 결재자
            _approver.setComment(null);
            _approver.setEndDate(null);
            _approver.setTruthEmpCode(null);
            _approver.setStatus(null);
            _approver.setTaskId(null);
           
            // 이전 결재자
            Approver _prevApprover = _approverList.get(i - 1);
            _prevApprover.setComment(null);
            _prevApprover.setEndDate(null);
            _prevApprover.setTruthEmpCode(null);
            _prevApprover.setStatus(null);
           
          }
        }
        approvalLine.setVersion(version);
        approvalLineDAO.update(approvalLine);
        approverDAO.add(_approverList);
     
      // 플래그로 반려
      } else if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_BACK_TO_FLAG) {
        BackActivity backActivity = new BackActivity();
        backActivity.setTargetSource(BackActivity.Flag);
        backActivity.setFlag(approvalLineAct.getFlag());
        backActivity.executeActivity(instance);
       
      // 결재선 종료
      } else if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_FINISH) {
        approvalAct.setEndTime(instance, endTime);
        approvalAct.getApprovalLineActivity().fireComplete(instance);
       
      }
     
   
    // 전결
    } else if (ExternalApprovalActivity.SIGN_ARBITRARY_APPROVED.equalsIgnoreCase(aacMsg.getApprovalStatus())) {
     
      ExternalApprovalActivity approvalAct = (ExternalApprovalActivity) instance.getProcessDefinition().getActivity(aacMsg.getTracingTag());
      approvalAct.setApprovalStatus(instance, ExternalApprovalActivity.SIGN_ARBITRARY_APPROVED);
     
      String taskId = approvalAct.getTaskIds(instance)[0];
      Calendar endTime = GlobalContext.getNow(instance.getProcessTransactionContext());
      instance.getWorkList().completeWorkItem(taskId, new KeyedParameter[]{}, instance.getProcessTransactionContext());
      approvalAct.setEndTime(instance, endTime);

      //전결시에는 NavienApprovalActivity 의 afterComplete 를 타지 않는다.(바로 윗줄에 보면 worklist 테이블만 update 시킨다.) 따라서 수동 update
      ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
      Approver approver = approverDAO.getByInstanceIdAndTracingTag(aacMsg.getApprovalKey(), Integer.parseInt(instance.getInstanceId()), aacMsg.getTracingTag());
      approver.setTruthEmpCode(aacMsg.getEndpoint());
      approver.setTaskId(taskId);
      approver.setStatus(ExternalApprovalActivity.SIGN_ARBITRARY_APPROVED);
      approver.setEndDate(new Timestamp(endTime.getTimeInMillis()));
      approver.setComment(aacMsg.getComment());
      approverDAO.update(approver);
     
      approvalAct.getApprovalLineActivity().fireComplete(instance);
     
    }   
   
View Full Code Here

    pm.setGenericContext(genericContext);
   
    ProcessInstance instance = pm.getProcessInstance(alcMsg.getInstanceId());
    this.bindProcessInfo(instance, alcMsg);
   
    ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
    List<Approver> approverList = approverDAO.list(alcMsg.getApprovalKey());
 
    ProcessDefinition tempPd = (ProcessDefinition) instance.getProcessDefinition().clone();
    Activity draftAct = tempPd.getActivity(approverList.get(0).getTracingTag());
    Activity approvalLineAct = draftAct.getParentActivity();
    while (!(approvalLineAct instanceof ExternalApprovalLineActivity)) {
      approvalLineAct = approvalLineAct.getParentActivity();
    }
   
    ComplexActivity parent = (ComplexActivity) approvalLineAct;
    final Vector childActs = new Vector();
    ActivityForLoop forLoop = new ActivityForLoop() {
      public void logic(Activity act) {
        try {
          if (act instanceof ExternalApprovalActivity) {
            childActs.add(act);
          }
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    };
    forLoop.run(parent);
   
    int readyIndex = -1;
    for (int i = 0; i < childActs.size(); i++) {
      Activity approvalAct = (Activity) childActs.get(i);
      if (Activity.STATUS_READY.equalsIgnoreCase(approvalAct.getStatus(instance))) {
        if (readyIndex == -1) {
          readyIndex = i;
        }
        parent.removeChildActivity(approvalAct);
      }
    }
   
    if (readyIndex > 0) {
      String preApprovalType = null;
      for (int i = readyIndex; i < approverList.size(); i++) {
        Approver approver = approverList.get(i);
       
        ExternalApprovalActivity childAct = (ExternalApprovalActivity) draftAct.clone();
        childAct.setName("결재");
        childAct.setTracingTag(null);
        childAct.setRole(null);
        childAct.setApprovalTypeByString(approver.getType());
       
        RoleMapping rm = RoleMapping.create();
        rm.setEndpoint(approver.getEmpCode());
        rm.fill(instance);
       
        // 결재 -> 합의
        if (!ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
          AllActivity allAct = new AllActivity();
          allAct.setTracingTag(null);
         
          parent.addChildActivity(allAct);
          parent = allAct;
        // 합의 -> 결재
        } else if (ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && !ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
          parent = (ComplexActivity) approvalLineAct;
        }
       
        parent.addChildActivity(childAct);
        childAct.setApprover(instance, rm);
       
        approver.setTracingTag(childAct.getTracingTag());
       
        preApprovalType = approver.getType();
      }
     
      pm.changeProcessDefinition(alcMsg.getInstanceId(), tempPd);
      approverDAO.update(approverList);
    }
   
  }
View Full Code Here

 
  @Override
  public void afterExecute(ProcessInstance instance) throws Exception {
   
    if (this.getApprovalType() > 1) {
      ApproverDAO alDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
      String approvalKey = (String) instance.getProperty(approvalLineActivity.getTracingTag(), ExternalApprovalLineActivity.KEY_APPR_KEY);
      Approver approver = alDAO.getByInstanceIdAndTracingTag(approvalKey, Integer.parseInt(instance.getInstanceId()), getTracingTag());
      if (approver != null) {
        approver.setTaskId(getTaskIds(instance)[0]);
        approver.setStatus(null);
        alDAO.update(approver)
      }
    }
   
    super.afterExecute(instance);
  }
View Full Code Here

      if (!isNotificationWorkitem())
        setApprovalStatus(instance, SIGN_APPROVED);
    }
   
    if (this.getApprovalType() > 1) {
      ApproverDAO alDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
      String approvalKey = (String) instance.getProperty(approvalLineActivity.getTracingTag(), ExternalApprovalLineActivity.KEY_APPR_KEY);
      Approver approver = alDAO.getByInstanceIdAndTracingTag(approvalKey, Integer.parseInt(instance.getInstanceId()), getTracingTag());
      if (approver != null) {
        approver.setTruthEmpCode(getRole().getMapping(instance).getEndpoint());
        approver.setTaskId(getTaskIds(instance)[0]);
        approver.setStatus(ExternalApprovalActivity.SIGN_APPROVED);
        approver.setEndDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
        approver.setComment(instance.getProcessTransactionContext().getServletRequest().getParameter("comment"));
        alDAO.update(approver);
      }
    }
   
    super.afterComplete(instance);
View Full Code Here

TOP

Related Classes of com.defaultcompany.external.repository.ApproverDAO

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.