[jira] Created: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

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

[jira] Created: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
Enrich Groovy integration with Ofbiz framework
----------------------------------------------

                 Key: OFBIZ-1968
                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
             Project: OFBiz
          Issue Type: Improvement
          Components: framework
            Reporter: Anil K Patel
            Priority: Minor


Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)

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

Jacopo Cappellato commented on OFBIZ-1968:
------------------------------------------

Anil,

this is a very interesting effort. Before we start I'd suggest to define together the end result of this prototype.
Here is the first thing I can think of (any comments are appreciated):

// Example of a simple "updateProduct" CRUD-like method

product = findOne([productId: parameters.productId]);
if (product) {
    setNonPkFields(parameters, product);
    product.store();
} else {
   addError("Product with ID [" + parameters.productId + "] not found.");
}
checkErrors();



> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Jacopo Cappellato commented on OFBIZ-1968:
------------------------------------------

Sorry for the bad code formatting of my last comments... I don't know why the new lines have been messed up when I have submitted the form.

Jacopo



> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Jacques Le Roux commented on OFBIZ-1968:
----------------------------------------

Hi Jacopo,

Simply put {code} around when your paste your code, the blue button at right allows you to check/modify

{code}
// Example of a simple "updateProduct" CRUD-like method
product = findOne([productId: parameters.productId]);
if (product) {
    setNonPkFields(parameters, product); product.store();
} else {
    addError("Product with ID [" + parameters.productId + "] not found.");
}
checkErrors();
{code}

Enjoy :o)

> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Issue Comment Edited: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

jacques.le.roux edited comment on OFBIZ-1968 at 9/25/08 2:34 AM:
-----------------------------------------------------------------

Sorry for the edit, I shall have used my own advices ;)
Hi Jacopo,

Simply put \{code\} around your code when your paste it. The little blue button at right allows you to check/modify.
It's the same syntax than WIki Markup in Confluence BTW

{code}
// Example of a simple "updateProduct" CRUD-like method
product = findOne([productId: parameters.productId]);
if (product) {
    setNonPkFields(parameters, product); product.store();
} else {
    addError("Product with ID [" + parameters.productId + "] not found.");
}
checkErrors();
{code}

Enjoy :o)

      was (Author: jacques.le.roux):
    Hi Jacopo,

Simply put {code} around when your paste your code, the blue button at right allows you to check/modify

{code}
// Example of a simple "updateProduct" CRUD-like method
product = findOne([productId: parameters.productId]);
if (product) {
    setNonPkFields(parameters, product); product.store();
} else {
    addError("Product with ID [" + parameters.productId + "] not found.");
}
checkErrors();
{code}

Enjoy :o)
 

> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Jacopo Cappellato commented on OFBIZ-1968:
------------------------------------------

Ok, following Jacques's suggestion, here is the original code formatted properly (thanks Jacques):

{code}
// Example of a simple "updateProduct" CRUD-like method
product = findOne([productId: parameters.productId]);
if (product) {
    setNonPkFields(parameters, product);
    product.store();
} else {
    addError("Product with ID [" + parameters.productId + "] not found.");
}
checkErrors();
{code}



> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Anil K Patel commented on OFBIZ-1968:
-------------------------------------

Jacopo, Jacques,
Thanks for interest in this topic. I am starting to learn Groovy. Very soon I'll post further details here. All the help and Ideas are much appreciated.

> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Scott Gray commented on OFBIZ-1968:
-----------------------------------

Part of a presentation I saw today covered DSLs with Groovy.  I think we could possibly do some cool stuff for with operator overloading and method/property interception

Something like:
{code}
product = "Product".findOne(['productId', productId])
serviceResult = "getWorkEffortsByPeriod".runSync(context)

entityExp = EntityExpression.prepare {
    "fixedAssetId" == fixedAssetId
    "currentStatusId" == currentStatusId
    "fromDate" >= nowTimestamp
}
{code}
or something like that anyway

> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Ashish Vijaywargiya commented on OFBIZ-1968:
--------------------------------------------

+1 to have feature something like this in OFBiz.
It will make developer's life little easy.

--
Ashish

> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Scott Gray commented on OFBIZ-1968:
-----------------------------------

Here's an example of using groovy's Categories with existing util classes:
{code}
import org.ofbiz.entity.util.EntityUtil;

