use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class GetProcessesCommand method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Project project = getProject(request);
respondJSON(response, project.processManager);
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class AnnotateOneRowCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
try {
Project project = getProject(request);
int rowIndex = Integer.parseInt(request.getParameter("row"));
String starredString = request.getParameter("starred");
if (starredString != null) {
boolean starred = "true".endsWith(starredString);
String description = (starred ? "Star row " : "Unstar row ") + (rowIndex + 1);
StarOneRowProcess process = new StarOneRowProcess(project, description, rowIndex, starred);
performProcessAndRespond(request, response, project, process);
return;
}
String flaggedString = request.getParameter("flagged");
if (flaggedString != null) {
boolean flagged = "true".endsWith(flaggedString);
String description = (flagged ? "Flag row " : "Unflag row ") + (rowIndex + 1);
FlagOneRowProcess process = new FlagOneRowProcess(project, description, rowIndex, flagged);
performProcessAndRespond(request, response, project, process);
return;
}
respond(response, "{ \"code\" : \"error\", \"message\" : \"invalid command parameters\" }");
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class DenormalizeCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
AbstractOperation op = new DenormalizeOperation();
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class GetProjectMetadataCommand method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Project project;
try {
project = getProject(request);
} catch (ServletException e) {
respond(response, "error", e.getLocalizedMessage());
return;
}
respondJSON(response, ProjectManager.singleton.getProjectMetadata(project.id));
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class TransposeColumnsIntoRowsCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
AbstractOperation op;
String startColumnName = request.getParameter("startColumnName");
int columnCount = Integer.parseInt(request.getParameter("columnCount"));
boolean ignoreBlankCells = Boolean.parseBoolean(request.getParameter("ignoreBlankCells"));
boolean fillDown = Boolean.parseBoolean(request.getParameter("fillDown"));
String combinedColumnName = request.getParameter("combinedColumnName");
if (combinedColumnName != null) {
boolean prependColumnName = Boolean.parseBoolean(request.getParameter("prependColumnName"));
String separator = request.getParameter("separator");
op = new TransposeColumnsIntoRowsOperation(startColumnName, columnCount, ignoreBlankCells, fillDown, combinedColumnName, prependColumnName, separator);
} else {
String keyColumnName = request.getParameter("keyColumnName");
String valueColumnName = request.getParameter("valueColumnName");
op = new TransposeColumnsIntoRowsOperation(startColumnName, columnCount, ignoreBlankCells, fillDown, keyColumnName, valueColumnName);
}
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
Aggregations