use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class ReconOperationTests method serializeReconProcess.
@Test
public void serializeReconProcess() throws Exception {
ReconOperation op = ParsingUtilities.mapper.readValue(json, ReconOperation.class);
Project project = mock(Project.class);
Process process = op.createProcess(project, new Properties());
TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode()));
}
use of com.google.refine.process.Process in project OpenRefine by OpenRefine.
the class ReconOperationTests method testFailingRecon.
@Test
public void testFailingRecon() throws Exception {
Project project = createCSVProject("my recon test project", "column\n" + "valueA\n" + "valueB\n" + "valueC");
StandardReconConfig reconConfig = mock(StandardReconConfig.class);
List<Recon> reconList = Arrays.asList((Recon) null, (Recon) null, (Recon) null);
ReconJob reconJob = mock(ReconJob.class);
when(reconConfig.batchRecon(Mockito.any(), Mockito.anyLong())).thenReturn(reconList);
when(reconConfig.getBatchSize()).thenReturn(10);
when(reconConfig.createJob(Mockito.eq(project), Mockito.anyInt(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(reconJob);
ReconOperation op = new ReconOperation(EngineConfig.reconstruct("{}"), "column", reconConfig);
Process process = op.createProcess(project, new Properties());
runAndWait(project.getProcessManager(), process, 1000);
Column column = project.columnModel.columns.get(0);
Assert.assertNotNull(column.getReconStats());
Assert.assertEquals(column.getReconStats().matchedTopics, 0);
Assert.assertNull(project.rows.get(0).getCell(0).recon);
Assert.assertNull(project.rows.get(1).getCell(0).recon);
Assert.assertNull(project.rows.get(2).getCell(0).recon);
}
use of com.google.refine.process.Process 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