use of com.google.refine.model.AbstractOperation 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.AbstractOperation in project OpenRefine by OpenRefine.
the class RowReorderOperationTests method testSortEmptyString.
@Test
public void testSortEmptyString() throws Exception {
String sortingJson = "{\"criteria\":[{\"column\":\"key\",\"valueType\":\"number\",\"reverse\":false,\"blankPosition\":2,\"errorPosition\":1}]}";
SortingConfig sortingConfig = SortingConfig.reconstruct(sortingJson);
project.rows.get(1).cells.set(0, new Cell("", null));
AbstractOperation op = new RowReorderOperation(Mode.RowBased, sortingConfig);
Process process = op.createProcess(project, new Properties());
process.performImmediate();
Assert.assertEquals("h", project.rows.get(0).cells.get(1).value);
Assert.assertEquals("f", project.rows.get(1).cells.get(1).value);
Assert.assertEquals("b", project.rows.get(2).cells.get(1).value);
Assert.assertEquals("d", project.rows.get(3).cells.get(1).value);
}
use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class HistoryProcessTests method setUp.
@BeforeMethod
public void setUp() {
project = new Project();
projectMetadata = mock(ProjectMetadata.class);
ProjectManager.singleton.registerProject(project, projectMetadata);
AbstractOperation op = mock(AbstractOperation.class);
Change ch = mock(Change.class);
HistoryEntry entry = new HistoryEntry(1234L, project, "first operation", op, ch);
project.history.addEntry(entry);
entry = new HistoryEntry(5678L, project, "second operation", op, ch);
project.history.addEntry(entry);
}
use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.
the class MoveColumnCommand 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 index = Integer.parseInt(request.getParameter("index"));
AbstractOperation op = new ColumnMoveOperation(columnName, index);
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 FillDownTests method testFillDownRecords.
// For issue #742
// https://github.com/OpenRefine/OpenRefine/issues/742
@Test
public void testFillDownRecords() throws Exception {
AbstractOperation op = new FillDownOperation(EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"), "second");
Process process = op.createProcess(project, new Properties());
process.performImmediate();
Assert.assertEquals("c", project.rows.get(0).cells.get(2).value);
Assert.assertEquals("c", project.rows.get(1).cells.get(2).value);
Assert.assertNull(project.rows.get(2).cells.get(2));
Assert.assertEquals("h", project.rows.get(3).cells.get(2).value);
}
Aggregations