Search in sources :

Example 16 with BusinessObjectService

use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.

the class CUObjectCodeGlobal method setCode.

/**
 * @param code the code to set
 */
public void setCode(String code) {
    this.code = code;
    this.cgReportingCode = code;
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    HashMap<String, String> keys = new HashMap<String, String>();
    keys.put("chartOfAccountsCode", this.chartOfAccountsCode);
    // lookup table has class attribute defined as "code"
    keys.put("code", this.code);
    contractGrantReportingCode = (ContractGrantReportingCode) bos.findByPrimaryKey(ContractGrantReportingCode.class, keys);
}
Also used : HashMap(java.util.HashMap) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 17 with BusinessObjectService

use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.

the class CuAccountDelegateGlobal method generateGlobalChangesToPersist.

/**
 * @see org.kuali.kfs.krad.document.GlobalBusinessObject#applyGlobalChanges(org.kuali.rice.krad.bo.BusinessObject)
 */
@SuppressWarnings("deprecation")
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
    BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
    List<AccountDelegate> persistables = new ArrayList();
    List<AccountDelegateGlobalDetail> changeDocuments = this.getDelegateGlobals();
    List<AccountGlobalDetail> accountDetails = this.getAccountGlobalDetails();
    for (AccountDelegateGlobalDetail changeDocument : changeDocuments) {
        for (AccountGlobalDetail accountDetail : accountDetails) {
            Account account = (Account) boService.findByPrimaryKey(Account.class, accountDetail.getPrimaryKeys());
            // the busines rules for this document should have caught this.
            if (account == null) {
                throw new RuntimeException("Account [" + accountDetail.getChartOfAccountsCode() + "-" + accountDetail.getAccountNumber() + "] was not present in the database. " + "This should never happen under normal circumstances, as an invalid account should have " + "been caught by the Business Rules infrastructure.");
            }
            // attempt to load the existing Delegate from the DB, if it exists. we do this to avoid
            // versionNumber conflicts if we tried to just insert a new record that already existed.
            Map pkMap = new HashMap();
            // chartOfAccountsCode & accountNumber
            pkMap.putAll(accountDetail.getPrimaryKeys());
            pkMap.put("financialDocumentTypeCode", changeDocument.getFinancialDocumentTypeCode());
            pkMap.put("accountDelegateSystemId", changeDocument.getAccountDelegateUniversalId());
            AccountDelegate delegate = (AccountDelegate) boService.findByPrimaryKey(AccountDelegate.class, pkMap);
            // so lets populate it with the primary keys
            if (delegate == null) {
                delegate = new AccountDelegate();
                delegate.setChartOfAccountsCode(accountDetail.getChartOfAccountsCode());
                delegate.setAccountNumber(accountDetail.getAccountNumber());
                delegate.setAccountDelegateSystemId(changeDocument.getAccountDelegateUniversalId());
                delegate.setFinancialDocumentTypeCode(changeDocument.getFinancialDocumentTypeCode());
                delegate.setActive(true);
            } else {
                delegate.setActive(true);
            }
            // APPROVAL FROM AMOUNT
            delegate.setFinDocApprovalFromThisAmt(changeDocument.getApprovalFromThisAmount());
            // APPROVAL TO AMOUNT
            delegate.setFinDocApprovalToThisAmount(changeDocument.getApprovalToThisAmount());
            // PRIMARY ROUTING
            delegate.setAccountsDelegatePrmrtIndicator(changeDocument.getAccountDelegatePrimaryRoutingIndicator());
            // START DATE
            if (changeDocument.getAccountDelegateStartDate() != null) {
                delegate.setAccountDelegateStartDate(new Date(changeDocument.getAccountDelegateStartDate().getTime()));
            }
            persistables.add(delegate);
        }
    }
    return new ArrayList<PersistableBusinessObject>(persistables);
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AccountDelegateGlobalDetail(org.kuali.kfs.coa.businessobject.AccountDelegateGlobalDetail) HashMap(java.util.HashMap) AccountDelegate(org.kuali.kfs.coa.businessobject.AccountDelegate) ArrayList(java.util.ArrayList) Date(java.sql.Date) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with BusinessObjectService

use of org.kuali.kfs.krad.service.BusinessObjectService 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 19 with BusinessObjectService

use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.

the class CuBatchExtractServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    BusinessObjectService businessObjectService = buildMockBusinessObjectService();
    DataDictionaryService dataDictionaryService = buildMockDataDictionaryService();
    cuBatchExtractServiceImpl = new CuBatchExtractServiceImpl();
    cuBatchExtractServiceImpl.setBusinessObjectService(businessObjectService);
    cuBatchExtractServiceImpl.setDataDictionaryService(dataDictionaryService);
}
Also used : DataDictionaryService(org.kuali.kfs.krad.service.DataDictionaryService) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) Before(org.junit.Before)

Example 20 with BusinessObjectService

use of org.kuali.kfs.krad.service.BusinessObjectService in project cu-kfs by CU-CommunityApps.

the class CuBatchExtractServiceImplTest method buildMockBusinessObjectService.

@SuppressWarnings({ "rawtypes", "unchecked" })
private BusinessObjectService buildMockBusinessObjectService() {
    BusinessObjectService businessObjectService = EasyMock.createMock(BusinessObjectService.class);
    // Had to leave the boClassArg's inner type as a raw type, due to compiling problems from a bounded-type service method argument.
    Capture<Class> boClassArg = EasyMock.newCapture();
    Capture<Map<String, ?>> criteriaArg = EasyMock.newCapture();
    EasyMock.expect(businessObjectService.findMatching(EasyMock.<Class>capture(boClassArg), EasyMock.capture(criteriaArg))).andStubAnswer(() -> findMatching(boClassArg.getValue(), criteriaArg.getValue()));
    EasyMock.replay(businessObjectService);
    return businessObjectService;
}
Also used : Map(java.util.Map) 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