use of org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput in project collect by openforis.
the class DataCleansingChainIntegrationTest method countResults.
private int countResults(DataQuery query) {
final List<Node<?>> nodes = new ArrayList<Node<?>>();
DataQueryExecutorJob job = jobManager.createJob(DataQueryExecutorJob.class);
DataQueryExecutorJobInput dataQueryExecutorJobInput = new DataQueryExecutorJobInput(query, Step.ENTRY, new NodeProcessor() {
public void process(Node<?> node) throws Exception {
nodes.add(node);
}
});
job.setInput(dataQueryExecutorJobInput);
jobManager.start(job, false);
return nodes.size();
}
use of org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput in project collect by openforis.
the class QueryExecutorIntegrationTest method testSimpleQuery.
@Test
public void testSimpleQuery() {
// select region from tree where dbh > 20
DataQuery query = new DataQuery(survey);
EntityDefinition treeDef = (EntityDefinition) survey.getSchema().getDefinitionByPath("/cluster/plot/tree");
AttributeDefinition dbhDef = (AttributeDefinition) survey.getSchema().getDefinitionByPath("/cluster/plot/tree/dbh");
query.setEntityDefinition(treeDef);
query.setAttributeDefinition(dbhDef);
query.setConditions("dbh > 20");
final List<Node<?>> nodes = new ArrayList<Node<?>>();
DataQueryExecutorJob job = jobManager.createJob(DataQueryExecutorJob.class);
DataQueryExecutorJobInput input = new DataQueryExecutorJobInput(query, Step.ENTRY, new NodeProcessor() {
public void process(Node<?> node) {
nodes.add(node);
}
});
job.setInput(input);
jobManager.start(job, false);
assertFalse(nodes.isEmpty());
// first result
Node<?> node = nodes.get(0);
assertTrue(node instanceof Attribute);
CollectRecord record = (CollectRecord) node.getRecord();
assertEquals(Arrays.asList("10_117"), record.getRootEntityKeyValues());
}
use of org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput in project collect by openforis.
the class DataQueryController method startTest.
@RequestMapping(value = "start-test.json", method = RequestMethod.POST)
@ResponseBody
public Response startTest(@Validated DataQueryForm form, @RequestParam Step recordStep, BindingResult result) {
List<ObjectError> errors = result.getAllErrors();
if (errors.isEmpty()) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataQuery query = new DataQuery(survey);
form.copyTo(query);
testJob = collectJobManager.createJob(DataQueryExecutorJob.class);
testJob.setInput(new DataQueryExecutorJobInput(query, recordStep, new MemoryStoreDataQueryResultItemProcessor(query), TEST_MAX_RECORDS));
collectJobManager.start(testJob);
return new Response();
} else {
return new SimpleFormUpdateResponse(errors);
}
}
Aggregations