Search in sources :

Example 1 with AddIWantItemEvent

use of edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method addNewItem.

private boolean addNewItem(IWantDocumentForm iWantDocumentForm, IWantDocument iWantDoc, IWantItem item) {
    KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
    boolean rulePassed = true;
    // call business rules
    rulePassed &= ruleService.applyRules(new AddIWantItemEvent(StringUtils.EMPTY, iWantDoc, item));
    if (rulePassed) {
        item = iWantDocumentForm.getAndResetNewIWantItemLine();
        iWantDoc.addItem(item);
    }
    return rulePassed;
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) AddIWantItemEvent(edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent)

Example 2 with AddIWantItemEvent

use of edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent in project cu-kfs by CU-CommunityApps.

the class IWantDocumentFeedServiceImpl method populateIWantDocItems.

/**
 * Populates I Want doc items.
 *
 * @param batchIWantDocument
 * @param iWantDocument
 * @return true if no errors encountered, false otherwise
 */
protected boolean populateIWantDocItems(BatchIWantDocument batchIWantDocument, IWantDocument iWantDocument) {
    LOG.info("Populate I Want doc items");
    boolean noErrors = true;
    // items
    List<IWantItem> iWantItems = batchIWantDocument.getItems();
    if (CollectionUtils.isNotEmpty(iWantItems)) {
        for (IWantItem item : iWantItems) {
            IWantItem addItem = new IWantItem();
            addItem.setItemDescription(item.getItemDescription());
            addItem.setItemTypeCode(item.getItemUnitOfMeasureCode());
            addItem.setItemCatalogNumber(item.getItemCatalogNumber());
            addItem.setItemUnitPrice(item.getItemUnitPrice());
            addItem.setPurchasingCommodityCode(item.getPurchasingCommodityCode());
            addItem.setItemQuantity(item.getItemQuantity());
            boolean rulePassed = ruleService.applyRules(new AddIWantItemEvent(StringUtils.EMPTY, iWantDocument, addItem));
            if (rulePassed) {
                iWantDocument.addItem(addItem);
            } else {
                logErrorMessages();
            }
            noErrors &= rulePassed;
        }
    }
    return noErrors;
}
Also used : AddIWantItemEvent(edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Aggregations

AddIWantItemEvent (edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent)2 IWantItem (edu.cornell.kfs.module.purap.businessobject.IWantItem)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1