Search in sources :

Example 16 with SurveySummary

use of org.openforis.collect.model.SurveySummary in project collect by openforis.

the class SurveySelectVM method updateSurveyList.

@GlobalCommand
public void updateSurveyList() {
    if (surveyImportPopUp != null || jobStatusPopUp != null) {
        // skip survey list update
        return;
    }
    try {
        List<SurveySummary> newSummaries = loadSurveySummaries(null);
        if (summaries == null) {
            summaries = newSummaries;
        } else {
            for (SurveySummary newSummary : newSummaries) {
                SurveySummary oldSummary = findSummary(newSummary.getId(), newSummary.isPublished(), newSummary.isTemporary());
                if (oldSummary == null) {
                // TODO handle this??
                } else {
                    oldSummary.setRecordValidationProcessStatus(newSummary.getRecordValidationProcessStatus());
                    BindUtils.postNotifyChange(null, null, oldSummary, "recordValidationProgressStatus");
                    BindUtils.postNotifyChange(null, null, oldSummary, "recordValidationInProgress");
                    BindUtils.postNotifyChange(null, null, oldSummary, "recordValidationProgressPercent");
                }
            }
        }
    } catch (Exception e) {
        return;
    }
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary) SurveyStoreException(org.openforis.collect.persistence.SurveyStoreException) IOException(java.io.IOException) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 17 with SurveySummary

use of org.openforis.collect.model.SurveySummary in project collect by openforis.

the class SurveyManager method loadSummaryByName.

public SurveySummary loadSummaryByName(String name) {
    SurveySummary temporarySummary = loadTemporarySummaryByName(name);
    SurveySummary publishedSummary = getPublishedSummaryByName(name);
    SurveySummary result = combineSummaries(temporarySummary, publishedSummary);
    return result;
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary)

Example 18 with SurveySummary

use of org.openforis.collect.model.SurveySummary in project collect by openforis.

the class SurveyManager method combineSummaries.

private SurveySummary combineSummaries(SurveySummary temporarySummary, SurveySummary publishedSummary) {
    SurveySummary result;
    if (temporarySummary != null) {
        result = temporarySummary;
        if (publishedSummary != null) {
            result.setPublished(true);
            result.setPublishedId(publishedSummary.getId());
        }
    } else {
        result = publishedSummary;
    }
    return result;
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary)

Example 19 with SurveySummary

use of org.openforis.collect.model.SurveySummary in project collect by openforis.

the class SurveyManager method loadCombinedSummaries.

public List<SurveySummary> loadCombinedSummaries(String labelLang, boolean includeDetails, Set<Integer> groupIds, List<SurveySummarySortField> sortFields) {
    List<SurveySummary> publishedSurveySummaries = getSurveySummaries(labelLang, groupIds);
    List<SurveySummary> temporarySurveySummaries = loadTemporarySummaries(labelLang, includeDetails, groupIds);
    List<SurveySummary> result = new ArrayList<SurveySummary>();
    Map<String, SurveySummary> summariesByUri = new HashMap<String, SurveySummary>();
    for (SurveySummary tempSummary : temporarySurveySummaries) {
        tempSummary.setPublished(false);
        tempSummary.setTemporary(true);
        result.add(tempSummary);
        summariesByUri.put(tempSummary.getUri(), tempSummary);
    }
    for (SurveySummary publishedSummary : publishedSurveySummaries) {
        publishedSummary.setPublishedId(publishedSummary.getId());
        SurveySummary temporarySurveySummary = summariesByUri.get(publishedSummary.getUri());
        if (temporarySurveySummary == null) {
            result.add(publishedSummary);
        } else {
            temporarySurveySummary.setAvailability(PUBLISHED);
            temporarySurveySummary.setPublished(true);
            temporarySurveySummary.setRecordValidationProcessStatus(publishedSummary.getRecordValidationProcessStatus());
        }
    }
    sortSummaries(result, sortFields);
    return result;
}
Also used : HashMap(java.util.HashMap) SurveySummary(org.openforis.collect.model.SurveySummary) ArrayList(java.util.ArrayList)

Example 20 with SurveySummary

use of org.openforis.collect.model.SurveySummary in project collect by openforis.

the class SurveyManager method loadSummaryByUri.

public SurveySummary loadSummaryByUri(String uri) {
    SurveySummary temporarySummary = loadTemporarySummaryByUri(uri);
    SurveySummary publishedSummary = getPublishedSummaryByUri(uri);
    SurveySummary result = combineSummaries(temporarySummary, publishedSummary);
    return result;
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary)

Aggregations

SurveySummary (org.openforis.collect.model.SurveySummary)34 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 Record (org.jooq.Record)8 Transactional (org.springframework.transaction.annotation.Transactional)8 ArrayList (java.util.ArrayList)5 OfcSurveyRecord (org.openforis.collect.persistence.jooq.tables.records.OfcSurveyRecord)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 UserGroup (org.openforis.collect.model.UserGroup)2 SurveyImportException (org.openforis.collect.persistence.SurveyImportException)2 Response (org.openforis.commons.web.Response)2 File (java.io.File)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 Test (org.junit.Test)1 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)1