<%
//
// Copyright 2011 New Zealand Institute of Language, Brain and Behaviour,
// University of Canterbury
// Written by Robert Fromont - robert.fromont@canterbury.ac.nz
//
// This file is part of LaBB-CAT.
//
// LaBB-CAT is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// LaBB-CAT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LaBB-CAT; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
%><%@ page import = "java.io.*"
%><%@ page import = "java.net.*"
%><%@ page import = "java.util.*"
%><%@ page import = "nz.ac.canterbury.ling.ag.*"
%><%@ page import = "java.sql.*"
%><%
{
request.setAttribute("title", "regenerate layers");
Connection connection = (Connection)request.getAttribute("db");
ServletContext context = request.getSession().getServletContext();
Vector<String> vMessages = (Vector<String>)request.getAttribute("messages");
Vector<String> vErrors = (Vector<String>)request.getAttribute("errors");
String sAnnotationUid = ""+request.getParameter("annotation_uid");
MetaAnnotation line = new MetaAnnotation(sAnnotationUid);
String sSMTPHost = context.getInitParameter("SMTPHost");
String sCorrectionsEmail = context.getInitParameter("correctionsEmail");
String sTitle = context.getInitParameter("title");
String sTranscriptUrl = context.getInitParameter("transcriptUrl");
String sHtmlTranscriptUrl = context.getInitParameter("htmlTranscriptUrl");
String sTranscriptPath = context.getInitParameter("transcriptPath");
String sTranscriptSubdir = context.getInitParameter("transcriptSubdir");
String sCorpusName = "";
String sFamilyName = "";
boolean bForm = true;
try
{
// from the uid info, get the transcription word and AG id
line = new DbMetaAnnotation(line, connection);
// from AG id get transcript name
DbAnnotationGraph ag = new DbAnnotationGraph(
line.getGraphId(), connection);
ag.loadRow();
line.setGraph(ag);
// get start/end times
line.setStartAnchor(new DbAnchor(
ag, line.getStartAnchor().getId(), connection));
line.setEndAnchor(new DbAnchor(
ag, line.getEndAnchor().getId(), connection));
// get speaker info
DbGraphSpeaker speaker = new DbGraphSpeaker(
new GraphSpeaker(ag, Integer.parseInt(line.getLabel())), connection);
request.setAttribute("ag", ag);
request.setAttribute("line", line);
request.setAttribute("speaker", speaker);
GraphFragment fragment = new DbGraphFragment(line, connection);
// handle form
String sCommand = request.getParameter("command");
if (sCommand != null)
{
String sCorrection = request.getParameter("correction");
if (sCorrection.trim().equals(fragment.getFragmentText().trim()))
{
request.setAttribute("message", "Your suggestion is the same as the original text. Please enter your correction");
}
else
{
bForm = false;
String sMessage = "A correction has been suggested for "
+ ag.getName();
if (request.getRemoteUser() != null)
{
sMessage += "\nSuggested by: " + request.getRemoteUser();
}
sMessage += "\nTranscript: " + sHtmlTranscriptUrl
+ "?format=htmlapplet&ag_id=" + ag.getId()
+ "#" + line.getStartAnchor().getOffsetId();
String sTrsTranscriptUrl = sHtmlTranscriptUrl.replaceFirst("transcript\\.jsp", "")
+ sTranscriptUrl
+ "/" + ag.getCorpusName()
+ "/" + ag.getSeriesName()
+ "/" + sTranscriptSubdir
+ "/" + ag.getName();
sMessage += "\nUtterence time: "
+ line.getStartAnchor().getOffset();
sMessage += "\nTranscript file: " + sTrsTranscriptUrl;
sMessage += "\n\nCurrent text: ";
sMessage += "\n----------------------------------------\n";
sMessage += fragment.getFragmentText();
sMessage += "\n----------------------------------------";
sMessage += "\n\nSuggested correction: ";
sMessage += "\n----------------------------------------\n";
sMessage += sCorrection;
sMessage += "\n----------------------------------------";
try
{
nz.net.fromont.mail.Mailer mailer
= new nz.net.fromont.mail.Mailer(
sSMTPHost, sCorrectionsEmail);
mailer.sendMessage(
sCorrectionsEmail,
"[" + sTitle + "] Suggested correction: " + ag.getName(),
sMessage);
request.setAttribute(
"result", "Thank you, your suggestion has been submitted");
}
catch (Exception ex)
{
request.setAttribute(
"result", "Your request was not submitted: <br>"
+ ex + "<br>"
+ "Please email <a href='mailto:" + sCorrectionsEmail + "'>"
+ sCorrectionsEmail + "</a>" );
}
} // suggestion is different from original text
} // handle form
if (bForm)
{
request.setAttribute("form", new Boolean(true));
request.setAttribute("fragment", fragment);
}
}
catch (Exception x)
{
request.setAttribute(
"message", "Specified utterance could not be found"
+ " ("+x+")");
}
request.setAttribute("mvcViewPath", "/mvc/correction_html.jsp");
}
%>