<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ 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.Transcription" %> <%@ page import="org.crosswire.community.projects.ntmss.data.DocumentGroup" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="org.crosswire.webtools.*" %> <%! @Description(value = "Rebuild verse cache for a manuscript.", name = "transcription/rebuildversecache") public static class MyParameters extends Parameters { @Description(value = "manuscript id for which to rebuild to verse cache", example = "10006") public Integer docID = null; @Description(value = "document group id for which to rebuild all grouped manuscripts' verse cache", example = "1") public Integer documentGroupID = null; @Description(value = "rebuild a specific user's transcription verse cache", defaultValue = "PUBLISHED", example = "psmith") public String userName = null; @Description(value = "should repository be pushed", defaultValue = "true", example = "false") public Boolean push = true; @Override protected void afterLoad() { userName = Transcription.assureUnicode(userName); } @Override protected void customValidation() { if (getUser() == null) { addError(-5, "Must be logged in to edit transcriptions."); return; } if (docID == null && documentGroupID == null) { addError(-3, "Must supply either {docID} or {documentGroupID}."); return; } } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0) { boolean isAdmin = params.getUser().hasRole("VMR Administrator") || params.getUser().hasRole("Transcription Manager"); Document docs[] = null; do { if (params.documentGroupID != null) { DocumentGroup dg = DocumentGroup.getDocumentGroup(params.documentGroupID); if (dg != null) { docs = dg.getDocuments(); } else { params.addError(-6, "Couldn't find documentGroupID: " + params.documentGroupID + "."); break; } } else docs = new Document[] { Document.getDocument(params.docID) }; if (docs != null) { int count = 0; for (Document doc : docs) { if (doc != null) { doc.removeTranscriptionVerse(0, 2139999999, params.userName); for (Page p: doc.getPages()) { try { String t = doc.getTranscriptionPage(p.getPageID(), params.userName, null); int lineCount = Document.getSubstringOccuranceCount(t, ""); doc.setTranscriptionPageExists(t != null, p.getPageID(), params.userName, lineCount, wordCount); if (t != null && t.trim().length() > 0) { doc.setTranscriptionVersesFromTranscription(t, params.userName, p.getPageID()); } } catch(Exception e) { e.printStackTrace(); } } ++count; } else { params.addError(-7, "Couldn't find docID: " + params.docID+"."); break; } } Serializer.output(response, out, params, XMLBlock.createXMLBlock("")); } } while (false); } else params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>