Search in sources :

Example 1 with ProposalOrganization

use of org.kuali.kfs.module.cg.businessobject.ProposalOrganization 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 2 with ProposalOrganization

use of org.kuali.kfs.module.cg.businessobject.ProposalOrganization 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)

Example 3 with ProposalOrganization

use of org.kuali.kfs.module.cg.businessobject.ProposalOrganization in project cu-kfs by CU-CommunityApps.

the class EzraServiceImpl method createProposalOrganizations.

private List<ProposalOrganization> createProposalOrganizations(String projectId, EzraProject project) {
    // EzraProject ep = (EzraProject)businessObjectService.findBySinglePrimaryKey(EzraProject.class, projectId);
    String orgCode = project.getProjectDepartmentId();
    Map deptFields = new HashMap();
    deptFields.put("organizationCode", orgCode);
    List<Organization> orgs = (List<Organization>) businessObjectService.findMatching(Organization.class, deptFields);
    LOG.info("Retrieved Orgs :" + orgs.size() + " for Proposal " + projectId);
    List<ProposalOrganization> propOrgs = new ArrayList<ProposalOrganization>();
    for (Organization org : orgs) {
        Map primaryKeys = new HashMap();
        primaryKeys.put("chartOfAccountsCode", org.getChartOfAccountsCode());
        primaryKeys.put("organizationCode", org.getOrganizationCode());
        primaryKeys.put("proposalNumber", projectId);
        ProposalOrganization po = (ProposalOrganization) businessObjectService.findByPrimaryKey(ProposalOrganization.class, primaryKeys);
        if (ObjectUtils.isNull(po)) {
            po = new ProposalOrganization();
        } else {
            po.setVersionNumber(po.getVersionNumber() + 1);
        }
        po.setChartOfAccountsCode("IT");
        po.setOrganizationCode(org.getOrganizationCode());
        // EzraProject ep = (EzraProject)businessObjectService.findBySinglePrimaryKey(EzraProject.class, projectId);
        if (org.getOrganizationCode().equals(project.getProjectDepartmentId())) {
            po.setProposalPrimaryOrganizationIndicator(true);
        }
        po.setActive(true);
        propOrgs.add(po);
    }
    return propOrgs;
}
Also used : ProposalOrganization(org.kuali.kfs.module.cg.businessobject.ProposalOrganization) AwardOrganization(org.kuali.kfs.module.cg.businessobject.AwardOrganization) ProposalOrganization(org.kuali.kfs.module.cg.businessobject.ProposalOrganization) Organization(org.kuali.kfs.coa.businessobject.Organization) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ProposalOrganization (org.kuali.kfs.module.cg.businessobject.ProposalOrganization)3 AwardOrganization (org.kuali.kfs.module.cg.businessobject.AwardOrganization)2 ProposalProjectDirector (org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector)2 EzraProject (edu.cornell.kfs.module.ezra.businessobject.EzraProject)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 Organization (org.kuali.kfs.coa.businessobject.Organization)1 Agency (org.kuali.kfs.module.cg.businessobject.Agency)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