Attached Files | issue31856.diff [^] (14,066 bytes) 2016-01-18 09:46 [Show Content] [Hide Content]diff --git a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java b/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
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java
@@ -554,7 +554,9 @@
* Updates the parent of a given node a returns its definition in a JSONObject and recomputes the
* sequence number of the nodes if the tree is ordered
*/
- protected JSONObject moveNode(Map<String, String> parameters, String nodeId, String newParentId,
+ @Override
+ protected JSONObject moveNode(Map<String, String> parameters,
+ Map<String, Object> datasourceParameters, String nodeId, String newParentId,
String prevNodeId, String nextNodeId) throws Exception {
String tableId = null;
String referencedTableId = parameters.get("referencedTableId");
@@ -589,7 +591,7 @@
}
}
- Tree tree = this.getTree(tableId);
+ Tree tree = (Tree) datasourceParameters.get("tree");
boolean isOrdered = this.isOrdered(tree);
Long seqNo = null;
if (isOrdered) {
diff --git a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java
@@ -439,7 +439,9 @@
/**
* Updates the parent of a given node a returns its definition in a JSONObject
*/
- protected JSONObject moveNode(Map<String, String> parameters, String nodeId, String newParentId,
+ @Override
+ protected JSONObject moveNode(Map<String, String> parameters,
+ Map<String, Object> datasourceSpecificParams, String nodeId, String newParentId,
String prevNodeId, String nextNodeId) throws Exception {
String referencedTableId = parameters.get("referencedTableId");
diff --git a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDataSourceForAccountTree.java b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDataSourceForAccountTree.java
new file mode 100644
--- /dev/null
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDataSourceForAccountTree.java
@@ -0,0 +1,44 @@
+/*
+ *************************************************************************
+ * 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) 2016 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.service.datasource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.utility.Tree;
+import org.openbravo.model.financialmgmt.accounting.coa.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TreeDataSourceForAccountTree extends ADTreeDatasourceService {
+ private static final Logger logger = LoggerFactory.getLogger(TreeDataSourceForAccountTree.class);
+
+ @Override
+ protected Map<String, Object> getDatasourceSpecificParams(Map<String, String> parameters) {
+ Map<String, Object> datasourceParams = new HashMap<String, Object>();
+ String accountTreeId = parameters.get("@FinancialMgmtElement.id@");
+ Element element = OBDal.getInstance().get(Element.class, accountTreeId);
+ Tree tree = element.getTree();
+ datasourceParams.put("tree", tree);
+ return datasourceParams;
+ }
+
+}
diff --git a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java
@@ -810,10 +810,12 @@
// nodes
String prevNodeId = parameters.get("prevNodeId");
String nextNodeId = parameters.get("nextNodeId");
+ Map<String, Object> datasourceSpecificParams = this.getDatasourceSpecificParams(parameters);
if (jsonObject.has("data")) {
JSONObject data = jsonObject.getJSONObject("data");
JSONObject oldValues = jsonObject.getJSONObject("oldValues");
- response = processNodeMovement(parameters, data, oldValues, prevNodeId, nextNodeId);
+ response = processNodeMovement(parameters, datasourceSpecificParams, data, oldValues,
+ prevNodeId, nextNodeId);
} else if (jsonObject.has("transaction")) {
// If more than one nodes are moved at the same time, we need to handle a transaction
JSONArray jsonResultArray = new JSONArray();
@@ -823,8 +825,8 @@
JSONObject operation = operations.getJSONObject(i);
JSONObject data = operation.getJSONObject("data");
JSONObject oldValues = operation.getJSONObject("oldValues");
- jsonResultArray.put(processNodeMovement(parameters, data, oldValues, prevNodeId,
- nextNodeId));
+ jsonResultArray.put(processNodeMovement(parameters, datasourceSpecificParams, data,
+ oldValues, prevNodeId, nextNodeId));
}
response = JSON_PREFIX + jsonResultArray.toString() + JSON_SUFFIX;
}
@@ -848,8 +850,9 @@
* new position of the node amount its peers
* @throws Exception
*/
- private String processNodeMovement(Map<String, String> parameters, JSONObject data,
- JSONObject oldValues, String prevNodeId, String nextNodeId) throws Exception {
+ private String processNodeMovement(Map<String, String> parameters,
+ Map<String, Object> datasourceSpecificParams, JSONObject data, JSONObject oldValues,
+ String prevNodeId, String nextNodeId) throws Exception {
String nodeId = data.getString("id");
String newParentId = data.getString("parentId");
@@ -896,7 +899,8 @@
// Move it
if (success) {
- JSONObject updatedData = moveNode(parameters, nodeId, newParentId, prevNodeId, nextNodeId);
+ JSONObject updatedData = moveNode(parameters, datasourceSpecificParams, nodeId, newParentId,
+ prevNodeId, nextNodeId);
if (updatedData != null) {
dataResponse.put(updatedData);
} else {
@@ -924,8 +928,9 @@
return jsonResult.toString();
}
- protected abstract JSONObject moveNode(Map<String, String> parameters, String nodeId,
- String newParentId, String prevNodeId, String nextNodeId) throws Exception;
+ protected abstract JSONObject moveNode(Map<String, String> parameters,
+ Map<String, Object> datasourceSpecificParams, String nodeId, String newParentId,
+ String prevNodeId, String nextNodeId) throws Exception;
/**
* Exception thrown when an operation can not be done upon a node that has several parents
diff --git a/src-db/database/sourcedata/AD_FIELD.xml b/src-db/database/sourcedata/AD_FIELD.xml
--- a/src-db/database/sourcedata/AD_FIELD.xml
+++ b/src-db/database/sourcedata/AD_FIELD.xml
@@ -179195,6 +179195,34 @@
<!--033280F204304D60943059571C5B01B8--> <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
<!--033280F204304D60943059571C5B01B8--></AD_FIELD>
+<!--035805A5AEF3496B82405CAB73175EBD--><AD_FIELD>
+<!--035805A5AEF3496B82405CAB73175EBD--> <AD_FIELD_ID><![CDATA[035805A5AEF3496B82405CAB73175EBD]]></AD_FIELD_ID>
+<!--035805A5AEF3496B82405CAB73175EBD--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--035805A5AEF3496B82405CAB73175EBD--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--035805A5AEF3496B82405CAB73175EBD--> <NAME><![CDATA[Table]]></NAME>
+<!--035805A5AEF3496B82405CAB73175EBD--> <DESCRIPTION><![CDATA[A dictionary table used for this tab that points to the database table.]]></DESCRIPTION>
+<!--035805A5AEF3496B82405CAB73175EBD--> <HELP><![CDATA[The Table indicates the table in which a field or fields reside.]]></HELP>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--035805A5AEF3496B82405CAB73175EBD--> <AD_TAB_ID><![CDATA[243]]></AD_TAB_ID>
+<!--035805A5AEF3496B82405CAB73175EBD--> <AD_COLUMN_ID><![CDATA[2D852A64DD7D4758AAA80AFB90FB5A84]]></AD_COLUMN_ID>
+<!--035805A5AEF3496B82405CAB73175EBD--> <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--035805A5AEF3496B82405CAB73175EBD--> <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--035805A5AEF3496B82405CAB73175EBD--> <SEQNO><![CDATA[80]]></SEQNO>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--035805A5AEF3496B82405CAB73175EBD--> <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--035805A5AEF3496B82405CAB73175EBD--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--035805A5AEF3496B82405CAB73175EBD--> <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--035805A5AEF3496B82405CAB73175EBD--> <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--035805A5AEF3496B82405CAB73175EBD--> <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--035805A5AEF3496B82405CAB73175EBD--> <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--035805A5AEF3496B82405CAB73175EBD--></AD_FIELD>
+
<!--0358AC4E992D4CC49CF6DE3E076C94E1--><AD_FIELD>
<!--0358AC4E992D4CC49CF6DE3E076C94E1--> <AD_FIELD_ID><![CDATA[0358AC4E992D4CC49CF6DE3E076C94E1]]></AD_FIELD_ID>
<!--0358AC4E992D4CC49CF6DE3E076C94E1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src-db/database/sourcedata/AD_TABLE_TREE.xml b/src-db/database/sourcedata/AD_TABLE_TREE.xml
--- a/src-db/database/sourcedata/AD_TABLE_TREE.xml
+++ b/src-db/database/sourcedata/AD_TABLE_TREE.xml
@@ -128,7 +128,8 @@
<!--8E70E92119184AB69AE031A72BF6BF9E--> <NAME><![CDATA[Element Value]]></NAME>
<!--8E70E92119184AB69AE031A72BF6BF9E--> <ISPARENTSELECTIONALLOWED><![CDATA[Y]]></ISPARENTSELECTIONALLOWED>
<!--8E70E92119184AB69AE031A72BF6BF9E--> <ISORDERED><![CDATA[Y]]></ISORDERED>
-<!--8E70E92119184AB69AE031A72BF6BF9E--> <TREESTRUCTURE><![CDATA[ADTree]]></TREESTRUCTURE>
+<!--8E70E92119184AB69AE031A72BF6BF9E--> <TREESTRUCTURE><![CDATA[Custom]]></TREESTRUCTURE>
+<!--8E70E92119184AB69AE031A72BF6BF9E--> <OBSERDS_DATASOURCE_ID><![CDATA[76AAAC09921B42678F4155A2218A66ED]]></OBSERDS_DATASOURCE_ID>
<!--8E70E92119184AB69AE031A72BF6BF9E--> <ISHANDLENODESMANUALLY><![CDATA[Y]]></ISHANDLENODESMANUALLY>
<!--8E70E92119184AB69AE031A72BF6BF9E--> <ISMAINTREE><![CDATA[Y]]></ISMAINTREE>
<!--8E70E92119184AB69AE031A72BF6BF9E--> <NODEDELETIONPOLICY><![CDATA[RCN]]></NODEDELETIONPOLICY>
diff --git a/src-db/database/sourcedata/OBSERDS_DATASOURCE.xml b/src-db/database/sourcedata/OBSERDS_DATASOURCE.xml
--- a/src-db/database/sourcedata/OBSERDS_DATASOURCE.xml
+++ b/src-db/database/sourcedata/OBSERDS_DATASOURCE.xml
@@ -53,6 +53,19 @@
<!--6654D607F650425A9DFF7B6961D54920--> <IDFKFILTERING><![CDATA[Y]]></IDFKFILTERING>
<!--6654D607F650425A9DFF7B6961D54920--></OBSERDS_DATASOURCE>
+<!--76AAAC09921B42678F4155A2218A66ED--><OBSERDS_DATASOURCE>
+<!--76AAAC09921B42678F4155A2218A66ED--> <OBSERDS_DATASOURCE_ID><![CDATA[76AAAC09921B42678F4155A2218A66ED]]></OBSERDS_DATASOURCE_ID>
+<!--76AAAC09921B42678F4155A2218A66ED--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--76AAAC09921B42678F4155A2218A66ED--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--76AAAC09921B42678F4155A2218A66ED--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--76AAAC09921B42678F4155A2218A66ED--> <NAME><![CDATA[TreeDataSourceForAccountTree]]></NAME>
+<!--76AAAC09921B42678F4155A2218A66ED--> <CLASSNAME><![CDATA[org.openbravo.service.datasource.TreeDataSourceForAccountTree]]></CLASSNAME>
+<!--76AAAC09921B42678F4155A2218A66ED--> <OBCLKER_TEMPLATE_ID><![CDATA[2BAD445C2A0343C58E455F9BD379C690]]></OBCLKER_TEMPLATE_ID>
+<!--76AAAC09921B42678F4155A2218A66ED--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--76AAAC09921B42678F4155A2218A66ED--> <USEASTABLEDATAORIGIN><![CDATA[N]]></USEASTABLEDATAORIGIN>
+<!--76AAAC09921B42678F4155A2218A66ED--> <IDFKFILTERING><![CDATA[Y]]></IDFKFILTERING>
+<!--76AAAC09921B42678F4155A2218A66ED--></OBSERDS_DATASOURCE>
+
<!--90034CAE96E847D78FBEF6D38CB1930D--><OBSERDS_DATASOURCE>
<!--90034CAE96E847D78FBEF6D38CB1930D--> <OBSERDS_DATASOURCE_ID><![CDATA[90034CAE96E847D78FBEF6D38CB1930D]]></OBSERDS_DATASOURCE_ID>
<!--90034CAE96E847D78FBEF6D38CB1930D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
|