Search in sources :

Example 1 with SurveyTarget

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;
}
Also used : SurveyTarget(org.openforis.collect.metamodel.SurveyTarget) InputStream(java.io.InputStream) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 2 with SurveyTarget

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;
}
Also used : SurveyTarget(org.openforis.collect.metamodel.SurveyTarget) InputStream(java.io.InputStream) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

InputStream (java.io.InputStream)2 SurveyTarget (org.openforis.collect.metamodel.SurveyTarget)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2