use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class ApplyOperationsCommand method reconstructOperation.
protected void reconstructOperation(Project project, JSONObject obj) {
AbstractOperation operation = OperationRegistry.reconstruct(project, obj);
if (operation != null) {
try {
Process process = operation.createProcess(project, new Properties());
project.processManager.queueProcess(process);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class SplitMultiValueCellsCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
String keyColumnName = request.getParameter("keyColumnName");
String separator = request.getParameter("separator");
String mode = request.getParameter("mode");
Boolean regex = Boolean.parseBoolean(request.getParameter("regex"));
AbstractOperation op;
if ("lengths".equals(mode)) {
String s = request.getParameter("fieldLengths");
int[] fieldLengths = ParsingUtilities.mapper.readValue(s, new TypeReference<int[]>() {
});
op = new MultiValuedCellSplitOperation(columnName, keyColumnName, fieldLengths);
} else {
op = new MultiValuedCellSplitOperation(columnName, keyColumnName, separator, regex);
}
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class RemoveColumnCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
AbstractOperation op = new ColumnRemovalOperation(columnName);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class ApplyOperationsCommand method reconstructOperation.
protected void reconstructOperation(Project project, ObjectNode obj) throws IOException {
AbstractOperation operation = ParsingUtilities.mapper.convertValue(obj, AbstractOperation.class);
if (operation != null && !(operation instanceof UnknownOperation)) {
try {
Process process = operation.createProcess(project, new Properties());
project.processManager.queueProcess(process);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class TransposeRowsIntoColumnsCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
int rowCount = Integer.parseInt(request.getParameter("rowCount"));
AbstractOperation op = new TransposeRowsIntoColumnsOperation(columnName, rowCount);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
Aggregations