Start start with @param IDs to query
* @param allres contains the result set to recursive data (query alias ID PID)
* @param POS Prior---> Up or down
* @return
*/
public static list<map<string, object>> Gettree (arraylist<string> IDs,
List<map<string, object>> allres,string POS) {
List<map<string, object>> res=new arraylist<map<string,object>> ();
if ("Up". Equals (POS)) {
Res=tocreattreeup (Ids,allres,res);
}
if ("Down". Equals (POS)) {
Res=tocreattreedown (Ids,allres,res);
}
return res;
}
private static list<map<string, object>> tocreattreeup (arraylist<string> IDs,
List<map<string, object>> allres,list<map<string, object>> Res) {
arraylist<string> IDSs = new arraylist<string> ();
for (String id:ids) {
For (map<string, object> map:allres) {
if (Id.equals (Map.get ("id"). toString ())) {
Idss.add (Map.get ("PID"). toString ());
Res.add (map);
}
}
}
if (Idss.size ()!=0) {
ids = IDSs;
res = Tocreattreeup (ids,allres,res);
}
return res;
}
private static list<map<string, object>> Tocreattreedown (arraylist<string> IDs,
List<map<string, object>> allres,list<map<string, object>> Res) {
arraylist<string> IDSs = new arraylist<string> ();
for (String id:ids) {
For (map<string, object> map:allres) {
if (Id.equals (Map.get ("id"). toString ())) {
Res.add (map);
}
if (Id.equals (Map.get ("PID"). ToString ())) {
Idss.add (Map.get ("ID"). toString ());
}
}
}
if (Idss.size ()!=0) {
ids = IDSs;
res = Tocreattreedown (ids,allres,res);
}
return res;
}
MySQL implementation start with