Author: jonesde
Date: Sun Oct 29 18:45:34 2006
New Revision: 469046

URL: http://svn.apache.org/viewvc?view=rev&rev=469046
Log:
Added option to condition-expr to ignore-case, makes things lots easier when 
you need something like that

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

Modified: 
incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?view=diff&rev=469046&r1=469045&r2=469046
==============================================================================
--- 
incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
 (original)
+++ 
incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
 Sun Oct 29 18:45:34 2006
@@ -157,6 +157,7 @@
         protected FlexibleStringExpander valueExdr;
         protected boolean ignoreIfNull;
         protected boolean ignoreIfEmpty;
+        protected boolean ignoreCase;
         
         public ConditionExpr(Element conditionExprElement) {
             this.fieldNameExdr = new 
FlexibleStringExpander(conditionExprElement.getAttribute("field-name"));
@@ -170,6 +171,7 @@
             this.valueExdr = new 
FlexibleStringExpander(conditionExprElement.getAttribute("value"));
             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"));
         }
         
         public EntityCondition createCondition(Map context, String entityName, 
GenericDelegator delegator) {
@@ -227,15 +229,28 @@
             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
-                return new EntityExpr(
-                        new EntityExpr(fieldName, (EntityComparisonOperator) 
operator, value), 
-                        EntityOperator.OR, 
-                        new EntityExpr(fieldName, EntityOperator.EQUALS, 
null));
+                if (ignoreCase) {
+                    return new EntityExpr(
+                            new EntityExpr(fieldName, true, 
(EntityComparisonOperator) operator, value, true), 
+                            EntityOperator.OR,
+                            new EntityExpr(fieldName, EntityOperator.EQUALS, 
null));
+                } else {
+                    return new EntityExpr(
+                            new EntityExpr(fieldName, 
(EntityComparisonOperator) operator, value), 
+                            EntityOperator.OR,
+                            new EntityExpr(fieldName, EntityOperator.EQUALS, 
null));
+                }
             } else {
-                return new EntityExpr(fieldName, (EntityComparisonOperator) 
operator, value);
+                if (ignoreCase) {
+                    // use the stuff to upper case both sides
+                    return new EntityExpr(fieldName, true, 
(EntityComparisonOperator) operator, value, true);
+                } else {
+                    return new EntityExpr(fieldName, 
(EntityComparisonOperator) operator, value);
+                }
             }
         }
     }
+    
     public static class ConditionList implements Condition {
         List conditionList = new LinkedList();
         FlexibleStringExpander combineExdr;

Modified: incubator/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd?view=diff&rev=469046&r1=469045&r2=469046
==============================================================================
--- incubator/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd (original)
+++ incubator/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd Sun Oct 29 
18:45:34 2006
@@ -952,6 +952,14 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="ignore-case" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="condition-object">
         <xs:complexType>

Modified: incubator/ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?view=diff&rev=469046&r1=469045&r2=469046
==============================================================================
--- incubator/ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ incubator/ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sun Oct 29 
18:45:34 2006
@@ -1231,6 +1231,14 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="ignore-case" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="condition-list">
         <xs:complexType>

Modified: incubator/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd?view=diff&rev=469046&r1=469045&r2=469046
==============================================================================
--- incubator/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd (original)
+++ incubator/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd Sun Oct 29 
18:45:34 2006
@@ -629,6 +629,14 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="ignore-case" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="condition-object">
         <xs:complexType>

Modified: incubator/ofbiz/trunk/framework/widget/dtd/widget-tree.xsd
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/widget/dtd/widget-tree.xsd?view=diff&rev=469046&r1=469045&r2=469046
==============================================================================
--- incubator/ofbiz/trunk/framework/widget/dtd/widget-tree.xsd (original)
+++ incubator/ofbiz/trunk/framework/widget/dtd/widget-tree.xsd Sun Oct 29 
18:45:34 2006
@@ -485,6 +485,22 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="ignore-if-empty" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
+        <xs:attribute name="ignore-case" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
 
     <!-- ================ CONDITIONS ================ -->


Reply via email to