use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordManager method loadUniqueRecordSummaryByKeys.
public CollectRecordSummary loadUniqueRecordSummaryByKeys(CollectSurvey survey, String rootEntityName, String... keyValues) {
RecordFilter filter = new RecordFilter(survey);
filter.setRootEntityId(survey.getSchema().getRootEntityDefinition(rootEntityName).getId());
filter.setKeyValues(keyValues);
List<CollectRecordSummary> oldRecords = loadSummaries(filter);
if (oldRecords == null || oldRecords.isEmpty()) {
return null;
} else if (oldRecords.size() == 1) {
return oldRecords.get(0);
} else {
throw new IllegalStateException(String.format("Multiple records found in survey %s with key(s): %s", survey.getName(), keyValues));
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataQueryExectutorTask method countTotalItems.
@Override
protected long countTotalItems() {
RecordFilter recordsFilter = createRecordsFilter(false);
int count = recordManager.countRecords(recordsFilter);
return count;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataQueryExectutorTask method execute.
@Override
@Transactional
protected void execute() throws Throwable {
CollectSurvey survey = input.query.getSurvey();
DataQueryEvaluator queryEvaluator = createQueryEvaluator(input.query);
RecordFilter filter = createRecordsFilter(true);
List<CollectRecordSummary> recordSummaries = recordManager.loadSummaries(filter);
Iterator<CollectRecordSummary> it = recordSummaries.iterator();
while (it.hasNext() && isRunning()) {
CollectRecordSummary recordSummary = (CollectRecordSummary) it.next();
CollectRecord record = recordManager.load(survey, recordSummary.getId(), input.step, false);
List<Node<?>> nodes = queryEvaluator.evaluate(record);
for (Node<?> node : nodes) {
processNode(node);
}
incrementProcessedItems();
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataQueryGroupExectutorTask method execute.
@Override
@Transactional
protected void execute() throws Throwable {
CollectSurvey survey = input.getSurvey();
RecordFilter filter = createRecordsFilter();
List<CollectRecordSummary> recordSummaries = recordManager.loadSummaries(filter);
Iterator<CollectRecordSummary> it = recordSummaries.iterator();
while (it.hasNext() && isRunning()) {
CollectRecordSummary recordSummary = (CollectRecordSummary) it.next();
Date modifiedDate = recordSummary.getModifiedDate();
if (lastRecordModifiedDate == null) {
lastRecordModifiedDate = modifiedDate;
} else if (modifiedDate.compareTo(lastRecordModifiedDate) > 0) {
lastRecordModifiedDate = modifiedDate;
}
CollectRecord record = recordManager.load(survey, recordSummary.getId(), input.step, false);
List<DataQuery> queries = input.getQueries();
for (DataQuery query : queries) {
DataQueryEvaluator queryEvaluator = createQueryEvaluator(query);
List<Node<?>> nodes = queryEvaluator.evaluate(record);
for (Node<?> node : nodes) {
processNode(query, node);
}
}
incrementProcessedItems();
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataCleansingChainExectutorTask method createRecordsFilter.
private RecordFilter createRecordsFilter() {
CollectSurvey survey = input.chain.getSurvey();
EntityDefinition rootEntityDef = survey.getSchema().getFirstRootEntityDefinition();
Integer rootEntityId = rootEntityDef.getId();
RecordFilter filter = new RecordFilter(survey);
filter.setStep(input.step);
filter.setRootEntityId(rootEntityId);
filter.setOffset(0);
filter.setMaxNumberOfRecords(input.maxRecords);
return filter;
}
Aggregations