예제 #1
0
  private static ActionRequest.Builder createActionRequestBuilder(
      ActionRequestValue actionRequestBo) {
    ActionRequest.Builder builder =
        ActionRequest.Builder.create(
            actionRequestBo.getActionRequestId(),
            ActionRequestType.fromCode(actionRequestBo.getActionRequested()),
            ActionRequestStatus.fromCode(actionRequestBo.getStatus()),
            actionRequestBo.getResponsibilityId(),
            actionRequestBo.getDocumentId(),
            RecipientType.fromCode(actionRequestBo.getRecipientTypeCd()));
    if (actionRequestBo.getActionTaken() != null) {
      builder.setActionTaken(
          ActionTaken.Builder.create(ActionTakenValue.to(actionRequestBo.getActionTaken())));
    }
    builder.setAnnotation(actionRequestBo.getAnnotation());
    builder.setCurrent(actionRequestBo.getCurrentIndicator().booleanValue());
    builder.setDateCreated(new DateTime(actionRequestBo.getCreateDate().getTime()));
    if (actionRequestBo.getDelegationType() != null) {
      builder.setDelegationType(actionRequestBo.getDelegationType());
    }
    builder.setForceAction(actionRequestBo.getForceAction().booleanValue());
    builder.setGroupId(actionRequestBo.getGroupId());
    builder.setNodeName(actionRequestBo.getPotentialNodeName());
    if (actionRequestBo.getParentActionRequestId() != null) {
      builder.setParentActionRequestId(actionRequestBo.getParentActionRequestId());
    }
    builder.setPrincipalId(actionRequestBo.getPrincipalId());
    if (actionRequestBo.getPriority() == null) {
      builder.setPriority(KewApiConstants.ACTION_REQUEST_DEFAULT_PRIORITY);
    } else {
      builder.setPriority(actionRequestBo.getPriority().intValue());
    }
    if (actionRequestBo.getRouteLevel() == null) {
      builder.setRouteLevel(0);
    } else {
      builder.setRouteLevel(actionRequestBo.getRouteLevel().intValue());
    }
    builder.setQualifiedRoleName(actionRequestBo.getQualifiedRoleName());
    builder.setQualifiedRoleNameLabel(actionRequestBo.getQualifiedRoleNameLabel());
    builder.setRequestLabel(actionRequestBo.getRequestLabel());
    if (!StringUtils.isBlank(actionRequestBo.getApprovePolicy())) {
      builder.setRequestPolicy(ActionRequestPolicy.fromCode(actionRequestBo.getApprovePolicy()));
    }
    builder.setResponsibilityDescription(actionRequestBo.getResponsibilityDesc());
    builder.setRoleName(actionRequestBo.getRoleName());
    if (actionRequestBo.getNodeInstance() != null) {
      builder.setRouteNodeInstanceId(actionRequestBo.getNodeInstance().getRouteNodeInstanceId());
    }

    List<ActionRequest.Builder> childRequests = new ArrayList<ActionRequest.Builder>();
    if (actionRequestBo.getChildrenRequests() != null) {
      for (ActionRequestValue childActionRequestBo : actionRequestBo.getChildrenRequests()) {
        childRequests.add(createActionRequestBuilder(childActionRequestBo));
      }
    }
    builder.setChildRequests(childRequests);
    return builder;
  }
