use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataService method loadRecordSummaries.
@Secured(USER)
public Map<String, Object> loadRecordSummaries(RecordFilterProxy filterProxy, List<RecordSummarySortField> sortFields, String localeStr) {
Map<String, Object> result = new HashMap<String, Object>();
CollectSurvey survey;
if (filterProxy.getSurveyId() > 0) {
survey = surveyManager.getById(filterProxy.getSurveyId());
} else {
SessionState sessionState = sessionManager.getSessionState();
survey = sessionState.getActiveSurvey();
}
RecordFilter filter = filterProxy.toFilter(survey);
// load summaries
List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter, sortFields);
Locale locale = LocaleUtils.toLocale(localeStr);
ProxyContext proxyContext = new ProxyContext(locale, messageSource, surveyContext);
List<RecordSummaryProxy> proxies = RecordSummaryProxy.fromList(summaries, proxyContext);
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 RDBReportingRepositories method getInfo.
@Override
public ReportingRepositoryInfo getInfo(String surveyName) {
Date rdbFileDate = localRDBStorageManager.getRDBFileDate(surveyName, RecordStep.ENTRY);
if (rdbFileDate == null) {
return null;
} else {
ReportingRepositoryInfo info = new ReportingRepositoryInfo();
info.setLastUpdate(rdbFileDate);
RecordFilter filter = new RecordFilter(surveyManager.get(surveyName));
filter.setModifiedSince(rdbFileDate);
info.setUpdatedRecordsSinceLastUpdate(recordManager.countRecords(filter));
return info;
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RDBReportingRepositories method insertRecords.
private void insertRecords(String surveyName, RecordStep recordStep, RelationalSchema targetSchema, Connection targetConn, ProgressListener progressListener) throws CollectRdbException {
ProcessProgressListener processProgressListener = new ProcessProgressListener(2);
CollectSurvey survey = surveyManager.get(surveyName);
DatabaseExporter databaseUpdater = createRDBUpdater(targetSchema, targetConn);
databaseUpdater.insertReferenceData(new ProcessStepProgressListener(processProgressListener, progressListener));
processProgressListener.stepCompleted();
RecordFilter recordFilter = new RecordFilter(survey);
Step step = Step.fromRecordStep(recordStep);
recordFilter.setStepGreaterOrEqual(step);
List<CollectRecordSummary> summaries = recordManager.loadSummaries(recordFilter);
ProcessStepProgressListener recordInsertProcessListener = new ProcessStepProgressListener(processProgressListener, progressListener);
recordInsertProcessListener.progressMade(new Progress(0, summaries.size()));
long processedRecords = 0;
for (CollectRecordSummary summary : summaries) {
CollectRecord record = recordManager.load(survey, summary.getId(), step, false);
databaseUpdater.insertRecordData(record, ProgressListener.NULL_PROGRESS_LISTENER);
processedRecords++;
recordInsertProcessListener.progressMade(new Progress(processedRecords, summaries.size()));
}
IOUtils.closeQuietly(databaseUpdater);
processProgressListener.stepCompleted();
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class BackupRestoreController 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 BackupRestoreController method startFullExport.
@Transactional
public JobProxy startFullExport(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