protected void finalizeOnlineReviewDocument( ProtocolOnlineReviewDocumentBase protocolOnlineReviewDocument, ProtocolSubmissionBase submission, String annotation) { try { final String principalId = identityManagementService .getPrincipalByPrincipalName(KRADConstants.SYSTEM_USER) .getPrincipalId(); WorkflowDocument workflowDocument = WorkflowDocumentFactory.loadDocument( principalId, protocolOnlineReviewDocument.getDocumentNumber()); ProtocolOnlineReviewBase review = protocolOnlineReviewDocument.getProtocolOnlineReview(); review.addActionPerformed( "Finalize:" + workflowDocument.getStatus().getCode() + ":" + review.getProtocolOnlineReviewStatusCode()); if (workflowDocument.isEnroute() || workflowDocument.isInitiated() || workflowDocument.isSaved()) { workflowDocument.superUserBlanketApprove(annotation); } } catch (Exception e) { String errorMessage = String.format( "Workflow exception generated while executing superUserApprove on document %s in finalizeOnlineReviewDocument. Message:%s", protocolOnlineReviewDocument.getDocumentNumber(), e.getMessage()); LOG.error(errorMessage); throw new RuntimeException(errorMessage, e); } }
/** * Tests that an exception is not thrown if you try to execute a "route" command on a document you * did not initiate. */ @Test public void testRouteDocumentAsNonInitiatorUser() throws Exception { WorkflowDocument firstDocument = WorkflowDocumentFactory.createDocument( getPrincipalIdForName("user1"), DOCUMENT_TYPE_POLICY_TEST_NAME); WorkflowDocument document = WorkflowDocumentFactory.loadDocument( getPrincipalIdForName("user2"), firstDocument.getDocumentId()); try { document.route(""); } catch (Exception e) { e.printStackTrace(); fail( "Exception thrown but should not have have been... Exception was of type " + e.getClass().getName() + " and message was " + e.getMessage()); } document = WorkflowDocumentFactory.loadDocument( getPrincipalIdForName("user1"), firstDocument.getDocumentId()); assertEquals( "Document should be in Enroute status.", DocumentStatus.ENROUTE, document.getStatus()); // verify that there is 1 action taken Collection<ActionTakenValue> actionTakens = KEWServiceLocator.getActionTakenService().findByDocumentId(document.getDocumentId()); assertEquals("There should be 1 action taken.", 1, actionTakens.size()); }
public boolean isValidRemovalRequest( ProtocolOnlineReviewDocument document, ProtocolReviewerBean reviewer, int reviewerIndex) { boolean isValid = true; WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); String propertyName = Constants.PROTOCOL_ASSIGN_REVIEWERS_PROPERTY_KEY + ".reviewer[" + reviewerIndex + "].reviewerTypeCode"; String documentRouteStatus = workflowDocument.getStatus().getCode(); // 1. check to see the workflow status if (StringUtils.equals(KewApiConstants.ROUTE_HEADER_FINAL_CD, documentRouteStatus)) { // we just report the warning, the request is still valid - the action should prompt for // confirmation. reportWarning( propertyName, KeyConstants.ERROR_PROTOCOL_REVIEWER_CANNOT_REMOVE_REVIEW_FINAL, reviewer.getFullName()); } if (document.getProtocolOnlineReview().getCommitteeScheduleMinutes().size() > 0) { // there are review comments that will be deleted by this operation // just report the warning. reportWarning( propertyName, KeyConstants.ERROR_PROTOCOL_REVIEWER_CANNOT_REMOVE_REVIEW_EXISTING_COMMENTS, reviewer.getFullName(), "" + document.getProtocolOnlineReview().getCommitteeScheduleMinutes().size()); } if (StringUtils.equals( document.getProtocolOnlineReview().getProtocolOnlineReviewStatusCode(), ProtocolOnlineReviewStatus.FINAL_STATUS_CD)) { reportWarning( propertyName, KeyConstants.ERROR_PROTOCOL_REVIEWER_CANNOT_REMOVE_FINAL_REVIEW, reviewer.getFullName()); } return isValid; }