<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.utils.Sessions" %> <%@ page import="org.crosswire.data.DataObject" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.xml.XMLDataElement" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Feature" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ShelfInstance" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document.SearchFilter" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document.SearchFilter.FeatureCriteria" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Page" %> <%@ page import="org.crosswire.sword.keys.SWKey" %> <%@ page import="org.crosswire.sword.keys.VerseKey" %> <%@ page import="org.crosswire.sword.keys.ListKey" %> <%@ page import="java.util.List" %> <%@ page import="java.util.LinkedHashSet" %> <%@ page import="java.util.Set" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.HashSet" %> <%@ page import="java.util.Date" %> <%@ page import="java.util.Arrays" %> <%@ page import="java.util.Map" %> <%@ page import="java.util.HashMap" %> <%@ page import="org.apache.log4j.Logger" %> <% Map quireFeatures = new HashMap(); List quires = new ArrayList(); int docID = -1; try {docID = Integer.parseInt(request.getParameter("docID"));} catch (Exception e){} if (docID > -1) { String bcid = Integer.toString(docID); Document doc = Document.getDocument(docID); String gaNum = doc.getGANumber(); String docName = gaNum; for (Feature f : Feature.getFeatures(doc.getDocumentID())) { if ("BCID".equals(f.getFeatureCode())) bcid = f.getStringVal1(); if ("QuirePagePosition".equals(f.getFeatureCode())) quireFeatures.put(f.getPageID(), f); } %> <% } else { %> <%=doc.getGANumber()%> (BC <%=bcid%>) <% } %> <% Map sis = new HashMap(); for (ShelfInstance i : doc.getShelfInstances()) { sis.put(i.getShelfInstanceID(), i); } List shelfInstances = new ArrayList(); Page pages[] = doc.getPages(true); for (Page p : pages) { ShelfInstance si = sis.get(p.getFirstShelfID()); if (si == null) continue; shelfInstances.add(si); sis.remove(si.getShelfInstanceID()); } int n = 1; List shelfIDs = new ArrayList(); for (ShelfInstance i : shelfInstances) { shelfIDs.add(i.getShelfInstanceID()); String shelfLabel = i.getInstitutionCountry(); if (i.getInstitutionPlace() != null && i.getInstitutionPlace().length() > 0) shelfLabel += (shelfLabel.length() > 0 ? ", " : "") + i.getInstitutionPlace(); if (i.getInstitutionName() != null && i.getInstitutionName().length() > 0) shelfLabel += (shelfLabel.length() > 0 ? ", " : "") + i.getInstitutionName(); if (i.getShelfNumber() != null && i.getShelfNumber().length() > 0) shelfLabel += (shelfLabel.length() > 0 ? ", " : "") + i.getShelfNumber(); %> <% ++n; } %><% n = -1; Set verses = new LinkedHashSet(); boolean first = true; int currentQuire = 0; int nextQuirePagePosition = 0; Feature currentQuireFeature = null; for (Page p : pages) { // deal with quires Feature quireMarker = quireFeatures.get(p.getPageID()); if (quireMarker != null) { currentQuire = quireMarker.getIntVal2(); nextQuirePagePosition = quireMarker.getIntVal1(); currentQuireFeature = quireMarker; } p.setIntValue("QUIRENUMBER", currentQuire); p.setIntValue("QUIREPAGEPOSITION", nextQuirePagePosition++); p.setValue("QUIREFEATURE", currentQuireFeature); if (shelfIDs.indexOf(p.getFirstShelfID()) != n) { if (verses.size() > 0) { Page x = new Page(); x.addVerses(new ArrayList(verses)); List contents = new ArrayList(); String running = ""; for (String c : x.getBiblicalContent().split(";")) { c = c.trim(); String runningBook = running.length() > 0 ? running.substring(0, running.indexOf(" ")) : ""; String book = c.substring(0, c.indexOf(" ")); if (runningBook.equals(book)) { running += (running.length() > 0 ? "; " : "") + c; } else { if (running.length() > 0) { contents.add(running); } running = c; } System.out.println("c: " + c + "; running: " + running + "; contents: " + contents); } if (running.length() > 0) contents.add(running); for (String c : contents) { %> <% first = false; } verses = new LinkedHashSet(); if (p.getVerses() != null && p.getVerses().length > 0) verses.addAll(Arrays.asList(p.getVerses())); } n = shelfIDs.indexOf(p.getFirstShelfID()); } else { if (p.getVerses() != null && p.getVerses().length > 0) verses.addAll(Arrays.asList(p.getVerses())); } } if (verses.size() > 0) { Page x = new Page(); x.addVerses(new ArrayList(verses)); List contents = new ArrayList(); String running = ""; for (String c : x.getBiblicalContent().split(";")) { c = c.trim(); String runningBook = running.length() > 0 ? running.substring(0, running.indexOf(" ")) : ""; String book = c.substring(0, c.indexOf(" ")); if (runningBook.equals(book)) { running += (running.length() > 0 ? "; " : "") + c; } else { if (running.length() > 0) { contents.add(running); } running = c; } } if (running.length() > 0) contents.add(running); for (String c : contents) { %> <% first = false; } } %>
<% if ("bcid".equals(request.getParameter("docName"))) { docName = bcid; %> <%=bcid%> (<%=gaNum%>)
 
<%=(n==1)?"Place:":""%><%=shelfLabel%><%=docName+"."+n%>
 
<%=(first)?"Content:":""%><%=c%><%=docName+"."+(n+1)%>
<%=(first)?"Content:":""%><%=c%><%=docName+"."+(n+1)%>
 
<% currentQuire = 0; int pagesInQuire = 0; currentQuireFeature = null; int lastQuirePosition = 0; int lastCummulativeQuirePosition = 0; List pageCounts = Arrays.asList(new String[] { "Union", "Binion", "Ternion", "Quaternion", "Quinion", "Sexternion", "Septernion", "Octernion" }); Page lastPage = null; for (Page p : pages) { int pQuire = p.getIntValue("QUIRENUMBER"); /* increment for missing quires if (lastPage == null) { if (pQuire != 1) { lastCummulativeQuirePosition = (pQuire - 1) * pagesInQuire; } } */ int pQuirePagePosition = p.getIntValue("QUIREPAGEPOSITION"); // out.println("pageID: " + p.getPageID() + "; quire: " + pQuire + "; page position: " + pQuirePagePosition + "
"); if (pQuire != currentQuire) { // finish last quire System.out.println("pQuire: " + pQuire); for (++lastQuirePosition, ++lastCummulativeQuirePosition; lastQuirePosition <= pagesInQuire; ++lastQuirePosition, ++lastCummulativeQuirePosition) { System.out.println("lastQuirePosition: " + lastQuirePosition + "; lastCummulativeQuirePosition: " + lastCummulativeQuirePosition + "; pagesInQuire: " + pagesInQuire); if (lastQuirePosition % 2 == 0) { printHalfLeaf(out, lastQuirePosition - 1, lastQuirePosition, lastCummulativeQuirePosition - 1, lastCummulativeQuirePosition, null, null, pagesInQuire, docName, shelfIDs); } } --lastCummulativeQuirePosition; currentQuireFeature = (Feature)p.getValue("QUIREFEATURE"); pagesInQuire = (pageCounts.indexOf(currentQuireFeature.getStringVal1()) + 1) * 4; currentQuire = currentQuireFeature.getIntVal2(); lastQuirePosition = 0; out.println("
"); out.println("" + ""); } for (++lastQuirePosition, ++lastCummulativeQuirePosition; lastQuirePosition < pQuirePagePosition; ++lastQuirePosition, ++lastCummulativeQuirePosition) { if (lastQuirePosition % 2 == 0) { printHalfLeaf(out, lastQuirePosition - 1, lastQuirePosition, lastCummulativeQuirePosition - 1, lastCummulativeQuirePosition, null, null, pagesInQuire, docName, shelfIDs); } lastPage = null; } if (lastQuirePosition % 2 == 0) { printHalfLeaf(out, lastQuirePosition - 1, lastQuirePosition, lastCummulativeQuirePosition - 1, lastCummulativeQuirePosition, lastPage, p, pagesInQuire, docName, shelfIDs); } else { lastPage = p; } %> <% } for (++lastQuirePosition, ++lastCummulativeQuirePosition; lastQuirePosition <= pagesInQuire; ++lastQuirePosition, ++lastCummulativeQuirePosition) { if (lastQuirePosition % 2 == 0) { printHalfLeaf(out, lastQuirePosition - 1, lastQuirePosition, lastCummulativeQuirePosition - 1, lastCummulativeQuirePosition, lastPage, null, pagesInQuire, docName, shelfIDs); } lastPage = null; } %>
Construction:
 
" + currentQuire + ". Quire" + currentQuireFeature.getStringVal1() + "Nr.Content

<% return; } %> <%! static Map quireGlyphs = new HashMap() {{ put(4, new String[] { "┏━━━━━━━", "┗━━━━━━━"}); put(8, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); put(12, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┃┏━━━━━", "┃┃┗━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); put(16, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┃┏━━━━━", "┃┃┃┏━━━━", "┃┃┃┗━━━━", "┃┃┗━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); put(20, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┃┏━━━━━", "┃┃┃┏━━━━", "┃┃┃┃┏━━━", "┃┃┃┃┗━━━", "┃┃┃┗━━━━", "┃┃┗━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); put(24, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┃┏━━━━━", "┃┃┃┏━━━━", "┃┃┃┃┏━━━", "┃┃┃┃┃┏━━", "┃┃┃┃┃┗━━", "┃┃┃┃┗━━━", "┃┃┃┗━━━━", "┃┃┗━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); put(28, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┃┏━━━━━", "┃┃┃┏━━━━", "┃┃┃┃┏━━━", "┃┃┃┃┃┏━━", "┃┃┃┃┃┃┏━", "┃┃┃┃┃┃┗━", "┃┃┃┃┃┗━━", "┃┃┃┃┗━━━", "┃┃┃┗━━━━", "┃┃┗━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); put(32, new String[] { "┏━━━━━━━", "┃┏━━━━━━", "┃┃┏━━━━━", "┃┃┃┏━━━━", "┃┃┃┃┏━━━", "┃┃┃┃┃┏━━", "┃┃┃┃┃┃┏━", "┃┃┃┃┃┃┃┏", "┃┃┃┃┃┃┃┗", "┃┃┃┃┃┃┗━", "┃┃┃┃┃┗━━", "┃┃┃┃┗━━━", "┃┃┃┗━━━━", "┃┃┗━━━━━", "┃┗━━━━━━", "┗━━━━━━━"}); }}; public static void printHalfLeaf(JspWriter out, int firstNumber, int secondNumber, int firstTotal, int secondTotal, Page firstPage, Page secondPage, int quireMax, String docName, List shelfIDs) { try { int n = 0; if (firstPage!=null) n = shelfIDs.indexOf(firstPage.getFirstShelfID()) + 1; if (secondPage!=null) n = shelfIDs.indexOf(secondPage.getFirstShelfID()) + 1; out.print(""+firstTotal+"/"+secondTotal+""); // out.print(""+firstNumber+"/"+secondNumber+""); out.print(""+(firstPage!=null?firstPage.getFolioNumber():"")+(firstPage!=null || secondPage!=null ? "/":"")+(secondPage!=null?secondPage.getFolioNumber():"")+""); // show page quire position glyphs out.print(""); out.println(quireGlyphs.get(quireMax)[secondNumber/2-1]); out.print(""); out.print(""+(n != 0 ? docName + "." + n : "")+""); Page x = new Page(); Set verses = new LinkedHashSet(); if (firstPage!=null) verses.addAll(Arrays.asList(firstPage.getVerses())); if (secondPage!=null) verses.addAll(Arrays.asList(secondPage.getVerses())); x.addVerses(new ArrayList(verses)); out.print(""+x.getBiblicalContent()+""); out.print(""); } catch (Exception e) {} } public static class Quire { public List pages = new ArrayList(); public Quire(Page firstPage) { pages.add(firstPage); } } %>

bibliacoptica/mssview

Retrieve BC view for a manuscript

Parameters

docIDdocument id from which to retrieve BC view
docNamedocument name to use throughout [gaNum, bcid], default: gaNum