use of org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition in project collect by openforis.
the class DatabaseLookupProvider method convertToSamplingPointColumnName.
private String convertToSamplingPointColumnName(Survey survey, String attribute) {
ReferenceDataSchema referenceDataSchema = survey.getReferenceDataSchema();
SamplingPointDefinition samplingPoint = referenceDataSchema == null ? null : referenceDataSchema.getSamplingPointDefinition();
if (samplingPoint != null) {
List<ReferenceDataDefinition.Attribute> infoAttributes = samplingPoint.getAttributes(false);
for (int i = 0; i < infoAttributes.size(); i++) {
ReferenceDataDefinition.Attribute infoAttr = infoAttributes.get(i);
if (infoAttr.getName().equals(attribute)) {
return SamplingDesignDao.INFO_FIELDS[i].getName();
}
}
}
return attribute;
}
use of org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition in project collect by openforis.
the class SamplingDesignImportService method updateSessionSurvey.
private void updateSessionSurvey() {
CollectSurvey processSurvey = importProcess.getSurvey();
if (processSurvey.isTemporary()) {
ReferenceDataSchema processReferenceDataSchema = processSurvey.getReferenceDataSchema();
SamplingPointDefinition processSamplingPoint = processReferenceDataSchema == null ? null : processReferenceDataSchema.getSamplingPointDefinition();
CollectSurvey editedSurvey = sessionManager.getActiveDesignerSurvey();
ReferenceDataSchema referenceDataSchema = editedSurvey.getReferenceDataSchema();
if (referenceDataSchema == null) {
referenceDataSchema = new ReferenceDataSchema();
editedSurvey.setReferenceDataSchema(referenceDataSchema);
}
referenceDataSchema.setSamplingPointDefinition(processSamplingPoint);
}
}
use of org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition in project collect by openforis.
the class SamplingDesignSummariesProxy method getInfoAttributes.
@ExternalizedProperty
public List<String> getInfoAttributes() {
ReferenceDataSchema referenceDataSchema = survey.getReferenceDataSchema();
SamplingPointDefinition samplingPoint = referenceDataSchema == null ? null : referenceDataSchema.getSamplingPointDefinition();
if (samplingPoint == null) {
return Collections.emptyList();
} else {
List<String> result = new ArrayList<String>();
List<ReferenceDataDefinition.Attribute> infoAttributes = samplingPoint.getAttributes(false);
for (ReferenceDataDefinition.Attribute attribute : infoAttributes) {
result.add(attribute.getName());
}
return result;
}
}
use of org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition in project collect by openforis.
the class SamplingDesignExportTask method getSamplingPointInfoAttributes.
private List<ReferenceDataDefinition.Attribute> getSamplingPointInfoAttributes() {
ReferenceDataSchema referenceDataSchema = survey.getReferenceDataSchema();
SamplingPointDefinition samplingPoint = referenceDataSchema == null ? null : referenceDataSchema.getSamplingPointDefinition();
if (samplingPoint == null) {
return Collections.emptyList();
} else {
List<ReferenceDataDefinition.Attribute> infoAttributes = samplingPoint.getAttributes(false);
return infoAttributes;
}
}
use of org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition in project collect by openforis.
the class SamplingDesignImportProcess method persistSamplingDesign.
protected void persistSamplingDesign() throws SurveyStoreException {
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);
saveSurvey();
List<SamplingDesignItem> items = createItemsFromLines();
samplingDesignManager.insert(survey, items, overwriteAll);
}
Aggregations