%@page import="com.ibm.icu.dev.util.ElapsedTimer"%>
<%@page import="org.unicode.cldr.web.*"%>
<%@page import="org.unicode.cldr.util.*,java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.unicode.cldr.test.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Soft to Hard Votes
<%
/**
Access this like so:
http:///cldr-apps/admin-softToHardVotes.jsp?vap=
then to really vote
http:///cldr-apps/admin-softToHardVotes.jsp?vap=&reallyVote=yes
where is the admin@ password.
*/
long start = System.currentTimeMillis();
ElapsedTimer overallTimer = new ElapsedTimer(
"softVoteToHardVote update started" + new java.util.Date());
int numupd = 0;
final SurveyMain sm = CookieSession.sm; // workaround - get the static survey main
%>
<%
if ((request.getParameter("vap") == null)
|| !request.getParameter("vap").equals(SurveyMain.vap)) {
%>
Not authorized.
<%
return;
}
final boolean reallyVote = request.getParameter("reallyVote") != null;
%>
DAIP vote update
<%
final STFactory stf = sm.getSTFactory();
Set sortSet = new TreeSet();
sortSet.addAll(SurveyMain.getLocalesSet());
try {
for (CLDRLocale loc : sortSet) {
%>
<%=loc.getDisplayName()%>
<%
final BallotBox bb = stf.ballotBoxForLocale(loc);
final CLDRFile file = stf.make(loc, false);
int pathCount = 0;
Exception[] exceptionList = new Exception[1];
DisplayAndInputProcessor daip = new DisplayAndInputProcessor(loc, false);
// now, for each xpath..
for(final String xpath : file.fullIterable()) {
Set values = bb.getValues(xpath);
if (values == null) {
continue;
}
for (String value : values) {
String daipValue = daip.processInput(xpath, value, exceptionList);
if(!value.equals(daipValue)) {
// for each value
final Set votes = bb.getVotesForValue(xpath, value);
if(votes != null && !votes.isEmpty()) { // did anyone vote for it?
pathCount++;
%>
<%= xpath %> : <%= value %> to <%= daipValue %> :
<%
for(final UserRegistry.User user : votes) {
%>
<%= user %>
<%
if(reallyVote) {
bb.voteForValue(user, xpath, daipValue);
numupd++;
}
}
}
}
}
}
%>
<%= pathCount %> paths
<%
}
%>
<%
} finally {
}
%>
Total upd:
<%=numupd + "/" + (sortSet.size() + 2)%>
Total time:
<%=overallTimer%>
:
<%=((System.currentTimeMillis() - start) / (1000.0 * 60))%>min
<%
System.err.println(overallTimer + " - updated " + numupd + "/"
+ (sortSet.size() + 2) + " in "
+ (System.currentTimeMillis() - start) / (1000.0 * 60)
+ " min");
%>