use of org.openforis.collect.model.CollectRecordSummary in project collect by openforis.
the class DataRestoreSummaryTask method createConflictingRecordItems.
private List<DataImportSummaryItem> createConflictingRecordItems() {
List<DataImportSummaryItem> conflictingRecordItems = new ArrayList<DataImportSummaryItem>();
Set<Integer> conflictingEntryIds = conflictingRecordByEntryId.keySet();
for (Integer entryId : conflictingEntryIds) {
CollectRecordSummary recordSummary = recordSummaryByEntryId.get(entryId);
CollectRecordSummary conflictingRecord = conflictingRecordByEntryId.get(entryId);
Set<Step> steps = stepsByEntryId.get(entryId);
DataImportSummaryItem item = new DataImportSummaryItem(entryId, recordSummary, new ArrayList<Step>(steps), conflictingRecord);
item.setWarnings(warningsByEntryId.get(entryId));
conflictingRecordItems.add(item);
}
return conflictingRecordItems;
}
use of org.openforis.collect.model.CollectRecordSummary in project collect by openforis.
the class DataRestoreSummaryTask method createRecordToImportItems.
private List<DataImportSummaryItem> createRecordToImportItems() {
List<DataImportSummaryItem> recordsToImport = new ArrayList<DataImportSummaryItem>();
Set<Integer> entryIds = recordSummaryByEntryId.keySet();
for (Integer entryId : entryIds) {
if (!conflictingRecordByEntryId.containsKey(entryId)) {
Set<Step> steps = stepsByEntryId.get(entryId);
CollectRecordSummary recordSummary = recordSummaryByEntryId.get(entryId);
DataImportSummaryItem item = new DataImportSummaryItem(entryId, recordSummary, new ArrayList<Step>(steps));
item.setWarnings(warningsByEntryId.get(entryId));
recordsToImport.add(item);
}
}
return recordsToImport;
}
use of org.openforis.collect.model.CollectRecordSummary in project collect by openforis.
the class RecordFileBackupTask method execute.
@Override
protected void execute() throws Throwable {
if (!hasFileAttributeDefinitions()) {
return;
}
RecordFilter filter = new RecordFilter(survey);
filter.setRootEntityId(survey.getSchema().getRootEntityDefinition(rootEntityName).getId());
recordManager.visitSummaries(filter, new Visitor<CollectRecordSummary>() {
public void visit(CollectRecordSummary summary) {
try {
backup(summary);
incrementProcessedItems();
} catch (Exception e) {
addSkippedRecord(summary);
log.error(String.format("Error backing up record files for record with id %d and keys %s", summary.getId(), summary.getRootEntityKeyValues().toString()));
}
}
}, new Predicate<CollectRecordSummary>() {
public boolean evaluate(CollectRecordSummary s) {
return !isRunning();
}
});
}
use of org.openforis.collect.model.CollectRecordSummary 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.CollectRecordSummary 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()));
}
}
Aggregations