ResultSet rset2 = null;
// retrieve functions...
Hashtable functions = new Hashtable();
ArrayList functionsPerNode = null;
ApplicationFunction f = null;
HashSet functionsAdded = new HashSet();
pstmt = conn.prepareStatement(
"select SYS06_FUNCTIONS.FUNCTION_CODE,SYS06_FUNCTIONS.IMAGE_NAME,SYS06_FUNCTIONS.METHOD_NAME,"+
"SYS18_FUNCTIONS_LINKS.PROGRESSIVE_HIE03,SYS10_TRANSLATIONS.DESCRIPTION,"+
"SYS07_ROLE_FUNCTIONS.CAN_INS,SYS07_ROLE_FUNCTIONS.CAN_UPD,SYS07_ROLE_FUNCTIONS.CAN_DEL,"+
"SYS06_FUNCTIONS.USE_COMPANY_CODE,SYS04_ROLES.PROGRESSIVE "+
"from SYS06_FUNCTIONS,SYS04_ROLES,SYS07_ROLE_FUNCTIONS,SYS14_USER_ROLES,SYS10_TRANSLATIONS,SYS18_FUNCTIONS_LINKS "+
"where SYS14_USER_ROLES.USERNAME_SYS03='"+username+"' and "+
"SYS18_FUNCTIONS_LINKS.FUNCTION_CODE_SYS06=SYS06_FUNCTIONS.FUNCTION_CODE and "+
"SYS14_USER_ROLES.PROGRESSIVE_SYS04=SYS04_ROLES.PROGRESSIVE and "+
"SYS04_ROLES.PROGRESSIVE=SYS07_ROLE_FUNCTIONS.PROGRESSIVE_SYS04 and "+
"SYS07_ROLE_FUNCTIONS.FUNCTION_CODE_SYS06=SYS06_FUNCTIONS.FUNCTION_CODE and "+
"SYS04_ROLES.ENABLED='Y' and "+
"SYS10_TRANSLATIONS.LANGUAGE_CODE='"+langId+"' and "+
"SYS10_TRANSLATIONS.PROGRESSIVE=SYS06_FUNCTIONS.PROGRESSIVE_SYS10 order by "+
"SYS18_FUNCTIONS_LINKS.PROGRESSIVE_HIE03,SYS18_FUNCTIONS_LINKS.POS_ORDER"
);
ResultSet rset = pstmt.executeQuery();
while(rset.next()) {
f = new ApplicationFunction(
rset.getString(5),
rset.getString(1),
rset.getString(2),
rset.getString(3)
);
functionsPerNode = (ArrayList)functions.get(new Integer(rset.getInt(4)));
if (functionsPerNode==null) {
functionsPerNode = new ArrayList();
functions.put(new Integer(rset.getInt(4)),functionsPerNode);
}
if (!functionsAdded.contains(new Integer(rset.getInt(4))+"-"+f.getFunctionId())) {
functionsAdded.add(new Integer(rset.getInt(4))+"-"+f.getFunctionId());
functionsPerNode.add(f);
}
}
pstmt.close();
// retrieve the whole tree...
DefaultTreeModel model = null;
pstmt = conn.prepareStatement(
"select HIE03_LEVELS.PROGRESSIVE,HIE03_LEVELS.PROGRESSIVE_HIE03,HIE03_LEVELS.LEV,SYS10_TRANSLATIONS.DESCRIPTION "+
"from HIE03_LEVELS,SYS10_TRANSLATIONS "+
"where HIE03_LEVELS.PROGRESSIVE = SYS10_TRANSLATIONS.PROGRESSIVE and "+
"SYS10_TRANSLATIONS.LANGUAGE_CODE='"+langId+"' and ENABLED='Y' and PROGRESSIVE_HIE04=2 "+
"order by LEV,PROGRESSIVE_HIE03,PROGRESSIVE"
);
rset = pstmt.executeQuery();
Hashtable currentLevelNodes = new Hashtable();
Hashtable newLevelNodes = new Hashtable();
int currentLevel = -1;
DefaultMutableTreeNode currentNode = null;
DefaultMutableTreeNode parentNode = null;
while(rset.next()) {
if (currentLevel!=rset.getInt(3)) {
// next level...
currentLevel = rset.getInt(3);
currentLevelNodes = newLevelNodes;
newLevelNodes = new Hashtable();
}
if (currentLevel==0) {
// prepare a tree model with the root node...
currentNode = new OpenSwingTreeNode();
model = new DefaultTreeModel(currentNode);
}
else {
currentNode = new ApplicationFunction(rset.getString(4),null);
parentNode = (DefaultMutableTreeNode)currentLevelNodes.get(new Integer(rset.getInt(2)));
parentNode.add(currentNode);
}