Search in sources :

Example 1 with EncoderRepository

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

the class SimpleBindingTest method mockEncoderRepository.

@SuppressWarnings({ "rawtypes", "unchecked" })
private EncoderRepository mockEncoderRepository() {
    EncoderRepository encoderRepository = mock(EncoderRepository.class);
    OwsOperationKey operationKey = new OwsOperationKey(response);
    OperationResponseEncoderKey operationEncoderKey = new OperationResponseEncoderKey(operationKey, MediaTypes.APPLICATION_JSON);
    Encoder encoder = Mockito.mock(Encoder.class);
    when(encoderRepository.getEncoder(operationEncoderKey)).thenReturn(encoder);
    return encoderRepository;
}
Also used : Encoder(org.n52.svalbard.encode.Encoder) EncoderRepository(org.n52.svalbard.encode.EncoderRepository) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey)

Example 2 with EncoderRepository

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

the class InsertResultTemplateRequestEncoderTest method setup.

@Before
public void setup() throws InvalidSridException, ParseException {
    SensorML procedure = new SensorML();
    procedure.setIdentifier(procedureIdentifier);
    SamplingFeature featureOfInterest = new SamplingFeature(new CodeWithAuthority(featureIdentifier));
    featureOfInterest.setIdentifier(featureIdentifier);
    featureOfInterest.setName(new CodeType(featureName));
    featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
    featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT(30 10)", 4326));
    observationTemplate = new OmObservationConstellation();
    observationTemplate.addOffering(offering);
    observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationTemplate.setProcedure(procedure);
    observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
    observationTemplate.setFeatureOfInterest(featureOfInterest);
    SweTextEncoding textEncoding = new SweTextEncoding();
    textEncoding.setBlockSeparator(blockSeparator);
    textEncoding.setTokenSeparator(tokenSeparator);
    SweDataRecord resultStructure = new SweDataRecord();
    SweTime sweTime = new SweTime();
    sweTime.setDefinition(field1Definition);
    sweTime.setUom(field1Uom);
    resultStructure.addField(new SweField(field1Name, sweTime));
    request = new InsertResultTemplateRequest(SosConstants.SOS, Sos2Constants.SERVICEVERSION, Sos2Constants.Operations.InsertResultTemplate.name());
    request.setResultEncoding(new SosResultEncoding(textEncoding));
    request.setResultStructure(new SosResultStructure(resultStructure));
    request.setIdentifier(templateIdentifier);
    request.setObservationTemplate(observationTemplate);
    Supplier<XmlOptions> xmlOptions = () -> new XmlOptions();
    encoder = new InsertResultTemplateRequestEncoder();
    encoder.setXmlOptions(xmlOptions);
    OmEncoderv20 omEncoder = new OmEncoderv20();
    omEncoder.setXmlOptions(xmlOptions);
    SamplingEncoderv20 samsEncoder = new SamplingEncoderv20();
    samsEncoder.setXmlOptions(xmlOptions);
    GmlEncoderv321 gml32Encoder = new GmlEncoderv321();
    gml32Encoder.setXmlOptions(xmlOptions);
    SweCommonEncoderv20 sweEncoderv20 = new SweCommonEncoderv20();
    sweEncoderv20.setXmlOptions(xmlOptions);
    EncoderRepository encoderRepository = new EncoderRepository();
    encoderRepository.setEncoders(Arrays.asList(encoder, omEncoder, samsEncoder, gml32Encoder, sweEncoderv20));
    encoderRepository.init();
    encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) XmlOptions(org.apache.xmlbeans.XmlOptions) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) CodeType(org.n52.shetland.ogc.gml.CodeType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Before(org.junit.Before)

Example 3 with EncoderRepository

use of org.n52.svalbard.encode.EncoderRepository 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 4 with EncoderRepository

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

the class Iso19139GmdEncoderTest method setup.

@Before
public void setup() {
    encoder = new Iso19139GmdEncoder();
    encoder.setXmlOptions(XmlOptions::new);
    Iso19139GcoEncoder iso19139GcoEncoder = new Iso19139GcoEncoder();
    iso19139GcoEncoder.setXmlOptions(XmlOptions::new);
    EncoderRepository encoderRepository = new EncoderRepository();
    encoderRepository.setEncoders(Arrays.asList(encoder, iso19139GcoEncoder));
    encoderRepository.init();
    encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
Also used : Iso19139GmdEncoder(org.n52.svalbard.encode.Iso19139GmdEncoder) XmlOptions(org.apache.xmlbeans.XmlOptions) Before(org.junit.Before)

Example 5 with EncoderRepository

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

the class SamplingEncoderv20Test method setup.

@Before
public void setup() throws InvalidSridException, ParseException {
    EncoderRepository encoderRepository = new EncoderRepository();
    OmEncoderv20 omEncoderv20 = new OmEncoderv20();
    omEncoderv20.setXmlOptions(XmlOptions::new);
    omEncoderv20.setEncoderRepository(encoderRepository);
    GmlEncoderv321 gmlEncoderv321 = new GmlEncoderv321();
    gmlEncoderv321.setEncoderRepository(encoderRepository);
    gmlEncoderv321.setXmlOptions(XmlOptions::new);
    SensorMLEncoderv20 sensorMLEncoderv20 = new SensorMLEncoderv20();
    sensorMLEncoderv20.setXmlOptions(XmlOptions::new);
    sensorMLEncoderv20.setEncoderRepository(encoderRepository);
    SweCommonEncoderv20 sweCommonEncoderv20 = new SweCommonEncoderv20();
    sweCommonEncoderv20.setEncoderRepository(encoderRepository);
    sweCommonEncoderv20.setXmlOptions(XmlOptions::new);
    encoder = new SamplingEncoderv20();
    encoder.setEncoderRepository(encoderRepository);
    encoder.setXmlOptions(XmlOptions::new);
    encoderRepository.setEncoders(Arrays.asList(omEncoderv20, gmlEncoderv321, sensorMLEncoderv20, sweCommonEncoderv20, encoder));
    encoderRepository.init();
    featureOfInterest = new SamplingFeature(new CodeWithAuthority("test-feature"));
    featureOfInterest.setIdentifier("test-feature-identifier");
    featureOfInterest.setName(new CodeType("test-feature-name"));
    featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
    featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT (30 10)", 4326));
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) CodeType(org.n52.shetland.ogc.gml.CodeType) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Before(org.junit.Before)

Aggregations

EncoderRepository (org.n52.svalbard.encode.EncoderRepository)5 XmlOptions (org.apache.xmlbeans.XmlOptions)4 Before (org.junit.Before)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 CodeType (org.n52.shetland.ogc.gml.CodeType)3 Test (org.junit.Test)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 URI (java.net.URI)1 EReportingChange (org.n52.shetland.aqd.EReportingChange)1 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)1 GeographicalName (org.n52.shetland.inspire.GeographicalName)1 Pronunciation (org.n52.shetland.inspire.Pronunciation)1 Spelling (org.n52.shetland.inspire.Spelling)1 AddressRepresentation (org.n52.shetland.inspire.ad.AddressRepresentation)1 Identifier (org.n52.shetland.inspire.base.Identifier)1 Contact (org.n52.shetland.inspire.base2.Contact)1 RelatedParty (org.n52.shetland.inspire.base2.RelatedParty)1 LocalisedCharacterString (org.n52.shetland.iso.gmd.LocalisedCharacterString)1