Search in sources :

Example 1 with ContractGrantReportingCode

use of edu.cornell.kfs.coa.businessobject.ContractGrantReportingCode 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)

Example 2 with ContractGrantReportingCode

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

the class ObjectCodeExtensionRule method checkContractGrantReportingCode.

/*
     * Verify value has been entered for required attribute cgReportingCode
     */
protected boolean checkContractGrantReportingCode(ObjectCode objectCode) {
    boolean success = true;
    ObjectCodeExtendedAttribute extendedAttributes = (ObjectCodeExtendedAttribute) objectCode.getExtension();
    String cgReportingCode = extendedAttributes.getCgReportingCode();
    String chartOfAccountsCode = objectCode.getChartOfAccountsCode();
    if ((!StringUtils.isBlank(cgReportingCode)) && (!StringUtils.isBlank(cgReportingCode))) {
        // have values for both table primary keys
        Map fieldValues = new HashMap();
        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("extension.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("extension.cgReportingCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(ObjectCode.class, "extension.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 : ObjectCodeExtendedAttribute(edu.cornell.kfs.coa.businessobject.ObjectCodeExtendedAttribute) HashMap(java.util.HashMap) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) HashMap(java.util.HashMap) Map(java.util.Map) ContractGrantReportingCode(edu.cornell.kfs.coa.businessobject.ContractGrantReportingCode) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Aggregations

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