use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.
the class CuAssetServiceImplTest method createMockBusinessObjectService.
protected BusinessObjectService createMockBusinessObjectService(String tagNumber, List<Asset> result) {
BusinessObjectService businessObjectService = mock(BusinessObjectServiceImpl.class);
Map<String, String> params = new HashMap<String, String>();
params.put(CamsPropertyConstants.Asset.CAMPUS_TAG_NUMBER, tagNumber);
when(businessObjectService.findMatching(Asset.class, params)).thenReturn(result);
return businessObjectService;
}
use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.
the class AccountExtensionRule method checkMajorReportingCategoryCode.
protected boolean checkMajorReportingCategoryCode(MaintenanceDocument document) {
boolean success = true;
String majorReportingCategoryCode = ((AccountExtendedAttribute) newAccount.getExtension()).getMajorReportingCategoryCode();
BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
// MajorReportingCategory code is not a required field, if no value is entered no validation is performed
if (!StringUtils.isBlank(majorReportingCategoryCode)) {
Map fieldValues = new HashMap();
fieldValues.put("majorReportingCategoryCode", majorReportingCategoryCode);
Collection<MajorReportingCategory> retVals = bos.findMatching(MajorReportingCategory.class, fieldValues);
if (retVals.isEmpty()) {
putFieldError("extension.majorReportingCategoryCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_MJR_RPT_CAT_CODE_NOT_EXIST, new String[] { majorReportingCategoryCode });
success = false;
} else {
for (MajorReportingCategory sfp : retVals) {
if (!sfp.isActive()) {
putFieldError("extension.majorReportingCategoryCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.majorReportingCategoryCode"));
success = false;
}
}
}
}
return success;
}
use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.
the class AccountExtensionRule method checkLaborBenefitCategoryCode.
// TODO This should no longer be required as laborBenefitCategoryCode is now in the base table and add to
// the list of fields the have existence checks.
@SuppressWarnings("deprecation")
protected boolean checkLaborBenefitCategoryCode(MaintenanceDocument document) {
boolean success = true;
String laborBenefitCategoryCode = newAccount.getLaborBenefitRateCategoryCode();
BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
// no validation is performed.
if (!StringUtils.isBlank(laborBenefitCategoryCode)) {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put("laborBenefitRateCategoryCode", laborBenefitCategoryCode);
Collection<LaborBenefitRateCategory> retVals = bos.findMatching(LaborBenefitRateCategory.class, fieldValues);
if (retVals.isEmpty()) {
success = false;
putFieldError("laborBenefitRateCategoryCode", KFSKeyConstants.ERROR_EXISTENCE, " Labor Benefit Rate Category Code " + laborBenefitCategoryCode);
}
}
return success;
}
use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.
the class AccountExtensionRule method checkAppropriationAccount.
protected boolean checkAppropriationAccount(MaintenanceDocument document) {
boolean success = true;
String subFundGroupCode = newAccount.getSubFundGroupCode();
String appropriationAccountNumber = ((AccountExtendedAttribute) newAccount.getExtension()).getAppropriationAccountNumber();
BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
if (!StringUtils.isBlank(appropriationAccountNumber)) {
Map fieldValues = new HashMap();
fieldValues.put("subFundGroupCode", subFundGroupCode);
fieldValues.put("appropriationAccountNumber", appropriationAccountNumber);
Collection<AppropriationAccount> retVals = bos.findMatching(AppropriationAccount.class, fieldValues);
if (retVals.isEmpty()) {
success = false;
putFieldError("extension.appropriationAccountNumber", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { appropriationAccountNumber, subFundGroupCode });
} else {
for (AppropriationAccount sfp : retVals) {
if (!sfp.isActive()) {
putFieldError("extension.appropriationAccountNumber", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.appropriationAccountNumber"));
success = false;
}
}
}
}
return success;
}
use of org.kuali.kfs.krad.service.BusinessObjectService 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;
}
Aggregations