Search in sources :

Example 1 with PurapAccountingService

use of org.kuali.kfs.module.purap.service.PurapAccountingService in project cu-kfs by CU-CommunityApps.

the class PurchasingAccountsPayableDocumentBase method getPersistedSourceAccountingLinesForComparison.

/**
 * Accounting lines that are read-only should skip validation
 *
 * @see org.kuali.kfs.sys.document.AccountingDocumentBase#getPersistedSourceAccountingLinesForComparison()
 */
@SuppressWarnings("rawtypes")
@Override
protected List getPersistedSourceAccountingLinesForComparison() {
    LOG.info("Checking persisted source accounting lines for read-only fields");
    List<String> restrictedItemTypesList = new ArrayList<String>();
    try {
        restrictedItemTypesList = new ArrayList<String>(SpringContext.getBean(ParameterService.class).getParameterValuesAsString(this.getClass(), PurapParameterConstants.PURAP_ITEM_TYPES_RESTRICTING_ACCOUNT_EDIT));
    } catch (IllegalArgumentException iae) {
    // do nothing, not a problem if no restricted types are defined
    }
    PurapAccountingService purApAccountingService = SpringContext.getBean(PurapAccountingService.class);
    List persistedSourceLines = new ArrayList();
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        // only check items that already have been persisted since last save
        if (ObjectUtils.isNotNull(item.getItemIdentifier())) {
            // Disable validation if the item is read-only
            final boolean isNotReadOnly = !((restrictedItemTypesList != null) && restrictedItemTypesList.contains(item.getItemTypeCode()));
            if (isNotReadOnly) {
                persistedSourceLines.addAll(purApAccountingService.getAccountsFromItem(item));
            }
        }
    }
    return persistedSourceLines;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PurapAccountingService(org.kuali.kfs.module.purap.service.PurapAccountingService)

Example 2 with PurapAccountingService

use of org.kuali.kfs.module.purap.service.PurapAccountingService in project cu-kfs by CU-CommunityApps.

the class PurchasingAccountsPayableDocumentBase method getSourceAccountingLinesForComparison.

/**
 * Accounting lines that are read-only should skip validation
 *
 * @see org.kuali.kfs.sys.document.AccountingDocumentBase#getSourceAccountingLinesForComparison()
 */
@SuppressWarnings("rawtypes")
@Override
protected List getSourceAccountingLinesForComparison() {
    LOG.info("Checking source accounting lines for read-only fields");
    List<String> restrictedItemTypesList = new ArrayList<String>();
    try {
        restrictedItemTypesList = new ArrayList<String>(SpringContext.getBean(ParameterService.class).getParameterValuesAsString(this.getClass(), PurapParameterConstants.PURAP_ITEM_TYPES_RESTRICTING_ACCOUNT_EDIT));
    } catch (IllegalArgumentException iae) {
    // do nothing, not a problem if no restricted types are defined
    }
    PurapAccountingService purApAccountingService = SpringContext.getBean(PurapAccountingService.class);
    List currentSourceLines = new ArrayList();
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        // Disable validation if the item is read-only
        final boolean isNotReadOnly = !((restrictedItemTypesList != null) && restrictedItemTypesList.contains(item.getItemTypeCode()));
        if (isNotReadOnly) {
            currentSourceLines.addAll(item.getSourceAccountingLines());
        }
    }
    return currentSourceLines;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PurapAccountingService(org.kuali.kfs.module.purap.service.PurapAccountingService)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PurapAccountingService (org.kuali.kfs.module.purap.service.PurapAccountingService)2