Search in sources :

Example 1 with CeoApplicationOptions

use of org.openforis.collect.persistence.xml.CeoApplicationOptions in project collect by openforis.

the class SurveyCreator method generateSimpleSurvey.

public CollectSurvey generateSimpleSurvey(SimpleSurveyCreationParameters parameters) throws SurveyStoreException, SurveyImportException {
    String projectName = parameters.getProjectName();
    String internalName = ObjectUtils.defaultIfNull(parameters.getName(), SurveyObjects.adjustInternalName(projectName));
    CollectSurvey existingSurvey = surveyManager.get(internalName);
    if (existingSurvey != null) {
        // TODO move it to validator
        throw new IllegalArgumentException(String.format("Survey with name %s already existing", internalName));
    }
    CollectSurvey survey = createTemporarySimpleSurvey(internalName, parameters.getCodeLists());
    survey.setProjectName(survey.getDefaultLanguage(), projectName);
    survey.setDescription(survey.getDefaultLanguage(), parameters.getDescription());
    UserGroup userGroup = userGroupManager.loadById(parameters.getUserGroupId());
    survey.setUserGroup(userGroup);
    CeoApplicationOptions ceoApplicationOptions = new CeoApplicationOptions();
    ceoApplicationOptions.setBaseMapSource(parameters.getCeoSettings().getBaseMapSource());
    ceoApplicationOptions.setImageryYear(parameters.getCeoSettings().getImageryYear());
    ceoApplicationOptions.setStackingProfile(parameters.getCeoSettings().getStackingProfile());
    SamplingPointGenerationSettings samplingPointGenerationSettings = parameters.getSamplingPointGenerationSettings();
    ceoApplicationOptions.setSamplingPointDataConfiguration(samplingPointGenerationSettings);
    survey.addApplicationOptions(ceoApplicationOptions);
    surveyManager.save(survey);
    SamplingPointDataGenerator generator = new SamplingPointDataGenerator(coordinateOperations, survey, parameters.getSamplingPointsByLevel(), samplingPointGenerationSettings);
    List<SamplingDesignItem> items = generator.generate();
    samplingDesignManager.insert(survey, items, true);
    return survey;
}
Also used : SamplingPointGenerationSettings(org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings) CeoApplicationOptions(org.openforis.collect.persistence.xml.CeoApplicationOptions) SamplingPointDataGenerator(org.openforis.collect.io.metadata.samplingpointdata.SamplingPointDataGenerator) CollectSurvey(org.openforis.collect.model.CollectSurvey) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) UserGroup(org.openforis.collect.model.UserGroup)

Aggregations

SamplingPointDataGenerator (org.openforis.collect.io.metadata.samplingpointdata.SamplingPointDataGenerator)1 SamplingPointGenerationSettings (org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)1 UserGroup (org.openforis.collect.model.UserGroup)1 CeoApplicationOptions (org.openforis.collect.persistence.xml.CeoApplicationOptions)1