/**
  * @see org.kuali.kra.irb.auth.ProtocolAuthorizer#isAuthorized(java.lang.String,
  *     org.kuali.kra.irb.auth.ProtocolTask)
  */
 public boolean isAuthorized(String username, ProtocolTask task) {
   Protocol protocol = task.getProtocol();
   return kraWorkflowService.isInWorkflow(protocol.getProtocolDocument())
       && isPendingOrSubmittedToCommittee(protocol)
       && isInSchedule(protocol)
       && hasPermission(username, protocol, PermissionConstants.PERFORM_IRB_ACTIONS_ON_PROTO);
 }
  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;
  }
 /**
  * @throws WorkflowException
  * @see
  *     org.kuali.kra.irb.actions.notifycommittee.ProtocolNotifyCommitteeService#submitCommitteeNotification(org.kuali.kra.irb.Protocol,
  *     org.kuali.kra.irb.actions.notifycommittee.ProtocolNotifyCommitteeBean)
  */
 public void submitCommitteeNotification(
     Protocol protocol, ProtocolNotifyCommitteeBean notifyCommitteeBean) throws WorkflowException {
   // we do not create a new submission here unlike in notify IRB
   ProtocolAction protocolAction =
       new ProtocolAction(protocol, null, ProtocolActionType.NOTIFIED_COMMITTEE);
   protocolAction.setComments(notifyCommitteeBean.getComment());
   protocolAction.setActionDate(new Timestamp(notifyCommitteeBean.getActionDate().getTime()));
   protocol.getProtocolActions().add(protocolAction);
   protocolActionService.updateProtocolStatus(protocolAction, protocol);
   documentService.saveDocument(protocol.getProtocolDocument());
 }
  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());
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.kuali.kra.common.specialreview.service.SpecialReviewService#getViewSpecialReviewProtocolRouteHeaderId(java.lang.String)
   */
  public Long getViewSpecialReviewProtocolRouteHeaderId(String protocolNumber) throws Exception {
    Long routeHeaderId = 0L;

    if (StringUtils.isNotBlank(protocolNumber)) {
      Protocol protocol = getProtocolFinderDao().findCurrentProtocolByNumber(protocolNumber);
      if (protocol != null) {
        Document document =
            getDocumentService()
                .getByDocumentHeaderId(protocol.getProtocolDocument().getDocumentNumber());
        routeHeaderId = document.getDocumentHeader().getWorkflowDocument().getRouteHeaderId();
      }
    }

    return routeHeaderId;
  }
  private void performGenericAction(
      Protocol protocol, ProtocolGenericActionBean actionBean, String protocolActionType)
      throws Exception {
    ProtocolAction protocolAction =
        (ProtocolAction) createProtocolActionAndAttach(protocol, actionBean, protocolActionType);

    if (protocol.getNotifyIrbSubmissionId() == null) {
      getProtocolActionService().updateProtocolStatus(protocolAction, protocol);
    } else {
      for (ProtocolSubmissionBase submission : protocol.getProtocolSubmissions()) {
        if (submission.getSubmissionId().equals(protocol.getNotifyIrbSubmissionId())) {
          submission.setSubmissionStatusCode(ProtocolSubmissionStatus.IRB_ACKNOWLEDGEMENT);
        }
      }
    }

    protocol.refreshReferenceObject("protocolStatus");
    protocol.refreshReferenceObject("protocolSubmission");
    getDocumentService().saveDocument(protocol.getProtocolDocument());
  }