svn commit: r707830 - in /ofbiz/trunk/framework/entity: dtd/entitymodel.xsd src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java src/org/ofbiz/entity/model/DynamicViewEntity.java src/org/ofbiz/entity/model/ModelViewEntity.java

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

svn commit: r707830 - in /ofbiz/trunk/framework/entity: dtd/entitymodel.xsd src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java src/org/ofbiz/entity/model/DynamicViewEntity.java src/org/ofbiz/entity/model/ModelViewEntity.java

jleroux@apache.org
Author: jleroux
Date: Sat Oct 25 03:02:40 2008
New Revision: 707830

URL: http://svn.apache.org/viewvc?rev=707830&view=rev
Log:
Revert r707216 on Adam and David's advices (OFBIZ-1232)

Modified:
    ofbiz/trunk/framework/entity/dtd/entitymodel.xsd
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java

Modified: ofbiz/trunk/framework/entity/dtd/entitymodel.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd?rev=707830&r1=707829&r2=707830&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/dtd/entitymodel.xsd (original)
+++ ofbiz/trunk/framework/entity/dtd/entitymodel.xsd Sat Oct 25 03:02:40 2008
@@ -245,7 +245,6 @@
                 <xs:element minOccurs="0" maxOccurs="unbounded" ref="alias-all"/>
                 <xs:element minOccurs="0" maxOccurs="unbounded" ref="alias"/>
                 <xs:element minOccurs="0" maxOccurs="unbounded" ref="view-link"/>
-                <xs:element minOccurs="0" maxOccurs="unbounded" ref="filter"/>
                 <xs:element minOccurs="0" maxOccurs="unbounded" ref="relation"/>
             </xs:sequence>
             <xs:attributeGroup ref="attlist.view-entity"/>
@@ -441,26 +440,6 @@
             </xs:simpleType>
         </xs:attribute>
     </xs:attributeGroup>
-    <xs:element name="filter">
-        <xs:annotation>
-            <xs:documentation>
-                Allows to filter a view using "entity-alias", "field-name", "operator" and "value"  
-                operator being one of (see EntityOperator.java for more details)
-                {not-in, greater, greaterThanEqualTo, less-equals, equals, or, greater-than, less-than-equal-to, like, in, not-equals,
-                greater-than-equal-to, and, not, lessThanEqualTo, not-equal, lessThan, greater-equals, greaterThan, not-like, less-than,
-                notEqual, between, less}
-            </xs:documentation>
-        </xs:annotation>
-        <xs:complexType>
-            <xs:attributeGroup ref="attlist.filter"/>
-        </xs:complexType>
-    </xs:element>
-    <xs:attributeGroup name="attlist.filter">
-        <xs:attribute type="xs:string" name="entity-alias" use="required"/>
-        <xs:attribute type="xs:string" name="field-name" use="required"/>
-        <xs:attribute type="xs:string" name="operator" use="required"/>
-        <xs:attribute type="xs:string" name="value" use="required"/>
-    </xs:attributeGroup>
 
     <xs:element name="extend-entity">
         <xs:complexType>

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=707830&r1=707829&r2=707830&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Sat Oct 25 03:02:40 2008
@@ -26,10 +26,10 @@
 import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.sql.Blob;
-import java.sql.Clob;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
+import java.sql.Clob;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -53,7 +53,6 @@
 import org.ofbiz.entity.GenericNotImplementedException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityConditionParam;
-import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.condition.OrderByList;
 import org.ofbiz.entity.config.DatasourceInfo;
 import org.ofbiz.entity.datasource.GenericDAO;
@@ -356,45 +355,11 @@
                 throw new GenericModelException("The join-style " + joinStyle + " is not supported");
             }
 
-            makeViewFilterWhereClause(modelViewEntity, whereString);
-            
             if (whereString.length() > 0) {
                 return "(" + whereString.toString() + ")";
             }
         }
         return "";
-    }    
-
-    /** Filter a view using this syntax :
-     * <filter entity-alias="<table_alias>" field-name="<field_name>" operator="<operator:equals, not-equals, like...>" value="<value_to_select>"/>
-     * */
-    public static void makeViewFilterWhereClause(ModelViewEntity modelViewEntity, StringBuilder whereString) throws GenericEntityException {
-
-        for (ModelViewEntity.ModelFilter filter : modelViewEntity.getFilters()) {            
-            ModelEntity filterEntity = modelViewEntity.getMemberModelEntity(filter.getEntityAlias());
-            if (filterEntity == null) {
-                throw new GenericEntityException("Link entity not found with alias: " + filter.getEntityAlias() + " for entity: " + modelViewEntity.getEntityName());
-            }
-            
-            ModelField filterField = filterEntity.getField(filter.getFieldName());
-            if (filterField == null) {
-                throw new GenericEntityException("The field " + filter.getFieldName() + " does not appear to belong to entity " + modelViewEntity.getEntityName());                
-            }
-            if (whereString.length() > 0) {
-                whereString.append(" AND ");
-            }
-            whereString.append(filter.getEntityAlias());
-            whereString.append(".");
-            whereString.append(filterColName(filterField.getColName()));
-            
-            EntityOperator<?> entityOperator = EntityOperator.lookup(filter.getOperator());
-            if (entityOperator == null) {
-             throw new GenericEntityException("Operator " + filter.getOperator() + " not supported in filter for entity: " + modelViewEntity.getEntityName());
-            }
-            whereString.append(" ").append(entityOperator.getCode()).append(" ");
-            
-            whereString.append("'" + filter.getValue().replaceAll("'", "''") + "'");
-        }
     }
 
     public static String makeOrderByClause(ModelEntity modelEntity, List<String> orderBy, DatasourceInfo datasourceInfo) throws GenericModelException {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java?rev=707830&r1=707829&r2=707830&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java Sat Oct 25 03:02:40 2008
@@ -28,7 +28,6 @@
 import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember;
 import org.ofbiz.entity.model.ModelViewEntity.ModelAlias;
 import org.ofbiz.entity.model.ModelViewEntity.ModelAliasAll;
-import org.ofbiz.entity.model.ModelViewEntity.ModelFilter;
 import org.ofbiz.entity.model.ModelViewEntity.ModelMemberEntity;
 import org.ofbiz.entity.model.ModelViewEntity.ModelViewLink;
 /**
@@ -64,9 +63,6 @@
     /** List of view links to define how entities are connected (or "joined") */
     protected List<ModelViewLink> viewLinks = new ArrayList<ModelViewLink>();
     
-    /** A List of criteria to filter view data */
-    protected List<ModelFilter> filters = new ArrayList<ModelFilter>();
-
     /** relations defining relationships between this entity and other entities */
     protected List<ModelRelation> relations = new ArrayList<ModelRelation>();
     
@@ -207,15 +203,6 @@
         addList.addAll(this.viewLinks);
     }
     
