Skip to content

Commit 9b5bdf1

Browse files
authored
Merge pull request #147 from glenrobson/ambigous_methods_fix
Fixing exception on empty manifest
2 parents d972b7d + 5bfced9 commit 9b5bdf1

File tree

6 files changed

+131
-114
lines changed

6 files changed

+131
-114
lines changed

.github/workflows/solr.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ jobs:
1515
distribution: 'temurin'
1616
cache: maven
1717
- name: Starting SOLR
18-
run: docker-compose -f docker/sas-solr/docker-compose.yml --project-directory . up -d solr
18+
run: mkdir solr-data && chmod 777 solr-data && docker-compose -f docker/sas-solr/docker-compose.yml --project-directory . up -d solr
19+
20+
- name: checking docker
21+
run: docker ps && docker logs sas_solr
1922

2023
- name: Wait for SOLR to start
21-
run: docker exec -t sas_solr /opt/docker-solr/scripts/wait-for-solr.sh --max-attempts 10 --wait-seconds 5 --solr-url http://0.0.0.0:8983/
24+
run: docker exec -t sas_solr /opt/docker-solr/scripts/wait-for-solr.sh --max-attempts 10 --wait-seconds 10 --solr-url http://0.0.0.0:8983/
2225

2326
- name: Run Tests
2427
run: export "config=solr.properties" && mvn test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ auth.json
1111
*auth.json
1212
node
1313
node_modules
14+
solr-data

docker/sas-solr/docker-compose.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ services:
99
- "8888:8080"
1010
solr:
1111
container_name: sas_solr
12-
image: "solr:latest"
12+
image: "solr:8"
1313
ports:
1414
- "8983:8983"
1515
volumes:
1616
- "./src/main/resources/solr:/tmp/config:ro"
17+
- "./solr-data:/var/solr/data"
1718
entrypoint:
1819
- bash
1920
- "-c"
20-
- "precreate-core testannotations /tmp/config; precreate-core annotations /tmp/config; exec solr -f"
21+
- "solr-precreate testannotations /tmp/config; solr-precreate annotations /tmp/config; exec solr -f"

