use of org.openforis.collect.model.CollectRecordSummary.StepSummary in project collect by openforis.
the class RecordManager method loadDetachedObjects.
private void loadDetachedObjects(CollectRecordSummary s) {
s.setCreatedBy(loadUser(s.getCreatedBy()));
s.setModifiedBy(loadUser(s.getModifiedBy()));
s.setOwner(loadUser(s.getOwner()));
Collection<StepSummary> stepSummaries = s.getStepSummaries().values();
for (StepSummary stepSummary : stepSummaries) {
stepSummary.setCreatedBy(loadUser(stepSummary.getCreatedBy()));
stepSummary.setModifiedBy(loadUser(stepSummary.getModifiedBy()));
}
}
use of org.openforis.collect.model.CollectRecordSummary.StepSummary in project collect by openforis.
the class RecordDao method visitSummaries.
public void visitSummaries(RecordFilter filter, List<RecordSummarySortField> sortFields, Visitor<CollectRecordSummary> visitor, boolean includeStepDetails, Predicate<CollectRecordSummary> stopWhenPredicate) {
SelectQuery<Record> q = createSelectSummariesQuery(filter, sortFields);
Cursor<Record> cursor = null;
try {
cursor = q.fetchLazy();
while (cursor.hasNext()) {
Record r = cursor.fetchOne();
CollectRecordSummary s = fromSummaryQueryRecord(filter.getSurvey(), r);
if (includeStepDetails) {
s.clearStepSummaries();
Map<Step, StepSummary> summaryByStep = loadLatestStepSummaries(filter.getSurvey(), s.getId());
for (Step step : Step.values()) {
StepSummary stepSummary = summaryByStep.get(step);
if (stepSummary != null) {
s.addStepSummary(stepSummary);
}
}
}
visitor.visit(s);
if (stopWhenPredicate.evaluate(s)) {
break;
}
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
use of org.openforis.collect.model.CollectRecordSummary.StepSummary in project collect by openforis.
the class RecordDao method loadLatestStepSummaries.
private Map<Step, StepSummary> loadLatestStepSummaries(CollectSurvey survey, int recordId) {
Map<Step, StepSummary> summaryByStep = new HashMap<Step, StepSummary>();
List<StepSummary> allStepsSummaries = loadAllStepsSummaries(survey, recordId);
ListIterator<StepSummary> listIterator = allStepsSummaries.listIterator(allStepsSummaries.size());
while (listIterator.hasPrevious() && summaryByStep.size() < Step.values().length) {
StepSummary stepSummary = listIterator.previous();
if (!summaryByStep.containsKey(stepSummary.getStep()) && stepSummary.getState() == null) {
summaryByStep.put(stepSummary.getStep(), stepSummary);
}
}
return summaryByStep;
}
Aggregations