Mercurial > hg > AnnotationManagerN4J
changeset 95:acd44dfec9c8
added last update field for annotations in database.
author | casties |
---|---|
date | Tue, 10 Feb 2015 18:11:17 +0100 |
parents | fcb6fe10e08c |
children | 8fefa4651d00 |
files | src/main/java/de/mpiwg/itgroup/annotations/Annotation.java src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationResource.java |
diffstat | 3 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/Annotation.java Tue Feb 10 17:45:56 2015 +0100 +++ b/src/main/java/de/mpiwg/itgroup/annotations/Annotation.java Tue Feb 10 18:11:17 2015 +0100 @@ -97,6 +97,11 @@ protected String created; /** + * The last update date of this annotation. + */ + protected String updated; + + /** * The user or group that has admin permissions. * null means any user. */ @@ -373,7 +378,15 @@ this.created = created; } - /** + public String getUpdated() { + return updated; + } + + public void setUpdated(String updated) { + this.updated = updated; + } + + /** * @return the adminPermission */ public Actor getAdminPermission() {
--- a/src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java Tue Feb 10 17:45:56 2015 +0100 +++ b/src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java Tue Feb 10 18:11:17 2015 +0100 @@ -610,10 +610,18 @@ * creation date */ if (annot.getCreated() == null) { - // set creation date + // new - set creation date SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); String ct = format.format(Calendar.getInstance().getTime()); annot.setCreated(ct); + } else { + /* + * update date + */ + // not new - set last update date + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + String ct = format.format(Calendar.getInstance().getTime()); + annot.setUpdated(ct); } /*
--- a/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationResource.java Tue Feb 10 17:45:56 2015 +0100 +++ b/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationResource.java Tue Feb 10 18:11:17 2015 +0100 @@ -64,7 +64,7 @@ @Override protected void doInit() throws ResourceException { super.doInit(); - // id from URI /annotations/persons/{id} + // id from URI /annotations/annotation/{id} requestId = (String) getRequest().getAttributes().get("id"); logger.fine("annoation-id=" + requestId); // get store instance @@ -86,7 +86,7 @@ } /** - * GET with HTML content type. Shows the person. + * GET with HTML content type. Shows the annotation. * * @param entity * @return @@ -120,7 +120,7 @@ result += "</table>\n</form>\n</body>\n</html>"; */ } else { - // output person content + // output content result = "<html><body>\n<h1>Annotation</h1>\n"; result += String.format("<p><a href=\"%s\">All annotations</a></p>", this.getReference().getParentRef()); result += "<table>"; @@ -131,6 +131,8 @@ result += String.format("<tr><td><b>quote</b></td><td>%s</td></tr>\n", annotation.getQuote()); result += String.format("<tr><td><b>resource</b></td><td>%s</td></tr>\n", annotation.getResourceUri()); result += String.format("<tr><td><b>creator</b></td><td>%s</td></tr>\n", annotation.getCreatorName()); + result += String.format("<tr><td><b>created</b></td><td>%s</td></tr>\n", annotation.getCreated()); + result += String.format("<tr><td><b>updated</b></td><td>%s</td></tr>\n", annotation.getUpdated()); result += "</table>\n"; result += "<br/>\n"; result += "<table>";