use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordFileBackupTask method countTotalItems.
@Override
protected long countTotalItems() {
if (hasFileAttributeDefinitions()) {
RecordFilter filter = new RecordFilter(survey);
filter.setRootEntityId(survey.getSchema().getRootEntityDefinition(rootEntityName).getId());
int count = recordManager.countRecords(filter);
return count;
} else {
return 0;
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordFileRestoreTask method findStoredRecordSummary.
private CollectRecordSummary findStoredRecordSummary(CollectRecord record) {
List<String> recordKeys = record.getRootEntityKeyValues();
RecordFilter filter = new RecordFilter(survey);
filter.setRootEntityId(record.getRootEntityDefinitionId());
filter.setKeyValues(recordKeys);
List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter);
if (summaries.size() == 1) {
CollectRecordSummary summary = summaries.get(0);
return summary;
} else if (summaries.size() == 0) {
throw new RuntimeException(String.format("Record with keys %s not found", recordKeys.toString()));
} else {
throw new RuntimeException(String.format("Multiple records found with keys %s not found", recordKeys.toString()));
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordOperationGenerator method findAlreadyExistingRecordSummary.
private CollectRecordSummary findAlreadyExistingRecordSummary(CollectRecord parsedRecord) {
CollectSurvey survey = (CollectSurvey) parsedRecord.getSurvey();
RecordFilter filter = new RecordFilter(survey);
filter.setRootEntityId(parsedRecord.getRootEntityDefinitionId());
filter.setKeyValues(parsedRecord.getRootEntityKeyValues());
List<CollectRecordSummary> summaries = recordManager.loadFullSummaries(filter, null);
switch(summaries.size()) {
case 0:
return null;
case 1:
return summaries.get(0);
default:
throw new IllegalArgumentException(String.format("Multiple records with keys %s found for survey %s", parsedRecord.getRootEntityKeyValues(), survey.getName()));
}
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordDao method countRecords.
public int countRecords(CollectSurvey survey, int rootDefinitionId, String... keyValues) {
RecordFilter filter = new RecordFilter(survey, rootDefinitionId);
filter.setKeyValues(keyValues);
return countRecords(filter);
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class CSVDataImportJobIntegrationTest method loadRecord.
private CollectRecord loadRecord(String key) {
RecordFilter filter = new RecordFilter(survey);
filter.setRootEntityId(survey.getSchema().getRootEntityDefinition("cluster").getId());
filter.setKeyValues(Arrays.asList(key));
List<CollectRecordSummary> summaries = recordDao.loadSummaries(filter);
assertEquals(1, summaries.size());
CollectRecordSummary summary = summaries.get(0);
CollectRecord reloadedRecord = recordManager.load(survey, summary.getId(), summary.getStep());
return reloadedRecord;
}
Aggregations