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 
>> [email protected] - http://www.brainfood.com - 214-720-0700 x 315 
>> 
>> 
> 

Reply via email to