use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataQueryExectutorTask method createRecordsFilter.
private RecordFilter createRecordsFilter(boolean limitResults) {
CollectSurvey survey = input.query.getSurvey();
EntityDefinition entityDef = (EntityDefinition) survey.getSchema().getDefinitionById(input.query.getEntityDefinitionId());
EntityDefinition rootEntityDef = entityDef.getRootEntity();
Integer rootEntityId = rootEntityDef.getId();
RecordFilter filter = new RecordFilter(survey);
filter.setStep(input.step);
filter.setRootEntityId(rootEntityId);
if (limitResults) {
filter.setOffset(0);
filter.setMaxNumberOfRecords(input.maxRecords);
}
return filter;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataQueryGroupExectutorTask method createRecordsFilter.
private RecordFilter createRecordsFilter() {
CollectSurvey survey = input.getSurvey();
RecordFilter filter = new RecordFilter(survey);
filter.setStep(input.step);
filter.setOffset(0);
filter.setMaxNumberOfRecords(input.maxRecords);
return filter;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataQueryGroupExectutorTask method countTotalItems.
@Override
protected long countTotalItems() {
RecordFilter recordsFilter = createRecordsFilter();
int count = recordManager.countRecords(recordsFilter);
return count;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataCleansingChainExectutorTask method execute.
@Override
@Transactional
protected void execute() throws Throwable {
CollectSurvey survey = input.chain.getSurvey();
RecordFilter filter = createRecordsFilter();
List<CollectRecordSummary> recordSummaries = recordManager.loadSummaries(filter);
datasetSize = recordSummaries.size();
lastRecordModifiedDate = null;
// Delete records in bulk if needed
Set<Integer> recordIdsToBeDeleted = new TreeSet<Integer>();
Iterator<CollectRecordSummary> it = recordSummaries.iterator();
while (it.hasNext() && isRunning()) {
CollectRecordSummary recordSummary = (CollectRecordSummary) it.next();
udpateLastRecordModifiedDate(recordSummary);
CollectRecord record = recordManager.load(survey, recordSummary.getId(), input.step, false);
boolean recordCleansed = false;
for (DataCleansingStep step : input.chain.getSteps()) {
DataCleansingStepExecutionResult stepExecutionResult = executeStep(record, step);
if (stepExecutionResult != null) {
recordCleansed = true;
if (stepExecutionResult == DataCleansingStepExecutionResult.RECORD_TO_BE_DELETED) {
recordIdsToBeDeleted.add(record.getId());
break;
}
}
}
if (recordCleansed) {
cleansedRecords++;
}
incrementProcessedItems();
}
recordManager.deleteByIds(recordIdsToBeDeleted);
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataExportService method fullExport.
@Transactional
public Proxy fullExport(CollectSurvey survey, boolean includeRecordFiles, boolean onlyOwnedRecords, String[] rootEntityKeyValues, boolean full) {
if (backupJob == null || !backupJob.isRunning()) {
resetJobs();
RecordFilter filter = createRecordFilter(survey, null, onlyOwnedRecords, rootEntityKeyValues);
SurveyBackupJob job = jobManager.createJob(SurveyBackupJob.class);
job.setFull(full);
if (full) {
job.setOutputFormat(OutputFormat.DESKTOP_FULL);
} else {
job.setOutputFormat(OutputFormat.ONLY_DATA);
}
job.setSurvey(survey);
job.setIncludeData(true);
job.setIncludeRecordFiles(includeRecordFiles);
job.setRecordFilter(filter);
backupJob = job;
jobManager.start(job);
}
return getCurrentJob();
}
Aggregations