use of org.openforis.collect.model.NodeProcessor 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.model.NodeProcessor 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.model.NodeProcessor in project collect by openforis.
the class GeoDataController method loadGeometryValues.
@RequestMapping(value = "survey/{surveyId}/data/geometries.json", method = GET)
@ResponseBody
public List<GeometryNodeInfo> loadGeometryValues(@PathVariable int surveyId, @RequestParam int attributeId, @RequestParam String srsId, @RequestParam int recordOffset, @RequestParam int maxNumberOfRecords) throws Exception {
final List<GeometryNodeInfo> result = new ArrayList<GeometryNodeInfo>();
CollectSurvey survey = surveyManager.loadSurvey(surveyId);
processNodes(survey, recordOffset, maxNumberOfRecords, attributeId, new NodeProcessor() {
public void process(Node<?> node) throws Exception {
if (!node.isEmpty()) {
result.add(new GeometryNodeInfo((TextAttribute) node));
}
}
});
return result;
}
Aggregations