<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Page" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement.Project" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus.Segment" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Feature" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.Convert" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.WitnessReading" %> <%@ page import="org.crosswire.data.DataObject" %> <%@ page import="org.crosswire.sword.keys.VerseKey" %> <%@ page import="org.crosswire.sword.keys.ListKey" %> <%@ page import="java.util.PriorityQueue" %> <%@ page import="java.util.Map" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.util.Set" %> <%@ page import="java.util.HashSet" %> <%@ page import="java.util.UUID" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Collections" %> <%@ page import="java.util.Comparator" %> <%@ page import="org.apache.log4j.Logger" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="org.crosswire.webtools.*" %> <%@ page import="org.crosswire.utils.Utils" %> <%@ page import="org.crosswire.utils.HTTPUtils" %> <%@ page import="javax.validation.constraints.NotNull" %> <%@ page import="javax.validation.constraints.Pattern" %> <%! @Description(value = "Retrieve manuscript transcription", name = "projects/qd/manuscript/get") public static class MyParameters extends Parameters { @NotNull @Description(value = "manuscript identifier", example = "1QS") public String docID = null; @Pattern(regexp = "^((tei|html|htmlfragment|plaintext).*)?$", message = "See usage for valid response formats.") @Description(value = "specify the result format: tei, htmlfragment, html, plaintext", defaultValue = "tei", example = "html") public String format = "tei"; @Override protected void customValidation() { } @Override protected String[] getExamples() { return new String[] { "For 1QS in HTML: ?docID=1QSformat=html", "For 1QS in TEI: ?docID=1QSformat=tei" }; } } static HashMap specialFonts = new HashMap(); static HashSet rightJustify = new HashSet(); static { specialFonts.put("bo", "Antinoou, AntinoouWeb"); specialFonts.put("sa", "Antinoou, AntinoouWeb"); specialFonts.put("fa", "Antinoou, AntinoouWeb"); specialFonts.put("mae", "Antinoou, AntinoouWeb"); specialFonts.put("ly", "Antinoou, AntinoouWeb"); specialFonts.put("cw", "Antinoou, AntinoouWeb"); // specialFonts.put("ar", "Arabic, ArabicWeb"); // specialFonts.put("arb", "Arabic, ArabicWeb"); specialFonts.put("syc", "Estrangelo Edessa, EstreWeb"); specialFonts.put("chu", "BukyvedeWeb"); rightJustify.add("syc"); rightJustify.add("he"); rightJustify.add("hbo"); rightJustify.add("arb"); rightJustify.add("ar"); } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); while (params.getErrors().size() == 0) { String defaultFontSpec = Utils.getSysConfig(session).getProperty("DefaultFontSpec", "GentiumPlus"); String transcriptionAttribution = Utils.getSysConfig(session).getProperty("TranscriptionAttributionDefault", ""); String transcriptionUsage = Utils.getSysConfig(session).getProperty("TranscriptionUsageSitewide", ""); transcriptionAttribution = "© 2022 DFG-Projekt 465277421 \"Qumran-Digital: Text und Lexikon\" CC-BY-SA 4.0"; transcriptionUsage = "Bereitgestellt durch das DFG-Projekt Nr. 465277421 \"Qumran-Digital: Text und Lexikon\" auf der Grundlage eines Textes des früheren Projekts \"Qumran-Wörterbuch\" der Niedersächsischen Akademie der Wissenschaften zu Göttingen, der auf einem Vorläufertext von Martin Abegg basierte."; String uuid = UUID.randomUUID().toString(); Document lastDoc = new Document(); Page lastPage = null; StringBuffer retVal = new StringBuffer(); String lang = ""; DataObject query = new DataObject(); String sql = "select manuscript, unique_ordered_id, `column`, line, reading, manuscript_sign_cluster_reading_id from dss.manuscript_view where manuscript={DOCID} order by manuscript, `column`, line"; query.setValue("DOCID", params.docID); lastDoc.setGANumber(params.docID); lastDoc.setValue("DOCUMENTID", params.docID); lastDoc.setLanguage("hbo"); lang = lastDoc.getLanguage(); List rows = query.getDataSet(sql); if (rows == null || rows.size() == 0) { params.addError(-3, "No document found: " + params.docID); break; } else { String lastCol = ""; String lastLine = ""; retVal.append(""); Collections.sort(rows, new Comparator() { @Override public int compare(DataObject o1, DataObject o2) { String s1 = o1.getStringValue("unique_ordered_id"); String s2 = o2.getStringValue("unique_ordered_id"); s1 = s1.replaceAll("([0-9]+)", "0000000000000000000000$1"); s1 = s1.replaceAll("0+([0-9]{15,})", "$1"); s2 = s2.replaceAll("([0-9]+)", "0000000000000000000000$1"); s2 = s2.replaceAll("0+([0-9]{15,})", "$1"); int d = s1.compareTo(s2); /* if (d == 0) { s1 = o1.getStringValue("line"); s2 = o2.getStringValue("line"); s1 = s1.replaceAll("([0-9]+)", "0000000000000000000000$1"); s1 = s1.replaceAll("0+([0-9]{15,})", "$1"); s2 = s2.replaceAll("([0-9]+)", "0000000000000000000000$1"); s2 = s2.replaceAll("0+([0-9]{15,})", "$1"); d = s1.compareTo(s2); } */ return d; } }); boolean inSupplied = false; final String suppliedStartTag = ""; final String suppliedEndTag = ""; final String saveDoubleOpen = "##DOUBLEOPEN##"; final String saveDoubleClose = "##DOUBLECLOSE##"; for (DataObject w : rows) { String col = w.getStringValue("column"); String line = w.getStringValue("line"); String text = w.getStringValue("reading"); String id = w.getStringValue("manuscript_sign_cluster_reading_id"); if (!lastCol.equals(col)) { inSupplied = false; retVal.append("\n"); lastCol = col; lastLine = ""; } if (!lastLine.equals(line)) { retVal.append("\n"); retVal.append(""); lastLine = line; } retVal.append(""); text = HTTPUtils.canonize(text); text = text.replace("]]", saveDoubleClose); text = text.replace("[[", saveDoubleOpen); int firstIndexEnd = text.indexOf("]"); int firstIndexStart = text.indexOf("["); int lastIndexEnd = text.lastIndexOf("]"); int lastIndexStart = text.lastIndexOf("["); if (firstIndexEnd > -1 && (firstIndexEnd < firstIndexStart || firstIndexStart < 0)) inSupplied = true; if (inSupplied) retVal.append(suppliedStartTag); text = text.replace("[", suppliedStartTag); text = text.replace("]", suppliedEndTag); if (lastIndexStart > -1 && (lastIndexStart > lastIndexEnd || lastIndexEnd < 0)) inSupplied = true; if (lastIndexEnd > -1 && (lastIndexEnd > lastIndexStart || lastIndexStart < 0)) inSupplied = false; text = text.replace(saveDoubleClose, "]]"); text = text.replace(saveDoubleOpen, "[["); retVal.append(text); if (inSupplied) retVal.append(suppliedEndTag); retVal.append(""); } if ("tei".equals(params.format) || "xml".equals(params.format) || "teiraw".equals(params.format)) { response.setContentType("text/xml"); boolean headerPresent = (retVal.indexOf(" -1); boolean richHeaderPresent = (retVal.indexOf("") > -1); if (headerPresent && !richHeaderPresent) { int endHeaderOffset = retVal.indexOf(""); if (endHeaderOffset > -1) retVal = new StringBuffer(retVal.substring(endHeaderOffset+6)); endHeaderOffset = retVal.lastIndexOf(""); if (endHeaderOffset > -1) retVal = new StringBuffer(retVal.substring(0, endHeaderOffset)); headerPresent = false; } while (retVal.toString().trim().startsWith("")+1).trim()); } %> <% if (!headerPresent) { Set wits= new HashSet(); for (WitnessReading wr : Convert.getTEITranscriptionText(retVal.toString(), true, true, true, true)) { wr.setDocumentName(lastDoc.getGANumber()+wr.getDocumentName()); wr.setDocumentIDString(lastDoc.getDocumentIDString()); wits.add(wr.getHand()); } %> <%=lastDoc.getGANumber()%> DFG-Projekt "Qumran Digital"; Akademie der Wissenschaften zu Göttingen

]]>

]]>

