Search in sources :

Example 1 with PostalCodeEbo

use of org.kuali.rice.location.framework.postalcode.PostalCodeEbo in project cu-kfs by CU-CommunityApps.

the class OrganizationGlobalMaintainableImpl method processAfterPost.

/**
 * Overridden to also add special handling for organization manager, city name and state code.
 * This is necessary to properly update the city and state information based on the zip and
 * country codes, and to properly clear out the manager object when the most recently stored
 * or refreshed principal name is an invalid one.
 *
 * Ideally, this would have been placed in a DerivedValuesSetter implementation; however, such
 * utility classes do not get called when performing a "save" action, so we resort to using
 * this method override instead.
 *
 * @see org.kuali.kfs.sys.document.FinancialSystemGlobalMaintainable#processAfterPost(org.kuali.kfs.kns.document.MaintenanceDocument, java.util.Map)
 */
@Override
public void processAfterPost(MaintenanceDocument document, Map<String, String[]> requestParameters) {
    super.processAfterPost(document, requestParameters);
    OrganizationGlobal orgGlobal = (OrganizationGlobal) getBusinessObject();
    // Forcibly set city name and state code if valid zip code is given, otherwise clear them.
    PostalCodeEbo zipCode = orgGlobal.getPostalZip();
    if (ObjectUtils.isNotNull(zipCode)) {
        // Valid zip-and-country combination is given; update city and state with corresponding values.
        orgGlobal.setOrganizationCityName(zipCode.getCityName());
        orgGlobal.setOrganizationStateCode(zipCode.getStateCode());
    } else {
        // Invalid or blank zip-and-country combination is given; clear city and state.
        orgGlobal.setOrganizationCityName(null);
        orgGlobal.setOrganizationStateCode(null);
    }
    // If the user is attempting to clear out an already-invalid principal name on the form, then clear out the manager object.
    Person orgManager = orgGlobal.getOrganizationManagerUniversal();
    String[] principalName = requestParameters.get("document.newMaintainableObject.organizationManagerUniversal.principalName");
    if (ObjectUtils.isNotNull(orgManager) && StringUtils.isBlank(orgManager.getEntityId()) && StringUtils.isNotBlank(orgManager.getPrincipalName()) && (principalName == null || principalName.length == 0 || StringUtils.isBlank(principalName[0]))) {
        // User is trying to clear out an invalid principal name; clear out principal ID and Person object accordingly.
        orgGlobal.setOrganizationManagerUniversalId(null);
        orgGlobal.setOrganizationManagerUniversal(null);
    }
}
Also used : OrganizationGlobal(edu.cornell.kfs.coa.businessobject.OrganizationGlobal) Person(org.kuali.rice.kim.api.identity.Person) PostalCodeEbo(org.kuali.rice.location.framework.postalcode.PostalCodeEbo)

Example 2 with PostalCodeEbo

use of org.kuali.rice.location.framework.postalcode.PostalCodeEbo in project cu-kfs by CU-CommunityApps.

the class OrganizationGlobal method getPostalZip.

public PostalCodeEbo getPostalZip() {
    // Copied zip-code-updating logic from Organization BO.
    if (StringUtils.isBlank(organizationZipCode) || StringUtils.isBlank(organizationCountryCode)) {
        postalZip = null;
    } else {
        if (postalZip == null || !StringUtils.equals(postalZip.getCode(), organizationZipCode) || !StringUtils.equals(postalZip.getCountryCode(), organizationCountryCode)) {
            ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
            if (moduleService != null) {
                Map<String, Object> keys = new HashMap<String, Object>(2);
                keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, organizationCountryCode);
                keys.put(LocationConstants.PrimaryKeyConstants.CODE, organizationZipCode);
                postalZip = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
            } else {
                throw new RuntimeException("CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed.");
            }
        }
    }
    return postalZip;
}
Also used : KualiModuleService(org.kuali.kfs.krad.service.KualiModuleService) KualiModuleService(org.kuali.kfs.krad.service.KualiModuleService) ModuleService(org.kuali.kfs.krad.service.ModuleService) HashMap(java.util.HashMap) GlobalBusinessObject(org.kuali.kfs.krad.bo.GlobalBusinessObject) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) PostalCodeEbo(org.kuali.rice.location.framework.postalcode.PostalCodeEbo)

Example 3 with PostalCodeEbo

use of org.kuali.rice.location.framework.postalcode.PostalCodeEbo in project cu-kfs by CU-CommunityApps.

the class Account method getPostalZipCode.

/**
 * Gets the postalZipCode attribute.
 *
 * @return Returns the postalZipCode.
 */
@Override
public PostalCodeEbo getPostalZipCode() {
    if (StringUtils.isBlank(accountZipCode) || StringUtils.isBlank(accountCountryCode)) {
        postalZipCode = null;
    } else {
        if (postalZipCode == null || !StringUtils.equals(postalZipCode.getCode(), accountZipCode) || !StringUtils.equals(postalZipCode.getCountryCode(), accountCountryCode)) {
            ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
            if (moduleService != null) {
                Map<String, Object> keys = new HashMap<String, Object>(2);
                keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, accountCountryCode);
                keys.put(LocationConstants.PrimaryKeyConstants.CODE, accountZipCode);
                postalZipCode = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
            } else {
                throw new RuntimeException("CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed.");
            }
        }
    }
    return postalZipCode;
}
Also used : KualiModuleService(org.kuali.kfs.krad.service.KualiModuleService) ContractsAndGrantsModuleService(org.kuali.kfs.integration.cg.ContractsAndGrantsModuleService) KualiModuleService(org.kuali.kfs.krad.service.KualiModuleService) ModuleService(org.kuali.kfs.krad.service.ModuleService) HashMap(java.util.HashMap) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) PostalCodeEbo(org.kuali.rice.location.framework.postalcode.PostalCodeEbo)

Aggregations

PostalCodeEbo (org.kuali.rice.location.framework.postalcode.PostalCodeEbo)3 HashMap (java.util.HashMap)2 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)2 KualiModuleService (org.kuali.kfs.krad.service.KualiModuleService)2 ModuleService (org.kuali.kfs.krad.service.ModuleService)2 OrganizationGlobal (edu.cornell.kfs.coa.businessobject.OrganizationGlobal)1 ContractsAndGrantsModuleService (org.kuali.kfs.integration.cg.ContractsAndGrantsModuleService)1 GlobalBusinessObject (org.kuali.kfs.krad.bo.GlobalBusinessObject)1 Person (org.kuali.rice.kim.api.identity.Person)1