Search in sources :

Example 6 with StepSummary

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()));
    }
}
Also used : StepSummary(org.openforis.collect.model.CollectRecordSummary.StepSummary)

Example 7 with StepSummary

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();
        }
    }
}
Also used : StepSummary(org.openforis.collect.model.CollectRecordSummary.StepSummary) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) OfcRecordRecord(org.openforis.collect.persistence.jooq.tables.records.OfcRecordRecord) CollectRecord(org.openforis.collect.model.CollectRecord) OfcRecordDataRecord(org.openforis.collect.persistence.jooq.tables.records.OfcRecordDataRecord) Record(org.jooq.Record) Step(org.openforis.collect.model.CollectRecord.Step)

Example 8 with StepSummary

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;
}
Also used : StepSummary(org.openforis.collect.model.CollectRecordSummary.StepSummary) HashMap(java.util.HashMap) Step(org.openforis.collect.model.CollectRecord.Step)

Aggregations

StepSummary (org.openforis.collect.model.CollectRecordSummary.StepSummary)8 Step (org.openforis.collect.model.CollectRecord.Step)7 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)5 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)2 Schema (org.openforis.idm.metamodel.Schema)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Record (org.jooq.Record)1 TableField (org.jooq.TableField)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 RecordFilter (org.openforis.collect.model.RecordFilter)1 OfcRecordDataRecord (org.openforis.collect.persistence.jooq.tables.records.OfcRecordDataRecord)1 OfcRecordRecord (org.openforis.collect.persistence.jooq.tables.records.OfcRecordRecord)1 CsvLine (org.openforis.commons.io.csv.CsvLine)1 CsvReader (org.openforis.commons.io.csv.CsvReader)1 ModelVersion (org.openforis.idm.metamodel.ModelVersion)1