[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.olingo.commons.api.data.ComplexValue;
|
||||
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.Property;
|
||||
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 ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
|
||||
final ResWrap<EntityCollection> container = atomDeserializer.toEntitySet(feed);
|
||||
|
||||
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
|
||||
@Path("/Person({entityId})")
|
||||
|
@ -1256,7 +1256,7 @@ public abstract class AbstractServices {
|
|||
rep.setInlineEntity(inline);
|
||||
} else if (link.getType().equals(Constants.get(ConstantKey.ATOM_LINK_FEED))) {
|
||||
// inline feed
|
||||
final EntitySet inline = atomDeserializer.toEntitySet(
|
||||
final EntityCollection inline = atomDeserializer.toEntitySet(
|
||||
xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
|
||||
rep.setInlineEntitySet(inline);
|
||||
}
|
||||
|
@ -1911,7 +1911,7 @@ public abstract class AbstractServices {
|
|||
alink.setRel(Constants.get(ConstantKey.ATOM_LINK_REL) + property.getName());
|
||||
|
||||
if (property.isCollection()) {
|
||||
EntitySet inline = new EntitySet();
|
||||
EntityCollection inline = new EntityCollection();
|
||||
for (Object value : property.asCollection()) {
|
||||
Entity inlineEntity = new Entity();
|
||||
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.MultipartBody;
|
||||
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.Property;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
|
@ -283,7 +283,7 @@ public class V4Services extends AbstractServices {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void setInlineCount(final EntitySet entitySet, final String count) {
|
||||
protected void setInlineCount(final EntityCollection entitySet, final String count) {
|
||||
if ("true".equals(count)) {
|
||||
entitySet.setCount(entitySet.getEntities().size());
|
||||
}
|
||||
|
@ -456,14 +456,14 @@ public class V4Services extends AbstractServices {
|
|||
if (StringUtils.isBlank(deltatoken)) {
|
||||
final InputStream input = (InputStream) getEntitySet(
|
||||
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");
|
||||
if (trackChanges) {
|
||||
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"),
|
||||
null,
|
||||
entitySet));
|
||||
|
@ -580,10 +580,10 @@ public class V4Services extends AbstractServices {
|
|||
+ "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
|
||||
entry.setEditLink(link);
|
||||
|
||||
final EntitySet feed = new EntitySet();
|
||||
final EntityCollection feed = new EntityCollection();
|
||||
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,
|
||||
feed);
|
||||
|
||||
|
@ -934,7 +934,7 @@ public class V4Services extends AbstractServices {
|
|||
// 3. Update the contained entity set
|
||||
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
|
||||
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);
|
||||
|
||||
final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||
|
@ -1050,7 +1050,7 @@ public class V4Services extends AbstractServices {
|
|||
// 3. Update the contained entity set
|
||||
final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
|
||||
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());
|
||||
|
||||
final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||
|
@ -1103,7 +1103,7 @@ public class V4Services extends AbstractServices {
|
|||
final InputStream feed = FSManager.instance(version).
|
||||
readFile(containedPath(entityId, tempContainedESName).toString(), Accept.ATOM);
|
||||
|
||||
final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
|
||||
final ResWrap<EntityCollection> container = atomDeserializer.toEntitySet(feed);
|
||||
|
||||
if (derivedType != null) {
|
||||
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.vfs2.FileObject;
|
||||
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.Property;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
|
@ -507,14 +507,14 @@ public abstract class AbstractUtilities {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public EntitySet readEntitySet(final Accept accept, final InputStream entitySet)
|
||||
public EntityCollection readEntitySet(final Accept accept, final InputStream entitySet)
|
||||
throws ODataDeserializerException {
|
||||
return (accept == Accept.ATOM || accept == Accept.XML ? atomDeserializer.toEntitySet(entitySet) : jsonDeserializer.
|
||||
toEntitySet(entitySet))
|
||||
.getPayload();
|
||||
}
|
||||
|
||||
public InputStream writeEntitySet(final Accept accept, final ResWrap<EntitySet> container)
|
||||
public InputStream writeEntitySet(final Accept accept, final ResWrap<EntityCollection> container)
|
||||
throws ODataSerializerException, IOException {
|
||||
|
||||
final StringWriter writer = new StringWriter();
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.catalina.LifecycleException;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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.ODataProperty;
|
||||
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()) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
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.response.ODataRetrieveResponse;
|
||||
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.domain.ODataAnnotation;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||
|
@ -240,7 +240,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
|||
+ " \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
|
||||
+ "}";
|
||||
|
||||
final ResWrap<EntitySet> entitySet =
|
||||
final ResWrap<EntityCollection> entitySet =
|
||||
client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
|
||||
|
||||
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.commons.api.data.Delta;
|
||||
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.Property;
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
|
@ -89,7 +89,7 @@ public interface ODataBinder {
|
|||
* @param resource entity set resource.
|
||||
* @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.
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* 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
|
||||
* 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
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "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
|
||||
* 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.communication.request.retrieve.ODataEntitySetRequest;
|
||||
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.domain.ODataEntitySet;
|
||||
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
|
||||
*/
|
||||
public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
||||
extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
|
||||
extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
|
||||
|
||||
private ES entitySet = null;
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
|||
protected class ODataEntitySetResponseImpl extends AbstractODataRetrieveResponse {
|
||||
|
||||
private ODataEntitySetResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
|
||||
final HttpResponse res) {
|
||||
final HttpResponse res) {
|
||||
|
||||
super(odataClient, httpClient, res);
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
|
|||
public ES getBody() {
|
||||
if (entitySet == null) {
|
||||
try {
|
||||
final ResWrap<EntitySet> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
||||
final ResWrap<EntityCollection> resource =
|
||||
odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
||||
toEntitySet(getRawResponse());
|
||||
|
||||
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.commons.api.data.Delta;
|
||||
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.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.ODataError;
|
||||
|
@ -71,7 +71,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||
public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||
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.DeltaLink;
|
||||
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.Linked;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
|
@ -192,8 +192,8 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EntitySet getEntitySet(final ODataEntitySet odataEntitySet) {
|
||||
final EntitySet entitySet = new EntitySet();
|
||||
public EntityCollection getEntitySet(final ODataEntitySet odataEntitySet) {
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.setCount(odataEntitySet.getCount());
|
||||
|
||||
|
@ -387,7 +387,7 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
|
||||
public ODataEntitySet getODataEntitySet(final ResWrap<EntityCollection> resource) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
|
@ -432,7 +432,7 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
final String href = link.getHref();
|
||||
final String title = link.getTitle();
|
||||
final Entity inlineEntity = link.getInlineEntity();
|
||||
final EntitySet inlineEntitySet = link.getInlineEntitySet();
|
||||
final EntityCollection inlineEntitySet = link.getInlineEntitySet();
|
||||
if (inlineEntity == null && inlineEntitySet == null) {
|
||||
ODataLinkType linkType = null;
|
||||
if (edmType instanceof EdmStructuredType) {
|
||||
|
@ -476,10 +476,10 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
inlineEntity)));
|
||||
}
|
||||
|
||||
private ODataInlineEntitySet createODataInlineEntitySet(final EntitySet inlineEntitySet,
|
||||
private ODataInlineEntitySet createODataInlineEntitySet(final EntityCollection inlineEntitySet,
|
||||
final URI uri, final String title, final String metadataETag) {
|
||||
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)));
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
|
||||
private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) {
|
||||
if (property.isCollection()) {
|
||||
EntitySet inlineEntitySet = new EntitySet();
|
||||
EntityCollection inlineEntitySet = new EntityCollection();
|
||||
for (final Object inlined : property.asCollection()) {
|
||||
Entity inlineEntity = new Entity();
|
||||
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.core.edm.ClientEdmProvider;
|
||||
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.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.ODataEntity;
|
||||
|
@ -98,7 +98,7 @@ public class ODataReaderImpl implements ODataReader {
|
|||
reference.cast(new ODataEntitySetIterator<ODataEntitySet, ODataEntity>(
|
||||
client, src, ODataFormat.fromString(format))));
|
||||
} 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);
|
||||
res = new ResWrap<T>(
|
||||
resource.getContextURL(),
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* 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
|
||||
* 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
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "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
|
||||
* 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.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.domain.ODataEntity;
|
||||
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 {
|
||||
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
|
||||
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||
getClient().getDeserializer(format).toEntitySet(input));
|
||||
getClient().getDeserializer(format).toEntitySet(input));
|
||||
assertNotNull(entitySet);
|
||||
|
||||
assertEquals(2, entitySet.getEntities().size());
|
||||
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)));
|
||||
assertEquals(entitySet, written);
|
||||
}
|
||||
|
@ -70,7 +71,7 @@ public class EntitySetTest extends AbstractTest {
|
|||
private void ref(final ODataFormat format) throws ODataDeserializerException {
|
||||
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
|
||||
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||
getClient().getDeserializer(format).toEntitySet(input));
|
||||
getClient().getDeserializer(format).toEntitySet(input));
|
||||
assertNotNull(entitySet);
|
||||
|
||||
for (ODataEntity entity : entitySet.getEntities()) {
|
||||
|
@ -78,7 +79,8 @@ public class EntitySetTest extends AbstractTest {
|
|||
}
|
||||
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)));
|
||||
assertEquals(entitySet, written);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.data;
|
|||
import java.util.ArrayList;
|
||||
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<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.net.URI;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EntitySet extends AbstractODataObject {
|
||||
public class EntityCollection extends AbstractODataObject {
|
||||
|
||||
private Integer count;
|
||||
|
|
@ -29,7 +29,7 @@ public class Link extends Annotatable {
|
|||
private String type;
|
||||
private String mediaETag;
|
||||
private Entity entity;
|
||||
private EntitySet entitySet;
|
||||
private EntityCollection entitySet;
|
||||
private String bindingLink;
|
||||
private List<String> bindingLinks = new ArrayList<String>();
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class Link extends Annotatable {
|
|||
*
|
||||
* @return in-line entity set.
|
||||
*/
|
||||
public EntitySet getInlineEntitySet() {
|
||||
public EntityCollection getInlineEntitySet() {
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class Link extends Annotatable {
|
|||
*
|
||||
* @param entitySet entity set.
|
||||
*/
|
||||
public void setInlineEntitySet(final EntitySet entitySet) {
|
||||
public void setInlineEntitySet(final EntityCollection entitySet) {
|
||||
this.entitySet = entitySet;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.olingo.commons.api.serialization;
|
||||
|
||||
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.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.ODataError;
|
||||
|
@ -35,9 +35,9 @@ public interface ODataDeserializer {
|
|||
* Gets an entity set object from the given InputStream.
|
||||
*
|
||||
* @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.
|
||||
|
|
|
@ -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.DeltaLink;
|
||||
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.Property;
|
||||
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 {
|
||||
|
||||
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 {
|
||||
if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
|
||||
return null;
|
||||
}
|
||||
final EntitySet entitySet = new EntitySet();
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
|
||||
if (xmlBase != null) {
|
||||
entitySet.setBaseURI(xmlBase.getValue());
|
||||
|
@ -788,7 +788,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||
public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||
try {
|
||||
final XMLEventReader reader = getReader(input);
|
||||
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.ContextURL;
|
||||
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.Property;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
|
@ -393,7 +393,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
writer.flush();
|
||||
}
|
||||
|
||||
private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet)
|
||||
private void entitySet(final XMLStreamWriter writer, final EntityCollection entitySet)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
if (entitySet.getBaseURI() != null) {
|
||||
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 {
|
||||
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
|
||||
|
||||
|
@ -455,7 +455,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
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 {
|
||||
final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
|
||||
|
||||
|
@ -491,8 +491,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
@Override
|
||||
public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
|
||||
try {
|
||||
if (obj instanceof EntitySet) {
|
||||
entitySet(writer, (EntitySet) obj);
|
||||
if (obj instanceof EntityCollection) {
|
||||
entitySet(writer, (EntityCollection) obj);
|
||||
} else if (obj instanceof Entity) {
|
||||
entity(writer, (Entity) obj);
|
||||
} else if (obj instanceof Property) {
|
||||
|
@ -527,8 +527,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
final T obj = container == null ? null : container.getPayload();
|
||||
|
||||
try {
|
||||
if (obj instanceof EntitySet) {
|
||||
this.entitySet(writer, (ResWrap<EntitySet>) container);
|
||||
if (obj instanceof EntityCollection) {
|
||||
this.entitySet(writer, (ResWrap<EntityCollection>) container);
|
||||
} else if (obj instanceof Entity) {
|
||||
entity(writer, (ResWrap<Entity>) container);
|
||||
} else if (obj instanceof Property) {
|
||||
|
@ -551,8 +551,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
if (container.getContextURL() != null) {
|
||||
final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
|
||||
String base = contextURL.getServiceRoot().toASCIIString();
|
||||
if (container.getPayload() instanceof EntitySet) {
|
||||
((EntitySet) container.getPayload()).setBaseURI(base);
|
||||
if (container.getPayload() instanceof EntityCollection) {
|
||||
((EntityCollection) container.getPayload()).setBaseURI(base);
|
||||
}
|
||||
if (container.getPayload() instanceof Entity) {
|
||||
((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.ComplexValue;
|
||||
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.Linked;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
|
@ -106,7 +106,7 @@ public class JsonDeserializer implements ODataDeserializer {
|
|||
} else if (inline instanceof ArrayNode) {
|
||||
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();) {
|
||||
entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ public class JsonDeserializer implements ODataDeserializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||
public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
|
||||
try {
|
||||
parser = new JsonFactory(new ObjectMapper()).createParser(input);
|
||||
return new JsonEntitySetDeserializer(serverMode).doDeserialize(parser);
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
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.edm.EdmPrimitiveTypeException;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
|
|||
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);
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
|
|||
return null;
|
||||
}
|
||||
|
||||
final EntitySet entitySet = new EntitySet();
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
URI contextURL;
|
||||
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.data.Annotation;
|
||||
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.edm.EdmPrimitiveTypeException;
|
||||
|
||||
|
@ -36,15 +36,15 @@ public class JsonEntitySetSerializer extends JsonSerializer {
|
|||
super(serverMode);
|
||||
}
|
||||
|
||||
protected void doSerialize(final EntitySet entitySet, final JsonGenerator jgen)
|
||||
protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
|
||||
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 {
|
||||
|
||||
final EntitySet entitySet = container.getPayload();
|
||||
final EntityCollection entitySet = container.getPayload();
|
||||
|
||||
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.ComplexValue;
|
||||
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.Linked;
|
||||
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 {
|
||||
try {
|
||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||
if (obj instanceof EntitySet) {
|
||||
new JsonEntitySetSerializer(serverMode).doSerialize((EntitySet) obj, json);
|
||||
if (obj instanceof EntityCollection) {
|
||||
new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
|
||||
} else if (obj instanceof Entity) {
|
||||
new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
|
||||
} else if (obj instanceof Property) {
|
||||
|
@ -113,8 +113,8 @@ public class JsonSerializer implements ODataSerializer {
|
|||
final T obj = container == null ? null : container.getPayload();
|
||||
try {
|
||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||
if (obj instanceof EntitySet) {
|
||||
new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntitySet>) container, json);
|
||||
if (obj instanceof EntityCollection) {
|
||||
new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
|
||||
} else if (obj instanceof Entity) {
|
||||
new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
|
||||
} else if (obj instanceof Property) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.InputStream;
|
||||
|
||||
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.junit.Test;
|
||||
|
||||
|
@ -230,7 +230,7 @@ public class AtomDeserializerTest {
|
|||
final ResWrap<Entity> entity = deserializer.toEntity(in);
|
||||
|
||||
assertNotNull(entity);
|
||||
final EntitySet inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
||||
final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
||||
assertNotNull(inlineEntitySet);
|
||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class AtomDeserializerTest {
|
|||
final ResWrap<Entity> entity = deserializer.toEntity(in);
|
||||
|
||||
assertNotNull(entity);
|
||||
final EntitySet inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
||||
final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
|
||||
assertNotNull(inlineEntitySet);
|
||||
assertEquals(1, inlineEntitySet.getEntities().size());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.net.URI;
|
|||
import java.util.List;
|
||||
|
||||
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.server.api.uri.queryoption.ExpandOption;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
|
@ -39,9 +39,9 @@ public interface DeserializerResult {
|
|||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.server.api.deserializer;
|
|||
import java.io.InputStream;
|
||||
|
||||
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.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.EdmProperty;
|
||||
|
@ -43,7 +43,7 @@ public interface ODataDeserializer {
|
|||
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 edmEntityType
|
||||
* @return {@link DeserializerResult#getEntityCollection()}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.server.api.serializer;
|
|||
import java.io.InputStream;
|
||||
|
||||
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.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||
|
@ -64,7 +64,7 @@ public interface ODataSerializer {
|
|||
* @param options options for the serializer
|
||||
*/
|
||||
SerializerResult entityCollection(ServiceMetadata metadata, EdmEntityType entityType,
|
||||
EntitySet entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
|
||||
EntityCollection entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
|
||||
|
||||
/**
|
||||
* Writes entity data into an InputStream.
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
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.Property;
|
||||
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 {
|
||||
private Entity entity;
|
||||
private EntitySet entitySet;
|
||||
private EntityCollection entitySet;
|
||||
private ExpandOption expandOption;
|
||||
private Property property;
|
||||
private List<Parameter> actionParametes;
|
||||
|
@ -45,7 +45,7 @@ public class DeserializerResultImpl implements DeserializerResult {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EntitySet getEntityCollection() {
|
||||
public EntityCollection getEntityCollection() {
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class DeserializerResultImpl implements DeserializerResult {
|
|||
|
||||
public static class DeserializerResultBuilder {
|
||||
private Entity entity;
|
||||
private EntitySet entitySet;
|
||||
private EntityCollection entitySet;
|
||||
private ExpandOption expandOption;
|
||||
private Property property;
|
||||
private List<Parameter> actionParametes;
|
||||
|
@ -98,7 +98,7 @@ public class DeserializerResultImpl implements DeserializerResult {
|
|||
return this;
|
||||
}
|
||||
|
||||
public DeserializerResultBuilder entityCollection(final EntitySet entitySet) {
|
||||
public DeserializerResultBuilder entityCollection(final EntityCollection entitySet) {
|
||||
this.entitySet = entitySet;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.Map.Entry;
|
|||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
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.Parameter;
|
||||
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 {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
// Consume entities
|
||||
JsonNode jsonNode = tree.get(Constants.VALUE);
|
||||
|
@ -339,7 +339,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
|
|||
expandBuilder.expand(edmNavigationProperty) : null;
|
||||
if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
|
||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||
EntitySet inlineEntitySet = new EntitySet();
|
||||
EntityCollection inlineEntitySet = new EntityCollection();
|
||||
inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode,
|
||||
childExpandBuilder));
|
||||
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.ContextURL;
|
||||
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.Linked;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
|
@ -130,7 +130,7 @@ public class ODataJsonSerializer implements ODataSerializer {
|
|||
|
||||
@Override
|
||||
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
||||
final EdmEntityType entityType, final EntitySet entitySet,
|
||||
final EdmEntityType entityType, final EntityCollection entitySet,
|
||||
final EntityCollectionSerializerOptions options) throws SerializerException {
|
||||
CircleStreamBuffer buffer = new CircleStreamBuffer();
|
||||
try {
|
||||
|
@ -194,7 +194,7 @@ public class ODataJsonSerializer implements ODataSerializer {
|
|||
}
|
||||
|
||||
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,
|
||||
SerializerException {
|
||||
json.writeStartArray();
|
||||
|
|
|
@ -23,7 +23,7 @@ import javax.xml.stream.XMLStreamException;
|
|||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
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.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||
|
@ -95,7 +95,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
|
|||
|
||||
@Override
|
||||
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
||||
final EdmEntityType entityType, final EntitySet entitySet,
|
||||
final EdmEntityType entityType, final EntityCollection entitySet,
|
||||
final EntityCollectionSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Entityset serialization not implemented for XML format",
|
||||
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.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.Property;
|
||||
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 final Map<String, EntitySet> data;
|
||||
private final Map<String, EntityCollection> data;
|
||||
|
||||
public DataCreator() {
|
||||
data = new HashMap<String, EntitySet>();
|
||||
data = new HashMap<String, EntityCollection>();
|
||||
data.put("ESTwoPrim", createESTwoPrim());
|
||||
data.put("ESAllPrim", createESAllPrim());
|
||||
data.put("ESCompAllPrim", createESCompAllPrim());
|
||||
|
@ -59,19 +59,19 @@ public class DataCreator {
|
|||
data.put("ESServerSidePaging", createESServerSidePaging());
|
||||
|
||||
// No data available but to allow an insert operation create empty EntitySets
|
||||
data.put("ESAllNullable", new EntitySet());
|
||||
data.put("ESMixEnumDefCollComp", new EntitySet());
|
||||
data.put("ESTwoBase", new EntitySet());
|
||||
data.put("ESBaseTwoKeyNav", new EntitySet());
|
||||
data.put("ESBaseTwoKeyTwoPrim", new EntitySet());
|
||||
data.put("ESTwoKeyTwoPrim", new EntitySet());
|
||||
data.put("ESCompCollAllPrim", new EntitySet());
|
||||
data.put("ESKeyTwoKeyComp", new EntitySet());
|
||||
data.put("ESFourKeyAlias", new EntitySet());
|
||||
data.put("ESBase", new EntitySet());
|
||||
data.put("ESTwoBaseTwoKeyTwoPrim", new EntitySet());
|
||||
data.put("ESInvisible", new EntitySet());
|
||||
data.put("ESCompMixPrimCollComp", new EntitySet());
|
||||
data.put("ESAllNullable", new EntityCollection());
|
||||
data.put("ESMixEnumDefCollComp", new EntityCollection());
|
||||
data.put("ESTwoBase", new EntityCollection());
|
||||
data.put("ESBaseTwoKeyNav", new EntityCollection());
|
||||
data.put("ESBaseTwoKeyTwoPrim", new EntityCollection());
|
||||
data.put("ESTwoKeyTwoPrim", new EntityCollection());
|
||||
data.put("ESCompCollAllPrim", new EntityCollection());
|
||||
data.put("ESKeyTwoKeyComp", new EntityCollection());
|
||||
data.put("ESFourKeyAlias", new EntityCollection());
|
||||
data.put("ESBase", new EntityCollection());
|
||||
data.put("ESTwoBaseTwoKeyTwoPrim", new EntityCollection());
|
||||
data.put("ESInvisible", new EntityCollection());
|
||||
data.put("ESCompMixPrimCollComp", new EntityCollection());
|
||||
|
||||
linkESTwoPrim(data);
|
||||
linkESAllPrim(data);
|
||||
|
@ -79,12 +79,12 @@ public class DataCreator {
|
|||
linkESTwoKeyNav(data);
|
||||
}
|
||||
|
||||
protected Map<String, EntitySet> getData() {
|
||||
protected Map<String, EntityCollection> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
private EntitySet createESServerSidePaging() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESServerSidePaging() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
for (int i = 1; i <= 503; i++) {
|
||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", i))
|
||||
|
@ -94,8 +94,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESKeyNav() {
|
||||
final EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESKeyNav() {
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
|
||||
entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
|
||||
|
@ -123,8 +123,8 @@ public class DataCreator {
|
|||
createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1))));
|
||||
}
|
||||
|
||||
private EntitySet createESTwoKeyNav() {
|
||||
final EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESTwoKeyNav() {
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "1"));
|
||||
entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
|
||||
|
@ -174,8 +174,8 @@ public class DataCreator {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntitySet createESCompCollComp() {
|
||||
final EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESCompCollComp() {
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||
.addProperty(createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
|
||||
|
@ -198,8 +198,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESTwoPrim() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESTwoPrim() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 32766))
|
||||
.addProperty(createPrimitive("PropertyString", "Test String1")));
|
||||
|
@ -216,8 +216,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESAllPrim() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESAllPrim() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||
.addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
|
||||
|
@ -266,8 +266,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESCompAllPrim() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESCompAllPrim() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
Entity entity = new Entity();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
|
||||
|
@ -318,8 +318,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESCollAllPrim() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESCollAllPrim() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
|
||||
createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
|
||||
|
@ -361,13 +361,13 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESMixPrimCollComp() {
|
||||
private EntityCollection createESMixPrimCollComp() {
|
||||
@SuppressWarnings("unchecked") final Property complexCollection = createComplexCollection("CollPropertyComp",
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
|
||||
Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
|
||||
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))
|
||||
.addProperty(
|
||||
|
@ -391,8 +391,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESAllKey() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESAllKey() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "First"))
|
||||
.addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
|
||||
|
@ -420,8 +420,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESCompComp() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESCompComp() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
Entity entity = new Entity();
|
||||
entity.addProperty(createPrimitive("PropertyInt16", 1));
|
||||
|
@ -440,8 +440,8 @@ public class DataCreator {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createESMedia() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createESMedia() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
Entity entity = new Entity().addProperty(createPrimitive("PropertyInt16", 1))
|
||||
.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"));
|
||||
}
|
||||
|
||||
private void linkESTwoPrim(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESTwoPrim");
|
||||
private void linkESTwoPrim(Map<String, EntityCollection> data) {
|
||||
final EntityCollection entitySet = data.get("ESTwoPrim");
|
||||
final List<Entity> targetEntities = data.get("ESAllPrim").getEntities();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
private void linkESAllPrim(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESAllPrim");
|
||||
private void linkESAllPrim(Map<String, EntityCollection> data) {
|
||||
final EntityCollection entitySet = data.get("ESAllPrim");
|
||||
final List<Entity> targetEntities = data.get("ESTwoPrim").getEntities();
|
||||
|
||||
setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoPrimMany", targetEntities.get(1));
|
||||
|
@ -493,8 +493,8 @@ public class DataCreator {
|
|||
targetEntities.get(3));
|
||||
}
|
||||
|
||||
private void linkESKeyNav(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESKeyNav");
|
||||
private void linkESKeyNav(Map<String, EntityCollection> data) {
|
||||
final EntityCollection entitySet = data.get("ESKeyNav");
|
||||
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
||||
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").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));
|
||||
}
|
||||
|
||||
private void linkESTwoKeyNav(Map<String, EntitySet> data) {
|
||||
final EntitySet entitySet = data.get("ESTwoKeyNav");
|
||||
private void linkESTwoKeyNav(Map<String, EntityCollection> data) {
|
||||
final EntityCollection entitySet = data.get("ESTwoKeyNav");
|
||||
final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
|
||||
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
|
||||
|
||||
|
@ -619,7 +619,7 @@ public class DataCreator {
|
|||
link = new Link();
|
||||
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
|
||||
link.setTitle(navigationPropertyName);
|
||||
EntitySet target = new EntitySet();
|
||||
EntityCollection target = new EntityCollection();
|
||||
target.getEntities().addAll(Arrays.asList(targets));
|
||||
link.setInlineEntitySet(target);
|
||||
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.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.Property;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
@ -55,7 +55,7 @@ public class DataProvider {
|
|||
|
||||
protected static final String MEDIA_PROPERTY_NAME = "$value";
|
||||
|
||||
final private Map<String, EntitySet> data;
|
||||
final private Map<String, EntityCollection> data;
|
||||
private Edm edm;
|
||||
private OData odata;
|
||||
|
||||
|
@ -63,16 +63,16 @@ public class DataProvider {
|
|||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 {
|
||||
try {
|
||||
for (final Entity entity : entitySet.getEntities()) {
|
||||
|
@ -129,7 +129,7 @@ public class DataProvider {
|
|||
|
||||
public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
|
||||
final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
|
||||
final EntitySet entitySet = readAll(edmEntitySet);
|
||||
final EntityCollection entitySet = readAll(edmEntitySet);
|
||||
final List<Entity> entities = entitySet.getEntities();
|
||||
final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
|
||||
final Entity newEntity = new Entity();
|
||||
|
@ -349,7 +349,7 @@ public class DataProvider {
|
|||
}
|
||||
|
||||
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>();
|
||||
|
||||
for (final Entity newEntity : changedEntitySet.getEntities()) {
|
||||
|
@ -473,7 +473,7 @@ public class DataProvider {
|
|||
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 {
|
||||
return FunctionData.entityCollectionFunction(function.getName(), parameters, data);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
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.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
@ -33,11 +33,11 @@ import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
|
|||
|
||||
public class FunctionData {
|
||||
|
||||
protected static EntitySet entityCollectionFunction(final String name, final List<UriParameter> parameters,
|
||||
final Map<String, EntitySet> data) throws DataProviderException {
|
||||
protected static EntityCollection entityCollectionFunction(final String name, final List<UriParameter> parameters,
|
||||
final Map<String, EntityCollection> data) throws DataProviderException {
|
||||
if (name.equals("UFCRTCollETTwoKeyNavParam")) {
|
||||
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());
|
||||
result.getEntities().addAll(
|
||||
esTwoKeyNav.subList(0,
|
||||
|
@ -53,7 +53,7 @@ public class FunctionData {
|
|||
}
|
||||
|
||||
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();
|
||||
if (name.equals("UFCRTETTwoKeyNav")) {
|
||||
return esTwoKeyNav.get(0);
|
||||
|
@ -71,7 +71,7 @@ public class FunctionData {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
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")) {
|
||||
return DataCreator.createPrimitive(name, 12345);
|
||||
} 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.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.Linked;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
|
@ -140,7 +140,7 @@ public class RequestValidator {
|
|||
}
|
||||
|
||||
if(edmProperty.isCollection()) {
|
||||
final EntitySet inlineEntitySet = navigationLink.getInlineEntitySet();
|
||||
final EntityCollection inlineEntitySet = navigationLink.getInlineEntitySet();
|
||||
if(!isInsert && inlineEntitySet.getEntities().size() > 0) {
|
||||
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
|
||||
} 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.Suffix;
|
||||
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.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||
|
@ -91,13 +91,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
.get(uriInfo.getUriResourceParts().size() - 1)).getType() :
|
||||
edmEntitySet.getEntityType();
|
||||
|
||||
final EntitySet entitySetInitial = readEntityCollection(uriInfo);
|
||||
final EntityCollection entitySetInitial = readEntityCollection(uriInfo);
|
||||
if (entitySetInitial == null) {
|
||||
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
||||
} else {
|
||||
// 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)
|
||||
EntitySet entitySet = new EntitySet();
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
entitySet.getEntities().addAll(entitySetInitial.getEntities());
|
||||
|
||||
// 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,
|
||||
// without affecting the data stored in the database.
|
||||
final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
|
||||
final EntitySet entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet,
|
||||
final EntityCollection entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet,
|
||||
edmEntitySet,
|
||||
expand);
|
||||
expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
|
||||
|
@ -155,7 +155,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
throws ODataApplicationException, SerializerException {
|
||||
validateOptions(uriInfo.asUriInfoResource());
|
||||
getEdmEntitySet(uriInfo); // including checks
|
||||
EntitySet entitySet = readEntityCollection(uriInfo);
|
||||
EntityCollection entitySet = readEntityCollection(uriInfo);
|
||||
if (entitySet == null) {
|
||||
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
|
||||
} else {
|
||||
|
@ -330,7 +330,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
|
||||
}
|
||||
|
||||
private void setCount(EntitySet entitySet) {
|
||||
private void setCount(EntityCollection entitySet) {
|
||||
if (entitySet.getCount() == null) {
|
||||
entitySet.setCount(entitySet.getEntities().size());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
|
||||
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.edm.EdmBindingTarget;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
|
@ -163,7 +163,7 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
return entity;
|
||||
}
|
||||
|
||||
protected EntitySet readEntityCollection(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||
protected EntityCollection readEntityCollection(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||
final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
|
||||
if (resourcePaths.size() > 1 && resourcePaths.get(1) instanceof UriResourceNavigation) {
|
||||
final Entity entity = readEntity(uriInfo);
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Locale;
|
|||
import java.util.Set;
|
||||
|
||||
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.edm.EdmBindingTarget;
|
||||
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 void applyExpandQueryOptions(final EntitySet entitySet, final EdmEntitySet edmEntitySet,
|
||||
public void applyExpandQueryOptions(final EntityCollection entitySet, final EdmEntitySet edmEntitySet,
|
||||
final ExpandOption expandOption) throws ODataApplicationException {
|
||||
if (expandOption == null) {
|
||||
return;
|
||||
|
@ -80,14 +80,14 @@ public class ExpandSystemQueryOptionHandler {
|
|||
|
||||
final Link link = entity.getNavigationLink(navPropertyName);
|
||||
if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
|
||||
applyOptionsToEntityCollection(link.getInlineEntitySet(),
|
||||
targetEdmEntitySet,
|
||||
item.getFilterOption(),
|
||||
item.getOrderByOption(),
|
||||
item.getCountOption(),
|
||||
item.getSkipOption(),
|
||||
item.getTopOption(),
|
||||
item.getExpandOption());
|
||||
applyOptionsToEntityCollection(link.getInlineEntitySet(),
|
||||
targetEdmEntitySet,
|
||||
item.getFilterOption(),
|
||||
item.getOrderByOption(),
|
||||
item.getCountOption(),
|
||||
item.getSkipOption(),
|
||||
item.getTopOption(),
|
||||
item.getExpandOption());
|
||||
}
|
||||
} else {
|
||||
throw new ODataApplicationException("Not supported resource part in expand system query option",
|
||||
|
@ -96,83 +96,84 @@ 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 SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption)
|
||||
throws ODataApplicationException {
|
||||
final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption)
|
||||
throws ODataApplicationException {
|
||||
|
||||
FilterHandler.applyFilterSystemQuery(filterOption, entitySet, edmBindingTarget);
|
||||
OrderByHandler.applyOrderByOption(orderByOption, entitySet, edmBindingTarget);
|
||||
// TODO Add CountHandler
|
||||
SkipHandler.applySkipSystemQueryHandler(skipOption, entitySet);
|
||||
TopHandler.applyTopSystemQueryOption(topOption, entitySet);
|
||||
|
||||
|
||||
// Apply nested expand system query options to remaining entities
|
||||
if(expandOption != null) {
|
||||
for(final Entity entity : entitySet.getEntities()) {
|
||||
if (expandOption != null) {
|
||||
for (final Entity entity : entitySet.getEntities()) {
|
||||
applyExpandOptionToEntity(entity, edmBindingTarget, expandOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EntitySet transformEntitySetGraphToTree(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget,
|
||||
final ExpandOption expand) throws ODataApplicationException {
|
||||
|
||||
final EntitySet newEntitySet = newEntitySet(entitySet);
|
||||
|
||||
for(final Entity entity : entitySet.getEntities()) {
|
||||
public EntityCollection transformEntitySetGraphToTree(final EntityCollection entitySet,
|
||||
final EdmBindingTarget edmBindingTarget, final ExpandOption expand) throws ODataApplicationException {
|
||||
|
||||
final EntityCollection newEntitySet = newEntitySet(entitySet);
|
||||
|
||||
for (final Entity entity : entitySet.getEntities()) {
|
||||
newEntitySet.getEntities().add(transformEntityGraphToTree(entity, edmBindingTarget, expand));
|
||||
}
|
||||
|
||||
|
||||
return newEntitySet;
|
||||
}
|
||||
|
||||
public Entity transformEntityGraphToTree(final Entity entity, EdmBindingTarget edmEntitySet,
|
||||
|
||||
public Entity transformEntityGraphToTree(final Entity entity, EdmBindingTarget edmEntitySet,
|
||||
final ExpandOption expand) throws ODataApplicationException {
|
||||
final Entity newEntity = newEntity(entity);
|
||||
if (hasExpandItems(expand)) {
|
||||
final boolean expandAll = expandAll(expand);
|
||||
final Set<String> expanded = expandAll ? null : getExpandedPropertyNames(expand.getExpandItems());
|
||||
final EdmEntityType edmType = edmEntitySet.getEntityType();
|
||||
|
||||
|
||||
for (final Link link : entity.getNavigationLinks()) {
|
||||
final String propertyName = link.getTitle();
|
||||
|
||||
|
||||
if (expandAll || expanded.contains(propertyName)) {
|
||||
final EdmNavigationProperty edmNavigationProperty = edmType.getNavigationProperty(propertyName);
|
||||
final EdmBindingTarget edmBindingTarget = edmEntitySet.getRelatedBindingTarget(propertyName);
|
||||
final Link newLink = newLink(link);
|
||||
newEntity.getNavigationLinks().add(newLink);
|
||||
final ExpandOption innerExpandOption = getInnerExpandOption(expand, propertyName);
|
||||
|
||||
if(edmNavigationProperty.isCollection()) {
|
||||
newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(),
|
||||
edmBindingTarget,
|
||||
innerExpandOption));
|
||||
|
||||
if (edmNavigationProperty.isCollection()) {
|
||||
newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(),
|
||||
edmBindingTarget,
|
||||
innerExpandOption));
|
||||
} else {
|
||||
newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(),
|
||||
edmBindingTarget,
|
||||
innerExpandOption));
|
||||
newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(),
|
||||
edmBindingTarget,
|
||||
innerExpandOption));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public EntitySet newEntitySet(final EntitySet entitySet) {
|
||||
final EntitySet newEntitySet = new EntitySet();
|
||||
|
||||
public EntityCollection newEntitySet(final EntityCollection entitySet) {
|
||||
final EntityCollection newEntitySet = new EntityCollection();
|
||||
newEntitySet.setCount(entitySet.getCount());
|
||||
newEntitySet.setDeltaLink(entitySet.getDeltaLink());
|
||||
newEntitySet.setNext(entitySet.getNext());
|
||||
|
||||
|
||||
return newEntitySet;
|
||||
}
|
||||
|
||||
|
||||
private Entity newEntity(final Entity entity) {
|
||||
final Entity newEntity = new Entity();
|
||||
|
||||
|
||||
newEntity.getProperties().addAll(entity.getProperties());
|
||||
newEntity.getAnnotations().addAll(entity.getAnnotations());
|
||||
newEntity.getAssociationLinks().addAll(entity.getAssociationLinks());
|
||||
|
@ -185,24 +186,24 @@ public class ExpandSystemQueryOptionHandler {
|
|||
newEntity.setSelfLink(entity.getSelfLink());
|
||||
newEntity.setType(entity.getType());
|
||||
newEntity.getNavigationBindings().addAll(entity.getNavigationBindings());
|
||||
|
||||
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
|
||||
private Link newLink(Link link) {
|
||||
final Link newLink = new Link();
|
||||
newLink.setMediaETag(link.getMediaETag());
|
||||
newLink.setTitle(link.getTitle());
|
||||
newLink.setType(link.getType());
|
||||
newLink.setRel(link.getRel());
|
||||
|
||||
|
||||
return newLink;
|
||||
}
|
||||
|
||||
|
||||
private boolean hasExpandItems(ExpandOption expand) {
|
||||
return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
private boolean expandAll(ExpandOption expand) {
|
||||
for (final ExpandItem item : expand.getExpandItems()) {
|
||||
if (item.isStar()) {
|
||||
|
@ -211,7 +212,7 @@ public class ExpandSystemQueryOptionHandler {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private Set<String> getExpandedPropertyNames(List<ExpandItem> expandItems) throws ODataApplicationException {
|
||||
Set<String> expanded = new HashSet<String>();
|
||||
for (final ExpandItem item : expandItems) {
|
||||
|
@ -230,14 +231,14 @@ public class ExpandSystemQueryOptionHandler {
|
|||
}
|
||||
|
||||
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);
|
||||
if(resource instanceof UriResourceNavigation
|
||||
if (resource instanceof UriResourceNavigation
|
||||
&& propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) {
|
||||
return item.getExpandOption();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
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;
|
||||
|
||||
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()) {
|
||||
entitySet.setCount(entitySet.getEntities().size());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Iterator;
|
|||
import java.util.Locale;
|
||||
|
||||
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.EdmPrimitiveType;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
@ -45,7 +45,7 @@ public class FilterHandler {
|
|||
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 {
|
||||
|
||||
if (filterOption == null) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Comparator;
|
|||
import java.util.Locale;
|
||||
|
||||
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.http.HttpStatusCode;
|
||||
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;
|
||||
|
||||
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 {
|
||||
|
||||
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 {
|
||||
Collections.sort(entitySet.getEntities(), new Comparator<Entity>() {
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
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.http.HttpStatusCode;
|
||||
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 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 {
|
||||
|
||||
if (edmEntitySet != null && shouldApplyServerSidePaging(edmEntitySet)) {
|
||||
|
|
|
@ -22,13 +22,13 @@ import java.util.Iterator;
|
|||
import java.util.Locale;
|
||||
|
||||
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.server.api.ODataApplicationException;
|
||||
import org.apache.olingo.server.api.uri.queryoption.SkipOption;
|
||||
|
||||
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 {
|
||||
|
||||
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();
|
||||
int i = 0;
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ package org.apache.olingo.server.tecsvc.processor.queryoptions.options;
|
|||
|
||||
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.server.api.ODataApplicationException;
|
||||
import org.apache.olingo.server.api.uri.queryoption.TopOption;
|
||||
|
||||
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 {
|
||||
|
||||
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) {
|
||||
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.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.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
|
@ -88,14 +88,14 @@ public class DataProviderTest {
|
|||
@Test
|
||||
public void esAllPrim() throws Exception {
|
||||
final DataProvider data = new DataProvider();
|
||||
EntitySet outSet = data.readAll(esAllPrim);
|
||||
EntityCollection outSet = data.readAll(esAllPrim);
|
||||
|
||||
Assert.assertEquals(3, outSet.getEntities().size());
|
||||
|
||||
Entity first = outSet.getEntities().get(0);
|
||||
Assert.assertEquals(16, first.getProperties().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.assertEquals(1, target.getEntities().size());
|
||||
Assert.assertEquals(data.readAll(entityContainer.getEntitySet("ESTwoPrim")).getEntities().get(1),
|
||||
|
@ -107,7 +107,7 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
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(17, outSet.getEntities().get(0).getProperties().size());
|
||||
|
@ -120,7 +120,7 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
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(2, outSet.getEntities().get(0).getProperties().size());
|
||||
|
@ -133,7 +133,7 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
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(4, outSet.getEntities().get(0).getProperties().size());
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.math.BigDecimal;
|
|||
import java.util.List;
|
||||
|
||||
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.edm.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
@ -43,7 +43,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
|
|||
public void esAllPrim() throws Exception {
|
||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
|
||||
InputStream stream = getFileAsStream("ESAllPrim.json");
|
||||
EntitySet entitySet =
|
||||
EntityCollection entitySet =
|
||||
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
||||
.getEntityCollection();
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
|
|||
public void eSCompCollComp() throws Exception {
|
||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompCollComp"));
|
||||
InputStream stream = getFileAsStream("ESCompCollComp.json");
|
||||
EntitySet entitySet =
|
||||
EntityCollection entitySet =
|
||||
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
||||
.getEntityCollection();
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
|
|||
String entityCollectionString = "{\"value\" : []}";
|
||||
InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
|
||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
|
||||
EntitySet entityCollection =
|
||||
EntityCollection entityCollection =
|
||||
OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
|
||||
.getEntityCollection();
|
||||
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.Suffix;
|
||||
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.ValueType;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
@ -159,7 +159,7 @@ public class ODataJsonSerializerTest {
|
|||
@Test
|
||||
public void entitySetAllPrim() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||
EntitySet entitySet = data.readAll(edmEntitySet);
|
||||
EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||
entitySet.setCount(entitySet.getEntities().size());
|
||||
entitySet.setNext(URI.create("/next"));
|
||||
CountOption countOption = Mockito.mock(CountOption.class);
|
||||
|
@ -305,7 +305,7 @@ public class ODataJsonSerializerTest {
|
|||
@Test
|
||||
public void entitySetTwoPrimNoMetadata() throws Exception {
|
||||
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)
|
||||
.entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
|
||||
EntityCollectionSerializerOptions.with()
|
||||
|
@ -338,7 +338,7 @@ public class ODataJsonSerializerTest {
|
|||
@Test
|
||||
public void entitySetMedia() throws Exception {
|
||||
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,
|
||||
edmEntitySet.getEntityType(), entitySet,
|
||||
EntityCollectionSerializerOptions.with()
|
||||
|
@ -398,7 +398,7 @@ public class ODataJsonSerializerTest {
|
|||
public void selectComplex() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
||||
final EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
|
||||
InputStream result = serializer
|
||||
|
@ -422,7 +422,7 @@ public class ODataJsonSerializerTest {
|
|||
public void selectComplexTwice() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
||||
final EntityCollection entitySet = data.readAll(edmEntitySet);
|
||||
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
|
||||
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.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.ValueType;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
|
@ -38,21 +38,21 @@ import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
|
|||
|
||||
public class DataProvider {
|
||||
|
||||
private final Map<String, EntitySet> data;
|
||||
private final Map<String, EntityCollection> data;
|
||||
|
||||
public DataProvider() {
|
||||
data = new HashMap<String, EntitySet>();
|
||||
data = new HashMap<String, EntityCollection>();
|
||||
data.put("Cars", createCars());
|
||||
data.put("Manufacturers", createManufacturers());
|
||||
}
|
||||
|
||||
public EntitySet readAll(EdmEntitySet edmEntitySet) {
|
||||
public EntityCollection readAll(EdmEntitySet edmEntitySet) {
|
||||
return data.get(edmEntitySet.getName());
|
||||
}
|
||||
|
||||
public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
|
||||
final EdmEntityType entityType = edmEntitySet.getEntityType();
|
||||
final EntitySet entitySet = data.get(edmEntitySet.getName());
|
||||
final EntityCollection entitySet = data.get(edmEntitySet.getName());
|
||||
if (entitySet == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -93,8 +93,8 @@ public class DataProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private EntitySet createCars() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createCars() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity()
|
||||
.addProperty(createPrimitive("Id", 1))
|
||||
|
@ -137,8 +137,8 @@ public class DataProvider {
|
|||
return entitySet;
|
||||
}
|
||||
|
||||
private EntitySet createManufacturers() {
|
||||
EntitySet entitySet = new EntitySet();
|
||||
private EntityCollection createManufacturers() {
|
||||
EntityCollection entitySet = new EntityCollection();
|
||||
|
||||
entitySet.getEntities().add(new Entity()
|
||||
.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.Suffix;
|
||||
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.edm.EdmComplexType;
|
||||
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
|
||||
// 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
|
||||
// support them in this example
|
||||
|
|
Loading…
Reference in New Issue