Commit 4b138176 authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

display some info if newer revision is available, basic list of published revisions (w.i.p.).

related to #45
parent 5333eb03
......@@ -3,11 +3,14 @@ package info.textgrid.rep.browse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.TreeMap;
import javax.ws.rs.client.ClientBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
......@@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import info.textgrid.clients.tgcrud.CrudClientException;
import info.textgrid.namespaces.middleware.tgsearch.ResultType;
import info.textgrid.namespaces.middleware.tgsearch.Revisions;
import info.textgrid.rep.i18n.I18N;
import info.textgrid.rep.i18n.I18NProvider;
import info.textgrid.rep.markdown.MarkdownUtils;
......@@ -112,6 +116,9 @@ public class BrowseController {
handleMarkdown(model, id);
}
// add revisions info
listRevisions(model, id, metadata);
return "browse";
}
......@@ -278,6 +285,25 @@ public class BrowseController {
model.addAttribute("htmlContent", content);
}
private void listRevisions(Model model, String id, ResultType metadata) {
Revisions revisions = tgsearchClientService.listRevisions(id);
int displayRev = metadata.getObject().getGeneric().getGenerated().getRevision();
BigInteger latestRev = Collections.max(revisions.getRevision());
if(BigInteger.valueOf(displayRev).compareTo(latestRev) < 0) {
model.addAttribute("higherRevisionAvailable", true);
}
if(revisions.getRevision().size() > 0) {
TreeMap revmap = new TreeMap<BigInteger, String>();
String baseUri = id.substring(0, id.indexOf("."));
for(BigInteger rev : revisions.getRevision()) {
revmap.put(rev, baseUri + "." + rev);
}
model.addAttribute("revisions", revmap);
}
}
private boolean hasIiifManifest(String id) {
......
......@@ -11,6 +11,7 @@ import info.textgrid.clients.SearchClient;
import info.textgrid.namespaces.middleware.tgsearch.FacetResponse;
import info.textgrid.namespaces.middleware.tgsearch.Response;
import info.textgrid.namespaces.middleware.tgsearch.ResultType;
import info.textgrid.namespaces.middleware.tgsearch.Revisions;
@Service
public class TgsearchClientService {
......@@ -95,4 +96,8 @@ public class TgsearchClientService {
}
public Revisions listRevisions(String id) {
return searchClient.infoQuery().listRevisions(id);
}
}
......@@ -86,6 +86,7 @@ collection-citation-heading=Zitationsvorschlag für diese Kollektion
aggregation-citation-heading=Zitationsvorschlag für diese Aggregation
work-citation-heading=Zitationsvorschlag für dieses Werk
item-citation-heading=Zitationsvorschlag für dieses Objekt
revisions=Revisionen
#usersettings.jsp
usersettings=Persönliche Einstellungen
......
......@@ -86,6 +86,7 @@ collection-citation-heading=Citation Suggestion for this Collection
aggregation-citation-heading=Citation Suggestion for this Aggregation
work-citation-heading=Citation Suggestion for this Work
item-citation-heading=Citation Suggestion for this Object
revisions=Revisions
#usersettings.jsp
usersettings=Personal Settings
......
......@@ -36,6 +36,20 @@
<aside class="tgrep sidebar">
<c:if test="${higherRevisionAvailable}">
<section class="tgrep sidebar_panel">
There is a higher revision available!
</section>
</c:if>
<c:if test="${revisions.size() > 0}">
<section class="tgrep sidebar_panel">
<h3 class="tgrep sidebar_subheading">${i18n['revisions']}</h3>
<c:forEach items="${revisions}" var="rev">
<a href="/browse/${rev.value}">${rev.key}</a>
</c:forEach>
</section>
</c:if>
<section class="tgrep sidebar_panel">
<h3 class="tgrep sidebar_subheading">${i18n['metadata']}</h3>
<!-- TODO: each for agent, pid, etc -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment