Some work on services

This commit is contained in:
Ziver Koc 2016-04-07 14:30:07 +02:00
parent fc093b3ab8
commit 8532b681ca
14 changed files with 152 additions and 131 deletions

View file

@ -66,6 +66,7 @@ public class WANavigation implements Iterable{
nav = new WANavigation(name);
nav.setParentNav(this);
subNav.add(nav);
sortSubNavs();
return nav;
}
/**
@ -82,6 +83,8 @@ public class WANavigation implements Iterable{
Collections.sort(subNav, new Comparator<WANavigation>() {
@Override
public int compare(WANavigation o1, WANavigation o2) {
if (o1.weight == o2.weight)
return o1.name.compareToIgnoreCase(o2.name);
return o1.weight - o2.weight;
}
});
@ -147,22 +150,7 @@ public class WANavigation implements Iterable{
return instance;
}
/**
* @param request A map of all url parameters sent from client
* @return a List of WANavigation objects depicting the navigation hierarchy for the
* requested page from the client. First entry will be the root navigation object.
*/
public static List<WANavigation> getBreadcrumb(Map<String, String> request) {
LinkedList list = new LinkedList();
if(request.containsKey(NAVIGATION_URL_KEY)){
WANavigation current = navMap.get(Integer.parseInt(request.get(NAVIGATION_URL_KEY)));
while(current != null){
list.addFirst(current);
current = current.parentNav;
}
}
return list;
}
public static WANavigation createRootNav(){
return new WANavigation(null);
@ -174,6 +162,33 @@ public class WANavigation implements Iterable{
return null;
}
/**
* @return the specific WANavigation object requested by client
*/
public static WANavigation getNavigation(Map<String, String> request) {
if(request.containsKey(NAVIGATION_URL_KEY))
return navMap.get(Integer.parseInt(request.get(NAVIGATION_URL_KEY)));
return null;
}
/**
* @param request A map of all url parameters sent from client
* @return a List of WANavigation objects depicting the navigation hierarchy for the
* requested page from the client. First entry will be the root navigation object.
*/
public static List<WANavigation> getBreadcrumb(Map<String, String> request) {
LinkedList list = new LinkedList();
WANavigation current = getNavigation(request);
if (current != null){
while(current != null){
list.addFirst(current);
current = current.parentNav;
}
}
return list;
}
public static class NavInstance{