Search in sources :

Example 1 with BusinessObjectService

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

the class CUAccountMaintainableImpl method saveBusinessObject.

@Override
public void saveBusinessObject() {
    boolean isClosingAccount = isClosingAccount();
    Account account = (Account) getBusinessObject();
    AccountExtendedAttribute aea = (AccountExtendedAttribute) (account.getExtension());
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    HashMap<String, String> keys = new HashMap<String, String>();
    keys.put("programCode", aea.getProgramCode());
    keys.put(SUB_FUND_GROUP_CODE, aea.getSubFundGroupCode());
    SubFundProgram sfp = (SubFundProgram) bos.findByPrimaryKey(SubFundProgram.class, keys);
    aea.setSubFundProgram(sfp);
    aea.setSubFundGroupCode(account.getSubFundGroupCode());
    keys = new HashMap<String, String>();
    keys.put("appropriationAccountNumber", aea.getAppropriationAccountNumber());
    keys.put(SUB_FUND_GROUP_CODE, aea.getSubFundGroupCode());
    AppropriationAccount aan = (AppropriationAccount) bos.findByPrimaryKey(AppropriationAccount.class, keys);
    aea.setAppropriationAccount(aan);
    if (account.isClosed() && aea.getAccountClosedDate() == null) {
        aea.setAccountClosedDate(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate());
    } else if (!account.isClosed() && aea.getAccountClosedDate() != null) {
        aea.setAccountClosedDate(null);
    }
    super.saveBusinessObject();
    // trickle down Account Reversion inactivation
    if (isClosingAccount) {
        SpringContext.getBean(AccountReversionTrickleDownInactivationService.class).trickleDownInactivateAccountReversions((Account) getBusinessObject(), getDocumentNumber());
    }
    // content and will display any future notes on account edits as well
    try {
        Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
        Account xmlaccount = (Account) ((MaintenanceDocument) document).getNewMaintainableObject().getBusinessObject();
        if (ObjectUtils.isNull(xmlaccount.getObjectId()) && (KFSConstants.MAINTENANCE_NEW_ACTION.equals(getMaintenanceAction()) || KFSConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction()))) {
            ((MaintenanceDocument) document).getNewMaintainableObject().setBusinessObject(account);
            SpringContext.getBean(DocumentService.class).saveDocument(document);
        }
    } catch (Exception e) {
        LOG.error("Account doc not saved successfully " + e.getMessage());
    }
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) 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) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) AccountReversionTrickleDownInactivationService(edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) Document(org.kuali.kfs.krad.document.Document) DocumentService(org.kuali.kfs.krad.service.DocumentService) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) SubFundProgram(edu.cornell.kfs.coa.businessobject.SubFundProgram)

Example 2 with BusinessObjectService

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

the class AccountExtensionRule method checkSubFundProgram.

protected boolean checkSubFundProgram(MaintenanceDocument document) {
    boolean success = true;
    String subFundGroupCode = newAccount.getSubFundGroupCode();
    String subFundProg = ((AccountExtendedAttribute) newAccount.getExtension()).getProgramCode();
    // String subFundProgramCode = ((AccountExtendedAttribute)newAccount.getExtension()).getSubFundProgram().getProgramCode();
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    if (!StringUtils.isBlank(subFundProg)) {
        Map fieldValues = new HashMap();
        fieldValues.put("subFundGroupCode", subFundGroupCode);
        fieldValues.put("programCode", subFundProg);
        Collection<SubFundProgram> retVals = bos.findMatching(SubFundProgram.class, fieldValues);
        if (retVals.isEmpty()) {
            success = false;
            putFieldError("extension.programCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_PROGRAM_CODE_NOT_GROUP_CODE, new String[] { subFundProg, subFundGroupCode });
        } else {
            for (SubFundProgram sfp : retVals) {
                if (!sfp.isActive()) {
                    putFieldError("extension.programCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.programCode"));
                    success = false;
                }
            }
        }
    } else {
        // BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
        Map fieldValues = new HashMap();
        fieldValues.put("subFundGroupCode", subFundGroupCode);
        Collection<SubFundProgram> retVals = bos.findMatching(SubFundProgram.class, fieldValues);
        if (!retVals.isEmpty()) {
            success = false;
            putFieldError("extension.programCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_PROGRAM_CODE_CANNOT_BE_BLANK_FOR_GROUP_CODE, new String[] { subFundGroupCode });
        }
    }
    return success;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) HashMap(java.util.HashMap) SubFundProgram(edu.cornell.kfs.coa.businessobject.SubFundProgram) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) HashMap(java.util.HashMap) Map(java.util.Map) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 3 with BusinessObjectService

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

