use of org.kuali.kfs.krad.bo.GlobalBusinessObjectDetail 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;
}
Aggregations