use of org.openforis.collect.metamodel.SurveyTarget in project collect by openforis.
the class SurveyController method createNewSurveyFromTemplate.
private CollectSurvey createNewSurveyFromTemplate(String name, String langCode, TemplateType templateType) throws IdmlParseException, SurveyValidationException {
String templateFileName = String.format(IDM_TEMPLATE_FILE_NAME_FORMAT, templateType.name().toLowerCase(Locale.ENGLISH));
InputStream surveyFileIs = this.getClass().getResourceAsStream(templateFileName);
CollectSurvey survey = surveyManager.unmarshalSurvey(surveyFileIs, false, true);
survey.setName(name);
survey.setTemporary(true);
survey.setUri(surveyManager.generateSurveyUri(name));
survey.setDefaultLanguage(langCode);
SurveyTarget target;
switch(templateType) {
case COLLECT_EARTH:
case COLLECT_EARTH_IPCC:
target = SurveyTarget.COLLECT_EARTH;
break;
default:
target = SurveyTarget.COLLECT_DESKTOP;
}
survey.setTarget(target);
if (survey.getSamplingDesignCodeList() == null) {
survey.addSamplingDesignCodeList();
}
return survey;
}
use of org.openforis.collect.metamodel.SurveyTarget in project collect by openforis.
the class NewSurveyParametersPopUpVM method createNewSurveyFromTemplate.
protected CollectSurvey createNewSurveyFromTemplate(String name, String langCode, TemplateType templateType) throws IdmlParseException, SurveyValidationException {
String templateFileName = String.format(IDM_TEMPLATE_FILE_NAME_FORMAT, templateType.name().toLowerCase(Locale.ENGLISH));
InputStream surveyFileIs = this.getClass().getResourceAsStream(templateFileName);
CollectSurvey survey = surveyManager.unmarshalSurvey(surveyFileIs, false, true);
survey.setName(name);
survey.setTemporary(true);
survey.setUri(surveyManager.generateSurveyUri(name));
survey.setDefaultLanguage(langCode);
SurveyTarget target;
switch(templateType) {
case COLLECT_EARTH:
case COLLECT_EARTH_IPCC:
target = SurveyTarget.COLLECT_EARTH;
break;
default:
target = SurveyTarget.COLLECT_DESKTOP;
}
survey.setTarget(target);
if (survey.getSamplingDesignCodeList() == null) {
survey.addSamplingDesignCodeList();
}
return survey;
}
Aggregations