[OLINGO-603] Rename entity set to entity collection
This commit is contained in:
parent
05935a0c3d
commit
d692d129bd
|
@ -70,7 +70,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||||
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
|
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
@ -997,7 +997,7 @@ public abstract class AbstractServices {
|
||||||
|
|
||||||
final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
|
final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
|
||||||
|
|
||||||
final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
|
final ResWrap<EntityCollection> container = atomDeserializer.toEntitySet(feed);
|
||||||
|
|
||||||
setInlineCount(container.getPayload(), count);
|
setInlineCount(container.getPayload(), count);
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ public abstract class AbstractServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void setInlineCount(final EntitySet feed, final String count);
|
protected abstract void setInlineCount(final EntityCollection feed, final String count);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/Person({entityId})")
|
@Path("/Person({entityId})")
|
||||||
|
@ -1256,7 +1256,7 @@ public abstract class AbstractServices {
|
||||||
rep.setInlineEntity(inline);
|
rep.setInlineEntity(inline);
|
||||||
} else if (link.getType().equals(Constants.get(ConstantKey.ATOM_LINK_FEED))) {
|
} else if (link.getType().equals(Constants.get(ConstantKey.ATOM_LINK_FEED))) {
|
||||||
// inline feed
|
// inline feed
|
||||||
final EntitySet inline = atomDeserializer.toEntitySet(
|
final EntityCollection inline = atomDeserializer.toEntitySet(
|
||||||
xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
|
xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
|
||||||
rep.setInlineEntitySet(inline);
|
rep.setInlineEntitySet(inline);
|
||||||
}
|
}
|
||||||
|
@ -1911,7 +1911,7 @@ public abstract class AbstractServices {
|
||||||
alink.setRel(Constants.get(ConstantKey.ATOM_LINK_REL) + property.getName());
|
alink.setRel(Constants.get(ConstantKey.ATOM_LINK_REL) + property.getName());
|
||||||
|
|
||||||
if (property.isCollection()) {
|
if (property.isCollection()) {
|
||||||
EntitySet inline = new EntitySet();
|
EntityCollection inline = new EntityCollection();
|
||||||
for (Object value : property.asCollection()) {
|
for (Object value : property.asCollection()) {
|
||||||
Entity inlineEntity = new Entity();
|
Entity inlineEntity = new Entity();
|
||||||
inlineEntity.setType(navProperties.get(property.getName()).getType());
|
inlineEntity.setType(navProperties.get(property.getName()).getType());
|
||||||
|
|
|
@ -64,7 +64,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||||
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
|
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
@ -283,7 +283,7 @@ public class V4Services extends AbstractServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setInlineCount(final EntitySet entitySet, final String count) {
|
protected void setInlineCount(final EntityCollection entitySet, final String count) {
|
||||||
if ("true".equals(count)) {
|
if ("true".equals(count)) {
|
||||||
entitySet.setCount(entitySet.getEntities().size());
|
entitySet.setCount(entitySet.getEntities().size());
|
||||||
}
|
}
|
||||||
|
@ -456,14 +456,14 @@ public class V4Services extends AbstractServices {
|
||||||
if (StringUtils.isBlank(deltatoken)) {
|
if (StringUtils.isBlank(deltatoken)) {
|
||||||
final InputStream input = (InputStream) getEntitySet(
|
final InputStream input = (InputStream) getEntitySet(
|
||||||
uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
|
uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
|
||||||
final EntitySet entitySet = xml.readEntitySet(acceptType, input);
|
final EntityCollection entitySet = xml.readEntitySet(acceptType, input);
|
||||||
|
|
||||||
boolean trackChanges = prefer.contains("odata.track-changes");
|
boolean trackChanges = prefer.contains("odata.track-changes");
|
||||||
if (trackChanges) {
|
if (trackChanges) {
|
||||||
entitySet.setDeltaLink(URI.create("Customers?$deltatoken=8015"));
|
entitySet.setDeltaLink(URI.create("Customers?$deltatoken=8015"));
|
||||||
}
|
}
|
||||||
|
|
||||||
output = xml.writeEntitySet(acceptType, new ResWrap<EntitySet>(
|
output = xml.writeEntitySet(acceptType, new ResWrap<EntityCollection>(
|
||||||
URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
|
URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
|
||||||
null,
|
null,
|
||||||
entitySet));
|
entitySet));
|
||||||
|
@ -580,10 +580,10 @@ public class V4Services extends AbstractServices {
|
||||||
+ "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
|
+ "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
|
||||||
entry.setEditLink(link);
|
entry.setEditLink(link);
|
||||||
|
|
||||||
final EntitySet feed = new EntitySet();
|
final EntityCollection feed = new EntityCollection();
|
||||||
feed.getEntities().add(entry);
|
feed.getEntities().add(entry);
|
||||||
|
|
||||||
final ResWrap<EntitySet> container = new ResWrap<EntitySet>(
|
final ResWrap<EntityCollection> container = new ResWrap<EntityCollection>(
|
||||||
URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
|
URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
|
||||||
feed);
|
feed);
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ public class V4Services extends AbstractServices {
|
||||||
// 3. Update the contained entity set
|
// 3. Update the contained entity set
|
||||||
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
|
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
|
||||||
final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
|
final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
|
||||||
final ResWrap<EntitySet> feedContainer = atomDeserializer.toEntitySet(feedIS);
|
final ResWrap<EntityCollection> feedContainer = atomDeserializer.toEntitySet(feedIS);
|
||||||
feedContainer.getPayload().getEntities().add(entry);
|
feedContainer.getPayload().getEntities().add(entry);
|
||||||
|
|
||||||
final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||||
|
@ -1050,7 +1050,7 @@ public class V4Services extends AbstractServices {
|
||||||
// 3. Update the contained entity set
|
// 3. Update the contained entity set
|
||||||
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
|
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
|
||||||
final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
|
final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
|
||||||
final ResWrap<EntitySet> feedContainer = atomDeserializer.toEntitySet(feedIS);
|
final ResWrap<EntityCollection> feedContainer = atomDeserializer.toEntitySet(feedIS);
|
||||||
feedContainer.getPayload().getEntities().remove(container.getPayload());
|
feedContainer.getPayload().getEntities().remove(container.getPayload());
|
||||||
|
|
||||||
final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||||
|
@ -1103,7 +1103,7 @@ public class V4Services extends AbstractServices {
|
||||||
final InputStream feed = FSManager.instance(version).
|
final InputStream feed = FSManager.instance(version).
|
||||||
readFile(containedPath(entityId, tempContainedESName).toString(), Accept.ATOM);
|
readFile(containedPath(entityId, tempContainedESName).toString(), Accept.ATOM);
|
||||||
|
|
||||||
final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
|
final ResWrap<EntityCollection> container = atomDeserializer.toEntitySet(feed);
|
||||||
|
|
||||||
if (derivedType != null) {
|
if (derivedType != null) {
|
||||||
final List<Entity> nonMatching = new ArrayList<Entity>();
|
final List<Entity> nonMatching = new ArrayList<Entity>();
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.vfs2.FileObject;
|
import org.apache.commons.vfs2.FileObject;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
@ -507,14 +507,14 @@ public abstract class AbstractUtilities {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySet readEntitySet(final Accept accept, final InputStream entitySet)
|
public EntityCollection readEntitySet(final Accept accept, final InputStream entitySet)
|
||||||
throws ODataDeserializerException {
|
throws ODataDeserializerException {
|
||||||
return (accept == Accept.ATOM || accept == Accept.XML ? atomDeserializer.toEntitySet(entitySet) : jsonDeserializer.
|
return (accept == Accept.ATOM || accept == Accept.XML ? atomDeserializer.toEntitySet(entitySet) : jsonDeserializer.
|
||||||
toEntitySet(entitySet))
|
toEntitySet(entitySet))
|
||||||
.getPayload();
|
.getPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream writeEntitySet(final Accept accept, final ResWrap<EntitySet> container)
|
public InputStream writeEntitySet(final Accept accept, final ResWrap<EntityCollection> container)
|
||||||
throws ODataSerializerException, IOException {
|
throws ODataSerializerException, IOException {
|
||||||
|
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.catalina.LifecycleException;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||||
import org.apache.olingo.commons.api.domain.ODataProperty;
|
import org.apache.olingo.commons.api.domain.ODataProperty;
|
||||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||||
|
@ -81,7 +81,7 @@ public abstract class AbstractBaseTestITCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void debugEntitySet(final EntitySet entitySet, final String message) {
|
protected void debugEntitySet(final EntityCollection entitySet, final String message) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataAnnotation;
|
import org.apache.olingo.commons.api.domain.ODataAnnotation;
|
||||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||||
|
@ -240,7 +240,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||||
+ " \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
|
+ " \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final ResWrap<EntitySet> entitySet =
|
final ResWrap<EntityCollection> entitySet =
|
||||||
client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
|
client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
|
||||||
|
|
||||||
assertEquals(5, entitySet.getPayload().getCount(), 0);
|
assertEquals(5, entitySet.getPayload().getCount(), 0);
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.client.api.serialization;
|
||||||
import org.apache.olingo.client.api.data.ServiceDocument;
|
import org.apache.olingo.client.api.data.ServiceDocument;
|
||||||
import org.apache.olingo.commons.api.data.Delta;
|
import org.apache.olingo.commons.api.data.Delta;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
@ -38,9 +38,9 @@ public interface ODataBinder {
|
||||||
* Gets a <tt>EntitySet</tt> from the given OData entity set.
|
* Gets a <tt>EntitySet</tt> from the given OData entity set.
|
||||||
*
|
*
|
||||||
* @param entitySet OData entity set.
|
* @param entitySet OData entity set.
|
||||||
* @return {@link EntitySet} object.
|
* @return {@link EntityCollection} object.
|
||||||
*/
|
*/
|
||||||
EntitySet getEntitySet(ODataEntitySet entitySet);
|
EntityCollection getEntitySet(ODataEntitySet entitySet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an <tt>Entity</tt> from the given OData entity.
|
* Gets an <tt>Entity</tt> from the given OData entity.
|
||||||
|
@ -89,7 +89,7 @@ public interface ODataBinder {
|
||||||
* @param resource entity set resource.
|
* @param resource entity set resource.
|
||||||
* @return {@link org.apache.olingo.commons.api.domain.ODataEntitySet} object.
|
* @return {@link org.apache.olingo.commons.api.domain.ODataEntitySet} object.
|
||||||
*/
|
*/
|
||||||
ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
|
ODataEntitySet getODataEntitySet(ResWrap<EntityCollection> resource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets <tt>ODataEntity</tt> from the given entity resource.
|
* Gets <tt>ODataEntity</tt> from the given entity resource.
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +25,7 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
|
@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||||
* @param <ES> concrete ODataEntitySet implementation
|
* @param <ES> concrete ODataEntitySet implementation
|
||||||
*/
|
*/
|
||||||
public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
||||||
extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
|
extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
|
||||||
|
|
||||||
private ES entitySet = null;
|
private ES entitySet = null;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
||||||
protected class ODataEntitySetResponseImpl extends AbstractODataRetrieveResponse {
|
protected class ODataEntitySetResponseImpl extends AbstractODataRetrieveResponse {
|
||||||
|
|
||||||
private ODataEntitySetResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
|
private ODataEntitySetResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
|
||||||
final HttpResponse res) {
|
final HttpResponse res) {
|
||||||
|
|
||||||
super(odataClient, httpClient, res);
|
super(odataClient, httpClient, res);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,8 @@ public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
||||||
public ES getBody() {
|
public ES getBody() {
|
||||||
if (entitySet == null) {
|
if (entitySet == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<EntitySet> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
final ResWrap<EntityCollection> resource =
|
||||||
|
odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
||||||
toEntitySet(getRawResponse());
|
toEntitySet(getRawResponse());
|
||||||
|
|
||||||
entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
|
entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.olingo.client.core.edm.xml.EdmxImpl;
|
||||||
import org.apache.olingo.client.core.edm.xml.XMLMetadataImpl;
|
import org.apache.olingo.client.core.edm.xml.XMLMetadataImpl;
|
||||||
import org.apache.olingo.commons.api.data.Delta;
|
import org.apache.olingo.commons.api.data.Delta;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataError;
|
import org.apache.olingo.commons.api.domain.ODataError;
|
||||||
|
@ -71,7 +71,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||||
return deserializer.toEntitySet(input);
|
return deserializer.toEntitySet(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.olingo.commons.api.data.DeletedEntity;
|
||||||
import org.apache.olingo.commons.api.data.Delta;
|
import org.apache.olingo.commons.api.data.Delta;
|
||||||
import org.apache.olingo.commons.api.data.DeltaLink;
|
import org.apache.olingo.commons.api.data.DeltaLink;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Linked;
|
import org.apache.olingo.commons.api.data.Linked;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -192,8 +192,8 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntitySet getEntitySet(final ODataEntitySet odataEntitySet) {
|
public EntityCollection getEntitySet(final ODataEntitySet odataEntitySet) {
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.setCount(odataEntitySet.getCount());
|
entitySet.setCount(odataEntitySet.getCount());
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
|
public ODataEntitySet getODataEntitySet(final ResWrap<EntityCollection> resource) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
|
@ -432,7 +432,7 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
final String href = link.getHref();
|
final String href = link.getHref();
|
||||||
final String title = link.getTitle();
|
final String title = link.getTitle();
|
||||||
final Entity inlineEntity = link.getInlineEntity();
|
final Entity inlineEntity = link.getInlineEntity();
|
||||||
final EntitySet inlineEntitySet = link.getInlineEntitySet();
|
final EntityCollection inlineEntitySet = link.getInlineEntitySet();
|
||||||
if (inlineEntity == null && inlineEntitySet == null) {
|
if (inlineEntity == null && inlineEntitySet == null) {
|
||||||
ODataLinkType linkType = null;
|
ODataLinkType linkType = null;
|
||||||
if (edmType instanceof EdmStructuredType) {
|
if (edmType instanceof EdmStructuredType) {
|
||||||
|
@ -476,10 +476,10 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
inlineEntity)));
|
inlineEntity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ODataInlineEntitySet createODataInlineEntitySet(final EntitySet inlineEntitySet,
|
private ODataInlineEntitySet createODataInlineEntitySet(final EntityCollection inlineEntitySet,
|
||||||
final URI uri, final String title, final String metadataETag) {
|
final URI uri, final String title, final String metadataETag) {
|
||||||
return new ODataInlineEntitySet(uri, ODataLinkType.ENTITY_SET_NAVIGATION, title,
|
return new ODataInlineEntitySet(uri, ODataLinkType.ENTITY_SET_NAVIGATION, title,
|
||||||
getODataEntitySet(new ResWrap<EntitySet>(
|
getODataEntitySet(new ResWrap<EntityCollection>(
|
||||||
inlineEntitySet.getBaseURI() == null ? null : inlineEntitySet.getBaseURI(), metadataETag,
|
inlineEntitySet.getBaseURI() == null ? null : inlineEntitySet.getBaseURI(), metadataETag,
|
||||||
inlineEntitySet)));
|
inlineEntitySet)));
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
|
|
||||||
private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) {
|
private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) {
|
||||||
if (property.isCollection()) {
|
if (property.isCollection()) {
|
||||||
EntitySet inlineEntitySet = new EntitySet();
|
EntityCollection inlineEntitySet = new EntityCollection();
|
||||||
for (final Object inlined : property.asCollection()) {
|
for (final Object inlined : property.asCollection()) {
|
||||||
Entity inlineEntity = new Entity();
|
Entity inlineEntity = new Entity();
|
||||||
inlineEntity.setType(propertyTypeName);
|
inlineEntity.setType(propertyTypeName);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||||
import org.apache.olingo.client.api.serialization.ODataReader;
|
import org.apache.olingo.client.api.serialization.ODataReader;
|
||||||
import org.apache.olingo.client.core.edm.ClientEdmProvider;
|
import org.apache.olingo.client.core.edm.ClientEdmProvider;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||||
|
@ -98,7 +98,7 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
reference.cast(new ODataEntitySetIterator<ODataEntitySet, ODataEntity>(
|
reference.cast(new ODataEntitySetIterator<ODataEntitySet, ODataEntity>(
|
||||||
client, src, ODataFormat.fromString(format))));
|
client, src, ODataFormat.fromString(format))));
|
||||||
} else if (ODataEntitySet.class.isAssignableFrom(reference)) {
|
} else if (ODataEntitySet.class.isAssignableFrom(reference)) {
|
||||||
final ResWrap<EntitySet> resource = client.getDeserializer(ODataFormat.fromString(format))
|
final ResWrap<EntityCollection> resource = client.getDeserializer(ODataFormat.fromString(format))
|
||||||
.toEntitySet(src);
|
.toEntitySet(src);
|
||||||
res = new ResWrap<T>(
|
res = new ResWrap<T>(
|
||||||
resource.getContextURL(),
|
resource.getContextURL(),
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.olingo.client.core.v4;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.core.AbstractTest;
|
import org.apache.olingo.client.core.AbstractTest;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||||
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
import org.apache.olingo.commons.api.domain.ODataEntitySet;
|
||||||
|
@ -46,13 +46,14 @@ public class EntitySetTest extends AbstractTest {
|
||||||
private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
|
private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
|
||||||
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
|
||||||
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||||
getClient().getDeserializer(format).toEntitySet(input));
|
getClient().getDeserializer(format).toEntitySet(input));
|
||||||
assertNotNull(entitySet);
|
assertNotNull(entitySet);
|
||||||
|
|
||||||
assertEquals(2, entitySet.getEntities().size());
|
assertEquals(2, entitySet.getEntities().size());
|
||||||
assertNull(entitySet.getNext());
|
assertNull(entitySet.getNext());
|
||||||
|
|
||||||
final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
|
final ODataEntitySet written =
|
||||||
|
getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
|
||||||
getClient().getBinder().getEntitySet(entitySet)));
|
getClient().getBinder().getEntitySet(entitySet)));
|
||||||
assertEquals(entitySet, written);
|
assertEquals(entitySet, written);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,7 @@ public class EntitySetTest extends AbstractTest {
|
||||||
private void ref(final ODataFormat format) throws ODataDeserializerException {
|
private void ref(final ODataFormat format) throws ODataDeserializerException {
|
||||||
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
|
||||||
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||||
getClient().getDeserializer(format).toEntitySet(input));
|
getClient().getDeserializer(format).toEntitySet(input));
|
||||||
assertNotNull(entitySet);
|
assertNotNull(entitySet);
|
||||||
|
|
||||||
for (ODataEntity entity : entitySet.getEntities()) {
|
for (ODataEntity entity : entitySet.getEntities()) {
|
||||||
|
@ -78,7 +79,8 @@ public class EntitySetTest extends AbstractTest {
|
||||||
}
|
}
|
||||||
entitySet.setCount(entitySet.getEntities().size());
|
entitySet.setCount(entitySet.getEntities().size());
|
||||||
|
|
||||||
final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
|
final ODataEntitySet written =
|
||||||
|
getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
|
||||||
getClient().getBinder().getEntitySet(entitySet)));
|
getClient().getBinder().getEntitySet(entitySet)));
|
||||||
assertEquals(entitySet, written);
|
assertEquals(entitySet, written);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.data;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Delta extends EntitySet {
|
public class Delta extends EntityCollection {
|
||||||
|
|
||||||
private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
|
private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
|
||||||
private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
|
private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EntitySet extends AbstractODataObject {
|
public class EntityCollection extends AbstractODataObject {
|
||||||
|
|
||||||
private Integer count;
|
private Integer count;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Link extends Annotatable {
|
||||||
private String type;
|
private String type;
|
||||||
private String mediaETag;
|
private String mediaETag;
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
private EntitySet entitySet;
|
private EntityCollection entitySet;
|
||||||
private String bindingLink;
|
private String bindingLink;
|
||||||
private List<String> bindingLinks = new ArrayList<String>();
|
private List<String> bindingLinks = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class Link extends Annotatable {
|
||||||
*
|
*
|
||||||
* @return in-line entity set.
|
* @return in-line entity set.
|
||||||
*/
|
*/
|
||||||
public EntitySet getInlineEntitySet() {
|
public EntityCollection getInlineEntitySet() {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ public class Link extends Annotatable {
|
||||||
*
|
*
|
||||||
* @param entitySet entity set.
|
* @param entitySet entity set.
|
||||||
*/
|
*/
|
||||||
public void setInlineEntitySet(final EntitySet entitySet) {
|
public void setInlineEntitySet(final EntityCollection entitySet) {
|
||||||
this.entitySet = entitySet;
|
this.entitySet = entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.olingo.commons.api.serialization;
|
package org.apache.olingo.commons.api.serialization;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.domain.ODataError;
|
import org.apache.olingo.commons.api.domain.ODataError;
|
||||||
|
@ -35,9 +35,9 @@ public interface ODataDeserializer {
|
||||||
* Gets an entity set object from the given InputStream.
|
* Gets an entity set object from the given InputStream.
|
||||||
*
|
*
|
||||||
* @param input stream to be de-serialized.
|
* @param input stream to be de-serialized.
|
||||||
* @return {@link EntitySet} instance.
|
* @return {@link EntityCollection} instance.
|
||||||
*/
|
*/
|
||||||
ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException;
|
ResWrap<EntityCollection> toEntitySet(InputStream input) throws ODataDeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an entity object from the given InputStream.
|
* Gets an entity object from the given InputStream.
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
|
||||||
import org.apache.olingo.commons.api.data.Delta;
|
import org.apache.olingo.commons.api.data.Delta;
|
||||||
import org.apache.olingo.commons.api.data.DeltaLink;
|
import org.apache.olingo.commons.api.data.DeltaLink;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
@ -712,7 +712,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void count(final XMLEventReader reader, final StartElement start, final EntitySet entitySet)
|
private void count(final XMLEventReader reader, final StartElement start, final EntityCollection entitySet)
|
||||||
throws XMLStreamException {
|
throws XMLStreamException {
|
||||||
|
|
||||||
boolean foundEndElement = false;
|
boolean foundEndElement = false;
|
||||||
|
@ -729,12 +729,12 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet entitySet(final XMLEventReader reader, final StartElement start)
|
private EntityCollection entitySet(final XMLEventReader reader, final StartElement start)
|
||||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||||
if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
|
if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
|
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
|
||||||
if (xmlBase != null) {
|
if (xmlBase != null) {
|
||||||
entitySet.setBaseURI(xmlBase.getValue());
|
entitySet.setBaseURI(xmlBase.getValue());
|
||||||
|
@ -788,7 +788,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||||
try {
|
try {
|
||||||
final XMLEventReader reader = getReader(input);
|
final XMLEventReader reader = getReader(input);
|
||||||
final StartElement start = skipBeforeFirstStartElement(reader);
|
final StartElement start = skipBeforeFirstStartElement(reader);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.data.Annotation;
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL;
|
import org.apache.olingo.commons.api.data.ContextURL;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
@ -393,7 +393,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet)
|
private void entitySet(final XMLStreamWriter writer, final EntityCollection entitySet)
|
||||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||||
if (entitySet.getBaseURI() != null) {
|
if (entitySet.getBaseURI() != null) {
|
||||||
writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
|
writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
|
||||||
|
@ -442,7 +442,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entitySet(final Writer outWriter, final EntitySet entitySet)
|
private void entitySet(final Writer outWriter, final EntityCollection entitySet)
|
||||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||||
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
|
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entitySet(final Writer outWriter, final ResWrap<EntitySet> entitySet)
|
private void entitySet(final Writer outWriter, final ResWrap<EntityCollection> entitySet)
|
||||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||||
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
|
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
|
||||||
|
|
||||||
|
@ -491,8 +491,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
||||||
@Override
|
@Override
|
||||||
public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
|
public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
|
||||||
try {
|
try {
|
||||||
if (obj instanceof EntitySet) {
|
if (obj instanceof EntityCollection) {
|
||||||
entitySet(writer, (EntitySet) obj);
|
entitySet(writer, (EntityCollection) obj);
|
||||||
} else if (obj instanceof Entity) {
|
} else if (obj instanceof Entity) {
|
||||||
entity(writer, (Entity) obj);
|
entity(writer, (Entity) obj);
|
||||||
} else if (obj instanceof Property) {
|
} else if (obj instanceof Property) {
|
||||||
|
@ -527,8 +527,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
||||||
final T obj = container == null ? null : container.getPayload();
|
final T obj = container == null ? null : container.getPayload();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (obj instanceof EntitySet) {
|
if (obj instanceof EntityCollection) {
|
||||||
this.entitySet(writer, (ResWrap<EntitySet>) container);
|
this.entitySet(writer, (ResWrap<EntityCollection>) container);
|
||||||
} else if (obj instanceof Entity) {
|
} else if (obj instanceof Entity) {
|
||||||
entity(writer, (ResWrap<Entity>) container);
|
entity(writer, (ResWrap<Entity>) container);
|
||||||
} else if (obj instanceof Property) {
|
} else if (obj instanceof Property) {
|
||||||
|
@ -551,8 +551,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
||||||
if (container.getContextURL() != null) {
|
if (container.getContextURL() != null) {
|
||||||
final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
|
final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
|
||||||
String base = contextURL.getServiceRoot().toASCIIString();
|
String base = contextURL.getServiceRoot().toASCIIString();
|
||||||
if (container.getPayload() instanceof EntitySet) {
|
if (container.getPayload() instanceof EntityCollection) {
|
||||||
((EntitySet) container.getPayload()).setBaseURI(base);
|
((EntityCollection) container.getPayload()).setBaseURI(base);
|
||||||
}
|
}
|
||||||
if (container.getPayload() instanceof Entity) {
|
if (container.getPayload() instanceof Entity) {
|
||||||
((Entity) container.getPayload()).setBaseURI(base);
|
((Entity) container.getPayload()).setBaseURI(base);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.data.Annotatable;
|
||||||
import org.apache.olingo.commons.api.data.Annotation;
|
import org.apache.olingo.commons.api.data.Annotation;
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Linked;
|
import org.apache.olingo.commons.api.data.Linked;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -106,7 +106,7 @@ public class JsonDeserializer implements ODataDeserializer {
|
||||||
} else if (inline instanceof ArrayNode) {
|
} else if (inline instanceof ArrayNode) {
|
||||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||||
|
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
for (final Iterator<JsonNode> entries = inline.elements(); entries.hasNext();) {
|
for (final Iterator<JsonNode> entries = inline.elements(); entries.hasNext();) {
|
||||||
entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
|
entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ public class JsonDeserializer implements ODataDeserializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||||
try {
|
try {
|
||||||
parser = new JsonFactory(new ObjectMapper()).createParser(input);
|
parser = new JsonFactory(new ObjectMapper()).createParser(input);
|
||||||
return new JsonEntitySetDeserializer(serverMode).doDeserialize(parser);
|
return new JsonEntitySetDeserializer(serverMode).doDeserialize(parser);
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.Annotation;
|
import org.apache.olingo.commons.api.data.Annotation;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
|
||||||
super(serverMode);
|
super(serverMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResWrap<EntitySet> doDeserialize(final JsonParser parser) throws IOException {
|
protected ResWrap<EntityCollection> doDeserialize(final JsonParser parser) throws IOException {
|
||||||
|
|
||||||
final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
|
final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
URI contextURL;
|
URI contextURL;
|
||||||
if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
|
if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
|
||||||
|
@ -115,6 +115,6 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResWrap<EntitySet>(contextURL, metadataETag, entitySet);
|
return new ResWrap<EntityCollection>(contextURL, metadataETag, entitySet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.Annotation;
|
import org.apache.olingo.commons.api.data.Annotation;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
|
||||||
|
@ -36,15 +36,15 @@ public class JsonEntitySetSerializer extends JsonSerializer {
|
||||||
super(serverMode);
|
super(serverMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSerialize(final EntitySet entitySet, final JsonGenerator jgen)
|
protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
|
||||||
throws IOException, EdmPrimitiveTypeException {
|
throws IOException, EdmPrimitiveTypeException {
|
||||||
doContainerSerialize(new ResWrap<EntitySet>(null, null, entitySet), jgen);
|
doContainerSerialize(new ResWrap<EntityCollection>(null, null, entitySet), jgen);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doContainerSerialize(final ResWrap<EntitySet> container, final JsonGenerator jgen)
|
protected void doContainerSerialize(final ResWrap<EntityCollection> container, final JsonGenerator jgen)
|
||||||
throws IOException, EdmPrimitiveTypeException {
|
throws IOException, EdmPrimitiveTypeException {
|
||||||
|
|
||||||
final EntitySet entitySet = container.getPayload();
|
final EntityCollection entitySet = container.getPayload();
|
||||||
|
|
||||||
jgen.writeStartObject();
|
jgen.writeStartObject();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.olingo.commons.api.data.Annotatable;
|
||||||
import org.apache.olingo.commons.api.data.Annotation;
|
import org.apache.olingo.commons.api.data.Annotation;
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Linked;
|
import org.apache.olingo.commons.api.data.Linked;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -81,8 +81,8 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
|
public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
|
||||||
try {
|
try {
|
||||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||||
if (obj instanceof EntitySet) {
|
if (obj instanceof EntityCollection) {
|
||||||
new JsonEntitySetSerializer(serverMode).doSerialize((EntitySet) obj, json);
|
new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
|
||||||
} else if (obj instanceof Entity) {
|
} else if (obj instanceof Entity) {
|
||||||
new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
|
new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
|
||||||
} else if (obj instanceof Property) {
|
} else if (obj instanceof Property) {
|
||||||
|
@ -113,8 +113,8 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
final T obj = container == null ? null : container.getPayload();
|
final T obj = container == null ? null : container.getPayload();
|
||||||
try {
|
try {
|
||||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||||
if (obj instanceof EntitySet) {
|
if (obj instanceof EntityCollection) {
|
||||||
new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntitySet>) container, json);
|
new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
|
||||||
} else if (obj instanceof Entity) {
|
} else if (obj instanceof Entity) {
|
||||||
new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
|
new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
|
||||||
} else if (obj instanceof Property) {
|
} else if (obj instanceof Property) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public class AtomDeserializerTest {
|
||||||
final ResWrap<Entity> entity = deserializer.toEntity(in);
|
final ResWrap<Entity> entity = deserializer.toEntity(in);
|
||||||
|
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
final EntitySet inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
||||||
assertNotNull(inlineEntitySet);
|
assertNotNull(inlineEntitySet);
|
||||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ public class AtomDeserializerTest {
|
||||||
final ResWrap<Entity> entity = deserializer.toEntity(in);
|
final ResWrap<Entity> entity = deserializer.toEntity(in);
|
||||||
|
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
final EntitySet inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
||||||
assertNotNull(inlineEntitySet);
|
assertNotNull(inlineEntitySet);
|
||||||
assertEquals(1, inlineEntitySet.getEntities().size());
|
assertEquals(1, inlineEntitySet.getEntities().size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Parameter;
|
import org.apache.olingo.commons.api.data.Parameter;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -39,9 +39,9 @@ public interface DeserializerResult {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a entity set
|
* Returns a entity set
|
||||||
* @return an {@link EntitySet} or null
|
* @return an {@link EntityCollection} or null
|
||||||
*/
|
*/
|
||||||
EntitySet getEntityCollection();
|
EntityCollection getEntityCollection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ExpandOptions for serialized entities
|
* Returns the ExpandOptions for serialized entities
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.server.api.deserializer;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAction;
|
import org.apache.olingo.commons.api.edm.EdmAction;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmProperty;
|
import org.apache.olingo.commons.api.edm.EdmProperty;
|
||||||
|
@ -43,7 +43,7 @@ public interface ODataDeserializer {
|
||||||
DeserializerResult entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
|
DeserializerResult entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserializes an entity collection stream into an {@link EntitySet} object.
|
* Deserializes an entity collection stream into an {@link EntityCollection} object.
|
||||||
* @param stream
|
* @param stream
|
||||||
* @param edmEntityType
|
* @param edmEntityType
|
||||||
* @return {@link DeserializerResult#getEntityCollection()}
|
* @return {@link DeserializerResult#getEntityCollection()}
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.server.api.serializer;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||||
|
@ -64,7 +64,7 @@ public interface ODataSerializer {
|
||||||
* @param options options for the serializer
|
* @param options options for the serializer
|
||||||
*/
|
*/
|
||||||
SerializerResult entityCollection(ServiceMetadata metadata, EdmEntityType entityType,
|
SerializerResult entityCollection(ServiceMetadata metadata, EdmEntityType entityType,
|
||||||
EntitySet entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
|
EntityCollection entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes entity data into an InputStream.
|
* Writes entity data into an InputStream.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Parameter;
|
import org.apache.olingo.commons.api.data.Parameter;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.server.api.deserializer.DeserializerResult;
|
import org.apache.olingo.server.api.deserializer.DeserializerResult;
|
||||||
|
@ -31,7 +31,7 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
||||||
|
|
||||||
public class DeserializerResultImpl implements DeserializerResult {
|
public class DeserializerResultImpl implements DeserializerResult {
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
private EntitySet entitySet;
|
private EntityCollection entitySet;
|
||||||
private ExpandOption expandOption;
|
private ExpandOption expandOption;
|
||||||
private Property property;
|
private Property property;
|
||||||
private List<Parameter> actionParametes;
|
private List<Parameter> actionParametes;
|
||||||
|
@ -45,7 +45,7 @@ public class DeserializerResultImpl implements DeserializerResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntitySet getEntityCollection() {
|
public EntityCollection getEntityCollection() {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class DeserializerResultImpl implements DeserializerResult {
|
||||||
|
|
||||||
public static class DeserializerResultBuilder {
|
public static class DeserializerResultBuilder {
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
private EntitySet entitySet;
|
private EntityCollection entitySet;
|
||||||
private ExpandOption expandOption;
|
private ExpandOption expandOption;
|
||||||
private Property property;
|
private Property property;
|
||||||
private List<Parameter> actionParametes;
|
private List<Parameter> actionParametes;
|
||||||
|
@ -98,7 +98,7 @@ public class DeserializerResultImpl implements DeserializerResult {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeserializerResultBuilder entityCollection(final EntitySet entitySet) {
|
public DeserializerResultBuilder entityCollection(final EntityCollection entitySet) {
|
||||||
this.entitySet = entitySet;
|
this.entitySet = entitySet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.Map.Entry;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Parameter;
|
import org.apache.olingo.commons.api.data.Parameter;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -92,9 +92,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree,
|
private EntityCollection consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree,
|
||||||
final ExpandTreeBuilder expandBuilder) throws DeserializerException {
|
final ExpandTreeBuilder expandBuilder) throws DeserializerException {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
// Consume entities
|
// Consume entities
|
||||||
JsonNode jsonNode = tree.get(Constants.VALUE);
|
JsonNode jsonNode = tree.get(Constants.VALUE);
|
||||||
|
@ -339,7 +339,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
|
||||||
expandBuilder.expand(edmNavigationProperty) : null;
|
expandBuilder.expand(edmNavigationProperty) : null;
|
||||||
if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
|
if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
|
||||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||||
EntitySet inlineEntitySet = new EntitySet();
|
EntityCollection inlineEntitySet = new EntityCollection();
|
||||||
inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode,
|
inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode,
|
||||||
childExpandBuilder));
|
childExpandBuilder));
|
||||||
link.setInlineEntitySet(inlineEntitySet);
|
link.setInlineEntitySet(inlineEntitySet);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL;
|
import org.apache.olingo.commons.api.data.ContextURL;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Linked;
|
import org.apache.olingo.commons.api.data.Linked;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -130,7 +130,7 @@ public class ODataJsonSerializer implements ODataSerializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
||||||
final EdmEntityType entityType, final EntitySet entitySet,
|
final EdmEntityType entityType, final EntityCollection entitySet,
|
||||||
final EntityCollectionSerializerOptions options) throws SerializerException {
|
final EntityCollectionSerializerOptions options) throws SerializerException {
|
||||||
CircleStreamBuffer buffer = new CircleStreamBuffer();
|
CircleStreamBuffer buffer = new CircleStreamBuffer();
|
||||||
try {
|
try {
|
||||||
|
@ -194,7 +194,7 @@ public class ODataJsonSerializer implements ODataSerializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
|
protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
|
||||||
final EntitySet entitySet, final ExpandOption expand, final SelectOption select,
|
final EntityCollection entitySet, final ExpandOption expand, final SelectOption select,
|
||||||
final boolean onlyReference, final JsonGenerator json) throws IOException,
|
final boolean onlyReference, final JsonGenerator json) throws IOException,
|
||||||
SerializerException {
|
SerializerException {
|
||||||
json.writeStartArray();
|
json.writeStartArray();
|
||||||
|
|
|
@ -23,7 +23,7 @@ import javax.xml.stream.XMLStreamException;
|
||||||
import javax.xml.stream.XMLStreamWriter;
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||||
|
@ -95,7 +95,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
||||||
final EdmEntityType entityType, final EntitySet entitySet,
|
final EdmEntityType entityType, final EntityCollection entitySet,
|
||||||
final EntityCollectionSerializerOptions options) throws SerializerException {
|
final EntityCollectionSerializerOptions options) throws SerializerException {
|
||||||
throw new SerializerException("Entityset serialization not implemented for XML format",
|
throw new SerializerException("Entityset serialization not implemented for XML format",
|
||||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ValueType;
|
import org.apache.olingo.commons.api.data.ValueType;
|
||||||
|
@ -41,10 +41,10 @@ public class DataCreator {
|
||||||
|
|
||||||
private static final UUID GUID = UUID.fromString("01234567-89ab-cdef-0123-456789abcdef");
|
private static final UUID GUID = UUID.fromString("01234567-89ab-cdef-0123-456789abcdef");
|
||||||
|
|
||||||
private final Map<String, EntitySet> data;
|
private final Map<String, EntityCollection> data;
|
||||||
|
|
||||||
public DataCreator() {
|
public DataCreator() {
|
||||||
data = new HashMap<String, EntitySet>();
|
data = new HashMap<String, EntityCollection>();
|
||||||
data.put("ESTwoPrim", createESTwoPrim());
|
data.put("ESTwoPrim", createESTwoPrim());
|
||||||
data.put("ESAllPrim", createESAllPrim());
|
data.put("ESAllPrim", createESAllPrim());
|
||||||
data.put("ESCompAllPrim", createESCompAllPrim());
|
data.put("ESCompAllPrim", createESCompAllPrim());
|
||||||
|
@ -59,19 +59,19 @@ public class DataCreator {
|
||||||
data.put("ESServerSidePaging", createESServerSidePaging());
|
data.put("ESServerSidePaging", createESServerSidePaging());
|
||||||
|
|
||||||
// No data available but to allow an insert operation create empty EntitySets
|
// No data available but to allow an insert operation create empty EntitySets
|
||||||
data.put("ESAllNullable", new EntitySet());
|
data.put("ESAllNullable", new EntityCollection());
|
||||||
data.put("ESMixEnumDefCollComp", new EntitySet());
|
data.put("ESMixEnumDefCollComp", new EntityCollection());
|
||||||
data.put("ESTwoBase", new EntitySet());
|
data.put("ESTwoBase", new EntityCollection());
|
||||||
data.put("ESBaseTwoKeyNav", new EntitySet());
|
data.put("ESBaseTwoKeyNav", new EntityCollection());
|
||||||
data.put("ESBaseTwoKeyTwoPrim", new EntitySet());
|
data.put("ESBaseTwoKeyTwoPrim", new EntityCollection());
|
||||||
data.put("ESTwoKeyTwoPrim", new EntitySet());
|
data.put("ESTwoKeyTwoPrim", new EntityCollection());
|
||||||
data.put("ESCompCollAllPrim", new EntitySet());
|
data.put("ESCompCollAllPrim", new EntityCollection());
|
||||||
data.put("ESKeyTwoKeyComp", new EntitySet());
|
data.put("ESKeyTwoKeyComp", new EntityCollection());
|
||||||
data.put("ESFourKeyAlias", new EntitySet());
|
data.put("ESFourKeyAlias", new EntityCollection());
|
||||||
data.put("ESBase", new EntitySet());
|
data.put("ESBase", new EntityCollection());
|
||||||
data.put("ESTwoBaseTwoKeyTwoPrim", new EntitySet());
|
data.put("ESTwoBaseTwoKeyTwoPrim", new EntityCollection());
|
||||||
data.put("ESInvisible", new EntitySet());
|
data.put("ESInvisible", new EntityCollection());
|
||||||
data.put("ESCompMixPrimCollComp", new EntitySet());
|
data.put("ESCompMixPrimCollComp", new EntityCollection());
|
||||||
|
|
||||||
linkESTwoPrim(data);
|
linkESTwoPrim(data);
|
||||||
linkESAllPrim(data);
|
linkESAllPrim(data);
|
||||||
|
@ -79,12 +79,12 @@ public class DataCreator {
|
||||||
linkESTwoKeyNav(data);
|
linkESTwoKeyNav(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, EntitySet> getData() {
|
protected Map<String, EntityCollection> getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESServerSidePaging() {
|
private EntityCollection createESServerSidePaging() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
for (int i = 1; i <= 503; i++) {
|
for (int i = 1; i <= 503; i++) {
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", i))
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", i))
|
||||||
|
@ -94,8 +94,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESKeyNav() {
|
private EntityCollection createESKeyNav() {
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
|
entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
|
||||||
entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
|
entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
|
||||||
|
@ -123,8 +123,8 @@ public class DataCreator {
|
||||||
createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1))));
|
createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESTwoKeyNav() {
|
private EntityCollection createESTwoKeyNav() {
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "1"));
|
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "1"));
|
||||||
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
|
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
|
||||||
|
@ -174,8 +174,8 @@ public class DataCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private EntitySet createESCompCollComp() {
|
private EntityCollection createESCompCollComp() {
|
||||||
final EntitySet entitySet = new EntitySet();
|
final EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||||
.addProperty(createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
|
.addProperty(createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
|
||||||
|
@ -198,8 +198,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESTwoPrim() {
|
private EntityCollection createESTwoPrim() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 32766))
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 32766))
|
||||||
.addProperty(createPrimitive("PropertyString", "Test String1")));
|
.addProperty(createPrimitive("PropertyString", "Test String1")));
|
||||||
|
@ -216,8 +216,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESAllPrim() {
|
private EntityCollection createESAllPrim() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||||
.addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
|
.addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
|
||||||
|
@ -266,8 +266,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESCompAllPrim() {
|
private EntityCollection createESCompAllPrim() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
Entity entity = new Entity();
|
Entity entity = new Entity();
|
||||||
entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
|
entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
|
||||||
|
@ -318,8 +318,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESCollAllPrim() {
|
private EntityCollection createESCollAllPrim() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
|
||||||
createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
|
createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
|
||||||
|
@ -361,13 +361,13 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESMixPrimCollComp() {
|
private EntityCollection createESMixPrimCollComp() {
|
||||||
@SuppressWarnings("unchecked") final Property complexCollection = createComplexCollection("CollPropertyComp",
|
@SuppressWarnings("unchecked") final Property complexCollection = createComplexCollection("CollPropertyComp",
|
||||||
Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
|
Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
|
||||||
Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
|
Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
|
||||||
Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
|
Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
|
||||||
|
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||||
.addProperty(
|
.addProperty(
|
||||||
|
@ -391,8 +391,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESAllKey() {
|
private EntityCollection createESAllKey() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "First"))
|
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "First"))
|
||||||
.addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
|
.addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
|
||||||
|
@ -420,8 +420,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESCompComp() {
|
private EntityCollection createESCompComp() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
Entity entity = new Entity();
|
Entity entity = new Entity();
|
||||||
entity.addProperty(createPrimitive("PropertyInt16", 1));
|
entity.addProperty(createPrimitive("PropertyInt16", 1));
|
||||||
|
@ -440,8 +440,8 @@ public class DataCreator {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createESMedia() {
|
private EntityCollection createESMedia() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
Entity entity = new Entity().addProperty(createPrimitive("PropertyInt16", 1))
|
Entity entity = new Entity().addProperty(createPrimitive("PropertyInt16", 1))
|
||||||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
|
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
|
||||||
|
@ -473,8 +473,8 @@ public class DataCreator {
|
||||||
+ " <circle cx=\"50\" cy=\"50\" r=\"42\"/>\n" + " </g>\n" + "</svg>\n").getBytes(Charset.forName("UTF-8"));
|
+ " <circle cx=\"50\" cy=\"50\" r=\"42\"/>\n" + " </g>\n" + "</svg>\n").getBytes(Charset.forName("UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkESTwoPrim(Map<String, EntitySet> data) {
|
private void linkESTwoPrim(Map<String, EntityCollection> data) {
|
||||||
final EntitySet entitySet = data.get("ESTwoPrim");
|
final EntityCollection entitySet = data.get("ESTwoPrim");
|
||||||
final List<Entity> targetEntities = data.get("ESAllPrim").getEntities();
|
final List<Entity> targetEntities = data.get("ESAllPrim").getEntities();
|
||||||
|
|
||||||
setLinks(entitySet.getEntities().get(1), "NavPropertyETAllPrimMany", targetEntities.get(1), targetEntities.get(2));
|
setLinks(entitySet.getEntities().get(1), "NavPropertyETAllPrimMany", targetEntities.get(1), targetEntities.get(2));
|
||||||
|
@ -482,8 +482,8 @@ public class DataCreator {
|
||||||
setLink(entitySet.getEntities().get(3), "NavPropertyETAllPrimOne", targetEntities.get(0));
|
setLink(entitySet.getEntities().get(3), "NavPropertyETAllPrimOne", targetEntities.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkESAllPrim(Map<String, EntitySet> data) {
|
private void linkESAllPrim(Map<String, EntityCollection> data) {
|
||||||
final EntitySet entitySet = data.get("ESAllPrim");
|
final EntityCollection entitySet = data.get("ESAllPrim");
|
||||||
final List<Entity> targetEntities = data.get("ESTwoPrim").getEntities();
|
final List<Entity> targetEntities = data.get("ESTwoPrim").getEntities();
|
||||||
|
|
||||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoPrimMany", targetEntities.get(1));
|
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoPrimMany", targetEntities.get(1));
|
||||||
|
@ -493,8 +493,8 @@ public class DataCreator {
|
||||||
targetEntities.get(3));
|
targetEntities.get(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkESKeyNav(Map<String, EntitySet> data) {
|
private void linkESKeyNav(Map<String, EntityCollection> data) {
|
||||||
final EntitySet entitySet = data.get("ESKeyNav");
|
final EntityCollection entitySet = data.get("ESKeyNav");
|
||||||
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
||||||
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
||||||
final List<Entity> esMediaTargets = data.get("ESMedia").getEntities();
|
final List<Entity> esMediaTargets = data.get("ESMedia").getEntities();
|
||||||
|
@ -524,8 +524,8 @@ public class DataCreator {
|
||||||
setLink(entitySet.getEntities().get(2), "NavPropertyETMediaOne", esMediaTargets.get(2));
|
setLink(entitySet.getEntities().get(2), "NavPropertyETMediaOne", esMediaTargets.get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkESTwoKeyNav(Map<String, EntitySet> data) {
|
private void linkESTwoKeyNav(Map<String, EntityCollection> data) {
|
||||||
final EntitySet entitySet = data.get("ESTwoKeyNav");
|
final EntityCollection entitySet = data.get("ESTwoKeyNav");
|
||||||
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
||||||
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ public class DataCreator {
|
||||||
link = new Link();
|
link = new Link();
|
||||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||||
link.setTitle(navigationPropertyName);
|
link.setTitle(navigationPropertyName);
|
||||||
EntitySet target = new EntitySet();
|
EntityCollection target = new EntityCollection();
|
||||||
target.getEntities().addAll(Arrays.asList(targets));
|
target.getEntities().addAll(Arrays.asList(targets));
|
||||||
link.setInlineEntitySet(target);
|
link.setInlineEntitySet(target);
|
||||||
entity.getNavigationLinks().add(link);
|
entity.getNavigationLinks().add(link);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
|
@ -55,7 +55,7 @@ public class DataProvider {
|
||||||
|
|
||||||
protected static final String MEDIA_PROPERTY_NAME = "$value";
|
protected static final String MEDIA_PROPERTY_NAME = "$value";
|
||||||
|
|
||||||
final private Map<String, EntitySet> data;
|
final private Map<String, EntityCollection> data;
|
||||||
private Edm edm;
|
private Edm edm;
|
||||||
private OData odata;
|
private OData odata;
|
||||||
|
|
||||||
|
@ -63,16 +63,16 @@ public class DataProvider {
|
||||||
data = new DataCreator().getData();
|
data = new DataCreator().getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySet readAll(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
public EntityCollection readAll(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
||||||
return data.get(edmEntitySet.getName());
|
return data.get(edmEntitySet.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
|
public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
|
||||||
final EntitySet entitySet = readAll(edmEntitySet);
|
final EntityCollection entitySet = readAll(edmEntitySet);
|
||||||
return entitySet == null ? null : read(edmEntitySet.getEntityType(), entitySet, keys);
|
return entitySet == null ? null : read(edmEntitySet.getEntityType(), entitySet, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity read(final EdmEntityType edmEntityType, final EntitySet entitySet, final List<UriParameter> keys)
|
public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet, final List<UriParameter> keys)
|
||||||
throws DataProviderException {
|
throws DataProviderException {
|
||||||
try {
|
try {
|
||||||
for (final Entity entity : entitySet.getEntities()) {
|
for (final Entity entity : entitySet.getEntities()) {
|
||||||
|
@ -129,7 +129,7 @@ public class DataProvider {
|
||||||
|
|
||||||
public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
||||||
final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
|
final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
|
||||||
final EntitySet entitySet = readAll(edmEntitySet);
|
final EntityCollection entitySet = readAll(edmEntitySet);
|
||||||
final List<Entity> entities = entitySet.getEntities();
|
final List<Entity> entities = entitySet.getEntities();
|
||||||
final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
|
final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
|
||||||
final Entity newEntity = new Entity();
|
final Entity newEntity = new Entity();
|
||||||
|
@ -349,7 +349,7 @@ public class DataProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Entity> createInlineEntities(final String rawBaseUri, final EdmEntitySet targetEntitySet,
|
private List<Entity> createInlineEntities(final String rawBaseUri, final EdmEntitySet targetEntitySet,
|
||||||
final EntitySet changedEntitySet) throws DataProviderException {
|
final EntityCollection changedEntitySet) throws DataProviderException {
|
||||||
List<Entity> entities = new ArrayList<Entity>();
|
List<Entity> entities = new ArrayList<Entity>();
|
||||||
|
|
||||||
for (final Entity newEntity : changedEntitySet.getEntities()) {
|
for (final Entity newEntity : changedEntitySet.getEntities()) {
|
||||||
|
@ -473,7 +473,7 @@ public class DataProvider {
|
||||||
entity.setMediaContentType(type);
|
entity.setMediaContentType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySet readFunctionEntitySet(final EdmFunction function, final List<UriParameter> parameters)
|
public EntityCollection readFunctionEntitySet(final EdmFunction function, final List<UriParameter> parameters)
|
||||||
throws DataProviderException {
|
throws DataProviderException {
|
||||||
return FunctionData.entityCollectionFunction(function.getName(), parameters, data);
|
return FunctionData.entityCollectionFunction(function.getName(), parameters, data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
|
@ -33,11 +33,11 @@ import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
|
||||||
|
|
||||||
public class FunctionData {
|
public class FunctionData {
|
||||||
|
|
||||||
protected static EntitySet entityCollectionFunction(final String name, final List<UriParameter> parameters,
|
protected static EntityCollection entityCollectionFunction(final String name, final List<UriParameter> parameters,
|
||||||
final Map<String, EntitySet> data) throws DataProviderException {
|
final Map<String, EntityCollection> data) throws DataProviderException {
|
||||||
if (name.equals("UFCRTCollETTwoKeyNavParam")) {
|
if (name.equals("UFCRTCollETTwoKeyNavParam")) {
|
||||||
final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
|
final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
|
||||||
EntitySet result = new EntitySet();
|
EntityCollection result = new EntityCollection();
|
||||||
final int endIndex = parameters.isEmpty() ? 0 : Short.valueOf(parameters.get(0).getText());
|
final int endIndex = parameters.isEmpty() ? 0 : Short.valueOf(parameters.get(0).getText());
|
||||||
result.getEntities().addAll(
|
result.getEntities().addAll(
|
||||||
esTwoKeyNav.subList(0,
|
esTwoKeyNav.subList(0,
|
||||||
|
@ -53,7 +53,7 @@ public class FunctionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Entity entityFunction(final String name, final List<UriParameter> parameters,
|
protected static Entity entityFunction(final String name, final List<UriParameter> parameters,
|
||||||
final Map<String, EntitySet> data) throws DataProviderException {
|
final Map<String, EntityCollection> data) throws DataProviderException {
|
||||||
final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
|
final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
|
||||||
if (name.equals("UFCRTETTwoKeyNav")) {
|
if (name.equals("UFCRTETTwoKeyNav")) {
|
||||||
return esTwoKeyNav.get(0);
|
return esTwoKeyNav.get(0);
|
||||||
|
@ -71,7 +71,7 @@ public class FunctionData {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected static Property primitiveComplexFunction(final String name, final List<UriParameter> parameters,
|
protected static Property primitiveComplexFunction(final String name, final List<UriParameter> parameters,
|
||||||
final Map<String, EntitySet> data) throws DataProviderException {
|
final Map<String, EntityCollection> data) throws DataProviderException {
|
||||||
if (name.equals("UFNRTInt16")) {
|
if (name.equals("UFNRTInt16")) {
|
||||||
return DataCreator.createPrimitive(name, 12345);
|
return DataCreator.createPrimitive(name, 12345);
|
||||||
} else if (name.equals("UFCRTString")) {
|
} else if (name.equals("UFCRTString")) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Linked;
|
import org.apache.olingo.commons.api.data.Linked;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
|
@ -140,7 +140,7 @@ public class RequestValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(edmProperty.isCollection()) {
|
if(edmProperty.isCollection()) {
|
||||||
final EntitySet inlineEntitySet = navigationLink.getInlineEntitySet();
|
final EntityCollection inlineEntitySet = navigationLink.getInlineEntitySet();
|
||||||
if(!isInsert && inlineEntitySet.getEntities().size() > 0) {
|
if(!isInsert && inlineEntitySet.getEntities().size() > 0) {
|
||||||
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
|
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.data.ContextURL;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL.Builder;
|
import org.apache.olingo.commons.api.data.ContextURL.Builder;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAction;
|
import org.apache.olingo.commons.api.edm.EdmAction;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||||
|
@ -91,13 +91,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
||||||
.get(uriInfo.getUriResourceParts().size() - 1)).getType() :
|
.get(uriInfo.getUriResourceParts().size() - 1)).getType() :
|
||||||
edmEntitySet.getEntityType();
|
edmEntitySet.getEntityType();
|
||||||
|
|
||||||
final EntitySet entitySetInitial = readEntityCollection(uriInfo);
|
final EntityCollection entitySetInitial = readEntityCollection(uriInfo);
|
||||||
if (entitySetInitial == null) {
|
if (entitySetInitial == null) {
|
||||||
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
||||||
} else {
|
} else {
|
||||||
// Modifying the original entitySet means modifying the "database", so we have to make a shallow
|
// Modifying the original entitySet means modifying the "database", so we have to make a shallow
|
||||||
// copy of the entity set (new EntitySet, but exactly the same data)
|
// copy of the entity set (new EntitySet, but exactly the same data)
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
entitySet.getEntities().addAll(entitySetInitial.getEntities());
|
entitySet.getEntities().addAll(entitySetInitial.getEntities());
|
||||||
|
|
||||||
// Apply system query options
|
// Apply system query options
|
||||||
|
@ -121,7 +121,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
||||||
// Create a shallow copy of each entity. So the expanded navigation properties can be modified for serialization,
|
// Create a shallow copy of each entity. So the expanded navigation properties can be modified for serialization,
|
||||||
// without affecting the data stored in the database.
|
// without affecting the data stored in the database.
|
||||||
final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
|
final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
|
||||||
final EntitySet entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet,
|
final EntityCollection entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet,
|
||||||
edmEntitySet,
|
edmEntitySet,
|
||||||
expand);
|
expand);
|
||||||
expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
|
expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
|
||||||
|
@ -155,7 +155,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
||||||
throws ODataApplicationException, SerializerException {
|
throws ODataApplicationException, SerializerException {
|
||||||
validateOptions(uriInfo.asUriInfoResource());
|
validateOptions(uriInfo.asUriInfoResource());
|
||||||
getEdmEntitySet(uriInfo); // including checks
|
getEdmEntitySet(uriInfo); // including checks
|
||||||
EntitySet entitySet = readEntityCollection(uriInfo);
|
EntityCollection entitySet = readEntityCollection(uriInfo);
|
||||||
if (entitySet == null) {
|
if (entitySet == null) {
|
||||||
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -330,7 +330,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
||||||
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
|
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCount(EntitySet entitySet) {
|
private void setCount(EntityCollection entitySet) {
|
||||||
if (entitySet.getCount() == null) {
|
if (entitySet.getCount() == null) {
|
||||||
entitySet.setCount(entitySet.getEntities().size());
|
entitySet.setCount(entitySet.getEntities().size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
|
@ -163,7 +163,7 @@ public abstract class TechnicalProcessor implements Processor {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntitySet readEntityCollection(final UriInfoResource uriInfo) throws ODataApplicationException {
|
protected EntityCollection readEntityCollection(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||||
final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
|
final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
|
||||||
if (resourcePaths.size() > 1 && resourcePaths.get(1) instanceof UriResourceNavigation) {
|
if (resourcePaths.size() > 1 && resourcePaths.get(1) instanceof UriResourceNavigation) {
|
||||||
final Entity entity = readEntity(uriInfo);
|
final Entity entity = readEntity(uriInfo);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Link;
|
import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
|
@ -48,7 +48,7 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.options.TopHandler
|
||||||
|
|
||||||
public class ExpandSystemQueryOptionHandler {
|
public class ExpandSystemQueryOptionHandler {
|
||||||
|
|
||||||
public void applyExpandQueryOptions(final EntitySet entitySet, final EdmEntitySet edmEntitySet,
|
public void applyExpandQueryOptions(final EntityCollection entitySet, final EdmEntitySet edmEntitySet,
|
||||||
final ExpandOption expandOption) throws ODataApplicationException {
|
final ExpandOption expandOption) throws ODataApplicationException {
|
||||||
if (expandOption == null) {
|
if (expandOption == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -81,13 +81,13 @@ public class ExpandSystemQueryOptionHandler {
|
||||||
final Link link = entity.getNavigationLink(navPropertyName);
|
final Link link = entity.getNavigationLink(navPropertyName);
|
||||||
if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
|
if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
|
||||||
applyOptionsToEntityCollection(link.getInlineEntitySet(),
|
applyOptionsToEntityCollection(link.getInlineEntitySet(),
|
||||||
targetEdmEntitySet,
|
targetEdmEntitySet,
|
||||||
item.getFilterOption(),
|
item.getFilterOption(),
|
||||||
item.getOrderByOption(),
|
item.getOrderByOption(),
|
||||||
item.getCountOption(),
|
item.getCountOption(),
|
||||||
item.getSkipOption(),
|
item.getSkipOption(),
|
||||||
item.getTopOption(),
|
item.getTopOption(),
|
||||||
item.getExpandOption());
|
item.getExpandOption());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ODataApplicationException("Not supported resource part in expand system query option",
|
throw new ODataApplicationException("Not supported resource part in expand system query option",
|
||||||
|
@ -96,10 +96,11 @@ public class ExpandSystemQueryOptionHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyOptionsToEntityCollection(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget,
|
private void applyOptionsToEntityCollection(final EntityCollection entitySet,
|
||||||
|
final EdmBindingTarget edmBindingTarget,
|
||||||
final FilterOption filterOption, final OrderByOption orderByOption, final CountOption countOption,
|
final FilterOption filterOption, final OrderByOption orderByOption, final CountOption countOption,
|
||||||
final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption)
|
final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption)
|
||||||
throws ODataApplicationException {
|
throws ODataApplicationException {
|
||||||
|
|
||||||
FilterHandler.applyFilterSystemQuery(filterOption, entitySet, edmBindingTarget);
|
FilterHandler.applyFilterSystemQuery(filterOption, entitySet, edmBindingTarget);
|
||||||
OrderByHandler.applyOrderByOption(orderByOption, entitySet, edmBindingTarget);
|
OrderByHandler.applyOrderByOption(orderByOption, entitySet, edmBindingTarget);
|
||||||
|
@ -108,19 +109,19 @@ public class ExpandSystemQueryOptionHandler {
|
||||||
TopHandler.applyTopSystemQueryOption(topOption, entitySet);
|
TopHandler.applyTopSystemQueryOption(topOption, entitySet);
|
||||||
|
|
||||||
// Apply nested expand system query options to remaining entities
|
// Apply nested expand system query options to remaining entities
|
||||||
if(expandOption != null) {
|
if (expandOption != null) {
|
||||||
for(final Entity entity : entitySet.getEntities()) {
|
for (final Entity entity : entitySet.getEntities()) {
|
||||||
applyExpandOptionToEntity(entity, edmBindingTarget, expandOption);
|
applyExpandOptionToEntity(entity, edmBindingTarget, expandOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySet transformEntitySetGraphToTree(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget,
|
public EntityCollection transformEntitySetGraphToTree(final EntityCollection entitySet,
|
||||||
final ExpandOption expand) throws ODataApplicationException {
|
final EdmBindingTarget edmBindingTarget, final ExpandOption expand) throws ODataApplicationException {
|
||||||
|
|
||||||
final EntitySet newEntitySet = newEntitySet(entitySet);
|
final EntityCollection newEntitySet = newEntitySet(entitySet);
|
||||||
|
|
||||||
for(final Entity entity : entitySet.getEntities()) {
|
for (final Entity entity : entitySet.getEntities()) {
|
||||||
newEntitySet.getEntities().add(transformEntityGraphToTree(entity, edmBindingTarget, expand));
|
newEntitySet.getEntities().add(transformEntityGraphToTree(entity, edmBindingTarget, expand));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,14 +146,14 @@ public class ExpandSystemQueryOptionHandler {
|
||||||
newEntity.getNavigationLinks().add(newLink);
|
newEntity.getNavigationLinks().add(newLink);
|
||||||
final ExpandOption innerExpandOption = getInnerExpandOption(expand, propertyName);
|
final ExpandOption innerExpandOption = getInnerExpandOption(expand, propertyName);
|
||||||
|
|
||||||
if(edmNavigationProperty.isCollection()) {
|
if (edmNavigationProperty.isCollection()) {
|
||||||
newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(),
|
newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(),
|
||||||
edmBindingTarget,
|
edmBindingTarget,
|
||||||
innerExpandOption));
|
innerExpandOption));
|
||||||
} else {
|
} else {
|
||||||
newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(),
|
newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(),
|
||||||
edmBindingTarget,
|
edmBindingTarget,
|
||||||
innerExpandOption));
|
innerExpandOption));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,8 +162,8 @@ public class ExpandSystemQueryOptionHandler {
|
||||||
return newEntity;
|
return newEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySet newEntitySet(final EntitySet entitySet) {
|
public EntityCollection newEntitySet(final EntityCollection entitySet) {
|
||||||
final EntitySet newEntitySet = new EntitySet();
|
final EntityCollection newEntitySet = new EntityCollection();
|
||||||
newEntitySet.setCount(entitySet.getCount());
|
newEntitySet.setCount(entitySet.getCount());
|
||||||
newEntitySet.setDeltaLink(entitySet.getDeltaLink());
|
newEntitySet.setDeltaLink(entitySet.getDeltaLink());
|
||||||
newEntitySet.setNext(entitySet.getNext());
|
newEntitySet.setNext(entitySet.getNext());
|
||||||
|
@ -230,9 +231,9 @@ public class ExpandSystemQueryOptionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExpandOption getInnerExpandOption(final ExpandOption expand, final String propertyName) {
|
private ExpandOption getInnerExpandOption(final ExpandOption expand, final String propertyName) {
|
||||||
for(final ExpandItem item : expand.getExpandItems()) {
|
for (final ExpandItem item : expand.getExpandItems()) {
|
||||||
final UriResource resource = item.getResourcePath().getUriResourceParts().get(0);
|
final UriResource resource = item.getResourcePath().getUriResourceParts().get(0);
|
||||||
if(resource instanceof UriResourceNavigation
|
if (resource instanceof UriResourceNavigation
|
||||||
&& propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) {
|
&& propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) {
|
||||||
return item.getExpandOption();
|
return item.getExpandOption();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.server.tecsvc.processor.queryoptions.options;
|
package org.apache.olingo.server.tecsvc.processor.queryoptions.options;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.CountOption;
|
import org.apache.olingo.server.api.uri.queryoption.CountOption;
|
||||||
|
|
||||||
public class CountHandler {
|
public class CountHandler {
|
||||||
public static void applyCountSystemQueryOption(final CountOption countOption, final EntitySet entitySet) {
|
public static void applyCountSystemQueryOption(final CountOption countOption, final EntityCollection entitySet) {
|
||||||
if(countOption != null && countOption.getValue()) {
|
if(countOption != null && countOption.getValue()) {
|
||||||
entitySet.setCount(entitySet.getEntities().size());
|
entitySet.setCount(entitySet.getEntities().size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
|
@ -45,7 +45,7 @@ public class FilterHandler {
|
||||||
primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
|
primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyFilterSystemQuery(FilterOption filterOption, EntitySet entitySet,
|
public static void applyFilterSystemQuery(FilterOption filterOption, EntityCollection entitySet,
|
||||||
EdmBindingTarget edmEntitySet) throws ODataApplicationException {
|
EdmBindingTarget edmEntitySet) throws ODataApplicationException {
|
||||||
|
|
||||||
if (filterOption == null) {
|
if (filterOption == null) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Comparator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.server.api.ODataApplicationException;
|
import org.apache.olingo.server.api.ODataApplicationException;
|
||||||
|
@ -34,7 +34,7 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.Express
|
||||||
import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
|
import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
|
||||||
|
|
||||||
public class OrderByHandler {
|
public class OrderByHandler {
|
||||||
public static void applyOrderByOption(final OrderByOption orderByOption, final EntitySet entitySet,
|
public static void applyOrderByOption(final OrderByOption orderByOption, final EntityCollection entitySet,
|
||||||
final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
|
final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
|
||||||
|
|
||||||
if (orderByOption == null) {
|
if (orderByOption == null) {
|
||||||
|
@ -54,7 +54,7 @@ public class OrderByHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyOrderByOptionInternal(final OrderByOption orderByOption, final EntitySet entitySet,
|
private static void applyOrderByOptionInternal(final OrderByOption orderByOption, final EntityCollection entitySet,
|
||||||
final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
|
final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
|
||||||
Collections.sort(entitySet.getEntities(), new Comparator<Entity>() {
|
Collections.sort(entitySet.getEntities(), new Comparator<Entity>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.server.api.ODataApplicationException;
|
import org.apache.olingo.server.api.ODataApplicationException;
|
||||||
|
@ -34,7 +34,7 @@ public class ServerSidePagingHandler {
|
||||||
private static final int MAX_PAGE_SIZE = 10;
|
private static final int MAX_PAGE_SIZE = 10;
|
||||||
private static final String ES_SERVER_SIDE_PAGING = "ESServerSidePaging";
|
private static final String ES_SERVER_SIDE_PAGING = "ESServerSidePaging";
|
||||||
|
|
||||||
public static void applyServerSidePaging(final SkipTokenOption skipTokenOption, final EntitySet entitySet,
|
public static void applyServerSidePaging(final SkipTokenOption skipTokenOption, final EntityCollection entitySet,
|
||||||
final EdmEntitySet edmEntitySet, final String rawRequestUri) throws ODataApplicationException {
|
final EdmEntitySet edmEntitySet, final String rawRequestUri) throws ODataApplicationException {
|
||||||
|
|
||||||
if (edmEntitySet != null && shouldApplyServerSidePaging(edmEntitySet)) {
|
if (edmEntitySet != null && shouldApplyServerSidePaging(edmEntitySet)) {
|
||||||
|
|
|
@ -22,13 +22,13 @@ import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.server.api.ODataApplicationException;
|
import org.apache.olingo.server.api.ODataApplicationException;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.SkipOption;
|
import org.apache.olingo.server.api.uri.queryoption.SkipOption;
|
||||||
|
|
||||||
public class SkipHandler {
|
public class SkipHandler {
|
||||||
public static void applySkipSystemQueryHandler(final SkipOption skipOption, final EntitySet entitySet)
|
public static void applySkipSystemQueryHandler(final SkipOption skipOption, final EntityCollection entitySet)
|
||||||
throws ODataApplicationException {
|
throws ODataApplicationException {
|
||||||
|
|
||||||
if (skipOption != null) {
|
if (skipOption != null) {
|
||||||
|
@ -41,7 +41,7 @@ public class SkipHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void popAtMost(final EntitySet entitySet, final int n) {
|
static void popAtMost(final EntityCollection entitySet, final int n) {
|
||||||
final Iterator<Entity> iter = entitySet.getEntities().iterator();
|
final Iterator<Entity> iter = entitySet.getEntities().iterator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@ package org.apache.olingo.server.tecsvc.processor.queryoptions.options;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.server.api.ODataApplicationException;
|
import org.apache.olingo.server.api.ODataApplicationException;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.TopOption;
|
import org.apache.olingo.server.api.uri.queryoption.TopOption;
|
||||||
|
|
||||||
public class TopHandler {
|
public class TopHandler {
|
||||||
public static void applyTopSystemQueryOption(final TopOption topOption, final EntitySet entitySet)
|
public static void applyTopSystemQueryOption(final TopOption topOption, final EntityCollection entitySet)
|
||||||
throws ODataApplicationException {
|
throws ODataApplicationException {
|
||||||
|
|
||||||
if (topOption != null) {
|
if (topOption != null) {
|
||||||
|
@ -39,7 +39,7 @@ public class TopHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reduceToSize(final EntitySet entitySet, final int n) {
|
static void reduceToSize(final EntityCollection entitySet, final int n) {
|
||||||
while (entitySet.getEntities().size() > n) {
|
while (entitySet.getEntities().size() > n) {
|
||||||
entitySet.getEntities().remove(entitySet.getEntities().size() - 1);
|
entitySet.getEntities().remove(entitySet.getEntities().size() - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||||
|
@ -88,14 +88,14 @@ public class DataProviderTest {
|
||||||
@Test
|
@Test
|
||||||
public void esAllPrim() throws Exception {
|
public void esAllPrim() throws Exception {
|
||||||
final DataProvider data = new DataProvider();
|
final DataProvider data = new DataProvider();
|
||||||
EntitySet outSet = data.readAll(esAllPrim);
|
EntityCollection outSet = data.readAll(esAllPrim);
|
||||||
|
|
||||||
Assert.assertEquals(3, outSet.getEntities().size());
|
Assert.assertEquals(3, outSet.getEntities().size());
|
||||||
|
|
||||||
Entity first = outSet.getEntities().get(0);
|
Entity first = outSet.getEntities().get(0);
|
||||||
Assert.assertEquals(16, first.getProperties().size());
|
Assert.assertEquals(16, first.getProperties().size());
|
||||||
Assert.assertEquals(2, first.getNavigationLinks().size());
|
Assert.assertEquals(2, first.getNavigationLinks().size());
|
||||||
final EntitySet target = first.getNavigationLink("NavPropertyETTwoPrimMany").getInlineEntitySet();
|
final EntityCollection target = first.getNavigationLink("NavPropertyETTwoPrimMany").getInlineEntitySet();
|
||||||
Assert.assertNotNull(target);
|
Assert.assertNotNull(target);
|
||||||
Assert.assertEquals(1, target.getEntities().size());
|
Assert.assertEquals(1, target.getEntities().size());
|
||||||
Assert.assertEquals(data.readAll(entityContainer.getEntitySet("ESTwoPrim")).getEntities().get(1),
|
Assert.assertEquals(data.readAll(entityContainer.getEntitySet("ESTwoPrim")).getEntities().get(1),
|
||||||
|
@ -107,7 +107,7 @@ public class DataProviderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void esCollAllPrim() throws Exception {
|
public void esCollAllPrim() throws Exception {
|
||||||
EntitySet outSet = new DataProvider().readAll(esCollAllPrim);
|
EntityCollection outSet = new DataProvider().readAll(esCollAllPrim);
|
||||||
|
|
||||||
Assert.assertEquals(3, outSet.getEntities().size());
|
Assert.assertEquals(3, outSet.getEntities().size());
|
||||||
Assert.assertEquals(17, outSet.getEntities().get(0).getProperties().size());
|
Assert.assertEquals(17, outSet.getEntities().get(0).getProperties().size());
|
||||||
|
@ -120,7 +120,7 @@ public class DataProviderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void esCompAllPrim() throws Exception {
|
public void esCompAllPrim() throws Exception {
|
||||||
EntitySet outSet = new DataProvider().readAll(esCompAllPrim);
|
EntityCollection outSet = new DataProvider().readAll(esCompAllPrim);
|
||||||
|
|
||||||
Assert.assertEquals(3, outSet.getEntities().size());
|
Assert.assertEquals(3, outSet.getEntities().size());
|
||||||
Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size());
|
Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size());
|
||||||
|
@ -133,7 +133,7 @@ public class DataProviderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void esMixPrimCollComp() throws Exception {
|
public void esMixPrimCollComp() throws Exception {
|
||||||
EntitySet outSet = new DataProvider().readAll(esMixPrimCollComp);
|
EntityCollection outSet = new DataProvider().readAll(esMixPrimCollComp);
|
||||||
|
|
||||||
Assert.assertEquals(3, outSet.getEntities().size());
|
Assert.assertEquals(3, outSet.getEntities().size());
|
||||||
Assert.assertEquals(4, outSet.getEntities().get(0).getProperties().size());
|
Assert.assertEquals(4, outSet.getEntities().get(0).getProperties().size());
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
@ -43,7 +43,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
|
||||||
public void esAllPrim() throws Exception {
|
public void esAllPrim() throws Exception {
|
||||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
|
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
|
||||||
InputStream stream = getFileAsStream("ESAllPrim.json");
|
InputStream stream = getFileAsStream("ESAllPrim.json");
|
||||||
EntitySet entitySet =
|
EntityCollection entitySet =
|
||||||
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
||||||
.getEntityCollection();
|
.getEntityCollection();
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
|
||||||
public void eSCompCollComp() throws Exception {
|
public void eSCompCollComp() throws Exception {
|
||||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompCollComp"));
|
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompCollComp"));
|
||||||
InputStream stream = getFileAsStream("ESCompCollComp.json");
|
InputStream stream = getFileAsStream("ESCompCollComp.json");
|
||||||
EntitySet entitySet =
|
EntityCollection entitySet =
|
||||||
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
||||||
.getEntityCollection();
|
.getEntityCollection();
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
|
||||||
String entityCollectionString = "{\"value\" : []}";
|
String entityCollectionString = "{\"value\" : []}";
|
||||||
InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
|
InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
|
||||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
|
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
|
||||||
EntitySet entityCollection =
|
EntityCollection entityCollection =
|
||||||
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
||||||
.getEntityCollection();
|
.getEntityCollection();
|
||||||
assertNotNull(entityCollection.getEntities());
|
assertNotNull(entityCollection.getEntities());
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL;
|
import org.apache.olingo.commons.api.data.ContextURL;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ValueType;
|
import org.apache.olingo.commons.api.data.ValueType;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
|
@ -159,7 +159,7 @@ public class ODataJsonSerializerTest {
|
||||||
@Test
|
@Test
|
||||||
public void entitySetAllPrim() throws Exception {
|
public void entitySetAllPrim() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
EntitySet entitySet = data.readAll(edmEntitySet);
|
EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||||
entitySet.setCount(entitySet.getEntities().size());
|
entitySet.setCount(entitySet.getEntities().size());
|
||||||
entitySet.setNext(URI.create("/next"));
|
entitySet.setNext(URI.create("/next"));
|
||||||
CountOption countOption = Mockito.mock(CountOption.class);
|
CountOption countOption = Mockito.mock(CountOption.class);
|
||||||
|
@ -305,7 +305,7 @@ public class ODataJsonSerializerTest {
|
||||||
@Test
|
@Test
|
||||||
public void entitySetTwoPrimNoMetadata() throws Exception {
|
public void entitySetTwoPrimNoMetadata() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
final EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||||
InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
|
InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
|
||||||
.entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
|
.entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
|
||||||
EntityCollectionSerializerOptions.with()
|
EntityCollectionSerializerOptions.with()
|
||||||
|
@ -338,7 +338,7 @@ public class ODataJsonSerializerTest {
|
||||||
@Test
|
@Test
|
||||||
public void entitySetMedia() throws Exception {
|
public void entitySetMedia() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
|
||||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
final EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||||
final String resultString = IOUtils.toString(serializer.entityCollection(metadata,
|
final String resultString = IOUtils.toString(serializer.entityCollection(metadata,
|
||||||
edmEntitySet.getEntityType(), entitySet,
|
edmEntitySet.getEntityType(), entitySet,
|
||||||
EntityCollectionSerializerOptions.with()
|
EntityCollectionSerializerOptions.with()
|
||||||
|
@ -398,7 +398,7 @@ public class ODataJsonSerializerTest {
|
||||||
public void selectComplex() throws Exception {
|
public void selectComplex() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
||||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
final EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||||
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
|
||||||
InputStream result = serializer
|
InputStream result = serializer
|
||||||
|
@ -422,7 +422,7 @@ public class ODataJsonSerializerTest {
|
||||||
public void selectComplexTwice() throws Exception {
|
public void selectComplexTwice() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
||||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
final EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||||
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
|
||||||
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp")));
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp")));
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.ODataException;
|
import org.apache.olingo.commons.api.ODataException;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ValueType;
|
import org.apache.olingo.commons.api.data.ValueType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
|
@ -38,21 +38,21 @@ import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
|
||||||
|
|
||||||
public class DataProvider {
|
public class DataProvider {
|
||||||
|
|
||||||
private final Map<String, EntitySet> data;
|
private final Map<String, EntityCollection> data;
|
||||||
|
|
||||||
public DataProvider() {
|
public DataProvider() {
|
||||||
data = new HashMap<String, EntitySet>();
|
data = new HashMap<String, EntityCollection>();
|
||||||
data.put("Cars", createCars());
|
data.put("Cars", createCars());
|
||||||
data.put("Manufacturers", createManufacturers());
|
data.put("Manufacturers", createManufacturers());
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySet readAll(EdmEntitySet edmEntitySet) {
|
public EntityCollection readAll(EdmEntitySet edmEntitySet) {
|
||||||
return data.get(edmEntitySet.getName());
|
return data.get(edmEntitySet.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
|
public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
|
||||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||||
final EntitySet entitySet = data.get(edmEntitySet.getName());
|
final EntityCollection entitySet = data.get(edmEntitySet.getName());
|
||||||
if (entitySet == null) {
|
if (entitySet == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,8 +93,8 @@ public class DataProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createCars() {
|
private EntityCollection createCars() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity()
|
entitySet.getEntities().add(new Entity()
|
||||||
.addProperty(createPrimitive("Id", 1))
|
.addProperty(createPrimitive("Id", 1))
|
||||||
|
@ -137,8 +137,8 @@ public class DataProvider {
|
||||||
return entitySet;
|
return entitySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySet createManufacturers() {
|
private EntityCollection createManufacturers() {
|
||||||
EntitySet entitySet = new EntitySet();
|
EntityCollection entitySet = new EntityCollection();
|
||||||
|
|
||||||
entitySet.getEntities().add(new Entity()
|
entitySet.getEntities().add(new Entity()
|
||||||
.addProperty(createPrimitive("Id", 1))
|
.addProperty(createPrimitive("Id", 1))
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Locale;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL;
|
import org.apache.olingo.commons.api.data.ContextURL;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
import org.apache.olingo.commons.api.data.ContextURL.Suffix;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
|
@ -97,7 +97,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
|
||||||
|
|
||||||
// Second we fetch the data for this specific entity set from the mock database and transform it into an EntitySet
|
// Second we fetch the data for this specific entity set from the mock database and transform it into an EntitySet
|
||||||
// object which is understood by our serialization
|
// object which is understood by our serialization
|
||||||
EntitySet entitySet = dataProvider.readAll(edmEntitySet);
|
EntityCollection entitySet = dataProvider.readAll(edmEntitySet);
|
||||||
|
|
||||||
// Next we create a serializer based on the requested format. This could also be a custom format but we do not
|
// Next we create a serializer based on the requested format. This could also be a custom format but we do not
|
||||||
// support them in this example
|
// support them in this example
|
||||||
|
|
Loading…
Reference in New Issue