Search in sources :

Example 46 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class SamplingDecoderv20 method getSampledFeatures.

/**
 * Parse {@link FeaturePropertyType} sampledFeature to
 * {@link AbstractFeature} list.
 *
 * @param sampledFeature
 *            SampledFeature to parse
 * @return List with the parsed sampledFeature
 * @throws DecodingException
 *             If an error occurs
 */
private List<AbstractFeature> getSampledFeatures(final FeaturePropertyType sampledFeature) throws DecodingException {
    final List<AbstractFeature> sampledFeatures = new ArrayList<>(1);
    if (sampledFeature != null && !sampledFeature.isNil()) {
        // if xlink:href is set
        if (sampledFeature.getHref() != null && !sampledFeature.getHref().isEmpty()) {
            if (sampledFeature.getHref().startsWith("#")) {
                sampledFeatures.add(new SamplingFeature(null, sampledFeature.getHref().replace("#", "")));
            } else {
                final SamplingFeature sampFeat = new SamplingFeature(new CodeWithAuthority(sampledFeature.getHref()));
                if (sampledFeature.getTitle() != null && !sampledFeature.getTitle().isEmpty()) {
                    sampFeat.addName(new CodeType(sampledFeature.getTitle()));
                }
                sampledFeatures.add(sampFeat);
            }
        } else {
            XmlObject abstractFeature = null;
            if (sampledFeature.getAbstractFeature() != null) {
                abstractFeature = sampledFeature.getAbstractFeature();
            } else if (sampledFeature.getDomNode().hasChildNodes()) {
                try {
                    abstractFeature = XmlObject.Factory.parse(XmlHelper.getNodeFromNodeList(sampledFeature.getDomNode().getChildNodes()));
                } catch (XmlException xmle) {
                    throw new DecodingException("Error while parsing feature request!", xmle);
                }
            }
            if (abstractFeature != null) {
                final Object decodedObject = decodeXmlObject(abstractFeature);
                if (decodedObject instanceof AbstractFeature) {
                    sampledFeatures.add((AbstractFeature) decodedObject);
                }
            }
            throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested sampledFeature type is not supported by this service!");
        }
    }
    return sampledFeatures;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) CodeType(org.n52.shetland.ogc.gml.CodeType) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 47 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method addVerticalDatum.

