[Tree Extension] Do not use parentRecord id to obtain adtree
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 18 Feb 2014 17:30:16 +0100
changeset 22511 a34353a80b6b
parent 22510 1e1e9902d388
child 22512 106d5d070f33
[Tree Extension] Do not use parentRecord id to obtain adtree
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java	Mon Feb 17 16:21:27 2014 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java	Tue Feb 18 17:30:16 2014 +0100
@@ -395,14 +395,13 @@
    * @param parentRecordId
    * @return
    */
-  private Tree getTree(String referencedTableId, String parentRecordId) {
+  private Tree getTree(String referencedTableId) {
     Table referencedTable = OBDal.getInstance().get(Table.class, referencedTableId);
 
     OBCriteria<Tree> treeCriteria = OBDal.getInstance().createCriteria(Tree.class);
     treeCriteria.add(Restrictions.eq(Tree.PROPERTY_TABLE, referencedTable));
-    if (parentRecordId != null && !parentRecordId.isEmpty() && !"null".equals(parentRecordId)) {
-      treeCriteria.add(Restrictions.eq(Tree.PROPERTY_PARENTRECORDID, parentRecordId));
-    }
+    treeCriteria.add(Restrictions.eq(Tree.PROPERTY_CLIENT, OBContext.getOBContext()
+        .getCurrentClient()));
     return (Tree) treeCriteria.uniqueResult();
   }
 
@@ -514,7 +513,6 @@
 
     String tableId = null;
     String referencedTableId = parameters.get("referencedTableId");
-    String parentRecordId = parameters.get("parentRecordId");
     String treeReferenceId = parameters.get("treeReferenceId");
     JSONArray selectedProperties = null;
     if (referencedTableId != null) {
@@ -535,7 +533,7 @@
       return new JSONObject();
     }
 
-    Tree tree = this.getTree(tableId, parentRecordId);
+    Tree tree = this.getTree(tableId);
     boolean isOrdered = this.isOrdered(tree);
     Long seqNo = null;
     if (isOrdered) {
@@ -637,7 +635,6 @@
   @Override
   protected Map<String, Object> getDatasourceSpecificParams(Map<String, String> parameters) {
     Map<String, Object> datasourceParams = new HashMap<String, Object>();
-    String parentRecordId = parameters.get("parentRecordId");
     String tabId = parameters.get("tabId");
     String treeReferenceId = parameters.get("treeReferenceId");
     String tableId = null;
@@ -652,7 +649,7 @@
           .error("A request to the TreeDatasourceService must include the tabId or the treeReferenceId parameter");
       return datasourceParams;
     }
-    Tree tree = this.getTree(tableId, parentRecordId);
+    Tree tree = this.getTree(tableId);
     datasourceParams.put("tree", tree);
     return datasourceParams;
   }