public ProtocolDocument getDeferredVersionedDocument(Protocol protocol) throws Exception {
    getDocumentService()
        .cancelDocument(
            protocol.getProtocolDocument(),
            "Protocol document cancelled - protocol has been deferred.");
    getProtocolOnlineReviewService()
        .cancelOnlineReviews(
            protocol.getProtocolSubmission(),
            "Protocol Review cancelled - protocol has been deferred.");

    ProtocolDocument newDocument = (ProtocolDocument) getVersionedDocument(protocol);
    setReferencesForProtocolCorrespondence(newDocument);

    ProtocolAction assignToAgendaProtocolAction =
        (ProtocolAction)
            getProtocolAssignToAgendaService()
                .getAssignedToAgendaProtocolAction((Protocol) newDocument.getProtocol());
    if (assignToAgendaProtocolAction != null) {
      newDocument.getProtocol().getProtocolActions().remove(assignToAgendaProtocolAction);
      getBusinessObjectService().delete(assignToAgendaProtocolAction);
    }
    newDocument.getProtocol().refreshReferenceObject("protocolStatus");
    getDocumentService().saveDocument(newDocument);

    return newDocument;
  }
  /**
   * Test the approval of a protocol. The protocol status and its corresponding action should be set
   * to approved.
   */
  @Test
  public void runApprovedTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    protocolSubmitActionService.submitToIrbForReview(
        protocolDocument.getProtocol(), getMockSubmitAction());

    documentService.routeDocument(protocolDocument, null, null);
    documentService.blanketApproveDocument(protocolDocument, null, null);
    WorkflowDocument workflowDoc = getWorkflowDocument(protocolDocument);
    WorkflowDocumentActionsService info =
        GlobalResourceLoader.getService("rice.kew.workflowDocumentActionsService");
    RoutingReportCriteria.Builder reportCriteriaBuilder =
        RoutingReportCriteria.Builder.createByDocumentId(workflowDoc.getDocumentId());
    DocumentDetail results1 = info.executeSimulation(reportCriteriaBuilder.build());

    assertTrue(workflowDoc.isFinal());

    // the status update is not happening within doRouteStatusChange anymore
    // assertEquals(protocolDocument.getProtocol().getProtocolStatusCode(),
    // ProtocolStatus.ACTIVE_OPEN_TO_ENROLLMENT);
    assertTrue(protocolDocument.getProtocol().isActive());
    // verifyProtocolAction(protocolDocument.getProtocol().getProtocolId(),
    // ProtocolActionType.APPROVED);
  }
  protected void populateDocumentOverview(
      Protocol protocol, ProposalDevelopmentDocument proposalDocument) {
    ProtocolDocument protocolDocument = (ProtocolDocument) protocol.getProtocolDocument();
    DocumentHeader proposalDocumentHeader = proposalDocument.getDocumentHeader();
    DocumentHeader protocolDocumentHeader = protocolDocument.getDocumentHeader();

    proposalDocumentHeader.setDocumentDescription(
        "PD - " + protocolDocumentHeader.getDocumentDescription());
    proposalDocumentHeader.setExplanation(
        "Document created from Protocol - " + protocolDocument.getDocumentNumber());
    proposalDocumentHeader.setOrganizationDocumentNumber(
        protocolDocumentHeader.getOrganizationDocumentNumber());
  }
  private Protocol getProtocolAssignedToAgenda() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    protocolSubmitActionService.submitToIrbForReview(protocolDocument, getMockSubmitAction(), null);
    assertEquals(
        ProtocolStatus.SUBMITTED_TO_IRB, protocolDocument.getProtocol().getProtocolStatusCode());

    protocolAssignCmtSchedService.assignToCommitteeAndSchedule(
        protocolDocument.getProtocol(), getMockAssignCmtSchedBean());
    assertEquals(
        ProtocolSubmissionStatus.SUBMITTED_TO_COMMITTEE,
        protocolDocument.getProtocol().getProtocolSubmission().getSubmissionStatusCode());

    return protocolDocument.getProtocol();
  }
  @Override
  public boolean processAssignReviewers(
      ProtocolDocument document, ProtocolAssignReviewersBean actionBean) {
    boolean isValid = true;
    List<ProtocolReviewerBean> reviewers = (List) actionBean.getReviewers();
    List<ProtocolOnlineReviewDocument> protocolOnlineReviewDocuments =
        (List)
            getProtocolOnlineReviewService()
                .getProtocolReviewDocumentsForCurrentSubmission(document.getProtocol());
    for (int i = 0; i < reviewers.size(); i++) {
      ProtocolReviewerBean reviewer = reviewers.get(i);
      if (!isReviewerValid(reviewer, i)) {
        isValid = false;
      } else if (StringUtils.isBlank(reviewer.getReviewerTypeCode())) {
        // get the review
        for (ProtocolOnlineReviewDocument pDocument : protocolOnlineReviewDocuments) {
          if (reviewer.isProtocolReviewerBeanForReviewer(
              pDocument.getProtocolOnlineReview().getProtocolReviewer())) {
            // the review exists and the user is asking to remove it...
            isValid &= isValidRemovalRequest(pDocument, reviewer, i);
            break;
          }
        }
      }
    }

    return isValid;
  }
  /**
   * Test a valid disapprove with more no votes than yes votes.
   *
   * @throws Exception
   */
  @Test
  public void testValidDisapprove() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    CommitteeDecision decision =
        getMockCommitteeDecisionBean(
            CommitteeDecisionMotionType.DISAPPROVE,
            YES_COUNT,
            null,
            null,
            null,
            protocolDocument.getProtocol(),
            true);
    rule.setAttendanceService(getMockCommitteeScheduleAttendanceService(YES_COUNT, 5));
    assertTrue(rule.proccessCommitteeDecisionRule(protocolDocument, decision));
  }
  /**
   * Test an invalid approve with no Yes count.
   *
   * @throws Exception
   */
  @Test
  public void testInvalidApprove() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    CommitteeDecision decision =
        getMockCommitteeDecisionBean(
            CommitteeDecisionMotionType.APPROVE,
            null,
            NO_COUNT,
            null,
            null,
            protocolDocument.getProtocol(),
            false);
    rule.setAttendanceService(getMockCommitteeScheduleAttendanceService(null, NO_COUNT));
    assertFalse(rule.proccessCommitteeDecisionRule(protocolDocument, decision));
  }
  /**
   * Test an invalid SRR with no comment.
   *
   * @throws Exception
   */
  @Test
  public void testInvalidSRR() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    CommitteeDecision decision =
        getMockCommitteeDecisionBean(
            CommitteeDecisionMotionType.SUBSTANTIVE_REVISIONS_REQUIRED,
            YES_COUNT,
            NO_COUNT,
            null,
            null,
            protocolDocument.getProtocol(),
            false);
    rule.setAttendanceService(getMockCommitteeScheduleAttendanceService(YES_COUNT, NO_COUNT));
    assertFalse(rule.proccessCommitteeDecisionRule(protocolDocument, decision));
  }
  /**
   * Test a valid SMR with a single comment.
   *
   * @throws Exception
   */
  @Test
  public void testValidSMR() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    CommitteeDecision decision =
        getMockCommitteeDecisionBean(
            CommitteeDecisionMotionType.SPECIFIC_MINOR_REVISIONS,
            YES_COUNT,
            NO_COUNT,
            null,
            null,
            protocolDocument.getProtocol(),
            true);
    rule.setAttendanceService(getMockCommitteeScheduleAttendanceService(YES_COUNT, NO_COUNT));
    assertTrue(rule.proccessCommitteeDecisionRule(protocolDocument, decision));
  }
  /**
   * Test the approval of an amendment. Verify that the sequence number has been incremented for the
   * protocol version and that it's status has been set to approved.
   *
   * @throws Exception
   */
  @Test
  public void runAmendmentTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument("0906000003");
    ProtocolSubmitAction submitAction = getMockSubmitAction();

    protocolSubmitActionService.submitToIrbForReview(protocolDocument.getProtocol(), submitAction);

    documentService.routeDocument(protocolDocument, null, null);
    documentService.blanketApproveDocument(protocolDocument, null, null);

    String docNbr =
        protocolAmendRenewService.createAmendment(protocolDocument, getMockProtocolAmendmentBean());

    ProtocolDocument amendmentDocument =
        (ProtocolDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(docNbr);
    protocolSubmitActionService.submitToIrbForReview(amendmentDocument.getProtocol(), submitAction);

    documentService.routeDocument(amendmentDocument, null, null);
    // temporarily disable unit test
    //        documentService.blanketApproveDocument(amendmentDocument, null, null);
    //
    //        assertTrue(getWorkflowDocument(amendmentDocument).isFinal());
    //
    //        Protocol newProtocol =
    // protocolFinder.findCurrentProtocolByNumber(protocolDocument.getProtocol().getProtocolNumber());
    //        assertTrue(newProtocol.getSequenceNumber() ==
    // protocolDocument.getProtocol().getSequenceNumber() + 1);
    //
    //        /*
    //         * Must read the protocol document again in order to obtain the most recent changes.
    //         */
    //        protocolDocument = (ProtocolDocument)
    // documentService.getByDocumentHeaderId(protocolDocument.getDocumentNumber());
    //
    //        assertFalse(protocolDocument.getProtocol().isActive());
    //        assertFalse(amendmentDocument.getProtocol().isActive());
    //        assertTrue(newProtocol.isActive());
    //
    //        // TODO: This test can be re-added once we can route the new protocol through
    // workflow.
    //        //assertEquals(getWorkflowDocument(newProtocol.getProtocolDocument).isFinal());
    //
    //        verifyProtocolAction(newProtocol, ProtocolActionType.APPROVED);
  }
  /**
   * Test the disapproval of a protocol. The protocol status and its corresponding action should be
   * set to disapproved.
   */
  @Test
  public void runDisapprovedTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument("0906000002");

    protocolSubmitActionService.submitToIrbForReview(
        protocolDocument.getProtocol(), getMockSubmitAction());

    documentService.routeDocument(protocolDocument, null, null);
    documentService.disapproveDocument(protocolDocument, null);

    assertTrue(getWorkflowDocument(protocolDocument).isDisapproved());
    // assertEquals(protocolDocument.getProtocol().getProtocolStatusCode(),
    // ProtocolStatus.DISAPPROVED);

    // assertTrue(protocolDocument.getProtocol().isActive());

    // verifyProtocolAction(protocolDocument.getProtocol().getProtocolId(),
    // ProtocolActionType.DISAPPROVED);
  }