<% /* for (ShelfInstance si : lastDoc.getShelfInstances()) { %> <%=si.getInstitutionCountry()%> <%=si.getInstitutionPlace()%> <%=HTTPUtils.canonize(si.getInstitutionName())%> <%=si.getShelfNumber()%> <% } */ String l = lastDoc.getLanguage(); if ("g".equals(l)) l = "grc"; %>
<% PriorityQueue wits2 = new PriorityQueue(wits); while (!wits2.isEmpty()) { String w = wits2.poll(); if ("firsthand".equals(w) || w.length() < 1) continue; %> <% } %>
<% } %> > <% /* if (params.filterNoise) { retVal = new StringBuffer(retVal.toString() .replaceAll("", "")); } */ // cleanups for transcription output retVal = new StringBuffer(Transcription.fixTranscription(retVal.toString())); %> <%= retVal %> <% if (!retVal.toString().trim().startsWith("
<% } } } else if ("html".equals(params.format) || "htmlfragment".equals(params.format)) { retVal = new StringBuffer(Transcription.fixTranscription(retVal.toString())); retVal = new StringBuffer(Convert.getTEIDisplayHTML(retVal.toString(), 1, null, null)); response.setContentType("text/html"); if (!"htmlfragment".equals(params.format)) { %> <% } else { } %> <% if (!"htmlfragment".equals(params.format)) { %> <% } %>
dir="rtl" <% } %> > <%= retVal %>