예제 #2
0
  public ActionRequestValue deepCopy(Map<Object, Object> visited) {
    if (visited.containsKey(this)) {
      return (ActionRequestValue) visited.get(this);
    }
    ActionRequestValue copy = new ActionRequestValue();
    visited.put(this, copy);
    copy.actionRequestId = actionRequestId;
    copy.actionRequested = actionRequested;
    copy.documentId = documentId;
    copy.ruleBaseValuesId = ruleBaseValuesId;
    copy.status = status;
    copy.responsibilityId = responsibilityId;
    copy.groupId = groupId;
    copy.roleName = roleName;
    copy.qualifiedRoleName = qualifiedRoleName;
    copy.qualifiedRoleNameLabel = qualifiedRoleNameLabel;
    copy.recipientTypeCd = recipientTypeCd;
    copy.priority = priority;
    copy.routeLevel = routeLevel;
    copy.docVersion = docVersion;
    if (createDate != null) {
      copy.createDate = new Timestamp(createDate.getTime());
    }
    copy.responsibilityDesc = responsibilityDesc;
    copy.annotation = annotation;
    copy.jrfVerNbr = jrfVerNbr;
    copy.principalId = principalId;
    copy.forceAction = forceAction;
    copy.currentIndicator = currentIndicator;
    copy.approvePolicy = approvePolicy;
    copy.delegationTypeCode = delegationTypeCode;
    copy.requestLabel = requestLabel;
    if (parentActionRequest != null) {
      copy.parentActionRequest = parentActionRequest.deepCopy(visited);
    }
    if (actionTaken != null) {
      copy.actionTaken = actionTaken.deepCopy(visited);
    }
    if (nodeInstance != null) {
      copy.nodeInstance = nodeInstance.deepCopy(visited);
    }
    if (childrenRequests != null) {
      List<ActionRequestValue> copies = new ArrayList<ActionRequestValue>();
      for (ActionRequestValue childRequest : childrenRequests) {
        copies.add(childRequest.deepCopy(visited));
      }
      copy.childrenRequests = copies;
    }

    copy.createDateString = createDateString;
    copy.displayStatus = displayStatus;
    copy.resolveResponsibility = resolveResponsibility;
    if (routeHeader != null) {
      copy.routeHeader = routeHeader.deepCopy(visited);
    }
    if (simulatedActionItems != null) {
      List<ActionItem> copies = new ArrayList<ActionItem>();
      for (ActionItem simulatedActionItem : simulatedActionItems) {
        copies.add(simulatedActionItem.deepCopy(visited));
      }
      copy.simulatedActionItems = copies;
    }
    return copy;
  }
  public void recordAction() throws InvalidActionTakenException {
    MDC.put("docId", getRouteHeader().getDocumentId());
    updateSearchableAttributesIfPossible();
    LOG.debug(
        "Moving document "
            + getRouteHeader().getDocumentId()
            + " to point: "
            + displayMovePoint(movePoint)
            + ", annotation: "
            + annotation);

    List actionRequests =
        getActionRequestService()
            .findAllValidRequests(
                getPrincipal().getPrincipalId(),
                getDocumentId(),
                KewApiConstants.ACTION_REQUEST_COMPLETE_REQ);
    Collection activeNodes =
        KEWServiceLocator.getRouteNodeService()
            .getActiveNodeInstances(getRouteHeader().getDocumentId());
    String errorMessage = validateActionRules(actionRequests, activeNodes);
    if (!org.apache.commons.lang.StringUtils.isEmpty(errorMessage)) {
      throw new InvalidActionTakenException(errorMessage);
    }

    RouteNodeInstance startNodeInstance = determineStartNode(activeNodes, movePoint);

    LOG.debug("Record the move action");
    Recipient delegator = findDelegatorForActionRequests(actionRequests);
    ActionTakenValue actionTaken = saveActionTaken(delegator);
    getActionRequestService().deactivateRequests(actionTaken, actionRequests);
    notifyActionTaken(actionTaken);

    // TODO this whole bit is a bit hacky at the moment
    if (movePoint.getStepsToMove() > 0) {
      Set<String> targetNodeNames = new HashSet<String>();
      targetNodeNames.add(determineFutureNodeName(startNodeInstance, movePoint));

      final boolean shouldIndex =
          getRouteHeader().getDocumentType().hasSearchableAttributes()
              && RouteContext.getCurrentRouteContext().isSearchIndexingRequestedForContext();
      String applicationId = routeHeader.getDocumentType().getApplicationId();
      DocumentOrchestrationQueue orchestrationQueue =
          KewApiServiceLocator.getDocumentOrchestrationQueue(
              routeHeader.getDocumentId(), applicationId);
      org.kuali.rice.kew.api.document.OrchestrationConfig orchestrationConfig =
          org.kuali.rice.kew.api.document.OrchestrationConfig.create(
              actionTaken.getActionTakenId(), targetNodeNames);
      DocumentProcessingOptions options =
          DocumentProcessingOptions.create(true, shouldIndex, false);
      orchestrationQueue.orchestrateDocument(
          routeHeader.getDocumentId(),
          getPrincipal().getPrincipalId(),
          orchestrationConfig,
          options);
    } else {
      String targetNodeName = determineReturnNodeName(startNodeInstance, movePoint);
      ReturnToPreviousNodeAction returnAction =
          new ReturnToPreviousNodeAction(
              KewApiConstants.ACTION_TAKEN_MOVE_CD,
              getRouteHeader(),
              getPrincipal(),
              annotation,
              targetNodeName,
              false);

      returnAction.recordAction();
    }
  }