changeset 77:985dcecba904

"show scans" link and indicator for all witnesses with digitalization (no check for public).
author casties
date Tue, 28 Jun 2016 16:18:49 -0400
parents 45b921e683d6
children 20c76ff72cf2
files src/main/java/de/mpiwg/itgroup/ismi/search/beans/DisplayBean.java src/main/java/de/mpiwg/itgroup/ismi/utils/templates/WitnessTemplate.java src/main/webapp/search/displayTitle.xhtml
diffstat 3 files changed, 32 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/search/beans/DisplayBean.java	Tue Jun 28 11:43:48 2016 -0400
+++ b/src/main/java/de/mpiwg/itgroup/ismi/search/beans/DisplayBean.java	Tue Jun 28 16:18:49 2016 -0400
@@ -7,7 +7,6 @@
 import javax.faces.model.SelectItem;
 
 import org.apache.log4j.Logger;
-import org.mpi.openmind.repository.bo.Attribute;
 import org.mpi.openmind.repository.bo.Entity;
 
 import de.mpiwg.itgroup.ismi.auxObjects.SelectItem0;
@@ -65,20 +64,24 @@
 			long startWitness = System.currentTimeMillis();
 			List<Entity> list = new ArrayList<Entity>();
 			List<Entity> allwits = getWrapper().getSourcesForTargetRelation(selectedTitleId, is_exemplar_of, WITNESS, -1);
-			for (Entity witness : allwits) {
-			    if (this.showWitnessesWithScans) {
-			        List<Entity> codices = getWrapper().getTargetsForSourceRelation(witness.getId(), is_part_of, CODEX, 1);
-			        Entity codex = codices.get(0);
-			        // TODO: look at DIGITALIZATION
-                    Attribute pub = getWrapper().getAttributeByName(codex.getId(), "public");
-                    if (pub == null || ! pub.getValue().equals("true")) {
-                        continue;
-                    }
-			    }
-				SelectItem0 item = new SelectItem0(witness.getId(), witness.getOwnValue() + " [" + witness.getId() + "]", true);
-				this.witnessItems.add(item);
-				list.add(witness);
-			}
+			boolean hasScans = false;
+            for (Entity witness : allwits) {
+                // get CODEX for WITNESS
+                List<Entity> codices = getWrapper().getTargetsForSourceRelation(witness.getId(), is_part_of, CODEX, 1);
+                Entity codex = codices.get(0);
+                // Attribute pub = getWrapper().getAttributeByName(codex.getId(), "public");
+                // if (pub == null || ! pub.getValue().equals("true")) {
+                // look at DIGITALIZATION
+                List<Entity> digis = getWrapper().getSourcesForTargetRelation(codex.getId(), is_digitalization_of, DIGITALIZATION, 1);
+                hasScans = !digis.isEmpty();
+                if (this.showWitnessesWithScans && !hasScans) {
+                    continue;
+                }
+                String witlabel = witness.getOwnValue() + " [" + witness.getId() + "]" + (hasScans ? "+S" : "");
+                SelectItem0 item = new SelectItem0(witness.getId(), witlabel, true);
+                this.witnessItems.add(item);
+                list.add(witness);
+            }
 			
 			if(list.size() > 0){
 				this.showWitness(list.get(0).getId());
--- a/src/main/java/de/mpiwg/itgroup/ismi/utils/templates/WitnessTemplate.java	Tue Jun 28 11:43:48 2016 -0400
+++ b/src/main/java/de/mpiwg/itgroup/ismi/utils/templates/WitnessTemplate.java	Tue Jun 28 16:18:49 2016 -0400
@@ -206,8 +206,7 @@
 				}
 				
 				//**** Getting the Codices
-				List<Entity> list = 
-						om.getTargetsForSourceRelation(witness.getId(), "is_part_of", "CODEX", 1);
+				List<Entity> list = om.getTargetsForSourceRelation(witness.getId(), "is_part_of", "CODEX", 1);
 				if (list.size() > 0) {
 					Entity codex = list.get(0);
 
@@ -217,11 +216,12 @@
 					}
 					
 					/*
-					 *  add scan viewer URL if codex is public
+					 *  add scan viewer URL 
 					 */
-					// TODO: use scans attribute if available?
-					Attribute pub = om.getAttributeByName(codex.getId(), "public");
-					if (pub != null && pub.getValue().equals("true")) {
+	                // look at DIGITALIZATION
+	                List<Entity> digis = om.getSourcesForTargetRelation(codex.getId(), "is_digitalization_of", "DIGITALIZATION", 1);
+					//Attribute pub = om.getAttributeByName(codex.getId(), "public");
+					if (!digis.isEmpty()) {
 						// FIXME: make viewer URL configurable
 						this.scanViewer = "/public/publicWitness.jsp?eid=" + this.id;
 					}
--- a/src/main/webapp/search/displayTitle.xhtml	Tue Jun 28 11:43:48 2016 -0400
+++ b/src/main/webapp/search/displayTitle.xhtml	Tue Jun 28 16:18:49 2016 -0400
@@ -281,6 +281,14 @@
 							</h:dataTable>
 						</h:panelGrid>
 
+                        <h:outputText value="Scans" />
+                        <h:outputLink rendered="#{!empty Session.displayTitle.witness.scanViewer}"
+                            value="#{request.contextPath}#{Session.displayTitle.witness.scanViewer}"
+                            target="_blank">
+                            See witness scans
+                        </h:outputLink>
+                        <h:outputText rendered="#{empty Session.displayTitle.witness.scanViewer}"/>
+
 						<h:outputText value="Notes" />
 						<h:outputText value="#{Session.displayTitle.witness.notes}" />