-    public void addFilter(String entityAlias, String fieldName, String operator, String value) {
-        ModelFilter modelFilter = new ModelFilter(entityAlias, fieldName, operator, value);
-        this.filters.add(modelFilter);
-    }
-    
-    public void addAllFiltersToList(List<ModelFilter> addList) {
-        addList.addAll(this.filters);
-    }
-    
     public void addRelation(String type, String title, String relEntityName, List<ModelKeyMap> modelKeyMaps) {
         ModelRelation relation = new ModelRelation(type, title, relEntityName, null, modelKeyMaps);
         this.relations.add(relation);

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=707830&r1=707829&r2=707830&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Sat Oct 25 03:02:40 2008
@@ -80,10 +80,6 @@
 
     protected Map<String, Map<String, ModelConversion>> conversions = FastMap.newInstance();
 
-    /** A List of criteria to filter view data */
-    protected List<ModelFilter> filters = FastList.newInstance();
-
-    
     public ModelViewEntity(ModelReader reader, Element entityElement, UtilTimer utilTimer, ModelInfo def) {
         super(reader, entityElement, def);
 
@@ -120,11 +116,6 @@
             this.addViewLink(viewLink);
         }
 
-        for (Element filterElement : UtilXml.childElementList(entityElement, "filter")) {
-            ModelFilter filter = new ModelFilter(filterElement);
-            this.addFilter(filter);
-        }
-
         if (utilTimer != null) utilTimer.timerString("  createModelEntity: before relations");
         this.populateRelated(reader, entityElement);
 
@@ -153,9 +144,6 @@
         
         // view-links
         dynamicViewEntity.addAllViewLinksToList(this.viewLinks);
-
-        // filters
-        dynamicViewEntity.addAllFiltersToList(this.filters);
         
         // relations
         dynamicViewEntity.addAllRelationsToList(this.relations);
@@ -283,21 +271,6 @@
         return colNameString(Arrays.asList(flds), separator, afterLast, alias);
     }
 
-    /** List of filters to define how entities are filtered when data is showed */
-    public List<ModelFilter> getFilters() {
-        return this.filters;
-    }
-
-    public List<ModelFilter> getFiltersCopy() {
-        List<ModelFilter> newList = FastList.newInstance();
-        newList.addAll(this.filters);
-        return newList;
-    }
-
-    public void addFilter(ModelFilter filter) {
-        this.filters.add(filter);
-    }
-    
     public String colNameString(List<ModelField> flds, String separator, String afterLast, boolean alias) {
         StringBuilder returnString = new StringBuilder();
 
@@ -1028,45 +1001,6 @@
         }
     }
 
-    public static class ModelFilter implements Serializable {
-        protected String entityAlias = "";
-        protected String fieldName = "";
-        protected String operator = "";
-        protected String value = "";
-
-        protected ModelFilter() {}
-
-        public ModelFilter(Element filterElement) {
-            this.entityAlias = UtilXml.checkEmpty(filterElement.getAttribute("entity-alias"));
-            this.fieldName = UtilXml.checkEmpty(filterElement.getAttribute("field-name"));
-            this.operator = UtilXml.checkEmpty(filterElement.getAttribute("operator"));
-            this.value = UtilXml.checkEmpty(filterElement.getAttribute("value"));
-        }
-
-        public ModelFilter(String entityAlias, String fieldName, String operator, String value) {
-            this.entityAlias = entityAlias;
-            this.fieldName = fieldName;
-            this.operator = operator;
-            this.value = value;
-        }
-
-        public String getEntityAlias() {
-            return this.entityAlias;
-        }
-
-        public String getFieldName() {
-            return this.fieldName;
-        }
-
-        public String getOperator() {
-            return this.operator;
-        }
-
-        public String getValue() {
-            return this.value;
-        }
-    }
-
     public class ModelConversion implements Serializable {
         protected String aliasName;
         protected ModelEntity fromModelEntity;