private void addVerticalDatum(MonitoringPointType mpt, List<Referenceable<VerticalDatum>> verticalDatums) throws EncodingException {
    for (Referenceable<VerticalDatum> verticalDatum : verticalDatums) {
        VerticalDatumPropertyType vdpt = mpt.addNewVerticalDatum();
        if (verticalDatum.isReference()) {
            Reference reference = verticalDatum.getReference();
            reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(vdpt::setActuate);
            reference.getArcrole().ifPresent(vdpt::setArcrole);
            reference.getHref().map(URI::toString).ifPresent(vdpt::setHref);
            reference.getRole().ifPresent(vdpt::setRole);
            reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(vdpt::setShow);
            reference.getTitle().ifPresent(vdpt::setTitle);
            reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(vdpt::setType);
        } else {
            if (verticalDatum.isInstance()) {
                Nillable<VerticalDatum> nillable = verticalDatum.getInstance();
                if (nillable.isPresent()) {
                    XmlObject xml = encodeGML(nillable.get());
                    if (xml != null && xml instanceof VerticalDatumType) {
                        vdpt.setVerticalDatum((VerticalDatumType) xml);
                    } else {
                        vdpt.setNil();
                        vdpt.setNilReason(Nillable.missing().get());
                    }
                } else {
                    vdpt.setNil();
                    if (nillable.hasReason()) {
                        vdpt.setNilReason(nillable.getNilReason().get());
                    } else {
                        vdpt.setNilReason(Nillable.missing().get());
                    }
                }
            }
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) Reference(org.n52.shetland.w3c.xlink.Reference) VerticalDatum(org.n52.shetland.ogc.gml.VerticalDatum) Actuate(org.n52.shetland.w3c.xlink.Actuate) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CodeType(org.n52.shetland.ogc.gml.CodeType) MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) CollectionType(net.opengis.waterml.x20.CollectionType) MediaType(org.n52.janmayen.http.MediaType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) OMObservationType(net.opengis.om.x20.OMObservationType) ShowType(org.w3.x1999.xlink.ShowType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 48 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method addRelatedParty.

private void addRelatedParty(MonitoringPointType mpt, List<Referenceable<CiResponsibleParty>> relatedParties) throws EncodingException {
    for (Referenceable<CiResponsibleParty> relatedParty : relatedParties) {
        CIResponsiblePartyPropertyType citppt = mpt.addNewRelatedParty();
        if (relatedParty.isReference()) {
            Reference reference = relatedParty.getReference();
            reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(citppt::setActuate);
            reference.getArcrole().ifPresent(citppt::setArcrole);
            reference.getHref().map(URI::toString).ifPresent(citppt::setHref);
            reference.getRole().ifPresent(citppt::setRole);
            reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(citppt::setShow);
            reference.getTitle().ifPresent(citppt::setTitle);
            reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(citppt::setType);
        } else {
            if (relatedParty.isInstance()) {
                Nillable<CiResponsibleParty> nillable = relatedParty.getInstance();
                if (nillable.isPresent()) {
                    XmlObject xml = encodeObjectToXml(nillable.get().getDefaultElementEncoding(), nillable.get());
                    if (xml != null && xml instanceof CIResponsiblePartyType) {
                        citppt.setCIResponsibleParty((CIResponsiblePartyType) xml);
                    } else {
                        citppt.setNil();
                        citppt.setNilReason(Nillable.missing().get());
                    }
                } else {
                    citppt.setNil();
                    if (nillable.hasReason()) {
                        citppt.setNilReason(nillable.getNilReason().get());
                    } else {
                        citppt.setNilReason(Nillable.missing().get());
                    }
                }
            }
        }
    }
}
Also used : CiResponsibleParty(org.n52.shetland.iso.gmd.CiResponsibleParty) ActuateType(org.w3.x1999.xlink.ActuateType) Reference(org.n52.shetland.w3c.xlink.Reference) Actuate(org.n52.shetland.w3c.xlink.Actuate) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CodeType(org.n52.shetland.ogc.gml.CodeType) MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) CollectionType(net.opengis.waterml.x20.CollectionType) MediaType(org.n52.janmayen.http.MediaType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) OMObservationType(net.opengis.om.x20.OMObservationType) ShowType(org.w3.x1999.xlink.ShowType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 49 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class OwsEncoderv110 method encodeServiceIdentification.

private XmlObject encodeServiceIdentification(OwsServiceIdentification serviceIdentification) throws EncodingException {
    ServiceIdentification serviceIdent;
    /* TODO check for required fields and fail on missing ones */
    serviceIdent = ServiceIdentification.Factory.newInstance();
    serviceIdentification.getAccessConstraints().forEach(serviceIdent::addAccessConstraints);
    if (!serviceIdentification.getFees().isEmpty()) {
        serviceIdent.setFees(serviceIdentification.getFees().iterator().next());
    }
    CodeType xbServiceType = serviceIdent.addNewServiceType();
    xbServiceType.setStringValue(serviceIdentification.getServiceType().getValue());
    if (serviceIdentification.getServiceType().getCodeSpace().isPresent()) {
        xbServiceType.setCodeSpace(serviceIdentification.getServiceType().getCodeSpace().get().toString());
    }
    encodeMultilingualString(serviceIdentification.getTitle(), serviceIdent::addNewTitle);
    encodeMultilingualString(serviceIdentification.getAbstract(), serviceIdent::addNewAbstract);
    serviceIdentification.getServiceTypeVersion().stream().forEach(serviceIdent::addServiceTypeVersion);
    serviceIdentification.getProfiles().stream().map(URI::toString).forEach(serviceIdent::addProfile);
    serviceIdentification.getKeywords().stream().collect(groupingBy(OwsKeyword::getType, mapping(OwsKeyword::getKeyword, toList()))).forEach((type, keywords) -> encodeOwsKeywords(type, keywords, serviceIdent.addNewKeywords()));
    return serviceIdent;
}
Also used : OwsKeyword(org.n52.shetland.ogc.ows.OwsKeyword) CodeType(net.opengis.ows.x11.CodeType) ServiceIdentification(net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification)

Example 50 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class AbstractCapabilitiesBaseTypeDecoder method parseRange.

private OwsRange parseRange(RangeType range) {
    if (range == null) {
        return null;
    }
    OwsValue upperBound = parseValue(range.getMaximumValue());
    OwsValue lowerBound = parseValue(range.getMinimumValue());
    OwsValue spacing = parseValue(range.getSpacing());
    String type = null;
    if (range.isSetRangeClosure() && !range.getRangeClosure().isEmpty()) {
        type = (String) range.getRangeClosure().get(0);
    }
    return new OwsRange(lowerBound, upperBound, type, spacing);
}
Also used : OwsRange(org.n52.shetland.ogc.ows.OwsRange) LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) OwsValue(org.n52.shetland.ogc.ows.OwsValue)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)27 DecodingException (org.n52.svalbard.decode.exception.DecodingException)15 Actuate (org.n52.shetland.w3c.xlink.Actuate)14 Reference (org.n52.shetland.w3c.xlink.Reference)14 Show (org.n52.shetland.w3c.xlink.Show)14 Type (org.n52.shetland.w3c.xlink.Type)14 ActuateType (org.w3.x1999.xlink.ActuateType)14 ShowType (org.w3.x1999.xlink.ShowType)14 TypeType (org.w3.x1999.xlink.TypeType)14 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)13 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 XmlException (org.apache.xmlbeans.XmlException)9 Test (org.junit.Test)9 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)9 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 SupportedType (org.n52.shetland.ogc.SupportedType)6