<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ 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.Apparatus.Segment" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Page" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ShelfInstance" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement.Project" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.sword.keys.ListKey" %> <%@ page import="org.crosswire.sword.keys.VerseKey" %> <%@ page import="java.util.List" %> <%@ page import="java.util.Collections" %> <%@ page import="java.util.Arrays" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="org.apache.log4j.Logger" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="org.crosswire.webtools.*" %> <%! @Description(value = "Perform sanity checks on various parts of the dataset", name = "statistics/integritycheck") public static class MyParameters extends Parameters { protected ProjectManagement.Project project = null; @Description(value = "Limit checks to a Project ID", defaultValue = "1", example = "43") public Integer projectID = 1; @Description(value = "Limit checks to a Project ID", defaultValue = "1", example = "43") public Integer documentGroupID; @Description(value = "Limit checks to a Project Name", example = "ECM Matthew") public String projectName; @Description(value = "Show this usage help", example = "true", defaultValue = "false") public Boolean help = false; // format(html) | xml @Override protected void afterLoad() { } @Override protected void customValidation() { projectName = Transcription.assureUnicode(projectName); if (projectID != null || projectName != null) { project = projectID != null ? ProjectManagement.getProject(projectID) : ProjectManagement.getProject(projectName); if (project == null) { addError(-7, "Project not found."); return; } } if (project != null && documentGroupID == null) { documentGroupID = project.getDocumentGroupID(); } } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0 && !params.help) { String format = request.getParameter("format"); if (format == null) format = "html"; boolean html = "html".equals(format); StringBuffer results = new StringBuffer(); String baseURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); // + request.getContextPath(); int amax = 10; int zzmax = 10; Segment query = new Segment(); String sql = "select VERSE, CONTEXTDESCRIPTION "; sql += ", (select count(1) from SEGMENTREADING SR left join SEGMENTREADINGWITNESS SRW on SRW.SEGMENTREADINGID=SR.SEGMENTREADINGID where SR.SEGMENTID=S.SEGMENTID and SRW.PROJECTID="+params.projectID+ ") WITCOUNT"; sql += ", (select count(distinct DOCUMENTID) from SEGMENTREADING SR left join SEGMENTREADINGWITNESS SRW on SRW.SEGMENTREADINGID=SR.SEGMENTREADINGID where SR.SEGMENTID=S.SEGMENTID and SRW.PROJECTID="+params.projectID+ ") DOCIDCOUNT"; sql += ", (select GROUP_CONCAT(DGD.DOCUMENTID SEPARATOR ', ') from DOCUMENTGROUPDOCUMENT DGD where DGD.DOCUMENTGROUPID="+params.documentGroupID+" and DOCUMENTID not in (SELECT SRW.DOCUMENTID from SEGMENTREADING SR left join SEGMENTREADINGWITNESS SRW on SRW.SEGMENTREADINGID=SR.SEGMENTREADINGID where SR.SEGMENTID=S.SEGMENTID and SRW.PROJECTID="+params.projectID+ ")) MISSINGDOCIDS"; sql += ", (select GROUP_CONCAT(DGD.DOCUMENTID SEPARATOR ', ') from DOCUMENTGROUPDOCUMENT DGD where DGD.DOCUMENTGROUPID="+params.documentGroupID+" and DOCUMENTID not in (SELECT SRW.DOCUMENTID from SEGMENTREADING SR left join SEGMENTREADINGWITNESS SRW on SRW.SEGMENTREADINGID=SR.SEGMENTREADINGID where SR.SEGMENTID=S.SEGMENTID and SRW.PROJECTID="+params.projectID+ " and HAND='')) MISSINGFIRSTHANDS"; sql += " from SEGMENT S left join SEGMENTGROUPSEGMENT SG on SG.SEGMENTID=S.SEGMENTID WHERE SEGMENTGROUPID="+params.projectID+" ORDER BY VERSE, CONTEXTDESCRIPTION;"; List rows = query.getDataSet(sql); Collections.sort(rows); if (html) { results.append("

Segment siglum counts

"); results.append(""); } else { results.append(""); } for (Segment d : rows) { if (html) { results.append(""); results.append(""); results.append(""); } else { results.append(""); } } if (html) results.append("
VerseContext DescriptionWit
Count
DocID
Count
MissingMissing FirsthandFixMeURL
"+d.getVerseTextShort()+"" +d.getContextDescription()+"" +d.getLongValue("WITCOUNT")+"" +d.getLongValue("DOCIDCOUNT")+"" +d.getStringValue("MISSINGDOCIDS")+"" +d.getStringValue("MISSINGFIRSTHANDS")+"fix me
"); else results.append(""); if (html) { %> <%=results%> <% } else { response.setContentType("text/xml"); %> <%=results%> <% } return; } params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>