use of pl.x3E.adInterface.ADMenuDocument in project adempiere by adempiere.
the class ADServiceImpl method getADMenu.
public ADMenuDocument getADMenu(int AD_Role_ID) throws XFireFault {
authenticate(webServiceName, "getADMenu");
ADMenuDocument res = ADMenuDocument.Factory.newInstance();
ADMenuItem menu = res.addNewADMenu();
menu.setName("Menu");
menu.setType("Summary");
AD_Role_ID = Integer.parseInt(m_cs.getM_ctx().getProperty("#AD_Role_ID"));
// Load Menu Structure ----------------------
int AD_Tree_ID = DB.getSQLValue(null, "SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)" + "FROM AD_ClientInfo ci" + " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) " + "WHERE AD_Role_ID=?", AD_Role_ID);
if (AD_Tree_ID <= 0)
// Menu
AD_Tree_ID = 10;
//log.fine("doPost - AD_Tree_ID=" + AD_Tree_ID + " - " + Env.getAD_Language(wsc.ctx));
// Language set in WLogin
MTree tree = new MTree(m_cs.getM_ctx(), AD_Tree_ID, false, false, null);
// Trim tree
MTreeNode root = tree.getRoot();
Enumeration en = root.preorderEnumeration();
// menu.addNewItems();
ADMenuItemList itl = null;
//, it_last = null;
ADMenuItem it = menu;
Stack stack = new Stack();
while (en.hasMoreElements()) {
MTreeNode nd = (MTreeNode) en.nextElement();
if (nd.isTask() || nd.isWorkbench() || nd.isWorkFlow() || // Reset Cache - kills the server
nd.getNode_ID() == 383) {
MTreeNode parent = (MTreeNode) nd.getParent();
parent.remove(nd);
}
}
tree.trimTree();
// Print tree
StringBuffer buf = new StringBuffer();
StringBuffer barbuf = new StringBuffer();
en = root.preorderEnumeration();
int oldLevel = 0;
while (en.hasMoreElements()) {
MTreeNode nd = (MTreeNode) en.nextElement();
// Level
// 0 == root
int level = nd.getLevel();
if (level == 0)
continue;
//
while (oldLevel < level) {
if (itl != null)
stack.push(itl);
itl = it.addNewItems();
oldLevel++;
}
while (oldLevel > level) {
oldLevel--;
itl = (ADMenuItemList) stack.pop();
}
// Print Node
ADMenuItem it_last = printNode(nd, m_cs.getM_ctx(), itl);
if (nd.isSummary())
it = it_last;
//if(nd.isOnBar() && !nd.isSummary())
//barbuf.append(printNode(nd, m_cs.getM_ctx() ));
}
return res;
}
Aggregations