Search in sources :

Example 71 with Data

use of org.geotoolkit.wps.xml.v200.Data in project fiware-cygnus by telefonicaid.

the class NotifyContextRequestNGSIv2Deserializer method deserialize.

@Override
public NotifyContextRequestNGSIv2 deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonObject jsonObject = json.getAsJsonObject();
    String subscriptionId = jsonObject.get("subscriptionId").getAsString();
    ArrayList<Data> data = deserializeAllData(jsonObject.getAsJsonArray("data"));
    NotifyContextRequestNGSIv2 ncr = new NotifyContextRequestNGSIv2();
    ncr.setSubscriptionId(subscriptionId);
    ncr.setData(data);
    return ncr;
}
Also used : NotifyContextRequestNGSIv2(com.telefonica.iot.cygnus.containers.NotifyContextRequestNGSIv2) JsonObject(com.google.gson.JsonObject) Data(com.telefonica.iot.cygnus.containers.NotifyContextRequestNGSIv2.Data)

Example 72 with Data

use of org.geotoolkit.wps.xml.v200.Data in project geotoolkit by Geomatys.

the class ExecuteTest method testRequestAndMarshall.

@Test
public void testRequestAndMarshall() throws Exception {
    final WebProcessingClient client = new WebProcessingClient(new URL("http://test.com"), null, WPSVersion.v100);
    final ExecuteRequest request = client.createExecute();
    final Execute execute = request.getContent();
    final GeographicCRS epsg4326 = CommonCRS.WGS84.geographic();
    final GeneralEnvelope env = new GeneralEnvelope(epsg4326);
    env.setRange(0, 10, 10);
    env.setRange(1, 10, 10);
    execute.setIdentifier("identifier");
    final List<DataInput> inputs = execute.getInput();
    inputs.add(new DataInput("literal", new Data(new LiteralValue("10", null, null))));
    inputs.add(new DataInput("bbox", new Data(new BoundingBoxType(env))));
    inputs.add(new DataInput("complex", new Data(new Format("UTF-8", WPSMimeType.APP_GML.val(), WPSSchema.OGC_GML_3_1_1.getValue(), null), new PointType(new DirectPosition2D(epsg4326, 0, 0)))));
    inputs.add(new DataInput("reference", new Reference("http://link.to/reference/", null, null)));
    execute.getOutput().add(new OutputDefinition("output", false));
    assertEquals("WPS", execute.getService());
    assertEquals("1.0.0", execute.getVersion().toString());
    assertEquals(execute.getIdentifier().getValue(), "identifier");
    final StringWriter stringWriter = new StringWriter();
    final Marshaller marshaller = WPSMarshallerPool.getInstance().acquireMarshaller();
    marshaller.marshal(execute, stringWriter);
    String result = stringWriter.toString();
    try (final InputStream expected = expectedRequest()) {
        assertXmlEquals(expected, result, "xmlns:*", "crs", "srsName");
    }
    WPSMarshallerPool.getInstance().recycle(marshaller);
}
Also used : Marshaller(javax.xml.bind.Marshaller) Execute(org.geotoolkit.wps.xml.v200.Execute) Reference(org.geotoolkit.wps.xml.v200.Reference) InputStream(java.io.InputStream) Data(org.geotoolkit.wps.xml.v200.Data) LiteralValue(org.geotoolkit.wps.xml.v200.LiteralValue) WebProcessingClient(org.geotoolkit.wps.client.WebProcessingClient) DirectPosition2D(org.apache.sis.geometry.DirectPosition2D) URL(java.net.URL) DataInput(org.geotoolkit.wps.xml.v200.DataInput) BoundingBoxType(org.geotoolkit.ows.xml.v200.BoundingBoxType) ExecuteRequest(org.geotoolkit.wps.client.ExecuteRequest) Format(org.geotoolkit.wps.xml.v200.Format) StringWriter(java.io.StringWriter) PointType(org.geotoolkit.gml.xml.v321.PointType) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope) OutputDefinition(org.geotoolkit.wps.xml.v200.OutputDefinition) Test(org.junit.Test)

Example 73 with Data

use of org.geotoolkit.wps.xml.v200.Data in project geotoolkit by Geomatys.

the class WPS2Process method fillOutputs.

private static void fillOutputs(Parameters outParams, DataOutput out) {
    if (out != null) {
        final GeneralParameterDescriptor param = outParams.getDescriptor().descriptor(out.getId());
        if (param instanceof ParameterDescriptorGroup) {
            // expecting a complex output
            final Parameters group = Parameters.castOrWrap(outParams.addGroup(out.getId()));
            for (DataOutput output : out.getOutput()) {
                fillOutputs(group, output);
            }
        } else {
            // simple output
            final ExtendedParameterDescriptor outDesc = (ExtendedParameterDescriptor) outParams.getDescriptor().descriptor(out.getId());
            final DataAdaptor adaptor = (DataAdaptor) outDesc.getUserObject().get(DataAdaptor.USE_ADAPTOR);
            final Object value = adaptor.fromWPS2Input(out);
            outParams.getOrCreate(outDesc).setValue(value);
        }
    } else {
        throw new UnsupportedOperationException("unsupported data type");
    }
}
Also used : DataOutput(org.geotoolkit.wps.xml.v200.DataOutput) Parameters(org.apache.sis.parameter.Parameters) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) DataAdaptor(org.geotoolkit.wps.adaptor.DataAdaptor) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) ExtendedParameterDescriptor(org.geotoolkit.utility.parameter.ExtendedParameterDescriptor)

Aggregations

Data (org.geotoolkit.wps.xml.v200.Data)42 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)33 IOException (java.io.IOException)25 Test (org.junit.Test)19 Reference (org.geotoolkit.wps.xml.v200.Reference)16 Path (java.nio.file.Path)15 DataInput (org.geotoolkit.wps.xml.v200.DataInput)15 Format (org.geotoolkit.wps.xml.v200.Format)14 DataStoreException (org.apache.sis.storage.DataStoreException)12 HashMap (java.util.HashMap)11 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)11 JAXBException (javax.xml.bind.JAXBException)9 ReferenceProxy (org.geotoolkit.wps.xml.ReferenceProxy)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)8 Feature (org.opengis.feature.Feature)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 Geometry (org.locationtech.jts.geom.Geometry)7 DataOutput (org.geotoolkit.wps.xml.v200.DataOutput)6