示例#12
0
  @Test
  public void testVersioning() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();
    ProtocolDocument newProtocolDocument =
        (ProtocolDocument) protocolVersionService.versionProtocolDocument(protocolDocument);
    assertNotNull(newProtocolDocument);
    assertTrue(
        !StringUtils.equals(
            protocolDocument.getDocumentNumber(), newProtocolDocument.getDocumentNumber()));
    assertTrue(
        (protocolDocument.getProtocol().getSequenceNumber() + 1
            == newProtocolDocument.getProtocol().getSequenceNumber()));
    assertFalse(protocolDocument.getProtocol().isActive());
    assertTrue(newProtocolDocument.getProtocol().isActive());

    List<DocumentNextvalue> nextValues = newProtocolDocument.getDocumentNextvalues();
    for (DocumentNextvalue nextValue : nextValues) {
      assertEquals(nextValue.getDocumentKey(), newProtocolDocument.getDocumentNumber());
    }
  }
 protected void setReferencesForProtocolCorrespondence(ProtocolDocument newDocument) {
   Protocol newProtocol = newDocument.getProtocol();
   newProtocol
       .getProtocolActions()
       .forEach(
           protocolAction -> {
             protocolAction.setSequenceNumber(newProtocol.getSequenceNumber());
             protocolAction
                 .getProtocolCorrespondences()
                 .forEach(
                     protocolCorrespondence -> {
                       protocolCorrespondence.setProtocolId(newProtocol.getProtocolId());
                       protocolCorrespondence.setSequenceNumber(newProtocol.getSequenceNumber());
                     });
           });
 }
 /**
  * @see
  *     org.kuali.kra.common.permissions.web.struts.action.PermissionsActionHelperBase#removeRoleFromUserInDatabase(org.kuali.core.document.Document,
  *     java.lang.String, java.lang.String)
  */
 @Override
 protected void removeUserFromRoleInDatabase(Document document, String userId, String roleName) {
   ProtocolDocument protocolDocument = (ProtocolDocument) document;
   getKraAuthorizationService().removeRole(userId, roleName, protocolDocument.getProtocol());
 }
 /*
  * Check if user is PI
  */
 private boolean isPrincipalInvestigator(ProtocolDocument protocolDocument, String personId) {
   return StringUtils.equals(
       personId, protocolDocument.getProtocol().getPrincipalInvestigatorId());
 }