use of org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector 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;
}
use of org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector in project cu-kfs by CU-CommunityApps.
the class CuAward method populateFromProposal.
/**
* This method takes all the applicable attributes from the associated proposal object and sets those attributes into their
* corresponding award attributes.
*
* @param proposal The associated proposal that the award will be linked to.
*/
public void populateFromProposal(Proposal proposal) {
if (ObjectUtils.isNotNull(proposal)) {
setProposalNumber(proposal.getProposalNumber());
setAgencyNumber(proposal.getAgencyNumber());
setAwardProjectTitle(proposal.getProposalProjectTitle());
setAwardDirectCostAmount(proposal.getProposalDirectCostAmount());
setAwardIndirectCostAmount(proposal.getProposalIndirectCostAmount());
setProposalAwardTypeCode(proposal.getProposalAwardTypeCode());
setFederalPassThroughIndicator(proposal.getProposalFederalPassThroughIndicator());
setFederalPassThroughAgencyNumber(proposal.getFederalPassThroughAgencyNumber());
setAwardPurposeCode(proposal.getProposalPurposeCode());
// copy proposal organizations to award organizations
getAwardOrganizations().clear();
for (ProposalOrganization pOrg : proposal.getProposalOrganizations()) {
AwardOrganization awardOrg = new AwardOrganization();
// newCollectionRecord is set to true to allow deletion of this record after being populated from proposal
awardOrg.setNewCollectionRecord(true);
awardOrg.setProposalNumber(pOrg.getProposalNumber());
awardOrg.setChartOfAccountsCode(pOrg.getChartOfAccountsCode());
awardOrg.setOrganizationCode(pOrg.getOrganizationCode());
awardOrg.setAwardPrimaryOrganizationIndicator(pOrg.isProposalPrimaryOrganizationIndicator());
awardOrg.setActive(pOrg.isActive());
awardOrg.setVersionNumber(pOrg.getVersionNumber());
getAwardOrganizations().add(awardOrg);
}
// copy proposal subcontractors to award subcontractors
getAwardSubcontractors().clear();
for (ProposalSubcontractor pSubcontractor : proposal.getProposalSubcontractors()) {
AwardSubcontractor awardSubcontractor = new AwardSubcontractor();
// newCollectionRecord is set to true to allow deletion of this record after being populated from proposal
awardSubcontractor.setNewCollectionRecord(true);
awardSubcontractor.setProposalNumber(pSubcontractor.getProposalNumber());
awardSubcontractor.setAwardSubcontractorNumber(pSubcontractor.getProposalSubcontractorNumber());
awardSubcontractor.setSubcontractorAmount(pSubcontractor.getProposalSubcontractorAmount());
awardSubcontractor.setAwardSubcontractorDescription(pSubcontractor.getProposalSubcontractorDescription());
awardSubcontractor.setSubcontractorNumber(pSubcontractor.getSubcontractorNumber());
awardSubcontractor.setActive(pSubcontractor.isActive());
awardSubcontractor.setVersionNumber(pSubcontractor.getVersionNumber());
getAwardSubcontractors().add(awardSubcontractor);
}
// copy proposal project directors to award propject directors
getAwardProjectDirectors().clear();
// use this to filter out duplicate projectdirectors
Set<String> directors = new HashSet<String>();
for (ProposalProjectDirector pDirector : proposal.getProposalProjectDirectors()) {
if (directors.add(pDirector.getPrincipalId())) {
AwardProjectDirector awardDirector = new AwardProjectDirector();
// newCollectionRecord is set to true to allow deletion of this record after being populated from proposal
awardDirector.setNewCollectionRecord(true);
awardDirector.setProposalNumber(pDirector.getProposalNumber());
awardDirector.setAwardPrimaryProjectDirectorIndicator(pDirector.isProposalPrimaryProjectDirectorIndicator());
awardDirector.setAwardProjectDirectorProjectTitle(pDirector.getProposalProjectDirectorProjectTitle());
awardDirector.setPrincipalId(pDirector.getPrincipalId());
awardDirector.setActive(pDirector.isActive());
awardDirector.setVersionNumber(pDirector.getVersionNumber());
getAwardProjectDirectors().add(awardDirector);
}
}
}
}
use of org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector in project cu-kfs by CU-CommunityApps.
the class EzraServiceImpl method createProposal.
protected Proposal createProposal(EzraProposalAward ezraProposal) {
String proposalId = ezraProposal.getProjectId();
Proposal proposal = new Proposal();
proposal.setProposalNumber(proposalId);
LOG.info("Creating Proposal: " + proposalId);
if (ezraProposal.getSponsorNumber() != null) {
Agency agency = businessObjectService.findBySinglePrimaryKey(Agency.class, ezraProposal.getSponsorNumber().toString());
if (ObjectUtils.isNull(agency)) {
agency = createAgency(ezraProposal.getSponsorNumber());
routeAgencyDocument(agency, null);
}
proposal.setAgencyNumber(ezraProposal.getSponsorNumber().toString());
}
EzraProject project = (EzraProject) businessObjectService.findBySinglePrimaryKey(EzraProject.class, proposal.getProposalNumber());
List<ProposalProjectDirector> ppds = createProjectDirectors(proposal.getProposalNumber(), project);
proposal.setProposalProjectDirectors(ppds);
List<ProposalOrganization> propOrgs = createProposalOrganizations(proposal.getProposalNumber(), project);
proposal.setProposalOrganizations(propOrgs);
// check to see if this is a real cfda
String myCfdaNumber = "";
if (ObjectUtils.isNotNull(ezraProposal.getCfdaNumber())) {
myCfdaNumber = ezraProposal.getCfdaNumber().trim();
CFDA cfda = businessObjectService.findBySinglePrimaryKey(CFDA.class, myCfdaNumber);
if (ObjectUtils.isNotNull(cfda)) {
proposal.setCfdaNumber(myCfdaNumber);
} else {
proposal.setCfdaNumber(UNKNOWN_DEFAULT_CFDA_NUMBER);
LOG.info("UNKNOWN CFDA NUMBER for Proposal Id: " + proposalId + ". CFDA Number from EZRA is: " + myCfdaNumber + ". Using " + UNKNOWN_DEFAULT_CFDA_NUMBER + " instead.");
}
} else
LOG.info("CFDA NUMBER for Proposal Id: " + proposalId + " was not provided from EZRA.");
if (project.getProjectTitle() != null) {
proposal.setProposalProjectTitle(project.getProjectTitle().trim());
}
if (ObjectUtils.isNotNull(ezraProposal.getSponsorProjectId())) {
int sponsorId = ezraProposal.getSponsorProjectId().length();
if (sponsorId > grantIdMax) {
proposal.setGrantNumber(ezraProposal.getSponsorProjectId().substring(0, 26));
} else {
proposal.setGrantNumber(ezraProposal.getSponsorProjectId());
}
}
proposal.setProposalStatusCode(getProposalStatusMap().get(ezraProposal.getStatus()));
proposal.setProposalPurposeCode(getProposalPurposeMap().get(ezraProposal.getPurpose()));
proposal.setProposalBeginningDate(ezraProposal.getStartDate());
proposal.setProposalEndingDate(ezraProposal.getStopDate());
proposal.setProposalDirectCostAmount(ezraProposal.getTotalAmt());
proposal.setProposalIndirectCostAmount(KualiDecimal.ZERO);
if (ezraProposal.getFederalPassThroughAgencyNumber() != null) {
Agency agency = businessObjectService.findBySinglePrimaryKey(Agency.class, ezraProposal.getFederalPassThroughAgencyNumber().toString());
if (ObjectUtils.isNull(agency)) {
agency = createAgency(ezraProposal.getFederalPassThroughAgencyNumber());
routeAgencyDocument(agency, null);
}
proposal.setFederalPassThroughAgencyNumber(ezraProposal.getFederalPassThroughAgencyNumber().toString());
}
proposal.setProposalFederalPassThroughIndicator(ezraProposal.getFederalPassThroughBoolean());
proposal.setProposalAwardTypeCode("Z");
proposal.setActive(true);
return proposal;
}
Aggregations