Search in sources :

Example 1 with ObjectCodeExtendedAttribute

use of edu.cornell.kfs.coa.businessobject.ObjectCodeExtendedAttribute 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)1 ObjectCodeExtendedAttribute (edu.cornell.kfs.coa.businessobject.ObjectCodeExtendedAttribute)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1