use of org.openforis.collect.model.SamplingDesignItem in project collect by openforis.
the class SamplingDesignExportTask method execute.
@Override
protected void execute() throws Throwable {
if (getTotalItems() > 0) {
Integer surveyId = survey.getId();
CsvWriter writer = new CsvWriter(outputStream, OpenForisIOUtils.UTF_8, ',', '"');
SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(surveyId);
ArrayList<String> colNames = getHeaders();
writer.writeHeaders(colNames);
List<SamplingDesignItem> items = summaries.getRecords();
for (SamplingDesignItem item : items) {
writeSummary(writer, item);
incrementProcessedItems();
}
writer.flush();
}
}
use of org.openforis.collect.model.SamplingDesignItem in project collect by openforis.
the class SamplingDesignImportTask method persistSamplingDesign.
protected void persistSamplingDesign() throws SurveyImportException {
List<String> infoColumnNames = reader.getInfoColumnNames();
List<ReferenceDataDefinition.Attribute> attributes = ReferenceDataDefinition.Attribute.fromNames(infoColumnNames);
SamplingPointDefinition samplingPoint;
if (attributes.isEmpty()) {
samplingPoint = null;
} else {
samplingPoint = new SamplingPointDefinition();
samplingPoint.setAttributes(attributes);
}
ReferenceDataSchema referenceDataSchema = survey.getReferenceDataSchema();
if (referenceDataSchema == null) {
referenceDataSchema = new ReferenceDataSchema();
survey.setReferenceDataSchema(referenceDataSchema);
}
referenceDataSchema.setSamplingPointDefinition(samplingPoint);
List<SamplingDesignItem> items = createItemsFromLines();
samplingDesignManager.insert(survey, items, overwriteAll);
}
use of org.openforis.collect.model.SamplingDesignItem in project collect by openforis.
the class SamplingDesignLine method toSamplingDesignItem.
public SamplingDesignItem toSamplingDesignItem(CollectSurvey survey, List<String> infoColumnNames) {
SamplingDesignItem item = new SamplingDesignItem();
item.setSurveyId(survey.getId());
item.setX(Double.parseDouble(x));
item.setY(Double.parseDouble(y));
item.setSrsId(srsId);
item.setLevelCodes(getKey().getLevelCodes());
List<String> infoAttributeNames = new ArrayList<String>();
for (String colName : infoColumnNames) {
infoAttributeNames.add(getInfoAttribute(colName));
}
item.setInfoAttributes(infoAttributeNames);
return item;
}
use of org.openforis.collect.model.SamplingDesignItem in project collect by openforis.
the class SamplingPointDataKmlGenerator method loadSamplingDesignItems.
private List<SamplingDesignItem> loadSamplingDesignItems() {
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId());
List<SamplingDesignItem> samplingDesignItems = samplingDesignSummaries.getRecords();
List<SamplingDesignItem> result = new ArrayList<SamplingDesignItem>();
for (SamplingDesignItem item : samplingDesignItems) {
result.add(item);
}
return result;
}
use of org.openforis.collect.model.SamplingDesignItem 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