src/main/java/uk/org/llgc/annotation/store/data/Manifest.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,19 @@ public void setURI(final String pURI) {
276276
*/
277277
public String getShortId() {
278278
if (_shortId == null || _shortId.isEmpty()) {
279-
if (_URI.endsWith("manifest.json")) {
279+
// Its no longer safe to use this NLW shortcut
280+
// as it fails the workbench:
281+
// https://glenrobson.github.io/workbench/manifests/projectmanifest.json"
282+
/*if (_URI.endsWith("manifest.json")) {
280283
String[] tURI = _URI.split("/");
281284
_shortId = tURI[tURI.length - 2];
282-
} else {
283-
try {
284-
_shortId = AnnotationUtils.getHash(_URI, "md5");
285-
} catch (IOException tExcpt) {
286-
tExcpt.printStackTrace();
287-
}
285+
} else {*/
286+
try {
287+
_shortId = AnnotationUtils.getHash(_URI, "md5");
288+
} catch (IOException tExcpt) {
289+
tExcpt.printStackTrace();
288290
}
291+
//}
289292
}
290293
return _shortId;
291294
}

src/main/webapp/manifest.xhtml

+106-101
Original file line numberDiff line numberDiff line change
@@ -25,120 +25,125 @@
2525
<h1 id="collectionName"><h:outputText value="#{manifest.label}" escape="false" /></h1>
2626
</div>
2727

28-
<div class="options">
29-
<div class="option_links">
30-
Manifest options:
31-
<a href="search.xhtml?iiif-content=#{manifest.URI}"><i class="fas fa-wrench"></i> Configure IIIF Search</a> |
32-
<a href="#" data-toggle="modal" data-target="#importAnnotations" onclick="hideMessage('importAnnoMessage');"><i class="fas fa-wrench"></i> Import Annotations</a> |
33-
<!-- <a href="#{manifest.URI}" target="_blank">Manifest Link</a>-->
28+
<c:if test="#{manifest != null}">
29+
<div class="options">
30+
<div class="option_links">
31+
Manifest options:
32+
<a href="search.xhtml?iiif-content=#{manifest.URI}"><i class="fas fa-wrench"></i> Configure IIIF Search</a> |
33+
<a href="#" data-toggle="modal" data-target="#importAnnotations" onclick="hideMessage('importAnnoMessage');"><i class="fas fa-wrench"></i> Import Annotations</a> |
34+
<!-- <a href="#{manifest.URI}" target="_blank">Manifest Link</a>-->
3435

35-
<ui:include src="WEB-INF/templates/content-state.xhtml">
36-
<ui:param name="url" value="#{manifest.URI}" />
37-
<ui:param name="description" value="Link to Manifest. Also draggable using IIIF Content State." />
38-
<ui:param name="mode" value="full" />
39-
</ui:include>
40-
</div>
41-
<div class="right_options">
42-
List: <a href="#" id="all" onClick="toggleAnnotated(this)">all</a> | <a id="annotated" class="selected" href="#" onClick="toggleAnnotated(this)">annotated</a>
36+
<ui:include src="WEB-INF/templates/content-state.xhtml">
37+
<ui:param name="url" value="#{manifest.URI}" />
38+
<ui:param name="description" value="Link to Manifest. Also draggable using IIIF Content State." />
39+
<ui:param name="mode" value="full" />
40+
</ui:include>
41+
</div>
42+
<div class="right_options">
43+
List: <a href="#" id="all" onClick="toggleAnnotated(this)">all</a> | <a id="annotated" class="selected" href="#" onClick="toggleAnnotated(this)">annotated</a>
44+
</div>
4345
</div>
44-
</div>
45-
<hr/>
46-
<c:set var="canvases" value="#{storeService.listAnnoPages(manifest)}" />
47-
<ul id="canvases" class="media-list">
48-
<c:forEach items="#{canvases}" var="annoPage" varStatus="iterMetadata">
49-
<c:set var="short_id" value="#{annoPage.canvas.shortId}" />
50-
<c:set var="isEmpty" value="#{annoPage.count == 0}" />
51-
<c:set var="className" value="canvas" />
52-
<c:if test="#{not isEmpty}">
53-
<c:set var="className" value="anno_canvas" />
54-
</c:if>
55-
<li class="manifestSummary #{className}" id="shortId">
56-
<div class="media-header-div">
57-
<h3 class="box_type">
58-
<c:if test="#{not isEmpty}">
59-
Annotated Canvas
60-
</c:if>
61-
<c:if test="#{isEmpty}">
62-
Canvas
63-
</c:if>
64-
</h3>
65-
</div>
66-
<div class="media-heading">
67-
<h5>
68-
<c:if test="#{not empty annoPage.canvas.label}">
69-
Label: <h:outputText value="#{annoPage.canvas.label}"/>
70-
</c:if>
71-
<c:if test="#{empty annoPage.canvas.label}">
72-
Label: unlabelled
73-
</c:if>
74-
</h5>
75-
</div>
76-
<div class="media">
77-
<a class="align-self-center" href="annotations.xhtml?iiif-content=#{annoPage.canvas.id}">
78-
<img class="align-self-center mr-3 media-img canvas_thum" data-canvas-id="#{annoPage.canvas.id}" src=""/>
79-
</a>
80-
<div class="media-body">
81-
<a href="view.xhtml?collection=#{collection.id}&amp;manifest=#{manifest.URI}&amp;canvas=#{annoPage.canvas.id}" class="btn btn-primary mb-2" title="Open manifest for editing"><i class="far fa-edit"></i> Annotate this page</a>
82-
<c:if test="#{not isEmpty}">
83-
<a href="annotations.xhtml?iiif-content=#{annoPage.canvas.id}&amp;collection=#{request.getParameter('collection')}&amp;manifest=#{param['iiif-content']}" class="btn btn-secondary mb-2" ><i class="fas fa-list"></i> List Annotations (<h:outputText value="#{annoPage.count}"/>)</a>
84-
</c:if>
46+
<hr/>
47+
<c:set var="canvases" value="#{storeService.listAnnoPages(manifest)}" />
48+
<ul id="canvases" class="media-list">
49+
<c:forEach items="#{canvases}" var="annoPage" varStatus="iterMetadata">
50+
<c:set var="short_id" value="#{annoPage.canvas.shortId}" />
51+
<c:set var="isEmpty" value="#{annoPage.count == 0}" />
52+
<c:set var="className" value="canvas" />
53+
<c:if test="#{not isEmpty}">
54+
<c:set var="className" value="anno_canvas" />
55+
</c:if>
56+
<li class="manifestSummary #{className}" id="shortId">
57+
<div class="media-header-div">
58+
<h3 class="box_type">
59+
<c:if test="#{not isEmpty}">
60+
Annotated Canvas
61+
</c:if>
62+
<c:if test="#{isEmpty}">
63+
Canvas
64+
</c:if>
65+
</h3>
66+
</div>
67+
<div class="media-heading">
68+
<h5>
69+
<c:if test="#{not empty annoPage.canvas.label}">
70+
Label: <h:outputText value="#{annoPage.canvas.label}"/>
71+
</c:if>
72+
<c:if test="#{empty annoPage.canvas.label}">
73+
Label: unlabelled
74+
</c:if>
75+
</h5>
76+
</div>
77+
<div class="media">
78+
<a class="align-self-center" href="annotations.xhtml?iiif-content=#{annoPage.canvas.id}">
79+
<img class="align-self-center mr-3 media-img canvas_thum" data-canvas-id="#{annoPage.canvas.id}" src=""/>
80+
</a>
81+
<div class="media-body">
82+
<a href="view.xhtml?collection=#{collection.id}&amp;manifest=#{manifest.URI}&amp;canvas=#{annoPage.canvas.id}" class="btn btn-primary mb-2" title="Open manifest for editing"><i class="far fa-edit"></i> Annotate this page</a>
83+
<c:if test="#{not isEmpty}">
84+
<a href="annotations.xhtml?iiif-content=#{annoPage.canvas.id}&amp;collection=#{request.getParameter('collection')}&amp;manifest=#{param['iiif-content']}" class="btn btn-secondary mb-2" ><i class="fas fa-list"></i> List Annotations (<h:outputText value="#{annoPage.count}"/>)</a>
85+
</c:if>
8586

86-
<p></p><p></p>
87-
<div id="actionBar">
88-
<span>
89-
<c:if test="#{not isEmpty}">
90-
<a class="actionLink" href="annotations/#{user.shortId}/#{short_id}.json" download="#{short_id}.json">Download annotations</a> |
91-
<a class="actionLink" href="#" data-count="#{annoPage.count}" data-canvas-id="#{annoPage.canvas.id}" data-mode="remove_annotations" data-manifest="#{param['iiif-content']}" data-collection="#{param['collection']}" onClick="showConfirm(event); return false;">Remove annotations</a>
92-
</c:if>
93-
</span>
87+
<p></p><p></p>
88+
<div id="actionBar">
89+
<span>
90+
<c:if test="#{not isEmpty}">
91+
<a class="actionLink" href="annotations/#{user.shortId}/#{short_id}.json" download="#{short_id}.json">Download annotations</a> |
92+
<a class="actionLink" href="#" data-count="#{annoPage.count}" data-canvas-id="#{annoPage.canvas.id}" data-mode="remove_annotations" data-manifest="#{param['iiif-content']}" data-collection="#{param['collection']}" onClick="showConfirm(event); return false;">Remove annotations</a>
93+
</c:if>
94+
</span>
95+
</div>
9496
</div>
9597
</div>
96-
</div>
97-
</li>
98-
</c:forEach>
99-
</ul>
98+
</li>
99+
</c:forEach>
100+
</ul>
100101

101-
<script>
102-
let canvas_ids = document.getElementsByClassName("canvas_thum");
103-
fetch('#{manifest.URI}')
104-
.then(response => response.json())
105-
.then(function(manifest) {
106-
for (let thumb of canvas_ids) {
107-
let url = getCanvasThumbnail(manifest, thumb.dataset.canvasId, 0, 100);
108-
thumb.src = url;
109-
};
110-
});
102+
<script>
103+
let canvas_ids = document.getElementsByClassName("canvas_thum");
104+
fetch('#{manifest.URI}')
105+
.then(response => response.json())
106+
.then(function(manifest) {
107+
for (let thumb of canvas_ids) {
108+
let url = getCanvasThumbnail(manifest, thumb.dataset.canvasId, 0, 100);
109+
thumb.src = url;
110+
};
111+
});
111112

112-
if (document.getElementsByClassName("anno_canvas").length === 0) {
113-
toggleAnnotated(document.getElementById("all"));
114-
}
113+
if (document.getElementsByClassName("anno_canvas").length === 0) {
114+
toggleAnnotated(document.getElementById("all"));
115+
}
115116

116-
function toggleAnnotated(link) {
117-
let mode = "";
118-
if (link.id === "all") {
119-
link.className = "selected";
117+
function toggleAnnotated(link) {
118+
let mode = "";
119+
if (link.id === "all") {
120+
link.className = "selected";
120121

121-
let annotatedLink = document.getElementById("annotated");
122-
annotatedLink.className = "";
122+
let annotatedLink = document.getElementById("annotated");
123+
annotatedLink.className = "";
123124

124-
mode = "block";
125-
} else {
126-
link.className = "selected";
125+
mode = "block";
126+
} else {
127+
link.className = "selected";
127128

128-
let annotatedLink = document.getElementById("all");
129-
annotatedLink.className = "";
129+
let annotatedLink = document.getElementById("all");
130+
annotatedLink.className = "";
130131

131-
mode = "none";
132+
mode = "none";
133+
}
134+
let canvases = document.getElementsByClassName("canvas");
135+
Array.prototype.forEach.call(canvases, function (canvas) {
136+
canvas.style.display = mode;
137+
})
132138
}
133-
let canvases = document.getElementsByClassName("canvas");
134-
Array.prototype.forEach.call(canvases, function (canvas) {
135-
canvas.style.display = mode;
136-
})
137-
}
138-
139-
</script>
140-
<ui:include src="WEB-INF/templates/dialogues/importAnnotations.xhtml"/>
141-
<ui:include src="WEB-INF/templates/dialogues/confirm.xhtml"/>
139+
140+
</script>
141+
<ui:include src="WEB-INF/templates/dialogues/importAnnotations.xhtml"/>
142+
<ui:include src="WEB-INF/templates/dialogues/confirm.xhtml"/>
143+
</c:if>
144+
<c:if test="#{manifest == null}">
145+
<p>It looks like there was a problem finding your manifest. Please add it again in the <a class="back_header" href="collections.xhtml?collection=#{param['collection']}">Collections screen.</a></p>
146+
</c:if>
142147
</ui:define>
143148
</ui:composition>
144149
</html>

src/main/webapp/stats/manifest.xhtml

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@
2828
</div>
2929
</main>
3030
<p:panel header="Percentage of items transcribed">
31-
<p:chart type="pie" model="#{statsService.getPercentAnnotated(tManifest)}" style="height:300px; width:500px;"/>
31+
<c:if test="#{tManifest != null}">
32+
<p:chart type="pie" model="#{statsService.getPercentAnnotated(tManifest)}" style="height:300px; width:500px;"/>
33+
</c:if>
3234
</p:panel>
3335

3436
<p:panel header="Annotations per Canvas">
35-
<p:chart type="bar" model="#{statsService.getManifestAnnoCount(tManifest)}" style="height500px;"/>
37+
<c:if test="#{tManifest != null}">
38+
<p:chart type="bar" model="#{statsService.getManifestAnnoCount(tManifest)}" style="height500px;"/>
39+
</c:if>
3640
</p:panel>
3741
</ui:define>
3842
</ui:composition>

0 commit comments

Comments
 (0)