the class EzraAwardProposalDaoOjb method getAwardsUpdatedSince.

public List<EzraProposalAward> getAwardsUpdatedSince(Date date) {
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    Collection<Award> awards = bos.findAll(Award.class);
    List awardNumbers = new ArrayList();
    for (Award award : awards) {
        awardNumbers.add(award.getProposalNumber());
    }
    Criteria criteria = new Criteria();
    criteria.addIn("projectId", awardNumbers);
    criteria.addLike("awardProposalId", "A%");
    // KFSPTS-1920 Edits associated with Award Descriptions of MTA(M), NDA(N), RDA(R) should not be picked up for edits to KFS Awards.
    criteria.addNotIn("awardDescriptionCode", getExcludedAwardDescriptions());
    if (date != null) {
        criteria.addGreaterThan("lastUpdated", date);
    }
    return (List<EzraProposalAward>) getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(EzraProposalAward.class, criteria));
}
Also used : Award(org.kuali.kfs.module.cg.businessobject.Award) EzraProposalAward(edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Criteria(org.apache.ojb.broker.query.Criteria) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 4 with BusinessObjectService

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

the class PaymentGroup method setPayeeIdAndName.

/**
 * @param string
 */
public void setPayeeIdAndName(String string) {
    if (string.split("-").length == 1) {
        // process Payee as a employee
        payeeId = string;
    } else {
        // process Payee as a vendor
        payeeId = string;
        BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
        String[] headerDetails = payeeId.split("-");
        Map<String, String> fieldValues = new HashMap<String, String>();
        fieldValues.put("vendorHeaderGeneratedIdentifier", headerDetails[0]);
        fieldValues.put("vendorDetailAssignedIdentifier", headerDetails[1]);
        List<VendorDetail> details = (List<VendorDetail>) bos.findMatching(VendorDetail.class, fieldValues);
        if (details.size() == 1) {
            payeeName = details.get(0).getVendorName();
        } else {
            throw new RuntimeException("Could not locate Vendor for payeeId [ " + string + " ]");
        }
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) List(java.util.List) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 5 with BusinessObjectService

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

the class PurchasingActionBase method refresh.

/**
 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentActionBase#refresh(org.apache.struts.action.ActionMapping,
 *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase baseForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocument document = (PurchasingDocument) baseForm.getDocument();
    String refreshCaller = baseForm.getRefreshCaller();
    BusinessObjectService businessObjectService = SpringContext.getBean(BusinessObjectService.class);
    PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);
    // Format phone numbers
    document.setInstitutionContactPhoneNumber(phoneNumberService.formatNumberIfPossible(document.getInstitutionContactPhoneNumber()));
    document.setRequestorPersonPhoneNumber(phoneNumberService.formatNumberIfPossible(document.getRequestorPersonPhoneNumber()));
    document.setDeliveryToPhoneNumber(phoneNumberService.formatNumberIfPossible(document.getDeliveryToPhoneNumber()));
    // names in KIM are longer than what we store these names at; truncate them to match our data dictionary maxlengths
    if (StringUtils.equals(refreshCaller, "kimPersonLookupable")) {
        Integer deliveryToNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(document.getClass(), PurapPropertyConstants.DELIVERY_TO_NAME);
        // KFSPTS-518/KFSUPGRADE-351
        if (deliveryToNameMaxLength == null && document instanceof PurchaseOrderAmendmentDocument) {
            deliveryToNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(PurchaseOrderDocument.class, PurapPropertyConstants.DELIVERY_TO_NAME);
        }
        if (StringUtils.isNotEmpty(document.getDeliveryToName()) && ObjectUtils.isNotNull(deliveryToNameMaxLength) && document.getDeliveryToName().length() > deliveryToNameMaxLength.intValue()) {
            document.setDeliveryToName(document.getDeliveryToName().substring(0, deliveryToNameMaxLength));
            GlobalVariables.getMessageMap().clearErrorPath();
            GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.DELIVERY_TAB_ERRORS);
            GlobalVariables.getMessageMap().putWarning(PurapPropertyConstants.DELIVERY_TO_NAME, PurapKeyConstants.WARNING_DELIVERY_TO_NAME_TRUNCATED);
            GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.DELIVERY_TAB_ERRORS);
        }
        Integer requestorNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(document.getClass(), PurapPropertyConstants.REQUESTOR_PERSON_NAME);
        // KFSPTS-518/KFSUPGRADE-351
        if (requestorNameMaxLength == null && document instanceof PurchaseOrderAmendmentDocument) {
            requestorNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(PurchaseOrderDocument.class, PurapPropertyConstants.REQUESTOR_PERSON_NAME);
        }
        if (StringUtils.isNotEmpty(document.getRequestorPersonName()) && ObjectUtils.isNotNull(requestorNameMaxLength) && document.getRequestorPersonName().length() > requestorNameMaxLength.intValue()) {
            document.setRequestorPersonName(document.getRequestorPersonName().substring(0, requestorNameMaxLength));
            GlobalVariables.getMessageMap().clearErrorPath();
            GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
            GlobalVariables.getMessageMap().putWarning(PurapPropertyConstants.REQUESTOR_PERSON_NAME, PurapKeyConstants.WARNING_REQUESTOR_NAME_TRUNCATED);
            GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
        }
    }
    // Refreshing the fields after returning from a vendor lookup in the vendor tab
    if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_LOOKUPABLE_IMPL) && document.getVendorDetailAssignedIdentifier() != null && document.getVendorHeaderGeneratedIdentifier() != null) {
        document.setVendorContractGeneratedIdentifier(null);
        document.refreshReferenceObject("vendorContract");
        // retrieve vendor based on selection from vendor lookup
        document.refreshReferenceObject("vendorDetail");
        document.templateVendorDetail(document.getVendorDetail());
        // KFSPTS-1612 : populate vendor contract name
        if (CollectionUtils.isNotEmpty(document.getVendorDetail().getVendorContracts())) {
            for (VendorContract vendorContract : document.getVendorDetail().getVendorContracts()) {
                if (vendorContract.isActive()) {
                    document.setVendorContractGeneratedIdentifier(vendorContract.getVendorContractGeneratedIdentifier());
                    document.refreshReferenceObject("vendorContract");
                }
            }
        }
        // populate default address based on selected vendor
        VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(document.getVendorDetail().getVendorAddresses(), document.getVendorDetail().getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), document.getDeliveryCampusCode());
        if (defaultAddress == null) {
            GlobalVariables.getMessageMap().putError(VendorPropertyConstants.VENDOR_DOC_ADDRESS, PurapKeyConstants.ERROR_INACTIVE_VENDORADDRESS);
        }
        document.templateVendorAddress(defaultAddress);
        // CU enhancement KFSUPGRDE-348
        document.setPurchaseOrderTransmissionMethodCode(((CuVendorAddressExtension) defaultAddress.getExtension()).getPurchaseOrderTransmissionMethodCode());
    }
    // Refreshing the fields after returning from a contract lookup in the vendor tab
    if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_CONTRACT_LOOKUPABLE_IMPL)) {
        if (StringUtils.isNotEmpty(request.getParameter(KFSPropertyConstants.DOCUMENT + "." + PurapPropertyConstants.VENDOR_CONTRACT_ID))) {
            // retrieve Contract based on selection from contract lookup
            VendorContract refreshVendorContract = new VendorContract();
            refreshVendorContract.setVendorContractGeneratedIdentifier(document.getVendorContractGeneratedIdentifier());
            refreshVendorContract = (VendorContract) businessObjectService.retrieve(refreshVendorContract);
            // retrieve Vendor based on selected contract
            document.setVendorHeaderGeneratedIdentifier(refreshVendorContract.getVendorHeaderGeneratedIdentifier());
            document.setVendorDetailAssignedIdentifier(refreshVendorContract.getVendorDetailAssignedIdentifier());
            document.refreshReferenceObject("vendorDetail");
            document.templateVendorDetail(document.getVendorDetail());
            // always template contract after vendor to keep contract defaults last
            document.templateVendorContract(refreshVendorContract);
            // populate default address from selected vendor
            VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(document.getVendorDetail().getVendorAddresses(), document.getVendorDetail().getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), "");
            if (defaultAddress == null) {
                GlobalVariables.getMessageMap().putError(VendorPropertyConstants.VENDOR_DOC_ADDRESS, PurapKeyConstants.ERROR_INACTIVE_VENDORADDRESS);
            }
            document.templateVendorAddress(defaultAddress);
            // update internal dollar limit for PO since the contract might affect this value
            if (document instanceof PurchaseOrderDocument) {
                PurchaseOrderDocument poDoc = (PurchaseOrderDocument) document;
                KualiDecimal limit = SpringContext.getBean(PurchaseOrderService.class).getInternalPurchasingDollarLimit(poDoc);
                poDoc.setInternalPurchasingLimit(limit);
            }
        }
    }
    // Refreshing the fields after returning from an address lookup in the vendor tab
    if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_ADDRESS_LOOKUPABLE_IMPL)) {
        if (StringUtils.isNotEmpty(request.getParameter(KFSPropertyConstants.DOCUMENT + "." + PurapPropertyConstants.VENDOR_ADDRESS_ID))) {
            // retrieve address based on selection from address lookup
            VendorAddress refreshVendorAddress = new VendorAddress();
            refreshVendorAddress.setVendorAddressGeneratedIdentifier(document.getVendorAddressGeneratedIdentifier());
            refreshVendorAddress = (VendorAddress) businessObjectService.retrieve(refreshVendorAddress);
            document.templateVendorAddress(refreshVendorAddress);
        }
    }
    // Refreshing corresponding fields after returning from various kuali lookups
    if (StringUtils.equals(refreshCaller, KFSConstants.KUALI_LOOKUPABLE_IMPL)) {
        if (request.getParameter("document.deliveryCampusCode") != null) {
            // returning from a building or campus lookup on the delivery tab (update billing address)
            BillingAddress billingAddress = new BillingAddress();
            billingAddress.setBillingCampusCode(document.getDeliveryCampusCode());
            Map keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(billingAddress);
            billingAddress = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BillingAddress.class, keys);
            document.templateBillingAddress(billingAddress);
            if (request.getParameter("document.deliveryBuildingName") == null) {
                // came from campus lookup not building, so clear building
                clearDeliveryBuildingInfo(document, true);
            } else {
                // came from building lookup then turn off "OTHER" and clear room and line2address
                document.setDeliveryBuildingOtherIndicator(false);
                document.setDeliveryBuildingRoomNumber("");
                document.setDeliveryBuildingLine2Address("");
            }
        } else if (request.getParameter("document.chartOfAccountsCode") != null) {
            // returning from a chart/org lookup on the document detail tab (update receiving address)
            document.loadReceivingAddress();
        } else {
            // returning from a building lookup in a capital asset tab location (update location address)
            String buildingCodeParam = findBuildingCodeFromCapitalAssetBuildingLookup(request);
            if (!StringUtils.isEmpty(buildingCodeParam)) {
                PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
                updateCapitalAssetLocation(request, purchasingForm, document, buildingCodeParam);
            }
        }
    }
    return super.refresh(mapping, form, request, response);
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PhoneNumberService(org.kuali.kfs.vnd.service.PhoneNumberService) VendorContract(org.kuali.kfs.vnd.businessobject.VendorContract) PurchaseOrderService(org.kuali.kfs.module.purap.document.service.PurchaseOrderService) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) VendorService(org.kuali.kfs.vnd.document.service.VendorService) BillingAddress(org.kuali.kfs.module.purap.businessobject.BillingAddress) PersistenceService(org.kuali.kfs.krad.service.PersistenceService) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) Map(java.util.Map) MessageMap(org.kuali.kfs.krad.util.MessageMap)

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