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);
}
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;
}
Aggregations