Search in sources :

Example 46 with Reference

use of org.eclipse.persistence.internal.jpa.rs.metadata.model.v2.Reference 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 47 with Reference

use of org.eclipse.persistence.internal.jpa.rs.metadata.model.v2.Reference in project eclipselink by eclipse-ee4j.

the class MetadataResource method buildQuerySchema.

private ResourceSchema buildQuerySchema(PersistenceContext context, DatabaseQuery query) {
    final ResourceSchema schema = new ResourceSchema();
    schema.setTitle(query.getName());
    schema.setSchema(HrefHelper.buildQueryMetadataHref(context, query.getName()) + "#");
    schema.addAllOf(new Reference(HrefHelper.buildBaseRestSchemaRef("#/collectionBaseResource")));
    // Link
    final String method = query.isReadQuery() ? "GET" : "POST";
    schema.setLinks((new ItemLinksBuilder()).addExecute(HrefHelper.buildQueryHref(context, query.getName(), getQueryParamString(query)), method).getList());
    // Definitions
    if (query.isReportQuery()) {
        // In case of report query we need to define a returned type
        final ResourceSchema returnType = new ResourceSchema();
        query.checkPrepare((AbstractSession) context.getServerSession(), new DatabaseRecord());
        for (ReportItem item : ((ReportQuery) query).getItems()) {
            final Property property;
            if (item.getMapping() != null) {
                if (item.getAttributeExpression() != null && item.getAttributeExpression().isMapEntryExpression()) {
                    if (((MapEntryExpression) item.getAttributeExpression()).shouldReturnMapEntry()) {
                        property = buildProperty(context, Map.Entry.class);
                    } else {
                        property = buildProperty(context, ((Class<?>) item.getMapping().getContainerPolicy().getKeyType()));
                    }
                } else {
                    property = buildProperty(context, item.getMapping().getAttributeClassification());
                }
            } else if (item.getResultType() != null) {
                property = buildProperty(context, item.getResultType());
            } else if (item.getDescriptor() != null) {
                property = buildProperty(context, item.getDescriptor().getJavaClass());
            } else if (item.getAttributeExpression() != null && item.getAttributeExpression().isConstantExpression()) {
                property = buildProperty(context, ((ConstantExpression) item.getAttributeExpression()).getValue().getClass());
            } else {
                // Use Object.class by default.
                property = buildProperty(context, Object.class);
            }
            returnType.addProperty(item.getName(), property);
        }
        schema.addDefinition("result", returnType);
        final Property items = new Property();
        items.setType("array");
        items.setItems(new Property("#/definitions/result"));
        schema.addProperty("items", items);
    } else {
        // Read all query. Each item is an entity. Make a JSON pointer.
        if (query.getReferenceClassName() != null) {
            final Property items = new Property();
            items.setType("array");
            items.setItems(new Property(HrefHelper.buildEntityMetadataHref(context, query.getReferenceClass().getSimpleName()) + "#"));
            schema.addProperty("items", items);
        }
    }
    return schema;
}
Also used : ItemLinksBuilder(org.eclipse.persistence.jpa.rs.features.ItemLinksBuilder) MapEntryExpression(org.eclipse.persistence.internal.expressions.MapEntryExpression) ResourceSchema(org.eclipse.persistence.internal.jpa.rs.metadata.model.v2.ResourceSchema) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) Reference(org.eclipse.persistence.internal.jpa.rs.metadata.model.v2.Reference) ReportQuery(org.eclipse.persistence.queries.ReportQuery) ConstantExpression(org.eclipse.persistence.internal.expressions.ConstantExpression) ReportItem(org.eclipse.persistence.internal.queries.ReportItem) Property(org.eclipse.persistence.internal.jpa.rs.metadata.model.v2.Property)

Aggregations

Reference (org.geotoolkit.wps.xml.v200.Reference)34 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)17 Path (java.nio.file.Path)14 Test (org.junit.Test)11 IOException (java.io.IOException)9 URL (java.net.URL)9 HashMap (java.util.HashMap)9 JAXBException (javax.xml.bind.JAXBException)6 AbstractWPSConverterTest (org.geotoolkit.wps.converters.AbstractWPSConverterTest)6 ArrayList (java.util.ArrayList)5 Feature (org.opengis.feature.Feature)5 BufferedReader (java.io.BufferedReader)4 DataStoreException (org.apache.sis.storage.DataStoreException)4 Geometry (org.locationtech.jts.geom.Geometry)4 RenderedImage (java.awt.image.RenderedImage)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 Reference (org.dishevelled.bio.assembly.gfa1.Reference)3 Traversal (org.dishevelled.bio.assembly.gfa1.Traversal)3 Reference (com.google.api.expr.v1alpha1.Reference)2 HashBasedTable (com.google.common.collect.HashBasedTable)2