Mercurial > hg > AnnotationManagerN4J
comparison 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 |
comparison
equal
deleted
inserted
replaced
18:aafa3884b2c4 | 19:f0f55ab768c9 |
---|---|
32 public Representation doGetHTML(Representation entity){ | 32 public Representation doGetHTML(Representation entity){ |
33 Form form = getRequest().getResourceRef().getQueryAsForm(); | 33 Form form = getRequest().getResourceRef().getQueryAsForm(); |
34 // id from URI /annotations/groups/{id} | 34 // id from URI /annotations/groups/{id} |
35 String id = (String) getRequest().getAttributes().get("id"); | 35 String id = (String) getRequest().getAttributes().get("id"); |
36 logger.debug("group-id=" + id); | 36 logger.debug("group-id=" + id); |
37 String retString="<html><body>\n<h1>Groups</h1>\n<table>"; | 37 String result="<html><body>\n<h1>Groups</h1>\n<table>"; |
38 result += "<tr><th>id</th><th>name</th><th>uri</th></tr>"; | |
38 store = getAnnotationStore(); | 39 store = getAnnotationStore(); |
39 if (id == null) { | 40 if (id == null) { |
40 // list all groups | 41 // list all groups |
41 List<Group> groups = store.getGroups("*"); | 42 List<Group> groups = store.getGroups("uri", "*"); |
42 for (Group group : groups) { | 43 for (Group group : groups) { |
43 retString += String.format("<tr><td>uri=%s</td></tr>\n", group.getUri()); | 44 String groupLink = group.getId(); |
45 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()); | |
44 } | 46 } |
45 | 47 |
46 } | 48 } |
47 retString += "</table>\n</body>\n</html>"; | 49 result += "</table>\n</body>\n</html>"; |
48 | 50 |
49 logger.debug("sending:"); | 51 logger.debug("sending:"); |
50 logger.debug(retString); | 52 logger.debug(result); |
51 return new StringRepresentation(retString,MediaType.TEXT_HTML); | 53 return new StringRepresentation(result,MediaType.TEXT_HTML); |
52 } | 54 } |
53 | 55 |
54 protected AnnotationStore getAnnotationStore() { | 56 protected AnnotationStore getAnnotationStore() { |
55 if (store == null) { | 57 if (store == null) { |
56 ServletContext sc = (ServletContext) getContext().getServerDispatcher().getContext().getAttributes() | 58 store = ((BaseRestlet) getApplication()).getAnnotationStore(); |
57 .get("org.restlet.ext.servlet.ServletContext"); | |
58 logger.debug("Getting AnnotationStore from Context"); | |
59 store = (AnnotationStore) sc.getAttribute(BaseRestlet.ANNSTORE_KEY); | |
60 } | 59 } |
61 return store; | 60 return store; |
62 } | 61 } |
63 } | 62 } |