use of edu.cornell.kfs.module.ezra.businessobject.Investigator in project cu-kfs by CU-CommunityApps.
the class EzraServiceImpl method createProjectDirectors.
private List<ProposalProjectDirector> createProjectDirectors(String projectId, EzraProject project) {
List<ProposalProjectDirector> projDirs = new ArrayList<ProposalProjectDirector>();
Investigator investigator = (Investigator) businessObjectService.findBySinglePrimaryKey(Investigator.class, project.getProjectDirectorId());
if (investigator != null) {
PersonService ps = SpringContext.getBean(PersonService.class);
if (investigator.getNetId() != null) {
Person director = ps.getPersonByPrincipalName(investigator.getNetId());
if (director != null) {
Map primaryKeys = new HashMap();
primaryKeys.put("principalId", director.getPrincipalId());
primaryKeys.put("proposalNumber", projectId);
ProposalProjectDirector ppd = (ProposalProjectDirector) businessObjectService.findByPrimaryKey(ProposalProjectDirector.class, primaryKeys);
if (ObjectUtils.isNull(ppd)) {
ppd = new ProposalProjectDirector();
}
// else {
// ppd.setVersionNumber(ppd.getVersionNumber());
// }
ppd.setPrincipalId(director.getPrincipalId());
ppd.setProposalNumber(project.getProjectId());
ppd.setProposalPrimaryProjectDirectorIndicator(true);
ppd.setActive(true);
KimApiServiceLocator.getRoleService().assignPrincipalToRole(director.getPrincipalId(), "KFS-SYS", "Contracts & Grants Project Director", new HashMap<String, String>());
projDirs.add(ppd);
} else {
LOG.error("PI: " + investigator.getNetId() + " for award :" + projectId + " is not in kfs");
}
} else {
LOG.error("PI netId for award :" + projectId + " is null");
}
} else {
LOG.error("Null PI: " + project.getProjectDirectorId());
}
Map fieldValues = new HashMap();
fieldValues.put("projectId", projectId.toString());
fieldValues.put("investigatorRole", "CO");
List<ProjectInvestigator> pis = (List<ProjectInvestigator>) businessObjectService.findMatching(ProjectInvestigator.class, fieldValues);
for (ProjectInvestigator pi : pis) {
if (pi.getInvestigatorId() != null) {
Investigator inv = (Investigator) businessObjectService.findBySinglePrimaryKey(Investigator.class, pi.getInvestigatorId());
if (inv != null) {
PersonService ps = SpringContext.getBean(PersonService.class);
if (inv.getNetId() != null) {
Person director = ps.getPersonByPrincipalName(inv.getNetId());
if (director != null) {
Map primaryKeys = new HashMap();
primaryKeys.put("principalId", director.getPrincipalId());
primaryKeys.put("proposalNumber", projectId);
ProposalProjectDirector ppd = (ProposalProjectDirector) businessObjectService.findByPrimaryKey(ProposalProjectDirector.class, primaryKeys);
if (ObjectUtils.isNull(ppd)) {
ppd = new ProposalProjectDirector();
}
ppd.setPrincipalId(director.getPrincipalId());
ppd.setProposalNumber(project.getProjectId());
ppd.setProposalPrimaryProjectDirectorIndicator(false);
ppd.setActive(true);
KimApiServiceLocator.getRoleService().assignPrincipalToRole(director.getPrincipalId(), "KFS-SYS", "Contracts & Grants Project Director", new HashMap<String, String>());
// check to make sure that this project director is not already in the list.
for (ProposalProjectDirector projDir : projDirs) {
if (projDir.getPrincipalId().equals(ppd.getPrincipalId()))
continue;
}
projDirs.add(ppd);
} else {
LOG.error("Investigator: " + investigator.getNetId() + " is for award :" + projectId + " is not in kfs");
}
} else {
LOG.error("Invesigator netId for award :" + projectId + " is null");
}
} else {
LOG.error("Null investigator: " + pi.getInvestigatorId());
}
} else {
LOG.error("Null investigator id: ");
}
}
return projDirs;
}
Aggregations