diff src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotationStoreGroups.java @ 19:f0f55ab768c9

more work on HTML UI.
author casties
date Thu, 06 Sep 2012 19:02:59 +0200
parents aafa3884b2c4
children 1ac626309352
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotationStoreGroups.java	Wed Sep 05 18:05:54 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotationStoreGroups.java	Thu Sep 06 19:02:59 2012 +0200
@@ -34,29 +34,28 @@
         // id from URI /annotations/groups/{id}
         String id = (String) getRequest().getAttributes().get("id");
         logger.debug("group-id=" + id);
-        String retString="<html><body>\n<h1>Groups</h1>\n<table>";
+        String result="<html><body>\n<h1>Groups</h1>\n<table>";
+        result += "<tr><th>id</th><th>name</th><th>uri</th></tr>";
         store = getAnnotationStore();
         if (id == null) {
             // list all groups
-            List<Group> groups = store.getGroups("*");
+            List<Group> groups = store.getGroups("uri", "*");
             for (Group group : groups) {
-                retString += String.format("<tr><td>uri=%s</td></tr>\n", group.getUri());
+                String groupLink = group.getId();
+                result += String.format("<tr><td><a href=\"%s\">%s</a></td><td>%s</td><td>%s</td></tr>\n", groupLink, group.getId(), group.getName(), group.getUri());
             }
             
         }
-        retString += "</table>\n</body>\n</html>";
+        result += "</table>\n</body>\n</html>";
         
         logger.debug("sending:");
-        logger.debug(retString);
-        return new StringRepresentation(retString,MediaType.TEXT_HTML);
+        logger.debug(result);
+        return new StringRepresentation(result,MediaType.TEXT_HTML);
     }
 
     protected AnnotationStore getAnnotationStore() {
         if (store == null) {
-            ServletContext sc = (ServletContext) getContext().getServerDispatcher().getContext().getAttributes()
-                    .get("org.restlet.ext.servlet.ServletContext");
-            logger.debug("Getting AnnotationStore from Context");
-            store = (AnnotationStore) sc.getAttribute(BaseRestlet.ANNSTORE_KEY);
+            store = ((BaseRestlet) getApplication()).getAnnotationStore();
         }
         return store;
     }