/** assemble all the menus into a tree * @param classdtolist database query all menu * Menu list * @return list<classdto> */private list<classdto& Gt Assembleclasstree (list<classdto> classdtolist) {list<classdto> classtreelist = Null;if ( Commonutils.listnotnull (classdtolist)) {classtreelist = new arraylist<classdto> (); for (Classdto classDTO1: Classdtolist) {if (Classdto1.islevel1 ()) {This.setchildclass (classDTO1, classdtolist); Classtreelist.add (classDTO1) ;}}} return classtreelist;} /** Assemble the menu tree by recursive method * @param classdto * @param classdtolist * @return */private void Setchildclass (Classdto parentclassdto, L ist<classdto> classdtolist) {list<classdto> childclasslist = Parentclassdto.getchildlist (); if ( Childclasslist = = null) {childclasslist = new arraylist<classdto> ();p arentclassdto.setchildlist (childClassList );} for (Classdto childclassdto:classdtolist) {if (Parentclassdto.getidclass (). Equals (Childclassdto.getidparentclass () ) {Childclasslist.add (childclassdto); This.setchildclass (ChildclasSdto, classdtolist);}}}
/** gets the subset of ParentID under a recursive method * @param parentid Parent ID * @param allclasstree menu Tree Collection * @return */private list<classdto> g Etchildclassbyparentid (String parentid, list<classdto> allclasstree) {for (classdto classdto:allclasstree) {// If ParentID is found, all the sub-sections under this palette are returned with the IF (Classdto.getidclass (). Equals (ParentID)) {return classdto.getchildlist (); Otherwise, continue looking for else {list<classdto> childlist = Classdto.getchildlist (); if (Commonutils.listnotnull (childlist)) { Childlist = This.getchildclassbyparentid (ParentID, childlist); if (childlist! = null) {return childlist;} else {continue;}}} return null;}
/** * gives a tree recursively to its next leaf node * @param alltree tree * @param leafclasslist leaf node * @throws businessserviceexception * /private void Loopleafclasslistbytree (list<classdto> alltree, list<classdto> leafClassList) {if ( Commonutils.listnotnull (Alltree)) {for (classdto classdto:alltree) {if (Classdto.isleafclass ()) {Leafclasslist.add ( Classdto);} else {list<classdto> childclasslist = Classdto.getchildlist (); if (Commonutils.listnotnull (childClassList)) { This.loopleafclasslistbytree (Childclasslist, leafclasslist);}}}}
N-level menu recursive query