<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.data.DataObject" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.sword.keys.VerseKey" %> <%@ page import="org.crosswire.sword.keys.ListKey" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <% String cjID = request.getParameter("conjID"); if (cjID != null && cjID.startsWith("cj")) cjID = cjID.substring(2); int conjectureID = -1; try {conjectureID = Integer.parseInt(cjID);} catch (Exception e){} String histID = request.getParameter("histID"); if (histID != null && histID.startsWith("s")) histID = histID.substring(1); int historyID = -1; try {historyID = Integer.parseInt(histID);} catch (Exception e){} String biblioID = request.getParameter("biblioID"); if (biblioID != null && biblioID.startsWith("b")) biblioID = biblioID.substring(1); int bibliographyID = -1; try {bibliographyID = Integer.parseInt(biblioID);} catch (Exception e){} String authID = request.getParameter("authorID"); if (authID != null && authID.startsWith("a")) authID = authID.substring(1); int authorID = -1; try {authorID = Integer.parseInt(authID);} catch (Exception e){} String format = request.getParameter("format"); String detail = request.getParameter("detail"); String indexContent = request.getParameter("indexContent"); if (conjectureID > -1 || historyID > -1 || bibliographyID > -1 || authorID > -1 || indexContent != null) { response.setContentType("text/xml"); DataObject query = new DataObject(); String SQL = "SELECT * from ntconjectures.CONJECTURE C "; SQL += " LEFT JOIN ntconjectures.CONJHISTORY CH on (CH.CONJID=C.CONJID and CH.KIND='Urheber')"; SQL += " WHERE 1=1 "; String sqlWhere = ""; if (indexContent != null) { VerseKey verse = new VerseKey("Gen.1.1"); verse.setIntros(true); ListKey verses = verse.ParseVerseList(indexContent, verse.toString(), true); if (verses.getCount() > 0) { sqlWhere += " AND ("; for (int i = 0; i < verses.getCount(); ++i) { VerseKey verseKey = (VerseKey) verses.getElement(i); if (i > 0) sqlWhere += " OR "; sqlWhere += " (C.INDEXEND>={VERSEMIN" + i + "} AND C.INDEXSTART<={VERSEMAX" + i + "}) "; query.setIntValue("VERSEMIN" + i, verseKey.getLowerBound().getHashNumber()); query.setIntValue("VERSEMAX" + i, verseKey.getUpperBound().getHashNumber()); } sqlWhere += " ) "; } } if (conjectureID > -1) { sqlWhere += " AND C.CONJID={CONJID}"; query.setIntValue("CONJID", conjectureID); } if (historyID > -1) { sqlWhere += " AND C.CONJID=(SELECT MIN(CONJID) from ntconjectures.CONJHISTORY CH where CH.CONJHISTID = {CONJHISTID})"; query.setIntValue("CONJHISTID", historyID); } if (bibliographyID > -1) { sqlWhere += " AND C.CONJID IN (SELECT CONJID from ntconjectures.CONJHISTORY CH where CH.BIBLIOID = {BIBLIOID})"; query.setIntValue("BIBLIOID", bibliographyID); } if (authorID > -1) { sqlWhere += " AND C.CONJID IN (SELECT CONJID from ntconjectures.CONJHISTORY CH where CH.AUTHORID = {AUTHORID})"; query.setIntValue("AUTHORID", authorID); } SQL += sqlWhere + " ORDER BY C.INDEXSTART,C.WORDSTART"; List conjectures = sqlWhere.length() > 0 ? query.getDataSet(SQL) : new ArrayList(); %> <% if (!"count".equals(detail)) { for (DataObject o : conjectures) { VerseKey verse = new VerseKey(o.getIntValue("INDEXSTART")); verse.setLowerBound(new VerseKey(o.getIntValue("INDEXSTART"))); verse.setUpperBound(new VerseKey(o.getIntValue("INDEXEND"))); o.setValue("VERSERANGE", verse.getShortRangeText()); String conj = o.toString().replace("", ""); conj = conj.replace("", ""); if ("history".equals(detail)) { DataObject queryDetail = new DataObject(); queryDetail.setIntValue("CONJID", o.getIntValue("CONJID")); String HISTORY_SQL = "SELECT * from ntconjectures.CONJHISTORY WHERE CONJID={CONJID} ORDER BY CASE WHEN KIND='Urheber' THEN 0 ELSE 1 END, YEAR"; List history = queryDetail.getDataSet(HISTORY_SQL); XMLBlock conjBlock = XMLBlock.createXMLBlock(conj); XMLBlock histBlock = conjBlock.createBlock("histories"); histBlock.setAttribute("count", Integer.toString(history.size())); for (DataObject h : history) { String conjHist = h.toString().replace("", ""); conjHist = conjHist.replace("", ""); histBlock.addBlock(XMLBlock.createXMLBlock(conjHist)); } conj = conjBlock.toString(); } out.println(conj); } } %> <% return; } %>

conjecture/get

Retrieve conjecture

Parameters

conjIDconjecture id to query, e.g., 11713
histIDconjecture id to query, e.g., 11713
biblioIDconjecture id to query, e.g., 11713
indexContentverse content
authorIDlimit conjecture by author id
detailcount|(conjecture)|history