Search in sources :

Example 21 with EncodingException

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

the class AbstractMonitoringObjectEncoder method setBroader.

private void setBroader(AbstractMonitoringObjectType amot, AbstractMonitoringObject abstractMonitoringObject) throws EncodingException {
    if (abstractMonitoringObject.isSetBroader()) {
        Hierarchy broader = abstractMonitoringObject.getBroader();
        if (broader.isSetSimpleAttrs()) {
            Broader b = amot.addNewBroader();
            b.setHref(broader.getSimpleAttrs().getHref());
            if (broader.getSimpleAttrs().isSetTitle()) {
                b.setTitle(broader.getSimpleAttrs().getTitle());
            }
        } else {
            amot.addNewBroader().addNewHierarchy().set(encodeEF(broader));
        }
    }
}
Also used : Hierarchy(org.n52.shetland.inspire.ef.Hierarchy) Broader(eu.europa.ec.inspire.schemas.ef.x40.AbstractMonitoringObjectType.Broader)

Example 22 with EncodingException

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

the class AbstractMonitoringObjectEncoder method setSupersedes.

private void setSupersedes(AbstractMonitoringObjectType amot, AbstractMonitoringObject abstractMonitoringObject) throws EncodingException {
    if (abstractMonitoringObject.isSetSupersedes()) {
        for (AbstractMonitoringObject supersedes : abstractMonitoringObject.getSupersedes()) {
            if (supersedes.isSetSimpleAttrs()) {
                Supersedes s = amot.addNewSupersedes();
                s.setHref(supersedes.getSimpleAttrs().getHref());
                if (supersedes.getSimpleAttrs().isSetTitle()) {
                    s.setTitle(supersedes.getSimpleAttrs().getTitle());
                }
            } else {
                amot.addNewSupersedes().addNewAbstractMonitoringObject().set(encodeEF(supersedes));
            }
        }
    }
}
Also used : AbstractMonitoringObject(org.n52.shetland.inspire.ef.AbstractMonitoringObject) Supersedes(eu.europa.ec.inspire.schemas.ef.x40.AbstractMonitoringObjectType.Supersedes)

Example 23 with EncodingException

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

the class AbstractOmEncoderv20 method encode.

@Override
public void encode(Object objectToEncode, OutputStream outputStream, EncodingContext ctx) throws EncodingException {
    try {
        XmlOptions xmlOptions = getXmlOptions();
        if (ctx.has(StreamingEncoderFlags.EMBEDDED)) {
            xmlOptions.setSaveNoXmlDecl();
        }
        encode(objectToEncode, ctx.with(StreamingEncoderFlags.ENCODER, this)).save(outputStream, xmlOptions);
    } catch (IOException ioe) {
        throw new EncodingException("Error while writing element to stream!", ioe);
    } finally {
        if (ctx.has(StreamingEncoderFlags.EMBEDDED)) {
            getXmlOptions().remove(XmlOptions.SAVE_NO_XML_DECL);
        }
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlOptions(org.apache.xmlbeans.XmlOptions) IOException(java.io.IOException)

Example 24 with EncodingException

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

the class AbstractOmEncoderv20 method encode.

@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof OmObservation) {
        encodedObject = encodeOmObservation((OmObservation) element, additionalValues);
    } else if (element instanceof NamedValue) {
        NamedValueType nvt = createNamedValue((NamedValue<?>) element);
        if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
            NamedValueDocument nvd = NamedValueDocument.Factory.newInstance();
            nvd.setNamedValue(nvt);
            encodedObject = nvd;
        } else if (additionalValues.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            NamedValuePropertyType nvpt = NamedValuePropertyType.Factory.newInstance();
            nvpt.setNamedValue(nvt);
            encodedObject = nvpt;
        } else {
            encodedObject = nvt;
        }
    } else if (element instanceof AbstractFeature) {
        encodedObject = encodeFeatureOfInterest((AbstractFeature) element);
    } else if (element instanceof SosProcedureDescription) {
        encodedObject = encodeProcedureDescription((SosProcedureDescription<?>) element);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    // XmlHelper.validateDocument(encodedObject));
    return encodedObject;
}
Also used : NamedValueDocument(net.opengis.om.x20.NamedValueDocument) NamedValueType(net.opengis.om.x20.NamedValueType) OmObservation(org.n52.shetland.ogc.om.OmObservation) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) NamedValue(org.n52.shetland.ogc.om.NamedValue) NamedValuePropertyType(net.opengis.om.x20.NamedValuePropertyType) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 25 with EncodingException

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

the class AbstractOmEncoderv20 method setValidTime.

private void setValidTime(OmObservation observation, OMObservationType xb) throws EncodingException {
    Time validTime = observation.getValidTime();
    if (validTime == null) {
        return;
    }
    if (validTime.getGmlId() == null) {
        validTime.setGmlId(OmConstants.VALID_TIME_NAME + "_" + observation.getObservationID());
    }
    xb.addNewValidTime().addNewTimePeriod().set(encodeGML(validTime));
}
Also used : Time(org.n52.shetland.ogc.gml.time.Time)

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