Hi Hans,

yes, I see... but maybe some sort of "use-when" attribute in the entity-condition (and then using two separate conditions) would have been better. Maybe I am too picky, but when it comes to framework stuff (and xsd grammars) I like to think a lot about the best way of enhancing the framework. Instead of adding a lot of small attributes like the ignore one, to solve existing issues, sometimes it makes sense to try to Let's say for example that, based on a given condition we have to query a different entity, or select different fields, or sort the results in a different way (and not just ignore a search constraint like in your situation): instead of adding a lot of small attributes (that are confusing), a "use-when" attribute would work fine for all these scenarios.
Just my 2 cents,

Jacopo

On Aug 28, 2008, at 1:13 PM, Hans Bakker wrote:

Hi Jacopo,

sure that would be nicer but much more involved....although using
sections and conditions already somewhat allows this....

what i committed now is a simple solution for a simple problem......

Bruno, what do you think?


On Thu, 2008-08-28 at 12:51 +0530, Jacopo Cappellato wrote:
Instead of this feature, I would have preferred to see implemented an
<if> element for actions.
In this way you could do:

<if>...condition...
<then>
entity find with all the exprs
</then>
<else>
entity find without the expr you want to skip
</else>
</if>

This is my opinion is more flexible and general purpose approach.
I am worried about the readability of the "ignore" attribute...

Jacopo


On Aug 28, 2008, at 9:47 AM, [EMAIL PROTECTED] wrote:

Author: hansbak
Date: Wed Aug 27 21:17:48 2008
New Revision: 689713

URL: http://svn.apache.org/viewvc?rev=689713&view=rev
Log:
OFBIZ-1934: Ignore property for condition-expr tag, excellent
contribution by Bruno Busco

Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/
EntityFinderUtil.java
ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd
ofbiz/trunk/framework/widget/dtd/widget-form.xsd
ofbiz/trunk/framework/widget/dtd/widget-screen.xsd
ofbiz/trunk/framework/widget/dtd/widget-tree.xsd

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/
EntityFinderUtil.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?rev=689713&r1=689712&r2=689713&view=diff
=
=
=
=
=
=
=
=
= = ====================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/
EntityFinderUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/
EntityFinderUtil.java Wed Aug 27 21:17:48 2008
@@ -154,6 +154,7 @@
    protected FlexibleStringExpander operatorExdr;
    protected FlexibleMapAccessor<Object> envNameAcsr;
    protected FlexibleStringExpander valueExdr;
+        protected FlexibleStringExpander ignoreExdr;
    protected boolean ignoreIfNull;
    protected boolean ignoreIfEmpty;
    protected boolean ignoreCase;
@@ -171,6 +172,7 @@
        this.ignoreIfNull =
"true".equals(conditionExprElement.getAttribute("ignore-if-null"));
        this.ignoreIfEmpty =
"true".equals(conditionExprElement.getAttribute("ignore-if-empty"));
        this.ignoreCase =
"true".equals(conditionExprElement.getAttribute("ignore-case"));
+            this.ignoreExdr =
FlexibleStringExpander
.getInstance(conditionExprElement.getAttribute("ignore"));
    }

    public EntityCondition createCondition(Map<String, ? extends
Object> context, String entityName, GenericDelegator delegator) {
@@ -225,6 +227,10 @@
            return null;
        }

+            if
("true".equals(this.ignoreExdr.expandString(context))) {
+                return null;
+            }
+
        if (operator == EntityOperator.NOT_EQUAL && value != null) {
            // since some databases don't consider nulls in !=
comparisons, explicitly include them
            // this makes more sense logically, but if anyone ever
needs it to not behave this way we should add an "or-null" attribute
that is true by default

Modified: ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd?rev=689713&r1=689712&r2=689713&view=diff
=
=
=
=
=
=
=
=
= = ====================================================================
--- ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd (original)
+++ ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd Wed Aug 27
21:17:48 2008
@@ -2643,6 +2643,14 @@
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
+        <xs:attribute name="ignore" default="false">
+            <xs:annotation>
+                <xs:documentation>
+                    Ignore the condition if flag is true.
+                    Defaults to false.
+                </xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
</xs:attributeGroup>
<xs:element name="condition-object">
    <xs:annotation>

Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=689713&r1=689712&r2=689713&view=diff
=
=
=
=
=
=
=
=
= = ====================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed Aug 27
21:17:48 2008
@@ -1594,6 +1594,14 @@
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
+        <xs:attribute name="ignore" default="false">
+            <xs:annotation>
+                <xs:documentation>
+                    Ignore the condition if flag is true.
+                    Defaults to false.
+                </xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
</xs:attributeGroup>
<xs:element name="condition-list">
    <xs:complexType>

Modified: ofbiz/trunk/framework/widget/dtd/widget-screen.xsd
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd?rev=689713&r1=689712&r2=689713&view=diff
=
=
=
=
=
=
=
=
= = ====================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-screen.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-screen.xsd Wed Aug 27
21:17:48 2008
@@ -669,6 +669,14 @@
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
+        <xs:attribute name="ignore" default="false">
+            <xs:annotation>
+                <xs:documentation>
+                    Ignore the condition if flag is true.
+                    Defaults to false.
+                </xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
</xs:attributeGroup>
<xs:element name="condition-object">
    <xs:complexType>

Modified: ofbiz/trunk/framework/widget/dtd/widget-tree.xsd
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-tree.xsd?rev=689713&r1=689712&r2=689713&view=diff
=
=
=
=
=
=
=
=
= = ====================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-tree.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-tree.xsd Wed Aug 27
21:17:48 2008
@@ -504,6 +504,14 @@
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
+        <xs:attribute name="ignore" default="false">
+            <xs:annotation>
+                <xs:documentation>
+                    Ignore the condition if flag is true.
+                    Defaults to false.
+                </xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
</xs:attributeGroup>

<!-- ================ CONDITIONS ================ -->



--
Antwebsystems.com: Quality OFBiz services for competitive prices


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to