private void setNarrativePermissions( Person user, ProposalDevelopmentDocument doc, Set<String> editModes) { List<Narrative> narratives = doc.getDevelopmentProposal().getNarratives(); synchronized (narratives) { for (Narrative narrative : narratives) { String prefix = "proposalAttachment." + narrative.getModuleNumber() + "."; if (isAuthorizedToViewNarrative(narrative, user)) { editModes.add(prefix + "download"); } if (isAuthorizedToReplaceNarrative(narrative, user)) { editModes.add(prefix + "replace"); } if (isAuthorizedToDeleteNarrative(narrative, user)) { editModes.add(prefix + "delete"); } if (isAuthorizedToModifyNarrative(narrative, user)) { editModes.add(prefix + "modifyStatus"); } if (isAuthorizedToModifyNarrative(narrative, user)) { editModes.add(prefix + "modifyRights"); } } narratives = doc.getDevelopmentProposal().getInstituteAttachments(); for (Narrative narrative : narratives) { String prefix = "instituteAttachment." + narrative.getModuleNumber() + "."; if (isAuthorizedToViewNarrative(narrative, user)) { editModes.add(prefix + "download"); } if (isAuthorizedToReplaceNarrative(narrative, user)) { editModes.add(prefix + "replace"); } if (isAuthorizedToDeleteNarrative(narrative, user)) { editModes.add(prefix + "delete"); } if (isAuthorizedToModifyNarrative(narrative, user)) { editModes.add(prefix + "modifyRights"); } } int i = 0; boolean canReplace = isAuthorizedToReplacePersonnelAttachement(doc, user); for (ProposalPersonBiography ppb : doc.getDevelopmentProposal().getPropPersonBios()) { ppb.setPositionNumber(i); String prefix = "biographyAttachments." + ppb.getPositionNumber() + "."; if (canReplace) { editModes.add(prefix + "replace"); } i++; } } }
@Override public void populateProposalPerson(ProposalPerson person, ProposalDevelopmentDocument document) { /* populate certification questions for new person */ person = getYnqService().getPersonYNQ(person, document); if (person.isInvestigator()) { if (!document.getDevelopmentProposal().getInvestigators().contains(person)) { document.getDevelopmentProposal().getInvestigators().add(person); } populateCreditTypes(person); } person.setRoleChanged(false); try { if (person.getPersonId() != null && person.getPerson().getExtendedAttributes() != null) { KcPerson origPerson = person.getPerson(); for (PersonDegree degree : origPerson.getExtendedAttributes().getPersonDegrees()) { ProposalPersonDegree newDegree = new ProposalPersonDegree(); newDegree.setDegree(degree.getDegree()); newDegree.setDegreeCode(degree.getDegreeCode()); newDegree.setFieldOfStudy(degree.getFieldOfStudy()); newDegree.setGraduationYear(degree.getGraduationYear()); newDegree.setSchool(degree.getSchool()); newDegree.setSchoolId(degree.getSchoolId()); newDegree.setSchoolIdCode(degree.getSchoolIdCode()); newDegree.setDegreeSequenceNumber( document.getDocumentNextValue(Constants.PROPOSAL_PERSON_DEGREE_SEQUENCE_NUMBER)); person.addDegree(newDegree); } if (origPerson.getExtendedAttributes().getAttachments() != null) { for (PersonBiosketch attachment : origPerson.getExtendedAttributes().getAttachments()) { ProposalPersonBiography bio = new ProposalPersonBiography(); bio.setProposalPersonNumber(person.getProposalPersonNumber()); bio.setDocumentTypeCode(getDefaultPersonAttachmentDocType()); bio.setDescription(attachment.getDescription()); bio.setName(attachment.getFileName()); bio.setType(attachment.getContentType()); ProposalPersonBiographyAttachment personnelAttachment = new ProposalPersonBiographyAttachment(); personnelAttachment.setName(attachment.getFileName()); personnelAttachment.setProposalNumber( document.getDevelopmentProposal().getProposalNumber()); personnelAttachment.setProposalPersonNumber(person.getProposalPersonNumber()); personnelAttachment.setData(attachment.getAttachmentContent()); personnelAttachment.setType(attachment.getContentType()); bio.setPersonnelAttachment(personnelAttachment); document.getDevelopmentProposal().addProposalPersonBiography(bio); } } } } catch (IllegalArgumentException e) { // catching the possibility that person.getPerson can not // find a EntityContract for this person id. } }