use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SurveySelectVM method loadSelectedSurveyForEdit.
protected CollectSurvey loadSelectedSurveyForEdit() {
String uri = selectedSurvey.getUri();
CollectSurvey temporarySurvey;
if (selectedSurvey.isTemporary()) {
temporarySurvey = surveyManager.loadSurvey(selectedSurvey.getId());
} else if (selectedSurvey.isPublished()) {
temporarySurvey = surveyManager.createTemporarySurveyFromPublished(uri, getLoggedUser());
} else {
throw new IllegalStateException("Trying to load an invalid survey: " + uri);
}
return temporarySurvey;
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SurveySelectVM method editSelectedSurvey.
@Command
public void editSelectedSurvey() throws IOException {
CollectSurvey temporarySurvey = loadSelectedSurveyForEdit();
SurveyEditVM.redirectToSurveyEditPage(temporarySurvey.getId());
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SurveyBaseVM method getCodeLists.
public List<CodeList> getCodeLists() {
CollectSurvey survey = getSurvey();
boolean includeSamplingDesignList = survey.getTarget() != SurveyTarget.COLLECT_EARTH;
List<CodeList> result = new ArrayList<CodeList>(survey.getCodeLists(includeSamplingDesignList));
result = sort(result);
return new BindingListModelList<CodeList>(result, false);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SurveyBaseVM method getVersionLabel.
public String getVersionLabel(int id) {
if (id > 0) {
CollectSurvey survey = getSurvey();
ModelVersion version = survey.getVersionById(id);
String result = null;
if (version != null) {
result = version.getLabel(currentLanguageCode);
if (result == null) {
result = version.getName();
}
}
return result;
} else {
return Labels.getLabel(EMPTY_OPTION);
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SurveyBaseVM method getRootEntities.
public List<EntityDefinition> getRootEntities() {
CollectSurvey survey = getSurvey();
if (survey == null) {
// TODO session expired...?
return Collections.emptyList();
} else {
Schema schema = survey.getSchema();
List<EntityDefinition> result = schema.getRootEntityDefinitions();
return result;
}
}
Aggregations