details:   https://code.openbravo.com/erp/devel/pi/rev/a644a005269e
changeset: 29358:a644a005269e
user:      Naroa Iriarte <naroa.iriarte <at> openbravo.com>
date:      Wed Apr 27 09:18:25 2016 +0200
summary:   Fixed issue 32321: The QueryBuilder class has been deleted

The only used thig was an enum, that enum now is in the AdvancedQueryBuilder 
class and
the QueryBuilder class has been removed.

details:   https://code.openbravo.com/erp/devel/pi/rev/1fd07e8b5372
changeset: 29359:1fd07e8b5372
user:      Naroa Iriarte <naroa.iriarte <at> openbravo.com>
date:      Wed Apr 27 09:19:33 2016 +0200
summary:   Fixed issue 30935: The SetContextInfoActionHandler class has been 
removed

The unused SetContextInfoActionHandler class has been removed.

diffstat:

 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/SetContextInfoActionHandler.java
                |   66 -
 
modules/org.openbravo.service.json/src-test/org/openbravo/service/json/test/DataQueryServiceTest.java
               |    4 +-
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
                         |    4 +
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
                                 |  737 ----------
 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDataSourceFilter.java
 |    2 +-
 5 files changed, 7 insertions(+), 806 deletions(-)

diffs (truncated from 854 to 300 lines):

diff -r e5e6126fc21b -r 1fd07e8b5372 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/SetContextInfoActionHandler.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/SetContextInfoActionHandler.java
      Tue Apr 26 10:47:23 2016 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-package org.openbravo.client.kernel;
-
-import java.util.Map;
-
-import javax.enterprise.context.ApplicationScoped;
-
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-import org.hibernate.criterion.Restrictions;
-import org.openbravo.dal.core.OBContext;
-import org.openbravo.dal.service.OBCriteria;
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.model.ad.ui.AuxiliaryInput;
-import org.openbravo.model.ad.ui.Tab;
-
-@ApplicationScoped
-public class SetContextInfoActionHandler extends BaseActionHandler {
-
-  @Override
-  protected JSONObject execute(Map<String, Object> parameters, String content) 
{
-
-    RequestContext rc = RequestContext.get();
-
-    // TODO Auto-generated method stub
-    try {
-      OBContext.setAdminMode();
-
-      JSONObject p = new JSONObject(content);
-
-      String tabId = p.getString("_tabId");
-      Tab tab = OBDal.getInstance().get(Tab.class, tabId);
-      String windowId = tab.getWindow().getId();
-
-      System.out.println("window: " + windowId);
-
-      JSONArray names = p.names();
-      for (int i = 0; i < names.length(); i++) {
-        String name = names.getString(i);
-        String value = p.getString(name);
-
-        rc.setSessionAttribute((windowId + "|" + name).toUpperCase(), value);
-        System.out.println((windowId + "|" + name).toUpperCase() + ":" + 
value);
-        System.out.println(name + ": " + value);
-      }
-
-      // Auxiliary inputs
-
-      OBCriteria<AuxiliaryInput> qInputs = 
OBDal.getInstance().createCriteria(AuxiliaryInput.class);
-      qInputs.add(Restrictions.eq(AuxiliaryInput.PROPERTY_TAB, tab));
-      for (AuxiliaryInput input : qInputs.list()) {
-
-      }
-
-    } catch (JSONException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
-    } finally {
-      OBContext.restorePreviousMode();
-    }
-
-    System.out.println("set context info");
-    return new JSONObject();
-  }
-
-}
diff -r e5e6126fc21b -r 1fd07e8b5372 
modules/org.openbravo.service.json/src-test/org/openbravo/service/json/test/DataQueryServiceTest.java
--- 
a/modules/org.openbravo.service.json/src-test/org/openbravo/service/json/test/DataQueryServiceTest.java
     Tue Apr 26 10:47:23 2016 +0200
+++ 
b/modules/org.openbravo.service.json/src-test/org/openbravo/service/json/test/DataQueryServiceTest.java
     Wed Apr 27 09:19:33 2016 +0200
@@ -39,8 +39,8 @@
 import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
 import org.openbravo.service.json.DataEntityQueryService;
 import org.openbravo.service.json.JsonConstants;
