Search in sources :

Example 1 with CUObjectCodeGlobal

use of edu.cornell.kfs.coa.businessobject.CUObjectCodeGlobal in project cu-kfs by CU-CommunityApps.

the class ObjectCodeGlobalExtensionRule method checkContractGrantReportingCode.

/*
   * Verify value has been entered for required attribute cgReportingCode
   */
protected boolean checkContractGrantReportingCode(CUObjectCodeGlobal ocg) {
    boolean success = true;
    String cgReportingCode = ocg.getCgReportingCode();
    for (GlobalBusinessObjectDetail ocgd : ocg.getAllDetailObjects()) {
        String chartOfAccountsCode = ((ObjectCodeGlobalDetail) ocgd).getChartOfAccountsCode();
        if ((!StringUtils.isBlank(cgReportingCode)) && (!StringUtils.isBlank(cgReportingCode))) {
            // have values for both table primary keys
            HashMap<String, String> fieldValues = new HashMap<String, String>();
            fieldValues.put("chartOfAccountsCode", chartOfAccountsCode);
            // prompt table has attribute defined as "code" and we need to use it for the lookup
            fieldValues.put("code", cgReportingCode);
            BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
            Collection<ContractGrantReportingCode> retVals = bos.findMatching(ContractGrantReportingCode.class, fieldValues);
            if (retVals.isEmpty()) {
                putFieldError("cgReportingCode", CUKFSKeyConstants.ERROR_DOCUMENT_OBJCDMAINT_CG_RPT_CAT_CODE_NOT_EXIST, new String[] { chartOfAccountsCode, cgReportingCode });
                success = false;
            } else {
                // verify the value to be assigned is active
                for (ContractGrantReportingCode sfp : retVals) {
                    if (!sfp.isActive()) {
                        putFieldError("cgReportingCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(CUObjectCodeGlobal.class, "cgReportingCode"));
                        success = false;
                    }
                }
            }
        }
    // implied else coa or cgReportingCode or both are blank, caught by maintenance doc having these fields defined as "required", else coding to report this causes double error messages
    }
    return success;
}
Also used : ObjectCodeGlobalDetail(org.kuali.kfs.coa.businessobject.ObjectCodeGlobalDetail) HashMap(java.util.HashMap) GlobalBusinessObjectDetail(org.kuali.kfs.krad.bo.GlobalBusinessObjectDetail) ContractGrantReportingCode(edu.cornell.kfs.coa.businessobject.ContractGrantReportingCode) CUObjectCodeGlobal(edu.cornell.kfs.coa.businessobject.CUObjectCodeGlobal) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Aggregations

CUObjectCodeGlobal (edu.cornell.kfs.coa.businessobject.CUObjectCodeGlobal)1 ContractGrantReportingCode (edu.cornell.kfs.coa.businessobject.ContractGrantReportingCode)1 HashMap (java.util.HashMap)1 ObjectCodeGlobalDetail (org.kuali.kfs.coa.businessobject.ObjectCodeGlobalDetail)1 GlobalBusinessObjectDetail (org.kuali.kfs.krad.bo.GlobalBusinessObjectDetail)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1