<% String contributorAttribution = ""; /* if (lastDoc != null) { Feature f = lastDoc.getFeature("TranscriptionEditors"); if (f != null) contributorAttribution += "Editors: " + f.getStringVal1(); f = lastDoc.getFeature("TranscriptionRevisors"); if (f != null) contributorAttribution += (contributorAttribution.length() > 0 ? "; " : "") + "Revisors: " + f.getStringVal1(); f = lastDoc.getFeature("TranscriptionCollaborators"); if (f != null) contributorAttribution += (contributorAttribution.length() > 0 ? "; " : "") + "Collaborators: " + f.getStringVal1(); f = lastDoc.getFeature("TranscriptionExtraAttribution"); if (f != null) contributorAttribution += (contributorAttribution.length() > 0 ? "
" : "") + f.getStringVal1(); } if (lastPage != null) { String folioPrefix = lastPage.getFolioNumber(); if (folioPrefix == null || folioPrefix.trim().length() < 1) folioPrefix = ""; else folioPrefix = "Page " + folioPrefix.trim() + " "; Feature f = lastPage.getFeature("TranscriptionEditors"); if (f != null) contributorAttribution += folioPrefix + "Editors: " + f.getStringVal1(); f = lastPage.getFeature("TranscriptionRevisors"); if (f != null) contributorAttribution += (contributorAttribution.length() > 0 ? "; " : "") + folioPrefix + "Revisors: " + f.getStringVal1(); f = lastPage.getFeature("TranscriptionCollaborators"); if (f != null) contributorAttribution += (contributorAttribution.length() > 0 ? "; " : "") + folioPrefix + "Collaborators: " + f.getStringVal1(); f = lastPage.getFeature("TranscriptionExtraAttribution"); if (f != null) contributorAttribution += (contributorAttribution.length() > 0 ? "
" : "") + folioPrefix + f.getStringVal1(); } if (contributorAttribution.length() > 0) { %> <%=contributorAttribution%>
<% } */ %> <%=transcriptionAttribution%>
<%=transcriptionUsage%>

View as:
<% if (!"htmlfragment".equals(params.format)) { %> <% } } else if ("plaintext".equals(params.format)) { response.setContentType("text/plain"); retVal = new StringBuffer(Transcription.fixTranscription(retVal.toString())); retVal = new StringBuffer(Convert.getTEIPlainText(retVal.toString())); %><%= retVal + "\n\n" + transcriptionAttribution + "\n" + transcriptionUsage %><% } } return; } ((Parameters)params).format = "html"; Serializer.reportErrors(request, response, out, params, true); %>