Search in sources :

Example 11 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class BatchFeedHelperServiceImpl method performExistenceAndActiveValidation.

/**
 * @see com.rsmart.kuali.kfs.sys.batch.service.BatchFeedHelperService#performExistenceAndActiveValidation(org.kuali.kfs.kns.bo.PersistableBusinessObject,
 *      java.lang.String, java.lang.String, org.kuali.kfs.kns.util.ErrorMap)
 */
public void performExistenceAndActiveValidation(PersistableBusinessObject businessObject, String referenceName, String propertyName, MessageMap errorMap) {
    Object propertyValue = ObjectUtils.getPropertyValue(businessObject, propertyName);
    if (propertyValue != null) {
        businessObject.refreshReferenceObject(referenceName);
        Object referenceValue = ObjectUtils.getPropertyValue(businessObject, referenceName);
        if (ObjectUtils.isNull(referenceValue)) {
            addExistenceError(propertyName, propertyValue.toString(), errorMap);
        } else if (MutableInactivatable.class.isAssignableFrom(referenceValue.getClass())) {
            if (!((MutableInactivatable) referenceValue).isActive()) {
                addInactiveError(propertyName, propertyValue.toString(), errorMap);
            }
        }
    }
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) MutableInactivatable(org.kuali.rice.core.api.mo.common.active.MutableInactivatable)

Example 12 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class SubAccountGlobal method generateGlobalChangesToPersist.

/**
 * @see org.kuali.kfs.krad.bo.GlobalBusinessObject#generateGlobalChangesToPersist()
 */
@Override
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
    List<PersistableBusinessObject> changesToPersist = new ArrayList<PersistableBusinessObject>();
    this.refreshReferenceObject(KFSPropertyConstants.A21_SUB_ACCOUNT);
    for (SubAccountGlobalDetail subAccountGlobalDetail : subAccountGlobalDetails) {
        subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
        SubAccount subAccount = subAccountGlobalDetail.getSubAccount();
        if (inactivate) {
            subAccount.setActive(false);
        }
        if (StringUtils.isNotBlank(subAccountName)) {
            subAccount.setSubAccountName(subAccountName);
        }
        if (a21SubAccount.offCampusCode) {
            subAccount.getA21SubAccount().setOffCampusCode(true);
        }
        if (StringUtils.isNotBlank(financialReportChartCode)) {
            subAccount.setFinancialReportChartCode(financialReportChartCode);
        }
        if (StringUtils.isNotBlank(finReportOrganizationCode)) {
            subAccount.setFinReportOrganizationCode(finReportOrganizationCode);
        }
        if (StringUtils.isNotBlank(financialReportingCode)) {
            subAccount.setFinancialReportingCode(financialReportingCode);
        }
        if (StringUtils.isNotBlank(a21SubAccount.indirectCostRecoveryTypeCode)) {
            subAccount.getA21SubAccount().setIndirectCostRecoveryTypeCode(a21SubAccount.indirectCostRecoveryTypeCode);
        }
        if (StringUtils.isNotBlank(a21SubAccount.financialIcrSeriesIdentifier)) {
            subAccount.getA21SubAccount().setFinancialIcrSeriesIdentifier(a21SubAccount.financialIcrSeriesIdentifier);
        }
        if (StringUtils.isNotBlank(a21SubAccount.costShareChartOfAccountCode)) {
            subAccount.getA21SubAccount().setCostShareChartOfAccountCode(a21SubAccount.costShareChartOfAccountCode);
        }
        if (StringUtils.isNotBlank(a21SubAccount.costShareSourceAccountNumber)) {
            subAccount.getA21SubAccount().setCostShareSourceAccountNumber(a21SubAccount.costShareSourceAccountNumber);
        }
        if (StringUtils.isNotBlank(a21SubAccount.costShareSourceSubAccountNumber)) {
            subAccount.getA21SubAccount().setCostShareSourceSubAccountNumber(a21SubAccount.costShareSourceSubAccountNumber);
        }
        List<IndirectCostRecoveryAccount> icrAccounts = new ArrayList<IndirectCostRecoveryAccount>();
        for (IndirectCostRecoveryAccount icrAccount : subAccountGlobalDetail.getSubAccount().getA21SubAccount().getA21IndirectCostRecoveryAccounts()) {
            icrAccounts.add(icrAccount);
        }
        updateIcrAccounts(subAccountGlobalDetail, icrAccounts);
        changesToPersist.add(subAccount);
    }
    return changesToPersist;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount)

Example 13 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class SubObjectCodeGlobalEdit method generateGlobalChangesToPersist.

/**
 * @see org.kuali.kfs.krad.bo.GlobalBusinessObject#generateGlobalChangesToPersist()
 */
@Override
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
    // the list of persist-ready BOs
    List<PersistableBusinessObject> persistables = new ArrayList<PersistableBusinessObject>();
    // walk over each change detail record
    for (SubObjectCodeGlobalEditDetail detail : subObjCdGlobalEditDetails) {
        // load the object by keys
        SubObjectCode subObjectCode = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(SubObjectCode.class, detail.getPrimaryKeys());
        // if we got a valid subObjectCode, inactivate it
        if (subObjectCode != null) {
            subObjectCode.setActive(false);
            persistables.add(subObjectCode);
        }
    }
    return persistables;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode) ArrayList(java.util.ArrayList) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 14 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method refresh.

