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;
}
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;
}
}
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;
}
}
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;
}
}
Aggregations