Search in sources :

Example 26 with Type

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

the class InsertSensorRequestEncoderTest method prepare.

@Before
public void prepare() {
    request = new InsertSensorRequest("service", "version");
    request.setProcedureDescriptionFormat(SensorML20Constants.SENSORML_20_OUTPUT_FORMAT_URL);
    request.setProcedureDescription(createProcedureDescription());
    SosInsertionMetadata metadata = new SosInsertionMetadata();
    metadata.setFeatureOfInterestTypes(CollectionHelper.list("test-foi-type-1", "test-foi-type-2"));
    metadata.setObservationTypes(CollectionHelper.list("test-observation-type-1", "test-observation-type-2"));
    request.setMetadata(metadata);
    request.setObservableProperty(CollectionHelper.list("test-property-1", "test-property-2"));
    encoder = new InsertSensorRequestEncoder();
    encoder.setXmlOptions(() -> new XmlOptions());
    SensorMLEncoderv20 sensorMLEncoderv20 = new SensorMLEncoderv20();
    sensorMLEncoderv20.setXmlOptions(() -> new XmlOptions());
    GmlEncoderv321 gmlEncoder = new GmlEncoderv321();
    gmlEncoder.setXmlOptions(() -> new XmlOptions());
    SosInsertionMetadataTypeEncoder metadataEncoder = new SosInsertionMetadataTypeEncoder();
    metadataEncoder.setXmlOptions(() -> new XmlOptions());
    EncoderRepository encoderRepository = new EncoderRepository();
    encoderRepository.setEncoders(Arrays.asList(encoder, sensorMLEncoderv20, gmlEncoder, metadataEncoder));
    encoderRepository.init();
    encoder.setEncoderRepository(encoderRepository);
    sensorMLEncoderv20.setEncoderRepository(encoderRepository);
    gmlEncoder.setEncoderRepository(encoderRepository);
    metadataEncoder.setEncoderRepository(encoderRepository);
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest) Before(org.junit.Before)

Example 27 with Type

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

the class Iso19139GmdEncoderTest method checkReturnType.

@Test
public void checkReturnType() throws Exception {
    GmdConformanceResult cr = GmdDomainConsistency.dataCapture(true);
    GmdQuantitativeResult qr = GmdDomainConsistency.uncertaintyEstimation(20);
    errors.checkThat(encoder.encode(cr), is(instanceOf(DQDomainConsistencyType.class)));
    errors.checkThat(encoder.encode(cr, DOCUMENT_TYPE), is(instanceOf(DQDomainConsistencyDocument.class)));
    errors.checkThat(encoder.encode(cr, PROPERTY_TYPE), is(instanceOf(DQDomainConsistencyPropertyType.class)));
    errors.checkThat(encoder.encode(cr, TYPE), is(instanceOf(DQDomainConsistencyType.class)));
    errors.checkThat(encoder.encode(qr), is(instanceOf(DQDomainConsistencyType.class)));
    errors.checkThat(encoder.encode(qr, DOCUMENT_TYPE), is(instanceOf(DQDomainConsistencyDocument.class)));
    errors.checkThat(encoder.encode(qr, PROPERTY_TYPE), is(instanceOf(DQDomainConsistencyPropertyType.class)));
    errors.checkThat(encoder.encode(qr, TYPE), is(instanceOf(DQDomainConsistencyType.class)));
}
Also used : GmdQuantitativeResult(org.n52.shetland.iso.gmd.GmdQuantitativeResult) GmdConformanceResult(org.n52.shetland.iso.gmd.GmdConformanceResult) Test(org.junit.Test)

Example 28 with Type

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

the class SosInsertionMetadataTypeEncoderTest method prepare.

@Before
public void prepare() {
    insertionMetadata = new SosInsertionMetadata();
    insertionMetadata.setObservationTypes(CollectionHelper.list("type-1", "type-2"));
    insertionMetadata.setFeatureOfInterestTypes(CollectionHelper.list("f-type-1", "f-type-2"));
    encoder = new SosInsertionMetadataTypeEncoder();
    encoder.setXmlOptions(() -> new XmlOptions());
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) Before(org.junit.Before)

Example 29 with Type

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

the class SweCommonEncoderv101Test method should_throw_NoApplicableCodeException_with_DataRecord_and_field_with_not_supported_element.

@Test
public void should_throw_NoApplicableCodeException_with_DataRecord_and_field_with_not_supported_element() throws EncodingException {
    thrown.expect(EncodingException.class);
    thrown.expectMessage("The element type '" + getClass().getName() + "$1' " + "of the received '" + SweField.class.getName() + "' is not supported" + " by this encoder '" + SweCommonEncoderv101.class.getName() + "'.");
    sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField("test", new SweAbstractDataComponent() {

        @Override
        public SweDataComponentType getDataComponentType() {
            return null;
        }

        @Override
        public <T, X extends Throwable> T accept(SweDataComponentVisitor<T, X> visitor) {
            return null;
        }

        @Override
        public <X extends Throwable> void accept(VoidSweDataComponentVisitor<X> visitor) {
        }

        @Override
        public SweAbstractDataComponent copy() {
            return null;
        }
    })));
}
Also used : SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SweDataComponentType(org.n52.shetland.ogc.swe.SweConstants.SweDataComponentType) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) Test(org.junit.Test)

Example 30 with Type

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

the class SpecimenEncoderv20 method createSpecimen.

private XmlObject createSpecimen(SfSpecimen specimen) throws EncodingException {
    SFSpecimenDocument sfsd = SFSpecimenDocument.Factory.newInstance(getXmlOptions());
    if (specimen.isSetXml()) {
        try {
            final XmlObject feature = XmlObject.Factory.parse(specimen.getXml(), getXmlOptions());
            XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), specimen.getGmlId(), null);
            if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SPEC) && feature instanceof SFSpecimenType) {
                sfsd.setSFSpecimen((SFSpecimenType) feature);
                addName(sfsd.getSFSpecimen(), specimen);
                addDescription(sfsd.getSFSpecimen(), specimen);
                return sfsd;
            }
            addName(((SFSpecimenDocument) feature).getSFSpecimen(), specimen);
            addDescription(((SFSpecimenDocument) feature).getSFSpecimen(), specimen);
            return feature;
        } catch (final XmlException xmle) {
            throw new EncodingException("Error while encoding GetFeatureOfInterest response, invalid specimen description!", xmle);
        }
    }
    final SFSpecimenType sfst = sfsd.addNewSFSpecimen();
    // TODO: CHECK for all fields set gml:id
    addId(sfst, specimen);
    addIdentifier(sfst, specimen);
    // set type
    addFeatureType(sfst, specimen);
    addName(sfst, specimen);
    addDescription(sfst, specimen);
    // set sampledFeatures
    addSampledFeatures(sfst, specimen);
    addParameter(sfst, specimen);
    // set specimen specific data
    addMaterialClass(sfst, specimen);
    addSamplingTime(sfst, specimen);
    addSamplingMethod(sfst, specimen);
    addSamplingLocation(sfst, specimen);
    addProcessingDetails(sfst, specimen);
    addSize(sfst, specimen);
    addCurrentLocation(sfst, specimen);
    addSpecimenType(sfst, specimen);
    specimen.wasEncoded();
    return sfsd;
}
Also used : SFSpecimenType(net.opengis.samplingSpecimen.x20.SFSpecimenType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) SFSpecimenDocument(net.opengis.samplingSpecimen.x20.SFSpecimenDocument)

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 Test (org.junit.Test)10 XmlException (org.apache.xmlbeans.XmlException)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