Search in sources :

Example 1 with SamplingPointDefinition

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;
}
Also used : ReferenceDataSchema(org.openforis.idm.metamodel.ReferenceDataSchema) SamplingPointDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition) ReferenceDataDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition)

Example 2 with SamplingPointDefinition

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);
    }
}
Also used : ReferenceDataSchema(org.openforis.idm.metamodel.ReferenceDataSchema) SamplingPointDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 3 with SamplingPointDefinition

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;
    }
}
Also used : ReferenceDataSchema(org.openforis.idm.metamodel.ReferenceDataSchema) SamplingPointDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition) ArrayList(java.util.ArrayList) ReferenceDataDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition) ExternalizedProperty(org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)

Example 4 with SamplingPointDefinition

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;
    }
}
Also used : ReferenceDataSchema(org.openforis.idm.metamodel.ReferenceDataSchema) SamplingPointDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition)

Example 5 with SamplingPointDefinition

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);
}
Also used : SamplingPointDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition) ReferenceDataSchema(org.openforis.idm.metamodel.ReferenceDataSchema) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Aggregations

ReferenceDataSchema (org.openforis.idm.metamodel.ReferenceDataSchema)8 SamplingPointDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition)8 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)2 ReferenceDataDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition)2 ArrayList (java.util.ArrayList)1 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1