Search in sources :

Example 81 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class SensorMLEncoderv20 method addPhysicalSystemValues.

private void addPhysicalSystemValues(PhysicalSystemType pst, PhysicalSystem abstractPhysicalProcess) throws EncodingException {
    addAbstractProcessValues(pst, abstractPhysicalProcess);
    addDescribedObjectValues(pst, abstractPhysicalProcess);
    addAbstractPhysicalProcessValues(pst, abstractPhysicalProcess);
    // set components
    if (abstractPhysicalProcess.isSetComponents()) {
        List<SmlComponent> smlComponents = checkForComponents(abstractPhysicalProcess);
        if (!smlComponents.isEmpty()) {
            ComponentListPropertyType clpt = createComponents(smlComponents);
            if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
                pst.setComponents(clpt);
            }
        }
    }
    // set connections
    if (abstractPhysicalProcess.isSetConnections() && !pst.isSetConnections()) {
        pst.setConnections(createConnections(abstractPhysicalProcess.getConnections()));
    }
}
Also used : ComponentListPropertyType(net.opengis.sensorml.x20.ComponentListPropertyType) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Example 82 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class SensorMLEncoderv20 method addAggregateProcessValues.

private void addAggregateProcessValues(AggregateProcessType apt, AggregateProcess abstractProcess) throws EncodingException {
    addAbstractProcessValues(apt, abstractProcess);
    addDescribedObjectValues(apt, abstractProcess);
    // set components
    if (abstractProcess.isSetComponents()) {
        List<SmlComponent> smlComponents = checkForComponents(abstractProcess);
        if (!smlComponents.isEmpty()) {
            ComponentListPropertyType clpt = createComponents(smlComponents);
            if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
                apt.setComponents(clpt);
            }
        }
    }
// set connections
}
Also used : ComponentListPropertyType(net.opengis.sensorml.x20.ComponentListPropertyType) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Example 83 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class SensorMLEncoderv20 method createOutputs.

/**
 * Creates the outputs section of the SensorML description.
 *
 * @param sosOutputs
 *            SOS SWE representation.
 *
 * @return XML Outputs element
 *
 * @throws org.n52.svalbard.encode.exception.EncodingException
 *             if the encoding fails
 */
private Outputs createOutputs(final List<SmlIo> sosOutputs) throws EncodingException {
    final Outputs outputs = Outputs.Factory.newInstance(getXmlOptions());
    final OutputListType outputList = outputs.addNewOutputList();
    final Set<String> definitions = Sets.newHashSet();
    int counter = 1;
    final Set<String> outputNames = Sets.newHashSet();
    for (final SmlIo sosSMLIo : sosOutputs) {
        if (sosSMLIo.isSetValue() && !definitions.contains(sosSMLIo.getIoValue().getDefinition())) {
            if (!sosSMLIo.isSetName() || outputNames.contains(sosSMLIo.getIoName())) {
                sosSMLIo.setIoName(getValidOutputName(counter++, outputNames));
            } else {
                sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
            }
            outputNames.add(sosSMLIo.getIoName());
            addOutput(outputList.addNewOutput(), sosSMLIo);
            definitions.add(sosSMLIo.getIoValue().getDefinition());
        }
    }
    return outputs;
}
Also used : Outputs(net.opengis.sensorml.x20.AbstractProcessType.Outputs) OutputListType(net.opengis.sensorml.x20.OutputListType) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Example 84 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createSimpleDataRecord.

private SimpleDataRecordType createSimpleDataRecord(SweSimpleDataRecord simpleDataRecord) throws EncodingException {
    SimpleDataRecordType xbSimpleDataRecord = SimpleDataRecordType.Factory.newInstance(getXmlOptions());
    if (simpleDataRecord.isSetDefinition()) {
        xbSimpleDataRecord.setDefinition(simpleDataRecord.getDefinition());
    }
    if (simpleDataRecord.isSetDescription()) {
        StringOrRefType xbSoR = StringOrRefType.Factory.newInstance();
        xbSoR.setStringValue(simpleDataRecord.getDefinition());
        xbSimpleDataRecord.setDescription(xbSoR);
    }
    if (simpleDataRecord.isSetFields()) {
        AnyScalarPropertyType[] xbFields = new AnyScalarPropertyType[simpleDataRecord.getFields().size()];
        int xbFieldIndex = 0;
        for (SweField sweField : simpleDataRecord.getFields()) {
            AnyScalarPropertyType xbField = createFieldForSimpleDataRecord(sweField);
            xbFields[xbFieldIndex] = xbField;
            xbFieldIndex++;
        }
        xbSimpleDataRecord.setFieldArray(xbFields);
    }
    return xbSimpleDataRecord;
}
Also used : StringOrRefType(net.opengis.gml.StringOrRefType) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SweField(org.n52.shetland.ogc.swe.SweField) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType)

Example 85 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createFieldForSimpleDataRecord.

private AnyScalarPropertyType createFieldForSimpleDataRecord(SweField sweField) throws EncodingException {
    SweAbstractDataComponent sosElement = sweField.getElement();
    AnyScalarPropertyType xbField = AnyScalarPropertyType.Factory.newInstance(getXmlOptions());
    if (sweField.isSetName()) {
        xbField.setName(sweField.getName().getValue());
    }
    AbstractDataComponentType xbDCD;
    if (sosElement instanceof SweBoolean) {
        xbDCD = xbField.addNewBoolean();
        xbDCD.set(createSimpleType((SweBoolean) sosElement));
    } else if (sosElement instanceof SweCategory) {
        xbDCD = xbField.addNewCategory();
        xbDCD.set(createSimpleType((SweCategory) sosElement));
    } else if (sosElement instanceof SweCount) {
        xbDCD = xbField.addNewCount();
        xbDCD.set(createSimpleType((SweCount) sosElement));
    } else if (sosElement instanceof SweQuantity) {
        xbDCD = xbField.addNewQuantity();
        xbDCD.set(createSimpleType((SweQuantity) sosElement));
    } else if (sosElement instanceof SweText) {
        xbDCD = xbField.addNewText();
        xbDCD.set(createSimpleType((SweText) sosElement));
    } else if (sosElement instanceof SweTime) {
        xbDCD = xbField.addNewTime();
        xbDCD.set(createSimpleType((SweTime) sosElement));
    } else {
        throw new EncodingException("The element type '%s' of the received %s is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
    }
    return xbField;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)124 Test (org.junit.Test)93 EncodingException (org.n52.svalbard.encode.exception.EncodingException)60 SweField (org.n52.shetland.ogc.swe.SweField)29 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)29 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)22 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)21 XmlException (org.apache.xmlbeans.XmlException)20 DateTime (org.joda.time.DateTime)19 OmObservation (org.n52.shetland.ogc.om.OmObservation)19 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)17 Time (org.n52.shetland.ogc.gml.time.Time)15 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)15 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)13 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)13 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)12 SystemType (net.opengis.sensorML.x101.SystemType)11 DataRecordType (net.opengis.swe.x101.DataRecordType)11