You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacopo Cappellato <ja...@hotwaxmedia.com> on 2014/09/26 14:11:16 UTC
Re: svn commit: r1338394 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
Adrian,
this is still related to the issue related to the field-to-result operation with an ${} value in the result name.
This is the modification you did a couple of years ago trying to fix the issue I reported at that time.
Could you help me to understand what is the effect of this enhancement? An example of intended usage of the <field-to-result/> element would be enough.
Jacopo
On May 14, 2012, at 10:49 PM, adrianc@apache.org wrote:
> Author: adrianc
> Date: Mon May 14 20:49:01 2012
> New Revision: 1338394
>
> URL: http://svn.apache.org/viewvc?rev=1338394&view=rev
> Log:
> Fixed a bug in Mini-language <field-to-result> element where nested expressions were not evaluated correctly.
>
> Modified:
> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>
> Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java?rev=1338394&r1=1338393&r2=1338394&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java (original)
> +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java Mon May 14 20:49:01 2012
> @@ -28,7 +28,7 @@ import org.ofbiz.minilang.method.MethodO
> import org.w3c.dom.Element;
>
> /**
> - * Copies a field to a service OUT attribute.
> + * Copies a field to the simple-method result Map.
> */
> public final class FieldToResult extends MethodOperation {
>
> @@ -58,9 +58,13 @@ public final class FieldToResult extends
> public boolean exec(MethodContext methodContext) throws MiniLangException {
> Object fieldVal = this.fieldFma.get(methodContext.getEnvMap());
> if (fieldVal != null) {
> - // FIXME: Needs special handling for nested expressions.
> - // The result attribute might contain a reference to an environment (not result Map) variable.
> - this.resultFma.put(methodContext.getResults(), fieldVal);
> + if (this.resultFma.containsNestedExpression()) {
> + String expression = (String) this.resultFma.get(methodContext.getEnvMap());
> + FlexibleMapAccessor<Object> resultFma = FlexibleMapAccessor.getInstance(expression);
> + resultFma.put(methodContext.getResults(), fieldVal);
> + } else {
> + this.resultFma.put(methodContext.getResults(), fieldVal);
> + }
> }
> return true;
> }
>
>
Re: svn commit: r1338394 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
Posted by Jacopo Cappellato <ja...@hotwaxmedia.com>.
On Sep 27, 2014, at 10:12 AM, Adrian Crum <ad...@sandglass-software.com> wrote:
> Yes. To be clear:
>
> <field-to-result field="total" result-name="someField"/>
>
> someField is an expression, and
>
> <field-to-result field="total" result-name="${result}"/>
>
> ${result} is a nested expression (an expression within an expression).
Ok, this was my understanding as well. Based on this, the fix you did in 1338394 *should* make it possible to set:
<field-to-result field="total" result-name="${result}"/>
and so the documentation on the xsd grammar should be updated.
However the code in commit 1338394 doesn't work as the test I have committed recently demonstrate.
>
> I can take another look at the Mini-language code next weekend if you are willing to wait until then.
This would be great, thank you. In the meantime I have fixed the code that was using this feature to prevent errors, so I don't have any rush. Take all the time you need.
Regards,
Jacopo
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 9/26/2014 4:09 PM, Jacopo Cappellato wrote:
>>
>> On Sep 26, 2014, at 5:02 PM, Adrian Crum <ad...@sandglass-software.com> wrote:
>>
>>> The change should be self-explanatory. If the attribute contains a nested expression, then use FSE to expand the nested expression before using FMA to retrieve the value.
>>
>> Like this:
>>
>> <field-to-result field="total" result-name="${result}"/>
>>
>> ?
>>
>>>
>>> Adrian Crum
>>> Sandglass Software
>>> www.sandglass-software.com
>>>
>>> On 9/26/2014 1:11 PM, Jacopo Cappellato wrote:
>>>> Adrian,
>>>>
>>>> this is still related to the issue related to the field-to-result operation with an ${} value in the result name.
>>>> This is the modification you did a couple of years ago trying to fix the issue I reported at that time.
>>>> Could you help me to understand what is the effect of this enhancement? An example of intended usage of the <field-to-result/> element would be enough.
>>>>
>>>> Jacopo
>>>>
>>>>
>>>>
>>>> On May 14, 2012, at 10:49 PM, adrianc@apache.org wrote:
>>>>
>>>>> Author: adrianc
>>>>> Date: Mon May 14 20:49:01 2012
>>>>> New Revision: 1338394
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=1338394&view=rev
>>>>> Log:
>>>>> Fixed a bug in Mini-language <field-to-result> element where nested expressions were not evaluated correctly.
>>>>>
>>>>> Modified:
>>>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>>>>
>>>>> Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java?rev=1338394&r1=1338393&r2=1338394&view=diff
>>>>> ==============================================================================
>>>>> --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java (original)
>>>>> +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java Mon May 14 20:49:01 2012
>>>>> @@ -28,7 +28,7 @@ import org.ofbiz.minilang.method.MethodO
>>>>> import org.w3c.dom.Element;
>>>>>
>>>>> /**
>>>>> - * Copies a field to a service OUT attribute.
>>>>> + * Copies a field to the simple-method result Map.
>>>>> */
>>>>> public final class FieldToResult extends MethodOperation {
>>>>>
>>>>> @@ -58,9 +58,13 @@ public final class FieldToResult extends
>>>>> public boolean exec(MethodContext methodContext) throws MiniLangException {
>>>>> Object fieldVal = this.fieldFma.get(methodContext.getEnvMap());
>>>>> if (fieldVal != null) {
>>>>> - // FIXME: Needs special handling for nested expressions.
>>>>> - // The result attribute might contain a reference to an environment (not result Map) variable.
>>>>> - this.resultFma.put(methodContext.getResults(), fieldVal);
>>>>> + if (this.resultFma.containsNestedExpression()) {
>>>>> + String expression = (String) this.resultFma.get(methodContext.getEnvMap());
>>>>> + FlexibleMapAccessor<Object> resultFma = FlexibleMapAccessor.getInstance(expression);
>>>>> + resultFma.put(methodContext.getResults(), fieldVal);
>>>>> + } else {
>>>>> + this.resultFma.put(methodContext.getResults(), fieldVal);
>>>>> + }
>>>>> }
>>>>> return true;
>>>>> }
>>>>>
>>>>>
>>>>
>>
Re: svn commit: r1338394 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
Posted by Adrian Crum <ad...@sandglass-software.com>.
Yes. To be clear:
<field-to-result field="total" result-name="someField"/>
someField is an expression, and
<field-to-result field="total" result-name="${result}"/>
${result} is a nested expression (an expression within an expression).
I can take another look at the Mini-language code next weekend if you
are willing to wait until then.
Adrian Crum
Sandglass Software
www.sandglass-software.com
On 9/26/2014 4:09 PM, Jacopo Cappellato wrote:
>
> On Sep 26, 2014, at 5:02 PM, Adrian Crum <ad...@sandglass-software.com> wrote:
>
>> The change should be self-explanatory. If the attribute contains a nested expression, then use FSE to expand the nested expression before using FMA to retrieve the value.
>
> Like this:
>
> <field-to-result field="total" result-name="${result}"/>
>
> ?
>
>>
>> Adrian Crum
>> Sandglass Software
>> www.sandglass-software.com
>>
>> On 9/26/2014 1:11 PM, Jacopo Cappellato wrote:
>>> Adrian,
>>>
>>> this is still related to the issue related to the field-to-result operation with an ${} value in the result name.
>>> This is the modification you did a couple of years ago trying to fix the issue I reported at that time.
>>> Could you help me to understand what is the effect of this enhancement? An example of intended usage of the <field-to-result/> element would be enough.
>>>
>>> Jacopo
>>>
>>>
>>>
>>> On May 14, 2012, at 10:49 PM, adrianc@apache.org wrote:
>>>
>>>> Author: adrianc
>>>> Date: Mon May 14 20:49:01 2012
>>>> New Revision: 1338394
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1338394&view=rev
>>>> Log:
>>>> Fixed a bug in Mini-language <field-to-result> element where nested expressions were not evaluated correctly.
>>>>
>>>> Modified:
>>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>>>
>>>> Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java?rev=1338394&r1=1338393&r2=1338394&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java (original)
>>>> +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java Mon May 14 20:49:01 2012
>>>> @@ -28,7 +28,7 @@ import org.ofbiz.minilang.method.MethodO
>>>> import org.w3c.dom.Element;
>>>>
>>>> /**
>>>> - * Copies a field to a service OUT attribute.
>>>> + * Copies a field to the simple-method result Map.
>>>> */
>>>> public final class FieldToResult extends MethodOperation {
>>>>
>>>> @@ -58,9 +58,13 @@ public final class FieldToResult extends
>>>> public boolean exec(MethodContext methodContext) throws MiniLangException {
>>>> Object fieldVal = this.fieldFma.get(methodContext.getEnvMap());
>>>> if (fieldVal != null) {
>>>> - // FIXME: Needs special handling for nested expressions.
>>>> - // The result attribute might contain a reference to an environment (not result Map) variable.
>>>> - this.resultFma.put(methodContext.getResults(), fieldVal);
>>>> + if (this.resultFma.containsNestedExpression()) {
>>>> + String expression = (String) this.resultFma.get(methodContext.getEnvMap());
>>>> + FlexibleMapAccessor<Object> resultFma = FlexibleMapAccessor.getInstance(expression);
>>>> + resultFma.put(methodContext.getResults(), fieldVal);
>>>> + } else {
>>>> + this.resultFma.put(methodContext.getResults(), fieldVal);
>>>> + }
>>>> }
>>>> return true;
>>>> }
>>>>
>>>>
>>>
>
Re: svn commit: r1338394 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
Posted by Jacopo Cappellato <ja...@hotwaxmedia.com>.
On Sep 26, 2014, at 5:02 PM, Adrian Crum <ad...@sandglass-software.com> wrote:
> The change should be self-explanatory. If the attribute contains a nested expression, then use FSE to expand the nested expression before using FMA to retrieve the value.
Like this:
<field-to-result field="total" result-name="${result}"/>
?
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 9/26/2014 1:11 PM, Jacopo Cappellato wrote:
>> Adrian,
>>
>> this is still related to the issue related to the field-to-result operation with an ${} value in the result name.
>> This is the modification you did a couple of years ago trying to fix the issue I reported at that time.
>> Could you help me to understand what is the effect of this enhancement? An example of intended usage of the <field-to-result/> element would be enough.
>>
>> Jacopo
>>
>>
>>
>> On May 14, 2012, at 10:49 PM, adrianc@apache.org wrote:
>>
>>> Author: adrianc
>>> Date: Mon May 14 20:49:01 2012
>>> New Revision: 1338394
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1338394&view=rev
>>> Log:
>>> Fixed a bug in Mini-language <field-to-result> element where nested expressions were not evaluated correctly.
>>>
>>> Modified:
>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>>
>>> Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java?rev=1338394&r1=1338393&r2=1338394&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java (original)
>>> +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java Mon May 14 20:49:01 2012
>>> @@ -28,7 +28,7 @@ import org.ofbiz.minilang.method.MethodO
>>> import org.w3c.dom.Element;
>>>
>>> /**
>>> - * Copies a field to a service OUT attribute.
>>> + * Copies a field to the simple-method result Map.
>>> */
>>> public final class FieldToResult extends MethodOperation {
>>>
>>> @@ -58,9 +58,13 @@ public final class FieldToResult extends
>>> public boolean exec(MethodContext methodContext) throws MiniLangException {
>>> Object fieldVal = this.fieldFma.get(methodContext.getEnvMap());
>>> if (fieldVal != null) {
>>> - // FIXME: Needs special handling for nested expressions.
>>> - // The result attribute might contain a reference to an environment (not result Map) variable.
>>> - this.resultFma.put(methodContext.getResults(), fieldVal);
>>> + if (this.resultFma.containsNestedExpression()) {
>>> + String expression = (String) this.resultFma.get(methodContext.getEnvMap());
>>> + FlexibleMapAccessor<Object> resultFma = FlexibleMapAccessor.getInstance(expression);
>>> + resultFma.put(methodContext.getResults(), fieldVal);
>>> + } else {
>>> + this.resultFma.put(methodContext.getResults(), fieldVal);
>>> + }
>>> }
>>> return true;
>>> }
>>>
>>>
>>
Re: svn commit: r1338394 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
Posted by Adrian Crum <ad...@sandglass-software.com>.
The change should be self-explanatory. If the attribute contains a
nested expression, then use FSE to expand the nested expression before
using FMA to retrieve the value.
Adrian Crum
Sandglass Software
www.sandglass-software.com
On 9/26/2014 1:11 PM, Jacopo Cappellato wrote:
> Adrian,
>
> this is still related to the issue related to the field-to-result operation with an ${} value in the result name.
> This is the modification you did a couple of years ago trying to fix the issue I reported at that time.
> Could you help me to understand what is the effect of this enhancement? An example of intended usage of the <field-to-result/> element would be enough.
>
> Jacopo
>
>
>
> On May 14, 2012, at 10:49 PM, adrianc@apache.org wrote:
>
>> Author: adrianc
>> Date: Mon May 14 20:49:01 2012
>> New Revision: 1338394
>>
>> URL: http://svn.apache.org/viewvc?rev=1338394&view=rev
>> Log:
>> Fixed a bug in Mini-language <field-to-result> element where nested expressions were not evaluated correctly.
>>
>> Modified:
>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>
>> Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java?rev=1338394&r1=1338393&r2=1338394&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java (original)
>> +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java Mon May 14 20:49:01 2012
>> @@ -28,7 +28,7 @@ import org.ofbiz.minilang.method.MethodO
>> import org.w3c.dom.Element;
>>
>> /**
>> - * Copies a field to a service OUT attribute.
>> + * Copies a field to the simple-method result Map.
>> */
>> public final class FieldToResult extends MethodOperation {
>>
>> @@ -58,9 +58,13 @@ public final class FieldToResult extends
>> public boolean exec(MethodContext methodContext) throws MiniLangException {
>> Object fieldVal = this.fieldFma.get(methodContext.getEnvMap());
>> if (fieldVal != null) {
>> - // FIXME: Needs special handling for nested expressions.
>> - // The result attribute might contain a reference to an environment (not result Map) variable.
>> - this.resultFma.put(methodContext.getResults(), fieldVal);
>> + if (this.resultFma.containsNestedExpression()) {
>> + String expression = (String) this.resultFma.get(methodContext.getEnvMap());
>> + FlexibleMapAccessor<Object> resultFma = FlexibleMapAccessor.getInstance(expression);
>> + resultFma.put(methodContext.getResults(), fieldVal);
>> + } else {
>> + this.resultFma.put(methodContext.getResults(), fieldVal);
>> + }
>> }
>> return true;
>> }
>>
>>
>