Search in sources :

Example 21 with BusinessObjectService

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;
}
Also used : HashMap(java.util.HashMap) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 22 with 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;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) MajorReportingCategory(edu.cornell.kfs.coa.businessobject.MajorReportingCategory) HashMap(java.util.HashMap) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) HashMap(java.util.HashMap) Map(java.util.Map) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 23 with BusinessObjectService

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;
}
Also used : HashMap(java.util.HashMap) LaborBenefitRateCategory(org.kuali.kfs.module.ld.businessobject.LaborBenefitRateCategory) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 24 with BusinessObjectService

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;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) HashMap(java.util.HashMap) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) HashMap(java.util.HashMap) Map(java.util.Map) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 25 with BusinessObjectService

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;
}
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

BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)34 HashMap (java.util.HashMap)26 Map (java.util.Map)7 Account (org.kuali.kfs.coa.businessobject.Account)7 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)6 ArrayList (java.util.ArrayList)6 List (java.util.List)5 AccountExtendedAttribute (edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)4 LinkedHashMap (java.util.LinkedHashMap)4 SubFundProgram (edu.cornell.kfs.coa.businessobject.SubFundProgram)3 ContractGrantReportingCode (edu.cornell.kfs.coa.businessobject.ContractGrantReportingCode)2 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)2 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 CUObjectCodeGlobal (edu.cornell.kfs.coa.businessobject.CUObjectCodeGlobal)1 CuAccountGlobal (edu.cornell.kfs.coa.businessobject.CuAccountGlobal)1 MajorReportingCategory (edu.cornell.kfs.coa.businessobject.MajorReportingCategory)1 ObjectCodeExtendedAttribute (edu.cornell.kfs.coa.businessobject.ObjectCodeExtendedAttribute)1 AccountReversionImportService (edu.cornell.kfs.coa.service.AccountReversionImportService)1 AccountReversionTrickleDownInactivationService (edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService)1 EzraProposalAward (edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward)1