[jira] [Commented] (OFBIZ-3847) Entity ECAs not triggered correctly when using Delegator.storeAll() method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-3847) Entity ECAs not triggered correctly when using Delegator.storeAll() method

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-3847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15279901#comment-15279901 ]

Gareth Carter commented on OFBIZ-3847:
--------------------------------------

Hi

I have just encountered an issue caused by the patch committed for this issue.

If you delete records in an entity that has an eca on operation="remove" and conditions on the eca, you receive a NPE because of the line highlighted
{code:title=org.ofbiz.entityext.eca.EntityEcaRule}
        if( !fieldsToLoad.isEmpty()) {
            Delegator delegator = dctx.getDelegator();
            --> GenericValue oldValue =  delegator.findOne(entityName, value.getPrimaryKey(), false); // null on remove
            for( String fieldName : fieldsToLoad) {
                value.put(fieldName, oldValue.get(fieldName));
            }
        }
{code}

The old value does not exist any more and is null.


An example eca:


{code:title=applications/product/entitydef/eecas.xml}
    <eca entity="InventoryItemDetail" operation="create-store-remove" event="return">
        <condition field-name="availableToPromiseDiff" operator="not-equals" value="0" type="BigDecimal"/>
        <action service="setLastInventoryCount" mode="sync"/>
    </eca>
{code}

> Entity ECAs not triggered correctly when using Delegator.storeAll() method
> --------------------------------------------------------------------------
>
>                 Key: OFBIZ-3847
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3847
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Release Branch 10.04
>            Reporter: Martin Kreidenweis
>            Assignee: Jacques Le Roux
>             Fix For: Upcoming Branch
>
>         Attachments: GenericDelegator.java.diff, OFBIZ-3847_Entity-ECAs-not-triggered-correctly.patch, OFBIZ-3847_Entity-ECAs-not-triggered-correctly.patch
>
>
> The conditions don't work when updating (not creating) entities using the Delegator.storeAll() method. E.g. the following condition does not work:
> {code}
> <eca entity="Product" operation="create-store" event="return">
>         <condition field-name="autoCreateKeywords" operator="not-equals" value="N"/>
>         <action service="indexProductKeywords" mode="sync" value-attr="productInstance"/>
> </eca>
> {code}
> The indexProductKeywords service is called anyway when the product is updated and the autoCreateKeywords was "N" and stays "N". It works correctly for newly created products.
> The problem is in the method GenericDelegator.storeAll(), where unchanged field values are not passed down to the store() method. The store method calls the ECA engine, which does not receive the unchanged values at all and thus cannot evaluate the EECA conditions correctly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)