/**
 * Multi-value asset lookup is implemented through the integration package by module's service
 * to gather the results. The results are processed for any capital accounting lines where
 * the line is marked for selection.  After the capital assets are populated with the
 * selected asset numbers, the system control amount is redistributed equally among the assets
 * when the distribution method is "distribute cost equally".
 *
 * @see org.kuali.rice.kns.web.struts.action.KualiAction#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 {
    super.refresh(mapping, form, request, response);
    // process the multiple value lookup data
    CapitalAssetInformationFormBase capitalAssetInformationFormBase = (CapitalAssetInformationFormBase) form;
    Collection<PersistableBusinessObject> rawValues = null;
    Map<String, Set<String>> segmentedSelection = new HashMap<>();
    // If multiple asset lookup was used to select the assets, then....
    if (StringUtils.equals(KFSConstants.MULTIPLE_VALUE, capitalAssetInformationFormBase.getRefreshCaller())) {
        String lookupResultsSequenceNumber = capitalAssetInformationFormBase.getLookupResultsSequenceNumber();
        if (StringUtils.isNotBlank(lookupResultsSequenceNumber)) {
            // actually returning from a multiple value lookup
            Set<String> selectedIds = SpringContext.getBean(SegmentedLookupResultsService.class).retrieveSetOfSelectedObjectIds(lookupResultsSequenceNumber, GlobalVariables.getUserSession().getPerson().getPrincipalId());
            for (String selectedId : selectedIds) {
                String selectedObjId = StringUtils.substringBefore(selectedId, ".");
                if (!segmentedSelection.containsKey(selectedObjId)) {
                    segmentedSelection.put(selectedObjId, new HashSet<>());
                }
            }
            // Retrieving selected data from table.
            if (LOG.isDebugEnabled()) {
                LOG.debug("Asking segmentation service for object ids " + segmentedSelection.keySet());
            }
            rawValues = SpringContext.getBean(SegmentedLookupResultsService.class).retrieveSelectedResultBOs(lookupResultsSequenceNumber, segmentedSelection.keySet(), Asset.class, GlobalVariables.getUserSession().getPerson().getPrincipalId());
        }
        if (rawValues == null || rawValues.size() == 0) {
            // redistribute capital asset amount to its group accounting lines on refresh
            DistributeCapitalAssetAmountToGroupAccountingLines((KualiAccountingDocumentFormBase) form);
            return mapping.findForward(KFSConstants.MAPPING_BASIC);
        }
        KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
        CapitalAccountingLinesFormBase calfb = (CapitalAccountingLinesFormBase) form;
        CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) calfb.getFinancialDocument();
        List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
        List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
        List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<>();
        for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
            if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
                selectedCapitalAccountingLines.add(capitalAccountingLine);
            }
        }
        // where capital accounting line is "selected" and its amount is greater than already allocated.
        if (rawValues != null) {
            for (PersistableBusinessObject bo : rawValues) {
                Asset asset = (Asset) bo;
                boolean addIt = modifyAssetAlreadyExists(capitalAssetInformation, asset.getCapitalAssetNumber());
                // If it doesn't already exist in the list add it.
                if (addIt) {
                    createNewModifyCapitalAsset(selectedCapitalAccountingLines, capitalAssetInformation, calfb.getDocument().getDocumentNumber(), KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR, getNextCapitalAssetLineNumber(kualiAccountingDocumentFormBase), asset.getCapitalAssetNumber());
                }
            }
            checkCapitalAccountingLinesSelected(calfb);
            // remove the blank capital asset modify records now...
            removeEmptyCapitalAssetModify(capitalAssetInformation);
            // now redistribute the amount for all assets if needed....
            redistributeModifyCapitalAssetAmount(mapping, form, request, response);
        }
    }
    // redistribute capital asset amount to its group accounting lines on refresh
    DistributeCapitalAssetAmountToGroupAccountingLines((KualiAccountingDocumentFormBase) form);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SegmentedLookupResultsService(org.kuali.kfs.sys.service.SegmentedLookupResultsService) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) Asset(org.kuali.kfs.integration.cam.businessobject.Asset) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 15 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method doesDocumentAllowImmediateSaveOfNewNote.

private boolean doesDocumentAllowImmediateSaveOfNewNote(Document document, Note note) {
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    PersistableBusinessObject noteTarget = document.getNoteTarget();
    // This is the same logic used by the KualiDocumentActionBase.insertBONote() method.
    return !workflowDocument.isInitiated() && StringUtils.isNotBlank(noteTarget.getObjectId()) && !(document instanceof MaintenanceDocument && StringUtils.equals(NoteType.BUSINESS_OBJECT.getCode(), note.getNoteTypeCode()));
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument)

Aggregations

PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)21 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 BufferedInputStream (java.io.BufferedInputStream)5 FileInputStream (java.io.FileInputStream)5 InputStream (java.io.InputStream)5 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)4 FavoriteAccount (edu.cornell.kfs.sys.businessobject.FavoriteAccount)2 Maintainable (org.kuali.kfs.kns.maintenance.Maintainable)2 Note (org.kuali.kfs.krad.bo.Note)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 DummyAntiVirusServiceImpl (edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl)1 AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)1 UserProcurementProfile (edu.cornell.kfs.sys.businessobject.UserProcurementProfile)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1