You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Scott Gray <sc...@hotwaxmedia.com> on 2010/04/18 11:39:15 UTC

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

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 
> ean@brainfood.com - http://www.brainfood.com - 214-720-0700 x 315 
> 
> 


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

Posted by Scott Gray <sc...@hotwaxmedia.com>.
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 
>>> ean@brainfood.com - http://www.brainfood.com - 214-720-0700 x 315 
>>> 
>>> 
>> 
> 


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

Posted by Adrian Crum <ad...@yahoo.com>.
Bravo!

-Adrian

--- On Sun, 4/18/10, Jacopo Cappellato <ja...@hotwaxmedia.com> wrote:

> From: Jacopo Cappellato <ja...@hotwaxmedia.com>
> Subject: Re: EntityConditionBuilder for Groovy WAS: Re: [jira] Commented: (OFBIZ-1968) Enrich Groovy integration with Ofbiz framework
> To: dev@ofbiz.apache.org
> 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 
> >> ean@brainfood.com
> - http://www.brainfood.com - 214-720-0700 x 315 
> >> 
> >> 
> > 
> 
> 


      

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

Posted by Jacopo Cappellato <ja...@hotwaxmedia.com>.
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 
>> ean@brainfood.com - http://www.brainfood.com - 214-720-0700 x 315 
>> 
>> 
> 


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

Posted by chris snow <ch...@googlemail.com>.
Very nice!