use of com.google.refine.model.Recon.Judgment in project OpenRefine by OpenRefine.
the class ReconJudgeSimilarCellsOperation method reconstruct.
public static AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
JSONObject engineConfig = obj.getJSONObject("engineConfig");
ReconCandidate match = null;
if (obj.has("match")) {
JSONObject matchObj = obj.getJSONObject("match");
JSONArray types = matchObj.getJSONArray("types");
String[] typeIDs = new String[types.length()];
for (int i = 0; i < typeIDs.length; i++) {
typeIDs[i] = types.getString(i);
}
match = new ReconCandidate(matchObj.getString("id"), matchObj.getString("name"), typeIDs, matchObj.getDouble("score"));
}
Judgment judgment = Judgment.None;
if (obj.has("judgment")) {
judgment = Recon.stringToJudgment(obj.getString("judgment"));
}
return new ReconJudgeSimilarCellsOperation(engineConfig, obj.getString("columnName"), obj.getString("similarValue"), judgment, match, obj.has("shareNewTopics") ? obj.getBoolean("shareNewTopics") : false);
}
use of com.google.refine.model.Recon.Judgment in project OpenRefine by OpenRefine.
the class ReconJudgeOneCellCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
Project project = getProject(request);
int rowIndex = Integer.parseInt(request.getParameter("row"));
int cellIndex = Integer.parseInt(request.getParameter("cell"));
Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment"));
ReconCandidate match = null;
String id = request.getParameter("id");
if (id != null) {
String scoreString = request.getParameter("score");
match = new ReconCandidate(id, request.getParameter("name"), request.getParameter("types").split(","), scoreString != null ? Double.parseDouble(scoreString) : 100);
}
JudgeOneCellProcess process = new JudgeOneCellProcess(project, "Judge one cell's recon result", judgment, rowIndex, cellIndex, match, request.getParameter("identifierSpace"), request.getParameter("schemaSpace"));
HistoryEntry historyEntry = project.processManager.queueProcess(process);
if (historyEntry != null) {
/*
* If the process is done, write back the cell's data so that the
* client side can update its UI right away.
*/
Pool pool = new Pool();
if (process.newCell != null && process.newCell.recon != null) {
pool.pool(process.newCell.recon);
}
respondJSON(response, new ReconClearOneCellCommand.CellResponse(historyEntry, process.newCell, pool));
} else {
respond(response, "{ \"code\" : \"pending\" }");
}
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.Recon.Judgment in project OpenRefine by OpenRefine.
the class ReconJudgeSimilarCellsCommand method createOperation.
@Override
protected AbstractOperation createOperation(Project project, HttpServletRequest request, JSONObject engineConfig) throws Exception {
String columnName = request.getParameter("columnName");
String similarValue = request.getParameter("similarValue");
Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment"));
ReconCandidate match = null;
String id = request.getParameter("id");
if (id != null) {
String scoreString = request.getParameter("score");
match = new ReconCandidate(id, request.getParameter("name"), request.getParameter("types").split(","), scoreString != null ? Double.parseDouble(scoreString) : 100);
}
String shareNewTopics = request.getParameter("shareNewTopics");
return new ReconJudgeSimilarCellsOperation(engineConfig, columnName, similarValue, judgment, match, "true".equals(shareNewTopics));
}
use of com.google.refine.model.Recon.Judgment in project OpenRefine by OpenRefine.
the class ReconJudgeSimilarCellsCommand method createOperation.
@Override
protected AbstractOperation createOperation(Project project, HttpServletRequest request, EngineConfig engineConfig) throws Exception {
String columnName = request.getParameter("columnName");
String similarValue = request.getParameter("similarValue");
Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment"));
ReconCandidate match = null;
String id = request.getParameter("id");
if (id != null) {
String scoreString = request.getParameter("score");
match = new ReconCandidate(id, request.getParameter("name"), request.getParameter("types").split(","), scoreString != null ? Double.parseDouble(scoreString) : 100);
}
String shareNewTopics = request.getParameter("shareNewTopics");
return new ReconJudgeSimilarCellsOperation(engineConfig, columnName, similarValue, judgment, match, "true".equals(shareNewTopics));
}
Aggregations