Exemplo n.º 1
0
 /** @return true if one or more reviews were created */
 public static boolean createNecessaryBranchEventReviews(
     StateEventType stateEventType,
     TeamWorkFlowArtifact teamArt,
     Date createdDate,
     IAtsUser createdBy,
     IAtsChangeSet changes)
     throws OseeCoreException {
   boolean created = false;
   if (stateEventType != StateEventType.CommitBranch
       && stateEventType != StateEventType.CreateBranch) {
     throw new OseeStateException("Invalid stateEventType [%s]", stateEventType);
   }
   // Create any decision and peerToPeer reviews for createBranch and commitBranch
   for (IAtsDecisionReviewDefinition decRevDef :
       teamArt.getStateDefinition().getDecisionReviews()) {
     if (decRevDef.getStateEventType() != null
         && decRevDef.getStateEventType().equals(stateEventType)) {
       DecisionReviewArtifact decArt =
           DecisionReviewDefinitionManager.createNewDecisionReview(
               decRevDef, changes, teamArt, createdDate, createdBy);
       if (decArt != null) {
         created = true;
         changes.add(decArt);
       }
     }
   }
   for (IAtsPeerReviewDefinition peerRevDef : teamArt.getStateDefinition().getPeerReviews()) {
     if (peerRevDef.getStateEventType() != null
         && peerRevDef.getStateEventType().equals(stateEventType)) {
       PeerToPeerReviewArtifact peerArt =
           PeerReviewDefinitionManager.createNewPeerToPeerReview(
               peerRevDef, changes, teamArt, createdDate, createdBy);
       if (peerArt != null) {
         created = true;
         changes.add(peerArt);
       }
     }
   }
   return created;
 }
  /**
   * Create a new decision review configured and transitioned to handle action validation
   *
   * @param force will force the creation of the review without checking that a review should be
   *     created
   */
  public static DecisionReviewArtifact createValidateReview(
      TeamWorkFlowArtifact teamArt,
      boolean force,
      Date createdDate,
      IAtsUser createdBy,
      SkynetTransaction transaction)
      throws OseeCoreException {
    // If not validate page, don't do anything
    if (!force && !isValidatePage(teamArt.getStateDefinition())) {
      return null;
    }
    // If validate review already created for this state, return
    if (!force && ReviewManager.getReviewsFromCurrentState(teamArt).size() > 0) {
      for (AbstractReviewArtifact rev : ReviewManager.getReviewsFromCurrentState(teamArt)) {
        if (rev.getName().equals(VALIDATE_REVIEW_TITLE)) {
          return null;
        }
      }
    }
    // Create validate review
    try {

      DecisionReviewArtifact decRev =
          DecisionReviewManager.createNewDecisionReview(
              teamArt,
              isValidateReviewBlocking(teamArt.getStateDefinition())
                  ? ReviewBlockType.Transition
                  : ReviewBlockType.None,
              true,
              createdDate,
              createdBy);
      decRev.setName(VALIDATE_REVIEW_TITLE);
      decRev.setSoleAttributeValue(
          AtsAttributeTypes.DecisionReviewOptions,
          "No;Followup;" + getValidateReviewFollowupUsersStr(teamArt) + "\n" + "Yes;Completed;");

      TransitionHelper helper =
          new TransitionHelper(
              "Transition to Decision",
              Arrays.asList(decRev),
              DecisionReviewState.Decision.getName(),
              Arrays.asList(teamArt.getCreatedBy()),
              null,
              TransitionOption.None);
      TransitionManager transitionMgr = new TransitionManager(helper, transaction);
      TransitionResults results = transitionMgr.handleAll();
      if (!results.isEmpty()) {
        OseeLog.logf(
            Activator.class,
            OseeLevel.SEVERE_POPUP,
            "Error transitioning Decision review [%s] to Decision %s",
            decRev.toStringWithId(),
            results);
      }

      return decRev;

    } catch (Exception ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }
    return null;
  }