Package org.openbravo.service.datasource
Class ADTreeDatasourceService
- java.lang.Object
-
- org.openbravo.service.datasource.BaseDataSourceService
-
- org.openbravo.service.datasource.DefaultDataSourceService
-
- org.openbravo.service.datasource.TreeDatasourceService
-
- org.openbravo.service.datasource.ADTreeDatasourceService
-
- All Implemented Interfaces:
DataSourceService
- Direct Known Subclasses:
AccountTreeDatasourceService
public class ADTreeDatasourceService extends TreeDatasourceService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openbravo.service.datasource.TreeDatasourceService
TreeDatasourceService.CycleInHierarchyException, TreeDatasourceService.MultipleParentsException, TreeDatasourceService.TooManyTreeNodesException
-
-
Field Summary
-
Fields inherited from class org.openbravo.service.datasource.TreeDatasourceService
ROOT_NODE_CLIENT, ROOT_NODE_DB
-
-
Constructor Summary
Constructors Constructor Description ADTreeDatasourceService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addNewNode(org.codehaus.jettison.json.JSONObject bobProperties)
Classes that extend TreeDatasourceService this method must implement this method to handle the creation of a node in a tree tableprotected void
deleteNode(org.codehaus.jettison.json.JSONObject bobProperties)
Classes that extend TreeDatasourceService this method must implement this method to handle the deletion of a node in a tree tableprotected org.codehaus.jettison.json.JSONArray
fetchFilteredNodesForTreesWithMultiParentNodes(Map<String,String> parameters, Map<String,Object> datasourceParameters, TableTree tableTree, List<String> filteredNodes, String hqlTreeWhereClause, String hqlTreeWhereClauseRootNodes, boolean allowNotApplyingWhereClauseToChildren)
protected org.codehaus.jettison.json.JSONArray
fetchNodeChildren(Map<String,String> parameters, Map<String,Object> datasourceParameters, String parentId, String hqlWhereClause, String hqlWhereClauseRootNodes)
protected Map<String,Object>
getDatasourceSpecificParams(Map<String,String> parameters)
protected org.codehaus.jettison.json.JSONObject
getJSONObjectByNodeId(Map<String,String> parameters, Map<String,Object> datasourceParameters, String nodeId)
protected org.codehaus.jettison.json.JSONObject
getJSONObjectByRecordId(Map<String,String> parameters, Map<String,Object> datasourceParameters, String bobId)
protected TableTree
getTableTree(Table table)
Obtains the ADTree TableTree associated with the tableprotected org.codehaus.jettison.json.JSONObject
moveNode(Map<String,String> parameters, String nodeId, String newParentId, String prevNodeId, String nextNodeId)
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 orderedprotected boolean
nodeConformsToWhereClause(TableTree tableTree, String nodeId, String hqlWhereClause)
Checks if the provided node complies with the hql where clauseprotected boolean
nodeHasChildren(Entity entity, String nodeId, String hqlWhereClause)
Classes that extend TreeDatasourceService this method must implement this method to handle the check if a node has children in a tree tableint
reparentChildrenOfDeletedNode(Tree tree, String newParentId, String deletedNodeId)
In the given tree, reparents the children of deletedNodeId, change it to newParentId-
Methods inherited from class org.openbravo.service.datasource.TreeDatasourceService
add, addNodeCommonAttributes, checkEditDatasourceAccess, checkFetchDatasourceAccess, fetch, getEntity, getParentRecordIdFromCriteria, remove, substituteParameters, update
-
Methods inherited from class org.openbravo.service.datasource.DefaultDataSourceService
add, addFetchParameters, fetch, fetch, getDataSourceProperties, getInitialProperties, remove
-
Methods inherited from class org.openbravo.service.datasource.BaseDataSourceService
getDataSource, getDataUrl, getEntity, getName, getTemplate, getWhereAndFilterClause, getWhereClause, handleExceptionUnsecuredDSAccess, setDataSource, setDataUrl, setEntity, setName, setWhereClause
-
-
-
-
Method Detail
-
addNewNode
protected void addNewNode(org.codehaus.jettison.json.JSONObject bobProperties)
Description copied from class:TreeDatasourceService
Classes that extend TreeDatasourceService this method must implement this method to handle the creation of a node in a tree table- Specified by:
addNewNode
in classTreeDatasourceService
-
deleteNode
protected void deleteNode(org.codehaus.jettison.json.JSONObject bobProperties)
Description copied from class:TreeDatasourceService
Classes that extend TreeDatasourceService this method must implement this method to handle the deletion of a node in a tree table- Specified by:
deleteNode
in classTreeDatasourceService
-
getTableTree
protected TableTree getTableTree(Table table)
Obtains the ADTree TableTree associated with the table- Parameters:
table
- table whose ADTree TableTree will be returned- Returns:
- the ADTree TableTree associated with the given table
-
reparentChildrenOfDeletedNode
public int reparentChildrenOfDeletedNode(Tree tree, String newParentId, String deletedNodeId)
In the given tree, reparents the children of deletedNodeId, change it to newParentId- Returns:
- The number of nodes that have been reparented
-
fetchNodeChildren
protected org.codehaus.jettison.json.JSONArray fetchNodeChildren(Map<String,String> parameters, Map<String,Object> datasourceParameters, String parentId, String hqlWhereClause, String hqlWhereClauseRootNodes) throws org.codehaus.jettison.json.JSONException, TreeDatasourceService.TooManyTreeNodesException
- Specified by:
fetchNodeChildren
in classTreeDatasourceService
- Parameters:
parameters
- a map with the parameters of the requestdatasourceParameters
- specific datasource parameters obtained using methodgetDatasourceSpecificParams(Map)
parentId
- id of the node whose children are to be retrievedhqlWhereClause
- hql where clase of the tab/selectorhqlWhereClauseRootNodes
- hql where clause that define what nodes are roots- Returns:
- A JSONArray containing all the children of the given node
- Throws:
org.codehaus.jettison.json.JSONException
TreeDatasourceService.TooManyTreeNodesException
- if the number of returned nodes were to be too high
-
nodeHasChildren
protected boolean nodeHasChildren(Entity entity, String nodeId, String hqlWhereClause)
Description copied from class:TreeDatasourceService
Classes that extend TreeDatasourceService this method must implement this method to handle the check if a node has children in a tree table- Overrides:
nodeHasChildren
in classTreeDatasourceService
-
moveNode
protected org.codehaus.jettison.json.JSONObject moveNode(Map<String,String> parameters, String nodeId, String newParentId, String prevNodeId, String nextNodeId) throws Exception
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- Specified by:
moveNode
in classTreeDatasourceService
- Throws:
Exception
-
getJSONObjectByNodeId
protected org.codehaus.jettison.json.JSONObject getJSONObjectByNodeId(Map<String,String> parameters, Map<String,Object> datasourceParameters, String nodeId) throws TreeDatasourceService.MultipleParentsException
- Specified by:
getJSONObjectByNodeId
in classTreeDatasourceService
- Parameters:
parameters
- a map with the parameters of the requestdatasourceParameters
- specific datasource parameters obtained using methodTreeDatasourceService.getDatasourceSpecificParams(Map)
nodeId
- id of the tree node- Returns:
- returns a json object with the definition of a node give its node id
- Throws:
TreeDatasourceService.MultipleParentsException
-
getJSONObjectByRecordId
protected org.codehaus.jettison.json.JSONObject getJSONObjectByRecordId(Map<String,String> parameters, Map<String,Object> datasourceParameters, String bobId)
- Specified by:
getJSONObjectByRecordId
in classTreeDatasourceService
- Parameters:
parameters
- a map with the parameters of the requestdatasourceParameters
- specific datasource parameters obtained using methodTreeDatasourceService.getDatasourceSpecificParams(Map)
bobId
- id of the tree node- Returns:
- returns a json object with the definition of a node give its record id
-
nodeConformsToWhereClause
protected boolean nodeConformsToWhereClause(TableTree tableTree, String nodeId, String hqlWhereClause)
Checks if the provided node complies with the hql where clause- Specified by:
nodeConformsToWhereClause
in classTreeDatasourceService
- Parameters:
tableTree
- tableTree that defines the tree category that defines the treenodeId
- id of the node to be checkedhqlWhereClause
- hql where clause to be applied
-
fetchFilteredNodesForTreesWithMultiParentNodes
protected org.codehaus.jettison.json.JSONArray fetchFilteredNodesForTreesWithMultiParentNodes(Map<String,String> parameters, Map<String,Object> datasourceParameters, TableTree tableTree, List<String> filteredNodes, String hqlTreeWhereClause, String hqlTreeWhereClauseRootNodes, boolean allowNotApplyingWhereClauseToChildren) throws TreeDatasourceService.MultipleParentsException, TreeDatasourceService.TooManyTreeNodesException
-
getDatasourceSpecificParams
protected Map<String,Object> getDatasourceSpecificParams(Map<String,String> parameters)
- Specified by:
getDatasourceSpecificParams
in classTreeDatasourceService
-
-