use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class ColumnRenameOperationTests method serializeColumnRenameOperation.
@Test
public void serializeColumnRenameOperation() throws Exception {
String json = "{\"op\":\"core/column-rename\"," + "\"description\":\"Rename column old name to new name\"," + "\"oldColumnName\":\"old name\"," + "\"newColumnName\":\"new name\"}";
AbstractOperation op = ParsingUtilities.mapper.readValue(json, AbstractOperation.class);
TestUtils.isSerializedTo(op, json);
}
use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class BlankDownTests method serializeBlankDownOperation.
@Test
public void serializeBlankDownOperation() throws Exception {
String json = "{\"op\":\"core/blank-down\"," + "\"description\":\"Blank down cells in column my column\"," + "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]}," + "\"columnName\":\"my column\"}";
AbstractOperation op = ParsingUtilities.mapper.readValue(json, BlankDownOperation.class);
TestUtils.isSerializedTo(op, json);
}
use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class JoinMultiValuedCellsTests method testJoinMultiValuedCells.
/*
* Test to demonstrate the intended behaviour of the function
*/
@Test
public void testJoinMultiValuedCells() throws Exception {
AbstractOperation op = new MultiValuedCellJoinOperation("Value", "Key", ",");
Process process = op.createProcess(project, new Properties());
process.performImmediate();
int keyCol = project.columnModel.getColumnByName("Key").getCellIndex();
int valueCol = project.columnModel.getColumnByName("Value").getCellIndex();
Assert.assertEquals(project.rows.get(0).getCellValue(keyCol), "Record_1");
Assert.assertEquals(project.rows.get(0).getCellValue(valueCol), "one,two,three,four");
}
use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class JoinMultiValueCellsCommand 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");
AbstractOperation op = new MultiValuedCellJoinOperation(columnName, keyColumnName, separator);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class KeyValueColumnizeCommand 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 keyColumnName = request.getParameter("keyColumnName");
String valueColumnName = request.getParameter("valueColumnName");
String noteColumnName = request.getParameter("noteColumnName");
AbstractOperation op = new KeyValueColumnizeOperation(keyColumnName, valueColumnName, noteColumnName);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
Aggregations