@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; }
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; }