taxInfos = delegator.findByAnd("PartyTaxAuthInfo", [partyId : billingParty.partyId, taxAuthGeoId : taxRate.taxAuthGeoId, taxAuthPartyId : taxRate.taxAuthPartyId])
use (EntityUtil) {
    // Equivalent to EntityUtil.filterByDate(taxInfos);
    dateFilteredTaxInfos = taxInfos.filterByDate();
}
{code}



> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Scott Gray commented on OFBIZ-1968:
-----------------------------------

Here's an example I can actually get to work for building entity expressions:
{code}
entityCondition = expression.AND() {
    equals (productId: 12345),
    in (productId: [1, 2, 3, 4]),
    like (productId: "1234%"),
    OR() {
        equals (productId: "54321"),
        between (productId: [0, 1, 2, 3, 4, 5])
    }
}
{code}

Any thoughts?

> Enrich Groovy integration with Ofbiz framework
> ----------------------------------------------
>
>                 Key: OFBIZ-1968
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1968
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Anil K Patel
>            Priority: Minor
>
> Enrich Groovy integration with Ofbiz framework in order to bring goodies of Minilang to Groovy scripts. Start with simple things like use findByPrimaryKey in groovy scripts without having to prefix it with delegator and then automatically find values for primary key fields from environment if they are not explicitly passed in the call. Later other similar goodies of minilang can be added.
> Use Groovy to add DSL where possible.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Ean Schuessler
That's some very interesting stuff you have going there. I'd definitely use that.

----- "Scott Gray (JIRA)" wrote:

