Search in sources :

Example 1 with ProposalProjectDirector

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;
}
Also used : HashMap(java.util.HashMap) PersonService(org.kuali.rice.kim.api.identity.PersonService) ArrayList(java.util.ArrayList) ProposalProjectDirector(org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector) Investigator(edu.cornell.kfs.module.ezra.businessobject.Investigator) ProjectInvestigator(edu.cornell.kfs.module.ezra.businessobject.ProjectInvestigator) ArrayList(java.util.ArrayList) List(java.util.List) ProjectInvestigator(edu.cornell.kfs.module.ezra.businessobject.ProjectInvestigator) Person(org.kuali.rice.kim.api.identity.Person) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ProposalProjectDirector

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);
            }
        }
    }
}
Also used : ProposalOrganization(org.kuali.kfs.module.cg.businessobject.ProposalOrganization) ProposalSubcontractor(org.kuali.kfs.module.cg.businessobject.ProposalSubcontractor) AwardSubcontractor(org.kuali.kfs.module.cg.businessobject.AwardSubcontractor) AwardProjectDirector(org.kuali.kfs.module.cg.businessobject.AwardProjectDirector) AwardOrganization(org.kuali.kfs.module.cg.businessobject.AwardOrganization) ProposalProjectDirector(org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector) HashSet(java.util.HashSet)

Example 3 with ProposalProjectDirector

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;
}
Also used : ProposalOrganization(org.kuali.kfs.module.cg.businessobject.ProposalOrganization) Agency(org.kuali.kfs.module.cg.businessobject.Agency) ProposalProjectDirector(org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector) EzraProject(edu.cornell.kfs.module.ezra.businessobject.EzraProject) Proposal(org.kuali.kfs.module.cg.businessobject.Proposal) CFDA(org.kuali.kfs.module.cg.businessobject.CFDA)

Aggregations

ProposalProjectDirector (org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector)3 ProposalOrganization (org.kuali.kfs.module.cg.businessobject.ProposalOrganization)2 EzraProject (edu.cornell.kfs.module.ezra.businessobject.EzraProject)1 Investigator (edu.cornell.kfs.module.ezra.businessobject.Investigator)1 ProjectInvestigator (edu.cornell.kfs.module.ezra.businessobject.ProjectInvestigator)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Agency (org.kuali.kfs.module.cg.businessobject.Agency)1 AwardOrganization (org.kuali.kfs.module.cg.businessobject.AwardOrganization)1 AwardProjectDirector (org.kuali.kfs.module.cg.businessobject.AwardProjectDirector)1 AwardSubcontractor (org.kuali.kfs.module.cg.businessobject.AwardSubcontractor)1 CFDA (org.kuali.kfs.module.cg.businessobject.CFDA)1 Proposal (org.kuali.kfs.module.cg.businessobject.Proposal)1 ProposalSubcontractor (org.kuali.kfs.module.cg.businessobject.ProposalSubcontractor)1 Person (org.kuali.rice.kim.api.identity.Person)1 PersonService (org.kuali.rice.kim.api.identity.PersonService)1