-import org.openbravo.service.json.QueryBuilder;
-import org.openbravo.service.json.QueryBuilder.TextMatching;
+import org.openbravo.service.json.AdvancedQueryBuilder;
+import org.openbravo.service.json.AdvancedQueryBuilder.TextMatching;
 import org.openbravo.test.base.OBBaseTest;
 
 /**
diff -r e5e6126fc21b -r 1fd07e8b5372 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Tue Apr 26 10:47:23 2016 +0200
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Wed Apr 27 09:19:33 2016 +0200
@@ -173,6 +173,10 @@
   // in the FROM clause
   private boolean creatingJoinsInWhereClauseIsPrevented = false;
 
+  public static enum TextMatching {
+    startsWith, exact, substring
+  }
+
   public Entity getEntity() {
     return entity;
   }
diff -r e5e6126fc21b -r 1fd07e8b5372 
modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
       Tue Apr 26 10:47:23 2016 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,737 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.service.json;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.openbravo.base.model.Entity;
-import org.openbravo.base.model.ModelProvider;
-import org.openbravo.base.model.Property;
-import org.openbravo.base.structure.IdentifierProvider;
-import org.openbravo.base.util.Check;
-import org.openbravo.client.kernel.RequestContext;
-import org.openbravo.dal.core.DalUtil;
-import org.openbravo.dal.core.OBContext;
-import org.openbravo.erpCommon.utility.Utility;
-import org.openbravo.service.db.DalConnectionProvider;
-
-/**
- * Encapsulates the logic to translate filter properties and values received 
from the client to a
- * where clauses in the query itself.
- * 
- * @author mtaal
- */
-public class QueryBuilder {
-
-  private static final String PARAM_DELIMITER = "@";
-  private static final String ALIAS_PREFIX = "alias_";
-  private static final char ESCAPE_CHAR = '|';
-
-  public static enum TextMatching {
-    startsWith, exact, substring
-  }
-
-  private static final Logger log = Logger.getLogger(QueryBuilder.class);
-
-  private Map<String, String> filterParameters = new HashMap<String, String>();
-  private List<Object> typedParameters = new ArrayList<Object>();
-  private Entity entity;
-  private boolean doOr = false;
-  private String mainAlias = null;
-  private int aliasIndex = 0;
-  private List<JoinDefinition> joinDefinitions = new 
ArrayList<JoinDefinition>();
-  private String orderBy;
-
-  private String orderByClause = null;
-  private String whereClause = null;
-  private String joinClause = null;
-
-  private TextMatching textMatching = TextMatching.exact;
-
-  public Entity getEntity() {
-    return entity;
-  }
-
-  public void setEntity(String entityName) {
-    this.entity = ModelProvider.getInstance().getEntity(entityName);
-  }
-
-  public void setEntity(Entity entity) {
-    this.entity = entity;
-  }
-
-  /**
-   * Translates the filter criteria ({@link #addFilterParameter(String, 
String)}) to a valid HQL
-   * where clause (without the 'where' keyword). After calling this method the 
method
-   * {@link #getNamedParameters()} can be called. Note that currently only 
filtering on string and
-   * boolean properties is supported. Also filtering on the identifier of a 
referenced business
-   * object is supported.
-   * 
-   * @return a valid where clause or an empty string if not set.
-   */
-  public String getWhereClause() {
-
-    if (whereClause != null) {
-      return whereClause;
-    }
-
-    // add some default filter parameters
-    filterParameters
-        .put(JsonConstants.QUERY_PARAM_USER, 
OBContext.getOBContext().getUser().getId());
-    if (!filterParameters.containsKey(JsonConstants.QUERY_PARAM_CLIENT)) {
-      filterParameters.put(JsonConstants.QUERY_PARAM_CLIENT, 
OBContext.getOBContext().getUser()
-          .getId());
-    }
-
-    final SimpleDateFormat simpleDateFormat = JsonUtils.createDateFormat();
-
-    Check.isNotNull(entity, "Entity must be set");
-
-    final StringBuilder sb = new StringBuilder();
-    boolean addAnd = false;
-    final StringBuilder orgPart = new StringBuilder();
-    final List<Property> propertyDone = new ArrayList<Property>();
-    String whereParameterValue = null;
-    for (String key : filterParameters.keySet()) {
-      String value = filterParameters.get(key);
-
-      if (key.equals(JsonConstants.WHERE_PARAMETER)) {
-        // there are cases where null is set as a string
-        // handle this
-        if (value.equals("null") || value.length() == 0) {
-          continue;
-        }
-        whereParameterValue = value;
-        continue;
-      }
-
-      // handle the case that we should filter on the accessible organizations
-      if (key.equals(JsonConstants.ORG_PARAMETER)) {
-        if (entity.isOrganizationEnabled() && value != null && value.length() 
> 0) {
-          final Set<String> orgs = 
OBContext.getOBContext().getOrganizationStructureProvider()
-              .getNaturalTree(value);
-          if (orgs.size() > 0) {
-            if (getMainAlias() != null) {
-              orgPart.append(" " + getMainAlias() + ".organization in (");
-            } else {
-              orgPart.append(" organization in (");
-            }
-            boolean addComma = false;
-            for (String org : orgs) {
-              if (addComma) {
-                orgPart.append(",");
-              }
-              orgPart.append("'" + org + "'");
-              addComma = true;
-            }
-            orgPart.append(") ");
-          }
-        }
-        continue;
-      }
-
-      // determine the property
-      final List<Property> properties = 
JsonUtils.getPropertiesOnPath(getEntity(), key);
-      if (properties.isEmpty()) {
-        continue;
-      }
-      final Property property = properties.get(properties.size() - 1);
-      // invalid propname, ignore this one
-      // TODO: possibly warn about it
-      if (property == null || propertyDone.contains(property)) {
-        continue;
-      }
-      propertyDone.add(property);
-
-      // we know the property and the string representation of the value...
-      // do the conversion
-
-      if (addAnd) {
-        if (doOr) {
-          sb.append(" or ");
-        } else {
-          sb.append(" and ");
-        }
-      }
-
-      String leftWherePart = null;
-      if (isDoOr()) {
-        leftWherePart = resolveJoins(properties, key);
-      } else if (getMainAlias() != null) {
-        leftWherePart = getMainAlias() + "." + key.trim();
-      } else {
-        leftWherePart = key;
-      }
-
-      // get rid of the identifier and replace it with the real property name
-      // or with the concatenation if there are multiple parts
-      // NOTE: the if and else check against the key variable and not the 
leftwherepart
-      // because the key contains the original string (with the _identifier 
part).
-      // Within the if the leftWherePart is used because it contains the join 
aliases
-      if (key.equals(JsonConstants.IDENTIFIER) || key.endsWith("." + 
JsonConstants.IDENTIFIER)) {
-        // the identifierProperties are read from the owning entity of the
-        // property, that should work fine, as this last property is always 
part of the

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to