use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataExportService method createRecordFilter.
private RecordFilter createRecordFilter(CollectSurvey survey, Integer rootEntityId, boolean onlyOwnedRecords, String[] rootEntityKeyValues) {
RecordFilter recordFilter = new RecordFilter(survey, rootEntityId);
// filter by record owner
if (onlyOwnedRecords) {
SessionState sessionState = sessionManager.getSessionState();
User user = sessionState.getUser();
recordFilter.setOwnerId(user.getId());
}
// filter by root entity keys
recordFilter.setKeyValues(rootEntityKeyValues);
return recordFilter;
}
use of org.openforis.collect.model.RecordFilter 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();
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataService method loadRecordSummaries.
/**
* @param rootEntityName
* @param offset
* @param toIndex
* @param orderByFieldName
* @param filter
*
* @return map with "count" and "records" items
*/
@Secured(USER)
public Map<String, Object> loadRecordSummaries(String rootEntityName, int offset, int maxNumberOfRows, List<RecordSummarySortField> sortFields, String[] keyValues) {
Map<String, Object> result = new HashMap<String, Object>();
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey activeSurvey = sessionState.getActiveSurvey();
Schema schema = activeSurvey.getSchema();
EntityDefinition rootEntityDefinition = schema.getRootEntityDefinition(rootEntityName);
RecordFilter filter = new RecordFilter(activeSurvey, rootEntityDefinition.getId());
filter.setKeyValues(keyValues);
filter.setOffset(offset);
filter.setMaxNumberOfRecords(maxNumberOfRows);
// load summaries
List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter, sortFields);
List<RecordSummaryProxy> proxies = RecordSummaryProxy.fromList(summaries, getProxyContext());
result.put("records", proxies);
// count total records
int count = recordManager.countRecords(filter);
result.put("count", count);
return result;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordFilterProxy method toFilter.
public RecordFilter toFilter(CollectSurvey survey) {
RecordFilter filter = new RecordFilter(survey);
filter.setCaseSensitiveKeyValues(isCaseSensitiveKeyValues());
filter.setKeyValues(getKeyValues());
filter.setMaxNumberOfRecords(getMaxNumberOfRecords());
filter.setModifiedSince(getModifiedSince());
filter.setOffset(getOffset());
filter.setOwnerIds(getOwnerIds());
filter.setRecordId(getRecordId());
filter.setRootEntityId(getRootEntityId());
filter.setStep(getStep());
filter.setStepGreaterOrEqual(getStepGreaterOrEqual());
return filter;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataBackupTask method createInternalVariables.
@Override
protected void createInternalVariables() throws Throwable {
if (recordFilter == null) {
recordFilter = new RecordFilter(survey);
}
initializeDataSummaryCSVWriter();
super.createInternalVariables();
}
Aggregations