Search in sources :

Example 1 with Sponsor

use of edu.cornell.kfs.module.ezra.businessobject.Sponsor 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;
}
Also used : Agency(org.kuali.kfs.module.cg.businessobject.Agency) HashMap(java.util.HashMap) Sponsor(edu.cornell.kfs.module.ezra.businessobject.Sponsor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with Sponsor

use of edu.cornell.kfs.module.ezra.businessobject.Sponsor 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;
}
Also used : Agency(org.kuali.kfs.module.cg.businessobject.Agency) Sponsor(edu.cornell.kfs.module.ezra.businessobject.Sponsor)

Example 3 with Sponsor

use of edu.cornell.kfs.module.ezra.businessobject.Sponsor 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");
    }
}
Also used : Agency(org.kuali.kfs.module.cg.businessobject.Agency) HashMap(java.util.HashMap) Calendar(java.util.Calendar) Sponsor(edu.cornell.kfs.module.ezra.businessobject.Sponsor) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.sql.Date) Date(java.sql.Date)

Example 4 with Sponsor

use of edu.cornell.kfs.module.ezra.businessobject.Sponsor in project cu-kfs by CU-CommunityApps.

the class ezraUpdateSponsorImplTest method agencyInKfs.

public boolean agencyInKfs(List<Sponsor> sponsors) {
    Agency agency = null;
    do {
        Map fields = new HashMap();
        Sponsor sponsor = sponsors.get(agencyCount);
        fields.clear();
        Long sponsorId = sponsor.getSponsorId();
        fields.put("agencyNumber", sponsorId.toString());
        agency = (Agency) businessObjectService.findByPrimaryKey(Agency.class, fields);
        agencyCount++;
    } while ((ObjectUtils.isNull(agency)) && (agencyCount < sponsors.size()));
    agencyNumber = agencyCount - 1;
    agencyCount = 0;
    if (ObjectUtils.isNull(agency)) {
        return false;
    } else {
        return true;
    }
}
Also used : Agency(org.kuali.kfs.module.cg.businessobject.Agency) HashMap(java.util.HashMap) Sponsor(edu.cornell.kfs.module.ezra.businessobject.Sponsor) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Sponsor (edu.cornell.kfs.module.ezra.businessobject.Sponsor)4 Agency (org.kuali.kfs.module.cg.businessobject.Agency)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Date (java.sql.Date)1 Calendar (java.util.Calendar)1