use of org.openforis.collect.model.CollectSurvey 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.CollectSurvey 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.CollectSurvey in project collect by openforis.
the class CodeTableDataExtractor method getCodeListService.
private CodeListService getCodeListService() {
CollectSurvey survey = (CollectSurvey) table.getCodeList().getSurvey();
SurveyContext context = survey.getContext();
CodeListService codeListService = context.getCodeListService();
return codeListService;
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class DataExportService method fullExport.
@Transactional
public Proxy fullExport(boolean includeRecordFiles, boolean onlyOwnedRecords, String[] rootEntityKeyValues) {
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
return fullExport(survey, includeRecordFiles, onlyOwnedRecords, rootEntityKeyValues, false);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class DataExportService method export.
@Transactional
public Proxy export(String rootEntityName, int stepNumber, Integer entityId, boolean includeAllAncestorAttributes, boolean includeEnumeratedEntities, boolean includeCompositeAttributeMergedColumn, boolean codeAttributeExpanded, boolean onlyOwnedRecords, String[] rootEntityKeyValues, boolean includeKMLColumnForCoordinates, boolean includeCodeItemLabelColumn, String headingSource, String languageCode, boolean includeGroupingLabels) throws IOException {
if (dataExportProcess == null || !dataExportProcess.getStatus().isRunning()) {
resetJobs();
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
File outputFile = File.createTempFile("collect_data_export_" + survey.getName(), ".zip");
Step step = Step.valueOf(stepNumber);
// prepare record filter
Schema schema = survey.getSchema();
EntityDefinition rootEntityDefn = schema.getRootEntityDefinition(rootEntityName);
RecordFilter recordFilter = createRecordFilter(survey, rootEntityDefn.getId(), onlyOwnedRecords, rootEntityKeyValues);
// filter by record step
recordFilter.setStepGreaterOrEqual(step);
// instantiate process
CSVDataExportProcess process = appContext.getBean(CSVDataExportProcess.class);
process.setOutputFile(outputFile);
process.setRecordFilter(recordFilter);
process.setEntityId(entityId);
process.setAlwaysGenerateZipFile(true);
CSVDataExportParameters config = new CSVDataExportParameters();
config.setIncludeAllAncestorAttributes(includeAllAncestorAttributes);
config.setIncludeEnumeratedEntities(includeEnumeratedEntities);
config.setIncludeCompositeAttributeMergedColumn(includeCompositeAttributeMergedColumn);
config.setIncludeKMLColumnForCoordinates(includeKMLColumnForCoordinates);
config.setCodeAttributeExpanded(codeAttributeExpanded);
config.setIncludeCodeItemLabelColumn(includeCodeItemLabelColumn);
config.setHeadingSource(HeadingSource.valueOf(headingSource));
config.setLanguageCode(languageCode);
config.setIncludeGroupingLabels(includeGroupingLabels);
process.setConfiguration(config);
process.init();
// start process
dataExportProcess = process;
ExecutorServiceUtil.executeInCachedPool(process);
}
return getCurrentJob();
}
Aggregations