Search in sources :

Example 31 with SurveySummary

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

the class SurveyManager method updateUserGroup.

public SurveySummary updateUserGroup(int id, int userGroupId) throws SurveyStoreException {
    UserGroup userGroup = userGroupManager.loadById(userGroupId);
    SurveySummary surveySummary = loadSummaryById(id);
    Set<Integer> surveyIdsToUpdate = new HashSet<Integer>();
    surveyIdsToUpdate.add(surveySummary.getId());
    // consider even updating associated published survey, if any
    org.apache.commons.collections.CollectionUtils.addIgnoreNull(surveyIdsToUpdate, surveySummary.getPublishedId());
    for (Integer surveyId : surveyIdsToUpdate) {
        CollectSurvey s = getOrLoadSurveyById(surveyId);
        s.setUserGroup(userGroup);
        save(s);
    }
    return surveySummary;
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary) CollectSurvey(org.openforis.collect.model.CollectSurvey) UserGroup(org.openforis.collect.model.UserGroup) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 32 with SurveySummary

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

the class SurveyManager method isSurveyTemporary.

public boolean isSurveyTemporary(CollectSurvey survey) {
    Integer id = survey.getId();
    String uri = survey.getUri();
    SurveySummary temporarySurveySummary = loadTemporarySummaryByUri(uri);
    if (temporarySurveySummary == null || !temporarySurveySummary.getId().equals(id)) {
        CollectSurvey publishedSurvey = getByUri(uri);
        if (publishedSurvey == null || !publishedSurvey.getId().equals(id)) {
            throw new IllegalStateException("Survey with uri '" + uri + "' not found");
        } else {
            return false;
        }
    } else {
        return true;
    }
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 33 with SurveySummary

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

the class SurveyEditVM method checkSurveyNameUniqueness.

private boolean checkSurveyNameUniqueness() {
    SurveySummary existingSurveySummary = surveyManager.loadSummaryByName(survey.getName());
    if (existingSurveySummary != null && !isCurrentEditedSurvey(existingSurveySummary)) {
        String messageKey = LabelKeys.SURVEY_SAVE_ERROR_DUPLICATE_NAME;
        MessageUtil.showWarning(messageKey);
        return false;
    } else {
        return true;
    }
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary)

Example 34 with SurveySummary

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

the class SurveyEditVM method checkSurveyUriUniqueness.

private boolean checkSurveyUriUniqueness() {
    SurveySummary existingSurveySummary = surveyManager.loadSummaryByUri(survey.getUri());
    if (existingSurveySummary != null && !isCurrentEditedSurvey(existingSurveySummary)) {
        String messageKey = LabelKeys.SURVEY_SAVE_ERROR_DUPLICATE_URI;
        MessageUtil.showWarning(messageKey);
        return false;
    } else {
        return true;
    }
}
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