use of org.kuali.kfs.module.cg.businessobject.Agency in project cu-kfs by CU-CommunityApps.
the class EzraServiceImpl method updateSponsorsSince.
public boolean updateSponsorsSince(Date date) {
boolean result = true;
List<Sponsor> sponsors = sponsorDao.getSponsorsUpdatedSince(date);
Map fields = new HashMap();
for (Sponsor sponsor : sponsors) {
Long sponsorId = sponsor.getSponsorId();
fields.clear();
fields.put("agencyNumber", sponsorId.toString());
Agency agency = (Agency) businessObjectService.findByPrimaryKey(Agency.class, fields);
Agency oldAgency = agency;
if (!ObjectUtils.isNull(agency)) {
updateAgency(agency, sponsor);
routeAgencyDocument(agency, oldAgency);
}
}
return result;
}
use of org.kuali.kfs.module.cg.businessobject.Agency in project cu-kfs by CU-CommunityApps.
the class EzraServiceImpl method createAgency.
public Agency createAgency(Long sponsorId) {
LOG.info("Creating Agency: " + sponsorId);
Sponsor sponsor = businessObjectService.findBySinglePrimaryKey(Sponsor.class, sponsorId);
Agency agency = new Agency();
agency.setAgencyNumber(sponsorId.toString());
agency.setReportingName(sponsor.getSponsorLabel());
if (ObjectUtils.isNotNull(sponsor.getSponsorName()) && sponsor.getSponsorName().length() > 150)
agency.setFullName(sponsor.getSponsorName().substring(0, 150));
else {
agency.setFullName(sponsor.getSponsorName());
}
if (sponsor.getParentSponsor() != null) {
// Need to create the reports to agency hierarchy.
Agency rptsToAgency = businessObjectService.findBySinglePrimaryKey(Agency.class, sponsor.getParentSponsor());
if (rptsToAgency == null) {
rptsToAgency = createAgency(sponsor.getParentSponsor());
routeAgencyDocument(rptsToAgency, null);
}
agency.setReportsToAgencyNumber(sponsor.getParentSponsor().toString());
}
String sponsorTypeCode = getAgencyTypeMap().get(sponsor.getSourceCode().toString());
agency.setAgencyTypeCode(sponsorTypeCode);
agency.setActive(true);
// agency.setExtension(ext);
return agency;
}
use of org.kuali.kfs.module.cg.businessobject.Agency in project cu-kfs by CU-CommunityApps.
the class ezraUpdateSponsorImplTest method testUpdateSponsors.
public void testUpdateSponsors() {
Map fields = new HashMap();
String sponsorName = "ezraUpdateTest";
String sponsorNameAfter = "";
Date sqlDate = today;
Agency agency = null;
List<Sponsor> sponsors = getSponsors(sqlDate);
int count = 0;
if (sponsors.isEmpty() || !agencyInKfs(sponsors)) {
do {
count--;
Calendar c = Calendar.getInstance();
c.setTime(today);
c.add(Calendar.DATE, count);
sqlDate = new java.sql.Date(c.getTimeInMillis());
sponsors = sponsorDao.getSponsorsUpdatedSince(sqlDate);
} while (sponsors.isEmpty() || !agencyInKfs(sponsors));
}
count = 0;
LOG.info("The Sql Date is " + sqlDate);
sponsors = sponsorDao.getSponsorsUpdatedSince(sqlDate);
Sponsor sponsor = sponsors.get(agencyNumber);
fields.clear();
Long sponsorId = sponsor.getSponsorId();
fields.put("agencyNumber", sponsorId);
agency = (Agency) businessObjectService.findByPrimaryKey(Agency.class, fields);
;
agency.setFullName(sponsorName);
businessObjectService.save(agency);
assertTrue(ezraService.updateSponsorsSince(sqlDate));
Agency agencyAfter = (Agency) businessObjectService.findByPrimaryKey(Agency.class, fields);
sponsorNameAfter = agency.getFullName();
LOG.info("Sponsor name before update " + sponsorName + " Sponsor name after update " + sponsorNameAfter);
if (sponsorName.equalsIgnoreCase(sponsorNameAfter)) {
fail("Ezra failed to update Sponsor");
}
}
use of org.kuali.kfs.module.cg.businessobject.Agency 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;
}
use of org.kuali.kfs.module.cg.businessobject.Agency in project cu-kfs by CU-CommunityApps.
the class EzraServiceImpl method updateAgency.
public void updateAgency(Agency agency, Sponsor sponsor) {
if (!StringUtils.equals(agency.getReportingName(), sponsor.getSponsorLabel())) {
agency.setReportingName(sponsor.getSponsorLabel());
}
if (!StringUtils.equals(agency.getFullName(), sponsor.getSponsorName())) {
if (sponsor.getSponsorName().length() > 150)
agency.setFullName(sponsor.getSponsorName().substring(0, 150));
else {
agency.setFullName(sponsor.getSponsorName());
}
}
if (sponsor.getParentSponsor() != null && !StringUtils.equals(agency.getReportsToAgencyNumber(), sponsor.getParentSponsor().toString())) {
// Need to create the reports to agency hierarchy.
Agency rptsToAgency = businessObjectService.findBySinglePrimaryKey(Agency.class, sponsor.getParentSponsor());
if (rptsToAgency == null) {
rptsToAgency = createAgency(sponsor.getParentSponsor());
routeAgencyDocument(rptsToAgency, null);
}
agency.setReportsToAgencyNumber(sponsor.getParentSponsor().toString());
}
String sponsorTypeCode = getAgencyTypeMap().get(sponsor.getSourceCode().toString());
if (!StringUtils.equals(agency.getAgencyTypeCode(), sponsorTypeCode)) {
agency.setAgencyTypeCode(sponsorTypeCode);
}
agency.setActive(true);
// AgencyExtension ext = (AgencyExtension)agency.getExtension();
// if (ext == null) {
// ext = new AgencyExtension();
// }
// //ext.setAgencyNumber(agency.getAgencyNumber());
// ext.setLastUpdated(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate());
// //ext.setVersionNumber(ext.getVersionNumber()+1);
// agency.setExtension(ext);
// agency.setActive(true);
// agency.refreshReferenceObject("extension");
// businessObjectService.save(ext);
}
Aggregations