> [ https://issues.apache.org/jira/browse/OFBIZ-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858261#action_12858261 ]
> Scott Gray commented on OFBIZ-1968:
> -----------------------------------
> Here's an example I can actually get to work for building entity expressions:
> {code}
> entityCondition = expression.AND() {
> equals (productId: 12345),
> in (productId: [1, 2, 3, 4]),
> like (productId: "1234%"),
> OR() {
> equals (productId: "54321"),
> between (productId: [0, 1, 2, 3, 4, 5])
> }
> }
> {code}
> Any thoughts?

--
Ean Schuessler, CTO Brainfood.com
[hidden email] - http://www.brainfood.com - 214-720-0700 x 315


Reply | Threaded
Open this post in threaded view
|

EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Scott Gray-2
There were a few quirks with words like "in" and "equals" so I had to go with upper case but it all works now.
Here's some example usage code:

import org.ofbiz.entity.condition.EntityConditionBuilder

expBldr = new EntityExpressionBuilder()

// build regular EntityConditions
equalsExp = expBldr.EQUALS(productId: "GZ-1000)

inExp = expBldr.IN(productId: ["GZ-1000", "GZ-1006"])

// build an EntityConditionList
orExp = expBldr.OR() {
    EQUALS(productId: "GZ-1000")
    IN(productId: ["GZ-1000", "GZ-1006"])
    AND() {
        LIKE(productName: "%Gizmo%")
        LIKE(productName: "%Micro%")
    }
}

// you can also build an EntityConditionList by passing a single or list of EntityConditions
// list
orExp = expBldr.OR([equalsExp, inExpr])
// single
orExp = expBldr.OR(equalsExp)

// add an existing EntityCondition and also some nested ones
orExp = expBldr.OR(equalsExpr) {
    IN(productId: ["GZ-1000", "GZ-1006"])
    AND() {
        LIKE(productName: "%Gizmo%")
        LIKE(productName: "%Micro%")
    }
}

Regards
Scott

On 18/04/2010, at 5:01 PM, Ean Schuessler wrote:

> That's some very interesting stuff you have going there. I'd definitely use that.
>
> ----- "Scott Gray (JIRA)" wrote:
>> [ https://issues.apache.org/jira/browse/OFBIZ-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858261#action_12858261 ]
>> Scott Gray commented on OFBIZ-1968:
>> -----------------------------------
>> Here's an example I can actually get to work for building entity expressions:
>> {code}
>> entityCondition = expression.AND() {
>> equals (productId: 12345),
>> in (productId: [1, 2, 3, 4]),
>> like (productId: "1234%"),
>> OR() {
>> equals (productId: "54321"),
>> between (productId: [0, 1, 2, 3, 4, 5])
>> }
>> }
>> {code}
>> Any thoughts?
>
> --
> Ean Schuessler, CTO Brainfood.com
> [hidden email] - http://www.brainfood.com - 214-720-0700 x 315
>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Jacopo Cappellato-4
Very cool, Scott!

Jacopo

On Apr 18, 2010, at 11:39 AM, Scott Gray wrote:

> There were a few quirks with words like "in" and "equals" so I had to go with upper case but it all works now.
> Here's some example usage code:
>
> import org.ofbiz.entity.condition.EntityConditionBuilder
>
> expBldr = new EntityExpressionBuilder()
>
> // build regular EntityConditions
> equalsExp = expBldr.EQUALS(productId: "GZ-1000)
>
> inExp = expBldr.IN(productId: ["GZ-1000", "GZ-1006"])
>
> // build an EntityConditionList
> orExp = expBldr.OR() {
>    EQUALS(productId: "GZ-1000")
>    IN(productId: ["GZ-1000", "GZ-1006"])
>    AND() {
>        LIKE(productName: "%Gizmo%")
>        LIKE(productName: "%Micro%")
>    }
> }
>
> // you can also build an EntityConditionList by passing a single or list of EntityConditions
> // list
> orExp = expBldr.OR([equalsExp, inExpr])
> // single
> orExp = expBldr.OR(equalsExp)
>
> // add an existing EntityCondition and also some nested ones
> orExp = expBldr.OR(equalsExpr) {
>    IN(productId: ["GZ-1000", "GZ-1006"])
>    AND() {
>        LIKE(productName: "%Gizmo%")
>        LIKE(productName: "%Micro%")
>    }
> }
>
> Regards
> Scott
>
> On 18/04/2010, at 5:01 PM, Ean Schuessler wrote:
>
>> That's some very interesting stuff you have going there. I'd definitely use that.
>>
>> ----- "Scott Gray (JIRA)" wrote:
>>> [ https://issues.apache.org/jira/browse/OFBIZ-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858261#action_12858261 ]
>>> Scott Gray commented on OFBIZ-1968:
>>> -----------------------------------
>>> Here's an example I can actually get to work for building entity expressions:
>>> {code}
>>> entityCondition = expression.AND() {
>>> equals (productId: 12345),
>>> in (productId: [1, 2, 3, 4]),
>>> like (productId: "1234%"),
>>> OR() {
>>> equals (productId: "54321"),
>>> between (productId: [0, 1, 2, 3, 4, 5])
>>> }
>>> }
>>> {code}
>>> Any thoughts?
>>
>> --
>> Ean Schuessler, CTO Brainfood.com
>> [hidden email] - http://www.brainfood.com - 214-720-0700 x 315
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Scott Gray-2
Thanks, I liked it enough myself that I just went ahead and committed it :-)

Based on a couple of conversions over to it, I think it should result in a lot less typing and better readability.

Regards
Scott

On 18/04/2010, at 9:48 PM, Jacopo Cappellato wrote:

> Very cool, Scott!
>
> Jacopo
>
> On Apr 18, 2010, at 11:39 AM, Scott Gray wrote:
>
>> There were a few quirks with words like "in" and "equals" so I had to go with upper case but it all works now.
>> Here's some example usage code:
>>
>> import org.ofbiz.entity.condition.EntityConditionBuilder
>>
>> expBldr = new EntityExpressionBuilder()
>>
>> // build regular EntityConditions
>> equalsExp = expBldr.EQUALS(productId: "GZ-1000)
>>
>> inExp = expBldr.IN(productId: ["GZ-1000", "GZ-1006"])
>>
>> // build an EntityConditionList
>> orExp = expBldr.OR() {
>>   EQUALS(productId: "GZ-1000")
>>   IN(productId: ["GZ-1000", "GZ-1006"])
>>   AND() {
>>       LIKE(productName: "%Gizmo%")
>>       LIKE(productName: "%Micro%")
>>   }
>> }
>>
>> // you can also build an EntityConditionList by passing a single or list of EntityConditions
>> // list
>> orExp = expBldr.OR([equalsExp, inExpr])
>> // single
>> orExp = expBldr.OR(equalsExp)
>>
>> // add an existing EntityCondition and also some nested ones
>> orExp = expBldr.OR(equalsExpr) {
>>   IN(productId: ["GZ-1000", "GZ-1006"])
>>   AND() {
>>       LIKE(productName: "%Gizmo%")
>>       LIKE(productName: "%Micro%")
>>   }
>> }
>>
>> Regards
>> Scott
>>
>> On 18/04/2010, at 5:01 PM, Ean Schuessler wrote:
>>
>>> That's some very interesting stuff you have going there. I'd definitely use that.
>>>
>>> ----- "Scott Gray (JIRA)" wrote:
>>>> [ https://issues.apache.org/jira/browse/OFBIZ-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858261#action_12858261 ]
>>>> Scott Gray commented on OFBIZ-1968:
>>>> -----------------------------------
>>>> Here's an example I can actually get to work for building entity expressions:
>>>> {code}
>>>> entityCondition = expression.AND() {
>>>> equals (productId: 12345),
>>>> in (productId: [1, 2, 3, 4]),
>>>> like (productId: "1234%"),
>>>> OR() {
>>>> equals (productId: "54321"),
>>>> between (productId: [0, 1, 2, 3, 4, 5])
>>>> }
>>>> }
>>>> {code}
>>>> Any thoughts?
>>>
>>> --
>>> Ean Schuessler, CTO Brainfood.com
>>> [hidden email] - http://www.brainfood.com - 214-720-0700 x 315
>>>
>>>
>>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

Adrian Crum-2
In reply to this post by Jacopo Cappellato-4
Bravo!

-Adrian

--- On Sun, 4/18/10, Jacopo Cappellato <[hidden email]> wrote:

> From: Jacopo Cappellato <[hidden email]>
> Subject: Re: EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework
> To: [hidden email]
> Date: Sunday, April 18, 2010, 2:48 AM
> Very cool, Scott!
>
> Jacopo
>
> On Apr 18, 2010, at 11:39 AM, Scott Gray wrote:
>
> > There were a few quirks with words like "in" and
> "equals" so I had to go with upper case but it all works
> now.
> > Here's some example usage code:
> >
> > import
> org.ofbiz.entity.condition.EntityConditionBuilder
> >
> > expBldr = new EntityExpressionBuilder()
> >
> > // build regular EntityConditions
> > equalsExp = expBldr.EQUALS(productId: "GZ-1000)
> >
> > inExp = expBldr.IN(productId: ["GZ-1000", "GZ-1006"])
> >
> > // build an EntityConditionList
> > orExp = expBldr.OR() {
> >    EQUALS(productId: "GZ-1000")
> >    IN(productId: ["GZ-1000", "GZ-1006"])
> >    AND() {
> >        LIKE(productName:
> "%Gizmo%")
> >        LIKE(productName:
> "%Micro%")
> >    }
> > }
> >
> > // you can also build an EntityConditionList by
> passing a single or list of EntityConditions
> > // list
> > orExp = expBldr.OR([equalsExp, inExpr])
> > // single
> > orExp = expBldr.OR(equalsExp)
> >
> > // add an existing EntityCondition and also some
> nested ones
> > orExp = expBldr.OR(equalsExpr) {
> >    IN(productId: ["GZ-1000", "GZ-1006"])
> >    AND() {
> >        LIKE(productName:
> "%Gizmo%")
> >        LIKE(productName:
> "%Micro%")
> >    }
> > }
> >
> > Regards
> > Scott
> >
> > On 18/04/2010, at 5:01 PM, Ean Schuessler wrote:
> >
> >> That's some very interesting stuff you have going
> there. I'd definitely use that.
> >>
> >> ----- "Scott Gray (JIRA)" wrote:
> >>> [ https://issues.apache.org/jira/browse/OFBIZ-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858261#action_12858261
> ]
> >>> Scott Gray commented on OFBIZ-1968:
> >>> -----------------------------------
> >>> Here's an example I can actually get to work
> for building entity expressions:
> >>> {code}
> >>> entityCondition = expression.AND() {
> >>> equals (productId: 12345),
> >>> in (productId: [1, 2, 3, 4]),
> >>> like (productId: "1234%"),
> >>> OR() {
> >>> equals (productId: "54321"),
> >>> between (productId: [0, 1, 2, 3, 4, 5])
> >>> }
> >>> }
> >>> {code}
> >>> Any thoughts?
> >>
> >> --
> >> Ean Schuessler, CTO Brainfood.com
> >> [hidden email]
> - http://www.brainfood.com - 214-720-0700 x 315
> >>
> >>
> >
>
>



Reply | Threaded
Open this post in threaded view
|

Re: EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework

chris snow-2
In reply to this post by Scott Gray-2
Very nice!