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