[OLINGO-200] Introducing specialization for V3 and V4 domain objects

This commit is contained in:
Francesco Chicchiriccò 2014-03-29 16:55:41 +01:00
parent ceda474058
commit 80e5ed56d5
97 changed files with 1905 additions and 905 deletions

View File

@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeReq
import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory;
import org.apache.olingo.client.api.op.ClientODataDeserializer;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
import org.apache.olingo.client.api.op.CommonODataBinder;
import org.apache.olingo.client.api.op.CommonODataReader;
import org.apache.olingo.commons.api.op.ODataSerializer;
@ -56,7 +56,7 @@ public interface CommonODataClient {
CommonODataBinder getBinder();
ODataObjectFactory getObjectFactory();
CommonODataObjectFactory getObjectFactory();
CommonRetrieveRequestFactory getRetrieveRequestFactory();

View File

@ -20,10 +20,10 @@ package org.apache.olingo.client.api.communication.request.cud;
import java.io.Serializable;
import java.net.URI;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData request factory class.
@ -39,17 +39,19 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param entity entity to be created.
* @return new ODataEntityCreateRequest instance.
*/
ODataEntityCreateRequest getEntityCreateRequest(URI targetURI, ODataEntity entity);
ODataEntityCreateRequest getEntityCreateRequest(URI targetURI, CommonODataEntity entity);
/**
* Gets an update request object instance.
*
* @param <UT> concrete UpdateType.
* @param targetURI edit link of the object to be updated.
* @param type type of update to be performed.
* @param changes changes to be applied.
* @return new ODataEntityUpdateRequest instance.
*/
<UT extends UpdateType> ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UT type, ODataEntity changes);
<UT extends UpdateType> ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UT type,
CommonODataEntity changes);
/**
* Gets an update request object instance; uses entity's edit link as endpoint.
@ -58,7 +60,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param entity changes to be applied.
* @return new ODataEntityUpdateRequest instance.
*/
ODataEntityUpdateRequest getEntityUpdateRequest(UpdateType type, ODataEntity entity);
ODataEntityUpdateRequest getEntityUpdateRequest(UpdateType type, CommonODataEntity entity);
/**
* Gets a create request object instance.
@ -81,7 +83,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param property value to be update.
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(URI targetURI, ODataProperty property);
ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(URI targetURI, CommonODataProperty property);
/**
* Gets an update request object instance.
@ -94,7 +96,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
URI targetURI, UpdateType type, ODataProperty property);
URI targetURI, UpdateType type, CommonODataProperty property);
/**
* Gets an update request object instance.
@ -105,7 +107,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param property value to be update.
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, ODataProperty property);
ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, CommonODataProperty property);
/**
* Gets an add link request object instance.

View File

@ -20,6 +20,9 @@ package org.apache.olingo.client.api.communication.request.retrieve;
import java.io.Serializable;
import java.net.URI;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData request factory class.
@ -59,10 +62,11 @@ public interface CommonRetrieveRequestFactory extends Serializable {
/**
* Gets a query request returning a set of one or more OData entities.
*
* @param <T> concrete ODataEntitySet implementation.
* @param uri request URI.
* @return new {@link ODataEntitySetRequest} instance.
*/
ODataEntitySetRequest getEntitySetRequest(URI uri);
<T extends CommonODataEntitySet> ODataEntitySetRequest<T> getEntitySetRequest(URI uri);
/**
* Gets a query request returning a set of one or more OData entities.
@ -78,18 +82,20 @@ public interface CommonRetrieveRequestFactory extends Serializable {
/**
* Gets a query request returning a single OData entity.
*
* @param <T> concrete ODataEntity implementation.
* @param uri request URI.
* @return new {@link ODataEntityRequest} instance.
*/
ODataEntityRequest getEntityRequest(URI uri);
<T extends CommonODataEntity> ODataEntityRequest<T> getEntityRequest(URI uri);
/**
* Gets a query request returning a single OData entity property.
*
* @param <T> concrete ODataProperty implementation.
* @param uri request URI.
* @return new {@link ODataPropertyRequest} instance.
*/
ODataPropertyRequest getPropertyRequest(URI uri);
<T extends CommonODataProperty> ODataPropertyRequest<T> getPropertyRequest(URI uri);
/**
* Gets a query request returning a single OData entity property value.

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData retrieve query request returning a single entity.
*/
public interface ODataEntityRequest extends ODataRetrieveRequest<ODataEntity, ODataPubFormat> {
public interface ODataEntityRequest<T extends CommonODataEntity> extends ODataRetrieveRequest<T, ODataPubFormat> {
}

View File

@ -18,11 +18,12 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData EntitySet query request.
*/
public interface ODataEntitySetRequest extends ODataRetrieveRequest<ODataEntitySet, ODataPubFormat> {
public interface ODataEntitySetRequest<T extends CommonODataEntitySet>
extends ODataRetrieveRequest<T, ODataPubFormat> {
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData entity property query request.
*/
public interface ODataPropertyRequest extends ODataRetrieveRequest<ODataProperty, ODataFormat> {
public interface ODataPropertyRequest<T extends CommonODataProperty> extends ODataRetrieveRequest<T, ODataFormat> {
}

View File

@ -20,9 +20,27 @@ package org.apache.olingo.client.api.communication.request.retrieve.v3;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
@SuppressWarnings("unchecked")
@Override
ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
@SuppressWarnings("unchecked")
@Override
ODataEntityRequest<ODataEntity> getEntityRequest(URI uri);
@SuppressWarnings("unchecked")
@Override
ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
/**
* Gets a query request returning a single OData link.
*

View File

@ -18,7 +18,24 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve.v4;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
@SuppressWarnings("unchecked")
public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
@Override
ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
@Override
ODataEntityRequest<ODataEntity> getEntityRequest(URI uri);
@Override
ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an OData entity create request.
@ -32,5 +32,5 @@ public interface ODataEntityCreateResponse extends ODataResponse {
*
* @return created object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an OData update request.
@ -32,5 +32,5 @@ public interface ODataEntityUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an Odata media entity create request.
@ -32,5 +32,5 @@ public interface ODataMediaEntityCreateResponse extends ODataResponse {
*
* @return created object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an Odata media entity update request.
@ -32,5 +32,5 @@ public interface ODataMediaEntityUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* This class implements the response to an OData update entity property request.
@ -32,5 +32,5 @@ public interface ODataPropertyUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataProperty getBody();
CommonODataProperty getBody();
}

View File

@ -32,8 +32,8 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
* <br/>
* <b>Please don't forget to call the <tt>close()>/<tt> method when not needed any more.</b>
*/
public class ODataEntitySetIterator implements Iterator<ODataEntity> {
public class ODataEntitySetIterator implements Iterator<CommonODataEntity> {
/**
* Logger.
@ -59,7 +59,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
private Entry cached;
private ODataEntitySet entitySet;
private CommonODataEntitySet entitySet;
private final ByteArrayOutputStream osFeed;
@ -127,9 +127,9 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
* {@inheritDoc }
*/
@Override
public ODataEntity next() {
public CommonODataEntity next() {
if (hasNext()) {
final ODataEntity res = odataClient.getBinder().getODataEntity(cached);
final CommonODataEntity res = odataClient.getBinder().getODataEntity(cached);
cached = null;
return res;
}

View File

@ -25,10 +25,10 @@ import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
public interface CommonODataBinder extends Serializable {
@ -40,7 +40,7 @@ public interface CommonODataBinder extends Serializable {
* @param reference reference class.
* @return <tt>Feed</tt> object.
*/
Feed getFeed(ODataEntitySet feed, Class<? extends Feed> reference);
Feed getFeed(CommonODataEntitySet feed, Class<? extends Feed> reference);
/**
* Gets an <tt>Entry</tt> from the given OData entity.
@ -49,7 +49,7 @@ public interface CommonODataBinder extends Serializable {
* @param reference reference class.
* @return <tt>Entry</tt> object.
*/
Entry getEntry(ODataEntity entity, Class<? extends Entry> reference);
Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference);
/**
* Gets an <tt>Entry</tt> from the given OData entity.
@ -59,7 +59,7 @@ public interface CommonODataBinder extends Serializable {
* @param setType whether to explicitly output type information.
* @return <tt>Entry</tt> object.
*/
Entry getEntry(ODataEntity entity, Class<? extends Entry> reference, boolean setType);
Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference, boolean setType);
/**
* Gets a <tt>Link</tt> from the given OData link.
@ -78,7 +78,16 @@ public interface CommonODataBinder extends Serializable {
* @param setType whether to explicitly output type information.
* @return <tt>Property</tt> object.
*/
Property getProperty(ODataProperty property, Class<? extends Entry> reference, boolean setType);
Property getProperty(CommonODataProperty property, Class<? extends Entry> reference, boolean setType);
/**
* Adds the given property to the given entity.
*
* @param entity OData entity.
* @param property OData property.
* @return whether add was successful or not.
*/
boolean add(CommonODataEntity entity, CommonODataProperty property);
/**
* Gets <tt>ODataServiceDocument</tt> from the given service document resource.
@ -94,7 +103,7 @@ public interface CommonODataBinder extends Serializable {
* @param resource feed resource.
* @return <tt>ODataEntitySet</tt> object.
*/
ODataEntitySet getODataEntitySet(Feed resource);
CommonODataEntitySet getODataEntitySet(Feed resource);
/**
* Gets <tt>ODataEntitySet</tt> from the given feed resource.
@ -103,7 +112,7 @@ public interface CommonODataBinder extends Serializable {
* @param defaultBaseURI default base URI.
* @return <tt>ODataEntitySet</tt> object.
*/
ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
CommonODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
/**
* Gets <tt>ODataEntity</tt> from the given entry resource.
@ -111,7 +120,7 @@ public interface CommonODataBinder extends Serializable {
* @param resource entry resource.
* @return <tt>ODataEntity</tt> object.
*/
ODataEntity getODataEntity(Entry resource);
CommonODataEntity getODataEntity(Entry resource);
/**
* Gets <tt>ODataEntity</tt> from the given entry resource.
@ -120,7 +129,7 @@ public interface CommonODataBinder extends Serializable {
* @param defaultBaseURI default base URI.
* @return <tt>ODataEntity</tt> object.
*/
ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
CommonODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
/**
* Gets an <tt>ODataProperty</tt> from the given property resource.
@ -128,5 +137,5 @@ public interface CommonODataBinder extends Serializable {
* @param property property resource.
* @return <tt>ODataProperty</tt> object.
*/
ODataProperty getODataProperty(Property property);
CommonODataProperty getODataProperty(Property property);
}

View File

@ -24,9 +24,9 @@ import java.util.List;
import org.apache.olingo.client.api.edm.xml.Schema;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -74,7 +74,7 @@ public interface CommonODataReader extends Serializable {
* @param format de-serialize as AtomFeed or JSONFeed
* @return de-serialized entity set.
*/
ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
/**
* Parses a stream taking care to de-serializes the first OData entity found.
@ -83,7 +83,7 @@ public interface CommonODataReader extends Serializable {
* @param format de-serialize as AtomEntry or JSONEntry
* @return entity de-serialized.
*/
ODataEntity readEntity(InputStream input, ODataPubFormat format);
CommonODataEntity readEntity(InputStream input, ODataPubFormat format);
/**
* Parses a stream taking care to de-serialize the first OData entity property found.
@ -92,7 +92,7 @@ public interface CommonODataReader extends Serializable {
* @param format de-serialize as XML or JSON
* @return OData entity property de-serialized.
*/
ODataProperty readProperty(InputStream input, ODataFormat format);
CommonODataProperty readProperty(InputStream input, ODataFormat format);
/**
* Parses a stream into an OData error.

View File

@ -21,9 +21,9 @@ package org.apache.olingo.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collection;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@ -43,7 +43,7 @@ public interface ODataWriter extends Serializable {
* @param format serialization format.
* @return stream of serialized objects.
*/
InputStream writeEntities(Collection<ODataEntity> entities, ODataPubFormat format);
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format);
/**
* Writes a collection of OData entities.
@ -53,7 +53,7 @@ public interface ODataWriter extends Serializable {
* @param outputType whether to explicitly output type information.
* @return stream of serialized objects.
*/
InputStream writeEntities(Collection<ODataEntity> entities, ODataPubFormat format, boolean outputType);
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format, boolean outputType);
/**
* Serializes a single OData entity.
@ -62,7 +62,7 @@ public interface ODataWriter extends Serializable {
* @param format serialization format.
* @return stream of serialized object.
*/
InputStream writeEntity(ODataEntity entity, ODataPubFormat format);
InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format);
/**
* Serializes a single OData entity.
@ -72,7 +72,7 @@ public interface ODataWriter extends Serializable {
* @param outputType whether to explicitly output type information.
* @return stream of serialized object.
*/
InputStream writeEntity(ODataEntity entity, ODataPubFormat format, boolean outputType);
InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format, boolean outputType);
/**
* Writes a single OData entity property.
@ -81,7 +81,7 @@ public interface ODataWriter extends Serializable {
* @param format serialization format.
* @return stream of serialized object.
*/
InputStream writeProperty(ODataProperty property, ODataFormat format);
InputStream writeProperty(CommonODataProperty property, ODataFormat format);
/**
* Writes an OData link.

View File

@ -18,12 +18,34 @@
*/
package org.apache.olingo.client.api.op.v3;
import java.net.URI;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
import org.apache.olingo.client.api.op.CommonODataBinder;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
public interface ODataBinder extends CommonODataBinder {
@Override
ODataEntitySet getODataEntitySet(Feed resource);
@Override
ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
@Override
ODataEntity getODataEntity(Entry resource);
@Override
ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
@Override
ODataProperty getODataProperty(Property property);
/**
* Gets <tt>ODataLinkCollection</tt> from the given link collection resource.
*

View File

@ -18,8 +18,29 @@
*/
package org.apache.olingo.client.api.op.v4;
import java.net.URI;
import org.apache.olingo.client.api.op.CommonODataBinder;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
public interface ODataBinder extends CommonODataBinder {
@Override
ODataEntitySet getODataEntitySet(Feed resource);
@Override
ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
@Override
ODataEntity getODataEntity(Entry resource);
@Override
ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
@Override
ODataProperty getODataProperty(Property property);
}

View File

@ -29,9 +29,13 @@ import org.apache.olingo.client.api.op.v3.ODataDeserializer;
import org.apache.olingo.client.api.op.v3.ODataReader;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.client.api.uri.v3.FilterFactory;
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
public interface ODataClient extends CommonODataClient {
@Override
Configuration getConfiguration();
@Override
ODataDeserializer getDeserializer();
@ -41,15 +45,15 @@ public interface ODataClient extends CommonODataClient {
@Override
ODataBinder getBinder();
@Override
Configuration getConfiguration();
@Override
URIBuilder getURIBuilder(String serviceRoot);
@Override
FilterFactory getFilterFactory();
@Override
ODataObjectFactory getObjectFactory();
@Override
RetrieveRequestFactory getRetrieveRequestFactory();

View File

@ -29,9 +29,13 @@ import org.apache.olingo.client.api.op.v4.ODataDeserializer;
import org.apache.olingo.client.api.op.v4.ODataReader;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.client.api.uri.v4.FilterFactory;
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
public interface ODataClient extends CommonODataClient {
@Override
Configuration getConfiguration();
@Override
ODataDeserializer getDeserializer();
@ -41,15 +45,15 @@ public interface ODataClient extends CommonODataClient {
@Override
ODataBinder getBinder();
@Override
Configuration getConfiguration();
@Override
URIBuilder getURIBuilder(String serviceRoot);
@Override
FilterFactory getFilterFactory();
@Override
ODataObjectFactory getObjectFactory();
@Override
RetrieveRequestFactory getRetrieveRequestFactory();

View File

@ -19,9 +19,7 @@
package org.apache.olingo.client.core;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.client.api.op.ODataWriter;
import org.apache.olingo.commons.core.domain.ODataObjectFactoryImpl;
import org.apache.olingo.client.core.op.ODataWriterImpl;
public abstract class AbstractODataClient implements CommonODataClient {
@ -30,16 +28,9 @@ public abstract class AbstractODataClient implements CommonODataClient {
private final ODataWriter writer = new ODataWriterImpl(this);
private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl(getServiceVersion());
@Override
public ODataWriter getWriter() {
return writer;
}
@Override
public ODataObjectFactory getObjectFactory() {
return objectFactory;
}
}

View File

@ -29,10 +29,10 @@ import org.apache.olingo.client.api.communication.request.cud.ODataLinkUpdateReq
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.client.api.http.HttpMethod;
public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFactory {
@ -46,13 +46,13 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
}
@Override
public ODataEntityCreateRequest getEntityCreateRequest(final URI targetURI, final ODataEntity entity) {
public ODataEntityCreateRequest getEntityCreateRequest(final URI targetURI, final CommonODataEntity entity) {
return new ODataEntityCreateRequestImpl(client, targetURI, entity);
}
@Override
public ODataEntityUpdateRequest getEntityUpdateRequest(
final URI targetURI, final UpdateType type, final ODataEntity changes) {
final URI targetURI, final UpdateType type, final CommonODataEntity changes) {
final ODataEntityUpdateRequest req;
@ -67,7 +67,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
}
@Override
public ODataEntityUpdateRequest getEntityUpdateRequest(final UpdateType type, final ODataEntity entity) {
public ODataEntityUpdateRequest getEntityUpdateRequest(final UpdateType type, final CommonODataEntity entity) {
if (entity.getEditLink() == null) {
throw new IllegalArgumentException("No edit link found");
}
@ -102,7 +102,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
@Override
public ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(
final URI targetURI, final ODataProperty property) {
final URI targetURI, final CommonODataProperty property) {
if (!property.hasPrimitiveValue()) {
throw new IllegalArgumentException("A primitive value is required");
@ -122,7 +122,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
@Override
public ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
final URI targetURI, final UpdateType type, final ODataProperty property) {
final URI targetURI, final UpdateType type, final CommonODataProperty property) {
if (!property.hasComplexValue()) {
throw new IllegalArgumentException("A complex value is required");
@ -142,7 +142,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
@Override
public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(
final URI targetURI, final ODataProperty property) {
final URI targetURI, final CommonODataProperty property) {
if (!property.hasCollectionValue()) {
throw new IllegalArgumentException("A collection value is required");

View File

@ -28,7 +28,7 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
@ -46,7 +46,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
/**
* Entity to be created.
*/
private final ODataEntity entity;
private final CommonODataEntity entity;
/**
* Constructor.
@ -55,7 +55,9 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
* @param targetURI entity set URI.
* @param entity entity to be created.
*/
ODataEntityCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final ODataEntity entity) {
ODataEntityCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI,
final CommonODataEntity entity) {
super(odataClient, ODataPubFormat.class, HttpMethod.POST, targetURI);
this.entity = entity;
}
@ -88,7 +90,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
*/
private class ODataEntityCreateResponseImpl extends AbstractODataResponse implements ODataEntityCreateResponse {
private ODataEntity entity = null;
private CommonODataEntity entity = null;
/**
* Constructor.
@ -112,7 +114,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
* {@inheritDoc }
*/
@Override
public ODataEntity getBody() {
public CommonODataEntity getBody() {
if (entity == null) {
try {
final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(),

View File

@ -28,7 +28,7 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
@ -46,7 +46,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
/**
* Changes to be applied.
*/
private final ODataEntity changes;
private final CommonODataEntity changes;
/**
* Constructor.
@ -57,7 +57,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
* @param changes changes to be applied.
*/
ODataEntityUpdateRequestImpl(final CommonODataClient odataClient,
final HttpMethod method, final URI uri, final ODataEntity changes) {
final HttpMethod method, final URI uri, final CommonODataEntity changes) {
super(odataClient, ODataPubFormat.class, method, uri);
this.changes = changes;
@ -94,7 +94,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
/**
* Changes.
*/
private ODataEntity entity = null;
private CommonODataEntity entity = null;
/**
* Constructor.
@ -118,7 +118,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
* {@inheritDoc ]
*/
@Override
public ODataEntity getBody() {
public CommonODataEntity getBody() {
if (entity == null) {
try {
final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(),

View File

@ -28,7 +28,7 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
@ -46,7 +46,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
/**
* Value to be created.
*/
private final ODataProperty property;
private final CommonODataProperty property;
/**
* Constructor.
@ -57,7 +57,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
* @param property value to be created.
*/
ODataPropertyUpdateRequestImpl(final CommonODataClient odataClient,
final HttpMethod method, final URI targetURI, final ODataProperty property) {
final HttpMethod method, final URI targetURI, final CommonODataProperty property) {
super(odataClient, ODataFormat.class, method, targetURI);
// set request body
@ -92,7 +92,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
*/
private class ODataPropertyUpdateResponseImpl extends AbstractODataResponse implements ODataPropertyUpdateResponse {
private ODataProperty property = null;
private CommonODataProperty property = null;
/**
* Constructor.
@ -116,7 +116,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
* {@inheritDoc }
*/
@Override
public ODataProperty getBody() {
public CommonODataProperty getBody() {
if (property == null) {
try {
final Container<Property> container = odataClient.getDeserializer().toProperty(getRawResponse(),

View File

@ -25,6 +25,7 @@ import java.net.URISyntaxException;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
@ -35,10 +36,10 @@ import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@ -98,23 +99,20 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult>
*/
@Override
public void setFormat(final ODataPubFormat format) {
final String _format = (reference.isAssignableFrom(ODataProperty.class) && format == ODataPubFormat.ATOM)
final String _format = (reference.isAssignableFrom(CommonODataProperty.class) && format == ODataPubFormat.ATOM)
? ODataFormat.XML.toString(odataClient.getServiceVersion())
: format.toString(odataClient.getServiceVersion());
setAccept(_format);
setContentType(_format);
}
/**
* {@inheritDoc }
*/
@Override
protected InputStream getPayload() {
if (!this.parameters.isEmpty() && this.method == HttpMethod.POST) {
// Additional, non-binding parameters MUST be sent as JSON
final ODataEntity tmp = odataClient.getObjectFactory().newEntity("");
final CommonODataEntity tmp = odataClient.getObjectFactory().newEntity(StringUtils.EMPTY);
for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
ODataProperty property = null;
CommonODataProperty property = null;
if (param.getValue().isPrimitive()) {
property = odataClient.getObjectFactory().
@ -128,7 +126,7 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult>
}
if (property != null) {
tmp.getProperties().add(property);
odataClient.getBinder().add(tmp, property);
}
}
@ -211,15 +209,15 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult>
}
try {
if (reference.isAssignableFrom(ODataEntitySet.class)) {
if (reference.isAssignableFrom(CommonODataEntitySet.class)) {
invokeResult = (T) odataClient.getReader().readEntitySet(res.getEntity().getContent(),
ODataPubFormat.fromString(getContentType()));
}
if (reference.isAssignableFrom(ODataEntity.class)) {
if (reference.isAssignableFrom(CommonODataEntity.class)) {
invokeResult = (T) odataClient.getReader().readEntity(res.getEntity().getContent(),
ODataPubFormat.fromString(getContentType()));
}
if (reference.isAssignableFrom(ODataProperty.class)) {
if (reference.isAssignableFrom(CommonODataProperty.class)) {
invokeResult = (T) odataClient.getReader().readProperty(res.getEntity().getContent(),
ODataFormat.fromString(getContentType()));
}

View File

@ -25,10 +25,10 @@ import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.invoke.AbstractInvokeRequestFactory;
@ -96,14 +96,14 @@ public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory imple
client, ODataNoContent.class, method, uri);
} else {
if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntitySet>(
client, ODataEntitySet.class, method, uri);
result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<CommonODataEntitySet>(
client, CommonODataEntitySet.class, method, uri);
} else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntity>(
client, ODataEntity.class, method, uri);
result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<CommonODataEntity>(
client, CommonODataEntity.class, method, uri);
} else {
result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataProperty>(
client, ODataProperty.class, method, uri);
result = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<CommonODataProperty>(
client, CommonODataProperty.class, method, uri);
}
}

View File

@ -21,12 +21,9 @@ package org.apache.olingo.client.core.communication.request.retrieve;
import java.net.URI;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
@ -42,26 +39,11 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe
this.client = client;
}
@Override
public ODataEntitySetRequest getEntitySetRequest(final URI query) {
return new ODataEntitySetRequestImpl(client, query);
}
@Override
public ODataEntitySetIteratorRequest getEntitySetIteratorRequest(final URI query) {
return new ODataEntitySetIteratorRequestImpl(client, query);
}
@Override
public ODataEntityRequest getEntityRequest(final URI query) {
return new ODataEntityRequestImpl(client, query);
}
@Override
public ODataPropertyRequest getPropertyRequest(final URI query) {
return new ODataPropertyRequestImpl(client, query);
}
@Override
public ODataValueRequest getValueRequest(final URI query) {
return new ODataValueRequestImpl(client, query);

View File

@ -26,14 +26,14 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData retrieve query request returning a single entity.
*/
public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest<ODataEntity, ODataPubFormat>
implements ODataEntityRequest {
public class ODataEntityRequestImpl<T extends CommonODataEntity>
extends AbstractODataRetrieveRequest<T, ODataPubFormat> implements ODataEntityRequest<T> {
/**
* Private constructor.
@ -41,7 +41,7 @@ public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest<ODataEn
* @param odataClient client instance getting this request
* @param query query to be executed.
*/
ODataEntityRequestImpl(final CommonODataClient odataClient, final URI query) {
public ODataEntityRequestImpl(final CommonODataClient odataClient, final URI query) {
super(odataClient, ODataPubFormat.class, query);
}
@ -49,7 +49,7 @@ public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest<ODataEn
* {@inheritDoc }
*/
@Override
public ODataRetrieveResponse<ODataEntity> execute() {
public ODataRetrieveResponse<T> execute() {
return new ODataEntityResponseImpl(httpClient, doExecute());
}
@ -58,7 +58,7 @@ public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest<ODataEn
*/
public class ODataEntityResponseImpl extends ODataRetrieveResponseImpl {
private ODataEntity entity = null;
private T entity = null;
/**
* Constructor.
@ -82,13 +82,14 @@ public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest<ODataEn
* {@inheritDoc }
*/
@Override
public ODataEntity getBody() {
@SuppressWarnings("unchecked")
public T getBody() {
if (entity == null) {
try {
final Container<Entry> container =
odataClient.getDeserializer().toEntry(getRawResponse(), ODataPubFormat.fromString(getContentType()));
entity = odataClient.getBinder().getODataEntity(extractFromContainer(container));
entity = (T) odataClient.getBinder().getODataEntity(extractFromContainer(container));
} finally {
this.close();
}

View File

@ -26,16 +26,16 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData EntitySet query request.
*/
public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest<ODataEntitySet, ODataPubFormat>
implements ODataEntitySetRequest {
public class ODataEntitySetRequestImpl<T extends CommonODataEntitySet>
extends AbstractODataRetrieveRequest<T, ODataPubFormat> implements ODataEntitySetRequest<T> {
private ODataEntitySet entitySet = null;
private T entitySet = null;
/**
* Private constructor.
@ -43,7 +43,7 @@ public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest<ODat
* @param odataClient client instance getting this request
* @param query query to be executed.
*/
ODataEntitySetRequestImpl(final CommonODataClient odataClient, final URI query) {
public ODataEntitySetRequestImpl(final CommonODataClient odataClient, final URI query) {
super(odataClient, ODataPubFormat.class, query);
}
@ -51,7 +51,7 @@ public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest<ODat
* {@inheritDoc }
*/
@Override
public ODataRetrieveResponse<ODataEntitySet> execute() {
public ODataRetrieveResponse<T> execute() {
final HttpResponse res = doExecute();
return new ODataEntitySetResponseImpl(httpClient, res);
}
@ -84,13 +84,13 @@ public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest<ODat
*/
@Override
@SuppressWarnings("unchecked")
public ODataEntitySet getBody() {
public T getBody() {
if (entitySet == null) {
try {
final Container<Feed> container =
odataClient.getDeserializer().toFeed(getRawResponse(), ODataPubFormat.fromString(getContentType()));
entitySet = odataClient.getBinder().getODataEntitySet(extractFromContainer(container));
entitySet = (T) odataClient.getBinder().getODataEntitySet(extractFromContainer(container));
} finally {
this.close();
}

View File

@ -25,7 +25,7 @@ import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.commons.api.data.Container;
@ -34,8 +34,8 @@ import org.apache.olingo.commons.api.data.Property;
/**
* This class implements an OData entity property query request.
*/
public class ODataPropertyRequestImpl extends AbstractODataRetrieveRequest<ODataProperty, ODataFormat>
implements ODataPropertyRequest {
public class ODataPropertyRequestImpl<T extends CommonODataProperty>
extends AbstractODataRetrieveRequest<T, ODataFormat> implements ODataPropertyRequest<T> {
/**
* Private constructor.
@ -43,7 +43,7 @@ public class ODataPropertyRequestImpl extends AbstractODataRetrieveRequest<OData
* @param odataClient client instance getting this request
* @param query query to be executed.
*/
ODataPropertyRequestImpl(final CommonODataClient odataClient, final URI query) {
public ODataPropertyRequestImpl(final CommonODataClient odataClient, final URI query) {
super(odataClient, ODataFormat.class, query);
}
@ -51,14 +51,14 @@ public class ODataPropertyRequestImpl extends AbstractODataRetrieveRequest<OData
* {@inheritDoc }
*/
@Override
public ODataRetrieveResponse<ODataProperty> execute() {
public ODataRetrieveResponse<T> execute() {
final HttpResponse res = doExecute();
return new ODataPropertyResponseImpl(httpClient, res);
}
protected class ODataPropertyResponseImpl extends ODataRetrieveResponseImpl {
private ODataProperty property = null;
private T property = null;
/**
* Constructor.
@ -82,14 +82,15 @@ public class ODataPropertyRequestImpl extends AbstractODataRetrieveRequest<OData
* {@inheritDoc }
*/
@Override
public ODataProperty getBody() {
@SuppressWarnings("unchecked")
public T getBody() {
if (property == null) {
try {
final Container<Property> container =
odataClient.getDeserializer().toProperty(
res.getEntity().getContent(), ODataFormat.fromString(getContentType()));
property = odataClient.getBinder().getODataProperty(extractFromContainer(container));
property = (T) odataClient.getBinder().getODataProperty(extractFromContainer(container));
} catch (IOException e) {
throw new HttpClientException(e);
} finally {

View File

@ -19,11 +19,20 @@
package org.apache.olingo.client.core.communication.request.retrieve.v3;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.v3.ODataLinkCollectionRequest;
import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
import org.apache.olingo.client.core.communication.request.retrieve.AbstractRetrieveRequestFactory;
import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl;
import org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl;
import org.apache.olingo.client.core.communication.request.retrieve.ODataPropertyRequestImpl;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
implements RetrieveRequestFactory {
@ -44,4 +53,22 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
public ODataLinkCollectionRequest getLinkCollectionRequest(final URI targetURI, final String linkName) {
return new ODataLinkCollectionRequestImpl((ODataClient) client, targetURI, linkName);
}
@SuppressWarnings("unchecked")
@Override
public ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(final URI query) {
return new ODataEntitySetRequestImpl<ODataEntitySet>(client, query);
}
@SuppressWarnings("unchecked")
@Override
public ODataEntityRequest<ODataEntity> getEntityRequest(final URI query) {
return new ODataEntityRequestImpl<ODataEntity>(client, query);
}
@SuppressWarnings("unchecked")
@Override
public ODataPropertyRequest<ODataProperty> getPropertyRequest(final URI query) {
return new ODataPropertyRequestImpl<ODataProperty>(client, query);
}
}

View File

@ -18,10 +18,20 @@
*/
package org.apache.olingo.client.core.communication.request.retrieve.v4;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.communication.request.retrieve.AbstractRetrieveRequestFactory;
import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl;
import org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl;
import org.apache.olingo.client.core.communication.request.retrieve.ODataPropertyRequestImpl;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
implements RetrieveRequestFactory {
@ -37,4 +47,22 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
return new XMLMetadataRequestImpl(((ODataClient) client),
client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
}
@SuppressWarnings("unchecked")
@Override
public ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(final URI query) {
return new ODataEntitySetRequestImpl<ODataEntitySet>(client, query);
}
@SuppressWarnings("unchecked")
@Override
public ODataEntityRequest<ODataEntity> getEntityRequest(final URI query) {
return new ODataEntityRequestImpl<ODataEntity>(client, query);
}
@SuppressWarnings("unchecked")
@Override
public ODataPropertyRequest<ODataProperty> getPropertyRequest(final URI query) {
return new ODataPropertyRequestImpl<ODataProperty>(client, query);
}
}

View File

@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.streamed.MediaEntityCreateStreamManager;
import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@ -98,7 +98,7 @@ public class ODataMediaEntityCreateRequestImpl
private class ODataMediaEntityCreateResponseImpl extends AbstractODataResponse
implements ODataMediaEntityCreateResponse {
private ODataEntity entity = null;
private CommonODataEntity entity = null;
/**
* Constructor.
@ -122,7 +122,7 @@ public class ODataMediaEntityCreateRequestImpl
* {@inheritDoc }
*/
@Override
public ODataEntity getBody() {
public CommonODataEntity getBody() {
if (entity == null) {
try {
final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(), getFormat());

View File

@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.streamed.MediaEntityUpdateStreamManager;
import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@ -101,7 +101,7 @@ public class ODataMediaEntityUpdateRequestImpl
private class ODataMediaEntityUpdateResponseImpl extends AbstractODataResponse
implements ODataMediaEntityUpdateResponse {
private ODataEntity entity = null;
private CommonODataEntity entity = null;
/**
* Constructor.
@ -125,7 +125,7 @@ public class ODataMediaEntityUpdateRequestImpl
* {@inheritDoc }
*/
@Override
public ODataEntity getBody() {
public CommonODataEntity getBody() {
if (entity == null) {
try {
final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(), getFormat());

View File

@ -35,14 +35,13 @@ import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.Value;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataOperation;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.core.domain.ODataPropertyImpl;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@ -89,7 +88,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
public Feed getFeed(final ODataEntitySet entitySet, final Class<? extends Feed> reference) {
public Feed getFeed(final CommonODataEntitySet entitySet, final Class<? extends Feed> reference) {
final Feed feed = ResourceFactory.newFeed(reference);
feed.setCount(entitySet.getCount());
@ -99,7 +98,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
feed.setNext(next);
}
for (ODataEntity entity : entitySet.getEntities()) {
for (CommonODataEntity entity : entitySet.getEntities()) {
feed.getEntries().add(getEntry(entity, ResourceFactory.entryClassForFeed(reference)));
}
@ -107,15 +106,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
public Entry getEntry(final ODataEntity entity, final Class<? extends Entry> reference) {
public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference) {
return getEntry(entity, reference, true);
}
@Override
public Entry getEntry(final ODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
final Entry entry = ResourceFactory.newEntry(reference);
entry.setId(entity.getReference());
entry.setType(entity.getName());
// -------------------------------------------------------------
@ -176,7 +174,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
entry.setMediaContentType(entity.getMediaContentType());
}
for (ODataProperty property : entity.getProperties()) {
for (CommonODataProperty property : entity.getProperties()) {
entry.getProperties().add(getProperty(property, reference, setType));
}
@ -194,13 +192,13 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
if (link instanceof ODataInlineEntity) {
// append inline entity
final ODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
final CommonODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
LOG.debug("Append in-line entity\n{}", inlineEntity);
linkResource.setInlineEntry(getEntry(inlineEntity, ResourceFactory.entryClassForFormat(isXML)));
} else if (link instanceof ODataInlineEntitySet) {
// append inline feed
final ODataEntitySet InlineFeed = ((ODataInlineEntitySet) link).getEntitySet();
final CommonODataEntitySet InlineFeed = ((ODataInlineEntitySet) link).getEntitySet();
LOG.debug("Append in-line feed\n{}", InlineFeed);
linkResource.setInlineFeed(getFeed(InlineFeed, ResourceFactory.feedClassForFormat(isXML)));
@ -210,7 +208,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
public Property getProperty(final ODataProperty property, final Class<? extends Entry> reference,
public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
final boolean setType) {
final Property propertyResource = ResourceFactory.newProperty(reference);
@ -243,7 +241,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
final ODataComplexValue _value = value.asComplex();
valueResource = new ComplexValueImpl();
for (final Iterator<ODataProperty> itor = _value.iterator(); itor.hasNext();) {
for (final Iterator<CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
valueResource.asComplex().get().add(getProperty(itor.next(), reference, setType));
}
} else if (value.isCollection()) {
@ -259,12 +257,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
public ODataEntitySet getODataEntitySet(final Feed resource) {
public CommonODataEntitySet getODataEntitySet(final Feed resource) {
return getODataEntitySet(resource, null);
}
protected abstract boolean add(CommonODataEntitySet entitySet, CommonODataEntity entity);
@Override
public ODataEntitySet getODataEntitySet(final Feed resource, final URI defaultBaseURI) {
public CommonODataEntitySet getODataEntitySet(final Feed resource, final URI defaultBaseURI) {
if (LOG.isDebugEnabled()) {
final StringWriter writer = new StringWriter();
client.getSerializer().feed(resource, writer);
@ -276,7 +276,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
final URI next = resource.getNext();
final ODataEntitySet entitySet = next == null
final CommonODataEntitySet entitySet = next == null
? client.getObjectFactory().newEntitySet()
: client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
@ -285,19 +285,19 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
for (Entry entryResource : resource.getEntries()) {
entitySet.getEntities().add(getODataEntity(entryResource));
add(entitySet, getODataEntity(entryResource));
}
return entitySet;
}
@Override
public ODataEntity getODataEntity(final Entry resource) {
public CommonODataEntity getODataEntity(final Entry resource) {
return getODataEntity(resource, null);
}
@Override
public ODataEntity getODataEntity(final Entry resource, final URI defaultBaseURI) {
public CommonODataEntity getODataEntity(final Entry resource, final URI defaultBaseURI) {
if (LOG.isDebugEnabled()) {
final StringWriter writer = new StringWriter();
client.getSerializer().entry(resource, writer);
@ -307,13 +307,11 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
final URI base = defaultBaseURI == null ? resource.getBaseURI() : defaultBaseURI;
final ODataEntity entity = resource.getSelfLink() == null
final CommonODataEntity entity = resource.getSelfLink() == null
? client.getObjectFactory().newEntity(resource.getType())
: client.getObjectFactory().newEntity(resource.getType(),
URIUtils.getURI(base, resource.getSelfLink().getHref()));
entity.setReference(resource.getId());
if (StringUtils.isNotBlank(resource.getETag())) {
entity.setETag(resource.getETag());
}
@ -362,18 +360,13 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
for (Property property : resource.getProperties()) {
entity.getProperties().add(getODataProperty(property));
add(entity, getODataProperty(property));
}
return entity;
}
@Override
public ODataProperty getODataProperty(final Property property) {
return new ODataPropertyImpl(property.getName(), getODataValue(property));
}
private ODataValue getODataValue(final Property resource) {
protected ODataValue getODataValue(final Property resource) {
ODataValue value = null;
if (resource.getValue().isPrimitive()) {

View File

@ -25,11 +25,11 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.client.api.edm.xml.Schema;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
@ -78,17 +78,17 @@ public abstract class AbstractODataReader implements CommonODataReader {
}
@Override
public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
public CommonODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
return client.getBinder().getODataEntitySet(client.getDeserializer().toFeed(input, format).getObject());
}
@Override
public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
public CommonODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
return client.getBinder().getODataEntity(client.getDeserializer().toEntry(input, format).getObject());
}
@Override
public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
public CommonODataProperty readProperty(final InputStream input, final ODataFormat format) {
final Property property = client.getDeserializer().toProperty(input, format).getObject();
return client.getBinder().getODataProperty(property);
}
@ -107,19 +107,19 @@ public abstract class AbstractODataReader implements CommonODataReader {
if (ODataEntitySetIterator.class.isAssignableFrom(reference)) {
res = new Container<T>(
null, null, (T) new ODataEntitySetIterator(client, src, ODataPubFormat.fromString(format)));
} else if (ODataEntitySet.class.isAssignableFrom(reference)) {
} else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
final Container<Feed> container = client.getDeserializer().toFeed(src, ODataPubFormat.fromString(format));
res = new Container<T>(
container.getContextURL(),
container.getMetadataETag(),
(T) client.getBinder().getODataEntitySet(container.getObject()));
} else if (ODataEntity.class.isAssignableFrom(reference)) {
} else if (CommonODataEntity.class.isAssignableFrom(reference)) {
final Container<Entry> container = client.getDeserializer().toEntry(src, ODataPubFormat.fromString(format));
res = new Container<T>(
container.getContextURL(),
container.getMetadataETag(),
(T) client.getBinder().getODataEntity(container.getObject()));
} else if (ODataProperty.class.isAssignableFrom(reference)) {
} else if (CommonODataProperty.class.isAssignableFrom(reference)) {
final Container<Property> container = client.getDeserializer().toProperty(src, ODataFormat.fromString(format));
res = new Container<T>(
container.getContextURL(),

View File

@ -26,9 +26,9 @@ import java.util.Collection;
import java.util.Collections;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.op.ODataWriter;
@ -44,17 +44,17 @@ public class ODataWriterImpl implements ODataWriter {
}
@Override
public InputStream writeEntities(final Collection<ODataEntity> entities, final ODataPubFormat format) {
public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format) {
return writeEntities(entities, format, true);
}
@Override
public InputStream writeEntities(
final Collection<ODataEntity> entities, final ODataPubFormat format, final boolean outputType) {
final Collection<CommonODataEntity> entities, final ODataPubFormat format, final boolean outputType) {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
for (ODataEntity entity : entities) {
for (CommonODataEntity entity : entities) {
client.getSerializer().entry(client.getBinder().getEntry(
entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM), outputType), output);
}
@ -66,17 +66,19 @@ public class ODataWriterImpl implements ODataWriter {
}
@Override
public InputStream writeEntity(final ODataEntity entity, final ODataPubFormat format) {
public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format) {
return writeEntity(entity, format, true);
}
@Override
public InputStream writeEntity(final ODataEntity entity, final ODataPubFormat format, final boolean outputType) {
return writeEntities(Collections.<ODataEntity>singleton(entity), format, outputType);
public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format,
final boolean outputType) {
return writeEntities(Collections.<CommonODataEntity>singleton(entity), format, outputType);
}
@Override
public InputStream writeProperty(final ODataProperty property, final ODataFormat format) {
public InputStream writeProperty(final CommonODataProperty property, final ODataFormat format) {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
client.getSerializer().property(client.getBinder().getProperty(

View File

@ -18,11 +18,22 @@
*/
package org.apache.olingo.client.core.op.impl.v3;
import java.net.URI;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
import org.apache.olingo.client.api.op.v3.ODataBinder;
import org.apache.olingo.client.core.op.AbstractODataBinder;
import org.apache.olingo.client.core.v3.ODataClientImpl;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.core.domain.v3.ODataPropertyImpl;
public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
@ -32,6 +43,41 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
super(client);
}
@Override
public boolean add(final CommonODataEntity entity, final CommonODataProperty property) {
return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
}
@Override
protected boolean add(final CommonODataEntitySet entitySet, final CommonODataEntity entity) {
return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
}
@Override
public ODataEntitySet getODataEntitySet(final Feed resource) {
return (ODataEntitySet) super.getODataEntitySet(resource);
}
@Override
public ODataEntitySet getODataEntitySet(final Feed resource, final URI defaultBaseURI) {
return (ODataEntitySet) super.getODataEntitySet(resource, defaultBaseURI);
}
@Override
public ODataEntity getODataEntity(final Entry resource) {
return (ODataEntity) super.getODataEntity(resource);
}
@Override
public ODataEntity getODataEntity(final Entry resource, final URI defaultBaseURI) {
return (ODataEntity) super.getODataEntity(resource, defaultBaseURI);
}
@Override
public ODataProperty getODataProperty(final Property property) {
return new ODataPropertyImpl(property.getName(), getODataValue(property));
}
@Override
public ODataLinkCollection getLinkCollection(final LinkCollection linkCollection) {
final ODataLinkCollection collection = new ODataLinkCollection(linkCollection.getNext());

View File

@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.core.op.impl.v4;
import java.net.URI;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.data.ServiceDocumentItem;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
@ -25,6 +26,16 @@ import org.apache.olingo.client.api.op.v4.ODataBinder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.core.op.AbstractODataBinder;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
@ -34,6 +45,16 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
super(client);
}
@Override
public boolean add(final CommonODataEntity entity, final CommonODataProperty property) {
return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
}
@Override
protected boolean add(final CommonODataEntitySet entitySet, final CommonODataEntity entity) {
return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
}
@Override
public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
final ODataServiceDocument serviceDocument = super.getODataServiceDocument(resource);
@ -56,4 +77,39 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
return serviceDocument;
}
@Override
public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
final Entry entry = super.getEntry(entity, reference, setType);
entry.setId(((ODataEntity) entity).getReference());
return entry;
}
@Override
public ODataEntitySet getODataEntitySet(final Feed resource) {
return (ODataEntitySet) super.getODataEntitySet(resource);
}
@Override
public ODataEntitySet getODataEntitySet(final Feed resource, final URI defaultBaseURI) {
return (ODataEntitySet) super.getODataEntitySet(resource, defaultBaseURI);
}
@Override
public ODataEntity getODataEntity(final Entry resource) {
return (ODataEntity) super.getODataEntity(resource);
}
@Override
public ODataEntity getODataEntity(final Entry resource, final URI defaultBaseURI) {
final ODataEntity entity = (ODataEntity) super.getODataEntity(resource, defaultBaseURI);
entity.setReference(resource.getId());
return entity;
}
@Override
public ODataProperty getODataProperty(final Property property) {
return new ODataPropertyImpl(property.getName(), getODataValue(property));
}
}

View File

@ -46,7 +46,9 @@ import org.apache.olingo.client.core.op.impl.v3.ODataReaderImpl;
import org.apache.olingo.client.core.op.impl.v3.ODataSerializerImpl;
import org.apache.olingo.client.core.uri.v3.URIBuilderImpl;
import org.apache.olingo.client.core.uri.v3.FilterFactoryImpl;
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.domain.v3.ODataObjectFactoryImpl;
public class ODataClientImpl extends AbstractODataClient implements ODataClient {
@ -64,6 +66,8 @@ public class ODataClientImpl extends AbstractODataClient implements ODataClient
private final ODataBinder binder = new ODataBinderImpl(this);
private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl(getServiceVersion());
private final RetrieveRequestFactory retrieveReqFact = new RetrieveRequestFactoryImpl(this);
private final CUDRequestFactory cudReqFact = new CUDRequestFactoryImpl(this);
@ -123,6 +127,11 @@ public class ODataClientImpl extends AbstractODataClient implements ODataClient
return binder;
}
@Override
public ODataObjectFactory getObjectFactory() {
return objectFactory;
}
@Override
public RetrieveRequestFactory getRetrieveRequestFactory() {
return retrieveReqFact;

View File

@ -46,7 +46,9 @@ import org.apache.olingo.client.core.op.impl.v4.ODataReaderImpl;
import org.apache.olingo.client.core.op.impl.v4.ODataSerializerImpl;
import org.apache.olingo.client.core.uri.v4.URIBuilderImpl;
import org.apache.olingo.client.core.uri.v4.FilterFactoryImpl;
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.domain.v4.ODataObjectFactoryImpl;
public class ODataClientImpl extends AbstractODataClient implements ODataClient {
@ -64,6 +66,8 @@ public class ODataClientImpl extends AbstractODataClient implements ODataClient
private final ODataBinder binder = new ODataBinderImpl(this);
private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl(getServiceVersion());
private final RetrieveRequestFactory retrieveReqFact = new RetrieveRequestFactoryImpl(this);
private final CUDRequestFactory cudReqFact = new CUDRequestFactoryImpl(this);
@ -122,6 +126,11 @@ public class ODataClientImpl extends AbstractODataClient implements ODataClient
return binder;
}
@Override
public ODataObjectFactory getObjectFactory() {
return objectFactory;
}
@Override
public RetrieveRequestFactory getRetrieveRequestFactory() {
return retrieveReqFact;

View File

@ -54,12 +54,12 @@ import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
@ -117,10 +117,10 @@ public abstract class AbstractTestITCase {
assertNotNull(foundActual);
if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
final ODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
final CommonODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
assertNotNull(originalInline);
final ODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
final CommonODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
assertNotNull(actualInline);
checkProperties(originalInline.getProperties(), actualInline.getProperties());
@ -128,23 +128,25 @@ public abstract class AbstractTestITCase {
}
}
protected void checkProperties(final Collection<ODataProperty> original, final Collection<ODataProperty> actual) {
protected void checkProperties(final Collection<? extends CommonODataProperty> original,
final Collection<? extends CommonODataProperty> actual) {
assertTrue(original.size() <= actual.size());
// re-organize actual properties into a Map<String, ODataProperty>
final Map<String, ODataProperty> actualProps = new HashMap<String, ODataProperty>(actual.size());
final Map<String, CommonODataProperty> actualProps = new HashMap<String, CommonODataProperty>(actual.size());
for (ODataProperty prop : actual) {
for (CommonODataProperty prop : actual) {
assertFalse(actualProps.containsKey(prop.getName()));
actualProps.put(prop.getName(), prop);
}
assertTrue(actual.size() <= actualProps.size());
for (ODataProperty prop : original) {
for (CommonODataProperty prop : original) {
assertNotNull(prop);
if (actualProps.containsKey(prop.getName())) {
final ODataProperty actualProp = actualProps.get(prop.getName());
final CommonODataProperty actualProp = actualProps.get(prop.getName());
assertNotNull(actualProp);
if (prop.getValue() != null && actualProp.getValue() != null) {
@ -168,13 +170,13 @@ public abstract class AbstractTestITCase {
original.getClass().getSimpleName(), actual.getClass().getSimpleName());
if (original.isComplex()) {
final List<ODataProperty> originalFileds = new ArrayList<ODataProperty>();
for (ODataProperty prop : original.asComplex()) {
final List<CommonODataProperty> originalFileds = new ArrayList<CommonODataProperty>();
for (CommonODataProperty prop : original.asComplex()) {
originalFileds.add(prop);
}
final List<ODataProperty> actualFileds = new ArrayList<ODataProperty>();
for (ODataProperty prop : (ODataComplexValue) actual) {
final List<CommonODataProperty> actualFileds = new ArrayList<CommonODataProperty>();
for (CommonODataProperty prop : (ODataComplexValue) actual) {
actualFileds.add(prop);
}
@ -207,39 +209,42 @@ public abstract class AbstractTestITCase {
}
}
protected ODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
final ODataEntity entity = getClient().getObjectFactory().newEntity(
protected CommonODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
final CommonODataEntity entity = getClient().getObjectFactory().newEntity(
"Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
entity.setMediaEntity(true);
entity.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Information",
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleinfo).setType(
EdmPrimitiveTypeKind.String).build()));
getClient().getBinder().add(entity,
getClient().getObjectFactory().newPrimitiveProperty("Information",
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleinfo).
setType(EdmPrimitiveTypeKind.String).build()));
return entity;
}
protected ODataEntity getSampleCustomerProfile(
protected CommonODataEntity getSampleCustomerProfile(
final int id, final String sampleName, final boolean withInlineInfo) {
final ODataEntity entity =
final CommonODataEntity entity =
getClient().getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
// add name attribute
entity.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Name",
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleName).setType(
EdmPrimitiveTypeKind.String).build()));
getClient().getBinder().add(entity,
getClient().getObjectFactory().newPrimitiveProperty("Name",
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleName).
setType(EdmPrimitiveTypeKind.String).build()));
// add key attribute
entity.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("CustomerId",
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)).setType(
EdmPrimitiveTypeKind.Int32).build()));
getClient().getBinder().add(entity,
getClient().getObjectFactory().newPrimitiveProperty("CustomerId",
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)).
setType(EdmPrimitiveTypeKind.Int32).build()));
// add BackupContactInfo attribute (collection)
final ODataCollectionValue backupContactInfoValue = getClient().getObjectFactory().newCollectionValue(
"Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
entity.getProperties().add(getClient().getObjectFactory().newCollectionProperty("BackupContactInfo",
backupContactInfoValue));
getClient().getBinder().add(entity,
getClient().getObjectFactory().newCollectionProperty("BackupContactInfo", backupContactInfoValue));
// add BackupContactInfo.ContactDetails attribute (complex)
final ODataComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
@ -302,7 +307,7 @@ public abstract class AbstractTestITCase {
}
}
protected void debugODataProperty(final ODataProperty property, final String message) {
protected void debugODataProperty(final CommonODataProperty property, final String message) {
LOG.debug(message + "\n{}", property.toString());
}
@ -310,7 +315,7 @@ public abstract class AbstractTestITCase {
LOG.debug(message + "\n{}", value.toString());
}
protected void debugODataEntity(final ODataEntity entity, final String message) {
protected void debugODataEntity(final CommonODataEntity entity, final String message) {
if (LOG.isDebugEnabled()) {
StringWriter writer = new StringWriter();
getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, AtomEntryImpl.class), writer);
@ -337,7 +342,7 @@ public abstract class AbstractTestITCase {
}
protected String getETag(final URI uri) {
final ODataRetrieveResponse<ODataEntity> res = getClient().getRetrieveRequestFactory().
final ODataRetrieveResponse<CommonODataEntity> res = getClient().getRetrieveRequestFactory().
getEntityRequest(uri).execute();
try {
return res.getEtag();
@ -346,12 +351,13 @@ public abstract class AbstractTestITCase {
}
}
protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
final ODataEntityRequest req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
protected CommonODataEntity read(final ODataPubFormat format, final URI editLink) {
final ODataEntityRequest<CommonODataEntity> req = getClient().getRetrieveRequestFactory().
getEntityRequest(editLink);
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<CommonODataEntity> res = req.execute();
final CommonODataEntity entity = res.getBody();
assertNotNull(entity);
@ -362,10 +368,10 @@ public abstract class AbstractTestITCase {
return entity;
}
protected ODataEntity createEntity(
protected CommonODataEntity createEntity(
final String serviceRootURL,
final ODataPubFormat format,
final ODataEntity original,
final CommonODataEntity original,
final String entitySetName) {
final CommonURIBuilder<?> uriBuilder = getClient().getURIBuilder(serviceRootURL).
@ -381,7 +387,7 @@ public abstract class AbstractTestITCase {
assertEquals(201, createRes.getStatusCode());
assertEquals("Created", createRes.getStatusMessage());
final ODataEntity created = createRes.getBody();
final CommonODataEntity created = createRes.getBody();
assertNotNull(created);
debugODataEntity(created, "Just created");
@ -389,9 +395,9 @@ public abstract class AbstractTestITCase {
return created;
}
protected ODataEntity compareEntities(final String serviceRootURL,
protected CommonODataEntity compareEntities(final String serviceRootURL,
final ODataPubFormat format,
final ODataEntity original,
final CommonODataEntity original,
final int actualObjectId,
final Collection<String> expands) {
@ -405,13 +411,14 @@ public abstract class AbstractTestITCase {
}
}
final ODataEntityRequest req = getClient().getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<CommonODataEntity> req = getClient().getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<CommonODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
final ODataEntity actual = res.getBody();
final CommonODataEntity actual = res.getBody();
assertNotNull(actual);
// check defined links
@ -427,7 +434,7 @@ public abstract class AbstractTestITCase {
protected void cleanAfterCreate(
final ODataPubFormat format,
final ODataEntity created,
final CommonODataEntity created,
final boolean includeInline,
final String baseUri) {
@ -437,15 +444,15 @@ public abstract class AbstractTestITCase {
if (includeInline) {
for (ODataLink link : created.getNavigationLinks()) {
if (link instanceof ODataInlineEntity) {
final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
if (inline.getEditLink() != null) {
toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
}
}
if (link instanceof ODataInlineEntitySet) {
final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
for (ODataEntity entity : inline.getEntities()) {
final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
for (CommonODataEntity entity : inline.getEntities()) {
if (entity.getEditLink() != null) {
toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
}
@ -465,7 +472,8 @@ public abstract class AbstractTestITCase {
deleteRes.close();
final ODataEntityRequest retrieveReq = getClient().getRetrieveRequestFactory().getEntityRequest(link);
final ODataEntityRequest<CommonODataEntity> retrieveReq = getClient().getRetrieveRequestFactory().
getEntityRequest(link);
// bug that needs to be fixed on the SampleService - cannot get entity not found with header
// Accept: application/json;odata=minimalmetadata
retrieveReq.setFormat(format == ODataPubFormat.JSON_FULL_METADATA ? ODataPubFormat.JSON : format);
@ -483,25 +491,25 @@ public abstract class AbstractTestITCase {
}
protected void updateEntityDescription(
final ODataPubFormat format, final ODataEntity changes, final UpdateType type) {
final ODataPubFormat format, final CommonODataEntity changes, final UpdateType type) {
updateEntityDescription(format, changes, type, null);
}
protected void updateEntityDescription(
final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
final ODataPubFormat format, final CommonODataEntity changes, final UpdateType type, final String etag) {
updateEntityStringProperty("Description", format, changes, type, etag);
}
protected void updateEntityStringProperty(final String propertyName,
final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
final ODataPubFormat format, final CommonODataEntity changes, final UpdateType type, final String etag) {
final URI editLink = changes.getEditLink();
final String newm = "New " + propertyName + "(" + System.currentTimeMillis() + ")";
ODataProperty propertyValue = changes.getProperty(propertyName);
CommonODataProperty propertyValue = changes.getProperty(propertyName);
final String oldm;
if (propertyValue == null) {
@ -513,16 +521,17 @@ public abstract class AbstractTestITCase {
assertNotEquals(newm, oldm);
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty(propertyName,
getClient().getBinder().add(changes,
getClient().getObjectFactory().newPrimitiveProperty(propertyName,
getClient().getObjectFactory().newPrimitiveValueBuilder().setText(newm).build()));
update(type, changes, format, etag);
final ODataEntity actual = read(format, editLink);
final CommonODataEntity actual = read(format, editLink);
propertyValue = null;
for (ODataProperty prop : actual.getProperties()) {
for (CommonODataProperty prop : actual.getProperties()) {
if (prop.getName().equals(propertyName)) {
propertyValue = prop;
}
@ -533,7 +542,7 @@ public abstract class AbstractTestITCase {
}
protected void update(
final UpdateType type, final ODataEntity changes, final ODataPubFormat format, final String etag) {
final UpdateType type, final CommonODataEntity changes, final ODataPubFormat format, final String etag) {
final ODataEntityUpdateRequest req = getClient().getCUDRequestFactory().getEntityUpdateRequest(type, changes);
if (getClient().getConfiguration().isUseXHTTPMethod()) {

View File

@ -19,25 +19,26 @@
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import java.net.URI;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.api.communication.request.streamed.MediaEntityCreateStreamManager;
import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.junit.Ignore;
import org.junit.Test;
@ -68,13 +69,14 @@ public class AsyncTestITCase extends AbstractTestITCase {
final ODataRetrieveResponse<ODataEntity> entityRes = client.getRetrieveRequestFactory().
getEntityRequest(uri).execute();
final ODataEntity entity = entityRes.getBody();
final CommonODataEntity entity = entityRes.getBody();
entity.getAssociationLinks().clear();
entity.getNavigationLinks().clear();
entity.getEditMediaLinks().clear();
entity.getProperties().remove(entity.getProperty("Description"));
entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Description",
getClient().getBinder().add(entity,
client.getObjectFactory().newPrimitiveProperty("Description",
client.getObjectFactory().newPrimitiveValueBuilder().setText("AsyncTest#updateEntity").build()));
final ODataEntityUpdateRequest updateReq =
@ -116,7 +118,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
assertEquals(201, createRes.getStatusCode());
final ODataEntity created = createRes.getBody();
final CommonODataEntity created = createRes.getBody();
assertNotNull(created);
assertEquals(2, created.getProperties().size());

View File

@ -18,11 +18,6 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URI;
import java.util.Collections;
import java.util.HashSet;
@ -39,17 +34,24 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.NoContentException;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Ignore;
import org.junit.Test;
@ -66,10 +68,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final int id = 1;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
final CommonODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@ -78,10 +80,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createAsJSON() {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final int id = 2;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
final CommonODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@ -90,10 +92,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createWithInlineAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final int id = 3;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual =
final CommonODataEntity actual =
compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
cleanAfterCreate(format, actual, true, getServiceRoot());
@ -104,10 +106,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
// this needs to be full, otherwise there is no mean to recognize links
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final int id = 4;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual =
final CommonODataEntity actual =
compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
cleanAfterCreate(format, actual, true, getServiceRoot());
@ -117,13 +119,13 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createInlineWithoutLinkAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final int id = 5;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
original.addLink(client.getObjectFactory().newInlineEntity(
"Info", null, getSampleCustomerInfo(id, "Sample Customer_Info")));
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual =
final CommonODataEntity actual =
compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
boolean found = false;
@ -144,13 +146,13 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createInlineWithoutLinkAsJSON() {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final int id = 6;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
original.addLink(client.getObjectFactory().newInlineEntity(
"Info", null, getSampleCustomerInfo(id, "Sample Customer_Info")));
createEntity(getServiceRoot(), format, original, "Customer");
final ODataEntity actual =
final CommonODataEntity actual =
compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
boolean found = false;
@ -170,7 +172,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createWithNavigationAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final ODataEntity actual = createWithNavigationLink(format, 5);
final CommonODataEntity actual = createWithNavigationLink(format, 5);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@ -178,14 +180,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createWithNavigationAsJSON() {
// this needs to be full, otherwise there is no mean to recognize links
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithNavigationLink(format, 6);
final CommonODataEntity actual = createWithNavigationLink(format, 6);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@Test
public void createWithFeedNavigationAsAtom() throws EdmPrimitiveTypeException {
final ODataPubFormat format = ODataPubFormat.ATOM;
final ODataEntity actual = createWithFeedNavigationLink(format, 7);
final CommonODataEntity actual = createWithFeedNavigationLink(format, 7);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@ -193,14 +195,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createWithFeedNavigationAsJSON() throws EdmPrimitiveTypeException {
// this needs to be full, otherwise there is no mean to recognize links
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithFeedNavigationLink(format, 8);
final CommonODataEntity actual = createWithFeedNavigationLink(format, 8);
cleanAfterCreate(format, actual, false, getServiceRoot());
}
@Test
public void createWithBackNavigationAsAtom() throws EdmPrimitiveTypeException {
final ODataPubFormat format = ODataPubFormat.ATOM;
final ODataEntity actual = createWithBackNavigationLink(format, 9);
final CommonODataEntity actual = createWithBackNavigationLink(format, 9);
cleanAfterCreate(format, actual, true, getServiceRoot());
}
@ -208,7 +210,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
public void createWithBackNavigationAsJSON() throws EdmPrimitiveTypeException {
// this needs to be full, otherwise there is no mean to recognize links
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final ODataEntity actual = createWithBackNavigationLink(format, 10);
final CommonODataEntity actual = createWithBackNavigationLink(format, 10);
cleanAfterCreate(format, actual, true, getServiceRoot());
}
@ -225,7 +227,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Test
public void createReturnNoContent() {
final int id = 1;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").build(), original);
@ -253,7 +255,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
@Ignore
public void issue135() {
final int id = 2;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer for issue 135", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer for issue 135", false);
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer");
final ODataEntityCreateRequest createReq =
@ -276,26 +278,28 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
}
}
private ODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id)
private CommonODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id)
throws EdmPrimitiveTypeException {
final String sampleName = "Sample customer";
final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
final CommonODataEntity original = getSampleCustomerProfile(id, sampleName, false);
final Set<Integer> keys = new HashSet<Integer>();
keys.add(-100);
keys.add(-101);
for (Integer key : keys) {
final ODataEntity order =
final CommonODataEntity order =
client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(key).setType(EdmPrimitiveTypeKind.Int32)
.build()));
order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).setType(EdmPrimitiveTypeKind.Int32)
.build()));
getClient().getBinder().add(order,
client.getObjectFactory().newPrimitiveProperty("OrderId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(key).
setType(EdmPrimitiveTypeKind.Int32).build()));
getClient().getBinder().add(order,
client.getObjectFactory().newPrimitiveProperty("CustomerId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).
setType(EdmPrimitiveTypeKind.Int32).build()));
final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Order").build(), order);
@ -306,24 +310,25 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
createReq.execute().getBody().getEditLink()));
}
final ODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
final CommonODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
// now, compare the created one with the actual one and go deeply into the associated customer info.....
final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
final CommonODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Orders");
final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
assertEquals(200, res.getStatusCode());
final ODataEntitySet entitySet = res.getBody();
final CommonODataEntitySet entitySet = res.getBody();
assertNotNull(entitySet);
assertEquals(2, entitySet.getCount());
for (ODataEntity entity : entitySet.getEntities()) {
for (CommonODataEntity entity : entitySet.getEntities()) {
final Integer key = entity.getProperty("OrderId").getPrimitiveValue().toCastValue(Integer.class);
final Integer customerId = entity.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class);
assertTrue(keys.contains(key));
@ -340,32 +345,32 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
return actual;
}
private ODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
private CommonODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
final String sampleName = "Sample customer";
final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
final CommonODataEntity original = getSampleCustomerProfile(id, sampleName, false);
original.addLink(client.getObjectFactory().newEntityNavigationLink(
"Info", URI.create(getServiceRoot() + "/CustomerInfo(12)")));
final ODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
final CommonODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
// now, compare the created one with the actual one and go deeply into the associated customer info.....
final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
final CommonODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
final ODataEntity info = res.getBody();
final CommonODataEntity info = res.getBody();
assertNotNull(info);
boolean found = false;
for (ODataProperty prop : info.getProperties()) {
for (CommonODataProperty prop : info.getProperties()) {
if ("CustomerInfoId".equals(prop.getName())) {
assertEquals("12", prop.getValue().toString());
found = true;
@ -377,27 +382,29 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
return actual;
}
private ODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id)
private CommonODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id)
throws EdmPrimitiveTypeException {
final String sampleName = "Sample customer";
ODataEntity customer = getSampleCustomerProfile(id, sampleName, false);
customer = createEntity(getServiceRoot(), format, customer, "Customer");
ODataEntity customer = (ODataEntity) getSampleCustomerProfile(id, sampleName, false);
customer = (ODataEntity) createEntity(getServiceRoot(), format, customer, "Customer");
ODataEntity order = client.getObjectFactory().newEntity(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
getClient().getBinder().add(order,
client.getObjectFactory().newPrimitiveProperty("CustomerId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).
setType(EdmPrimitiveTypeKind.Int32).build()));
order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId",
getClient().getBinder().add(order,
client.getObjectFactory().newPrimitiveProperty("OrderId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).
setType(EdmPrimitiveTypeKind.Int32).build()));
order.addLink(client.getObjectFactory().newEntityNavigationLink(
"Customer", URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString())));
order = createEntity(getServiceRoot(), format, order, "Order");
order = (ODataEntity) createEntity(getServiceRoot(), format, order, "Order");
ODataEntity changes = client.getObjectFactory().newEntity(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
@ -406,7 +413,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
"Orders", URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString())));
update(UpdateType.PATCH, changes, format, null);
final ODataEntityRequest customerreq = client.getRetrieveRequestFactory().getEntityRequest(
final ODataEntityRequest<ODataEntity> customerreq = client.getRetrieveRequestFactory().getEntityRequest(
URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString() + "/Customer"));
customerreq.setFormat(format);
@ -415,7 +422,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
assertEquals(Integer.valueOf(id),
customer.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class));
final ODataEntitySetRequest orderreq = client.getRetrieveRequestFactory().getEntitySetRequest(
final ODataEntitySetRequest<ODataEntitySet> orderreq = client.getRetrieveRequestFactory().getEntitySetRequest(
URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "/Orders"));
orderreq.setFormat(format);
@ -426,7 +433,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
orderres.getBody().getEntities().get(0).getProperty("OrderId").getPrimitiveValue().
toCastValue(Integer.class));
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(
URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "?$expand=Orders"));
req.setFormat(format);
@ -444,25 +451,31 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
}
private void multiKey(final ODataPubFormat format) {
final ODataEntity message = client.getObjectFactory().newEntity(
final CommonODataEntity message = client.getObjectFactory().newEntity(
"Microsoft.Test.OData.Services.AstoriaDefaultService.Message");
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("MessageId",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("MessageId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(1000).
setType(EdmPrimitiveTypeKind.Int32).build()));
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FromUsername",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("FromUsername",
client.getObjectFactory().newPrimitiveValueBuilder().setValue("1").
setType(EdmPrimitiveTypeKind.String).build()));
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("ToUsername",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("ToUsername",
client.getObjectFactory().newPrimitiveValueBuilder().setValue("xlodhxzzusxecbzptxlfxprneoxkn").
setType(EdmPrimitiveTypeKind.String).build()));
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Subject",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("Subject",
client.getObjectFactory().newPrimitiveValueBuilder().setValue("Test subject").
setType(EdmPrimitiveTypeKind.String).build()));
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Body",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("Body",
client.getObjectFactory().newPrimitiveValueBuilder().setValue("Test body").
setType(EdmPrimitiveTypeKind.String).build()));
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("IsRead",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(false).
setType(EdmPrimitiveTypeKind.Boolean).build()));

View File

@ -18,11 +18,6 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.LinkedHashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
@ -30,16 +25,22 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.core.op.ResourceFactory;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.core.op.ResourceFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
@ -55,7 +56,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Info");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -72,13 +73,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntity) {
final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
assertNotNull(inline);
debugEntry(client.getBinder().getEntry(
inline, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
final List<ODataProperty> properties = inline.getProperties();
final List<? extends CommonODataProperty> properties = inline.getProperties();
assertEquals(2, properties.size());
assertTrue(properties.get(0).getName().equals("CustomerInfoId")
@ -108,7 +109,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Orders");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -119,7 +120,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntitySet) {
final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
assertNotNull(inline);
debugFeed(client.getBinder().getFeed(inline, ResourceFactory.feedClassForFormat(
@ -153,10 +154,10 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ODataEntitySet entitySet = res.getBodyAs(ODataEntitySet.class);
final CommonODataEntitySet entitySet = res.getBodyAs(CommonODataEntitySet.class);
assertNull(entitySet);
final ODataEntity entity = res.getBodyAs(ODataEntity.class);
final CommonODataEntity entity = res.getBodyAs(CommonODataEntity.class);
assertNotNull(entity);
}
@ -179,7 +180,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Message").appendKeySegment(multiKey);
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -212,7 +213,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder =
client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Product").appendKeySegment(-10);
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -221,7 +222,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final String etag = res.getEtag();
assertTrue(StringUtils.isNotBlank(etag));
final ODataEntity product = res.getBody();
final CommonODataEntity product = res.getBody();
assertEquals(etag, product.getETag());
}
@ -229,7 +230,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
public void issue99() {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Car");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.JSON);
// this statement should cause an IllegalArgumentException bearing JsonParseException

View File

@ -18,9 +18,6 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
@ -28,13 +25,16 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.core.op.ResourceFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
@ -90,7 +90,8 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("Customer");
final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
@ -143,7 +144,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ODataEntitySet entitySet = res.getBodyAs(ODataEntitySet.class);
final CommonODataEntitySet entitySet = res.getBodyAs(CommonODataEntitySet.class);
assertNotNull(entitySet);
}
}

View File

@ -18,23 +18,24 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.net.URI;
import java.util.LinkedHashMap;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.junit.Test;
/**
@ -52,7 +53,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
final CommonODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
merge.setEditLink(uri);
updateEntityDescription(format, merge, UpdateType.MERGE, etag);
}
@ -63,7 +64,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
final CommonODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
merge.setEditLink(uri);
updateEntityDescription(format, merge, UpdateType.MERGE, etag);
}
@ -74,7 +75,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
final CommonODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
patch.setEditLink(uri);
updateEntityDescription(format, patch, UpdateType.PATCH, etag);
}
@ -85,7 +86,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
final String etag = getETag(uri);
final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
final CommonODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
patch.setEditLink(uri);
updateEntityDescription(format, patch, UpdateType.PATCH, etag);
}
@ -93,7 +94,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void replaceAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
final CommonODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
}
@ -101,7 +102,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
@Test
public void replaceAsJSON() {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
final CommonODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
}
@ -120,7 +121,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).build();
final ODataEntity patch =
final CommonODataEntity patch =
client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
patch.setEditLink(uri);
@ -137,10 +138,10 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
customerInfoURI = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-10).appendNavigationSegment("Info").build();
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
req.setFormat(format);
ODataEntity newInfo = req.execute().getBody();
CommonODataEntity newInfo = req.execute().getBody();
assertEquals(Integer.valueOf(12),
newInfo.getProperty("CustomerInfoId").getPrimitiveValue().toCastValue(Integer.class));
@ -178,14 +179,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
multiKey.put("FromUsername", "1");
multiKey.put("MessageId", -10);
final ODataEntity message = read(format, client.getURIBuilder(getServiceRoot()).
final CommonODataEntity message = read(format, client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Message").appendKeySegment(multiKey).build());
message.getAssociationLinks().clear();
message.getNavigationLinks().clear();
final boolean before = message.getProperty("IsRead").getPrimitiveValue().toCastValue(Boolean.class);
message.getProperties().remove(message.getProperty("IsRead"));
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead",
getClient().getBinder().add(message,
client.getObjectFactory().newPrimitiveProperty("IsRead",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(!before).
setType(EdmPrimitiveTypeKind.Boolean).build()));
@ -224,7 +226,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Product").appendKeySegment(-10).build();
String etag = getETag(uri);
final ODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
final CommonODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
product.setEditLink(uri);
updateEntityStringProperty("BaseConcurrency",
client.getConfiguration().getDefaultPubFormat(), product, UpdateType.MERGE, etag);

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
@ -32,16 +32,17 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.junit.Test;
/**
@ -79,7 +80,7 @@ public class ErrorTestITCase extends AbstractTestITCase {
}
@Override
public ODataEntity getBody() {
public CommonODataEntity getBody() {
return odataClient.getObjectFactory().newEntity("Invalid");
}
}
@ -117,7 +118,7 @@ public class ErrorTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("Customer(154)");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
try {

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.core.it.v3;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.client.api.uri.v3.FilterArgFactory;
@ -42,7 +42,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment(entitySet).filter(filter);
final ODataEntitySet feed = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
final CommonODataEntitySet feed = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
execute().getBody();
assertNotNull(feed);
assertEquals(expected, feed.getEntities().size());

View File

@ -21,7 +21,7 @@ package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.junit.Test;
@ -30,7 +30,7 @@ public class FilterTestITCase extends AbstractTestITCase {
private void filterQueryTest(final String entity, final String filter, final int expected) {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment(entity).filter(filter);
final ODataEntitySet entitySet = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
final CommonODataEntitySet entitySet = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
execute().getBody();
assertNotNull(entitySet);
assertEquals(expected, entitySet.getEntities().size());

View File

@ -21,13 +21,14 @@ package org.apache.olingo.client.core.it.v3;
import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
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.domain.ODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -42,7 +43,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customer").appendKeySegment(-10);
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -67,10 +68,10 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
public void createODataEntityAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final int id = 1;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
createEntity(testStaticServiceRootURL, format, original, "Customer");
final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
final CommonODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
cleanAfterCreate(format, actual, false, testStaticServiceRootURL);
}
@ -79,10 +80,10 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
public void createODataEntityAsJSON() {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final int id = 2;
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
createEntity(testStaticServiceRootURL, format, original, "Customer");
final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
final CommonODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
cleanAfterCreate(format, actual, false, testStaticServiceRootURL);
}
@ -90,7 +91,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void replaceODataEntityAsAtom() {
final ODataPubFormat format = ODataPubFormat.ATOM;
final ODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
final CommonODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
}
@ -98,7 +99,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
@Test
public void replaceODataEntityAsJSON() {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final ODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
final CommonODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Car").appendKeySegment(14).build());
updateEntityDescription(format, changes, UpdateType.REPLACE);
}

View File

@ -36,8 +36,8 @@ import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreat
import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.communication.response.ODataStreamUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataMediaFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
@ -164,12 +164,12 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
final ODataMediaEntityCreateResponse createRes = streamManager.getResponse();
assertEquals(201, createRes.getStatusCode());
final ODataEntity created = createRes.getBody();
final CommonODataEntity created = createRes.getBody();
assertNotNull(created);
assertEquals(2, created.getProperties().size());
Integer id = null;
for (ODataProperty prop : created.getProperties()) {
for (CommonODataProperty prop : created.getProperties()) {
if ("VIN".equals(prop.getName())) {
id = prop.getPrimitiveValue().toCastValue(Integer.class);
}

View File

@ -18,11 +18,6 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
@ -38,25 +33,30 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.junit.Test;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
@ -66,7 +66,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.ATOM;
final String contentType = "application/atom+xml";
final String prefer = "return-content";
final ODataEntity actual = createNavigation(format, 20, contentType, prefer);
final CommonODataEntity actual = createNavigation(format, 20, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// create navigation link with JSON full metadata
@ -76,7 +76,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final String contentType = "application/json;odata=fullmetadata";
final String prefer = "return-content";
final ODataEntity actual = createNavigation(format, 21, contentType, prefer);
final CommonODataEntity actual = createNavigation(format, 21, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// throws Null pointer exception when the format is JSON No metadata
@ -86,7 +86,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
final String contentType = "application/json;odata=nometadata";
final String prefer = "return-content";
final ODataEntity actual = createNavigation(format, 22, contentType, prefer);
final CommonODataEntity actual = createNavigation(format, 22, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// test with JSON accept and atom content type
@ -97,7 +97,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final String contentType = "application/atom+xml";
final String prefer = "return-content";
final ODataEntity actual = createNavigation(format, 23, contentType, prefer);
final CommonODataEntity actual = createNavigation(format, 23, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// test with JSON full metadata in format and json no metadata in content type
@ -107,7 +107,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final String contentType = "application/json;odata=nometadata";
final String prefer = "return-content";
final ODataEntity actual = createNavigation(format, 24, contentType, prefer);
final CommonODataEntity actual = createNavigation(format, 24, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// test with JSON no metadata format and json no metadata in content type
@ -117,7 +117,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
final String contentType = "application/json;odata=fullmetadata";
final String prefer = "return-content";
final ODataEntity actual = createNavigation(format, 25, contentType, prefer);
final CommonODataEntity actual = createNavigation(format, 25, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// create collection navigation link with ATOM
@ -127,7 +127,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.ATOM;
final String contentType = "application/atom+xml";
final String prefer = "return-content";
final ODataEntity actual = createCollectionNavigation(format, 55, contentType, prefer);
final CommonODataEntity actual = createCollectionNavigation(format, 55, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// create collection navigation link with JSON
@ -137,27 +137,27 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
final String contentType = "application/json;odata=fullmetadata";
final String prefer = "return-content";
final ODataEntity actual = createCollectionNavigation(format, 77, contentType, prefer);
final CommonODataEntity actual = createCollectionNavigation(format, 77, contentType, prefer);
delete(format, actual, false, testStaticServiceRootURL);
}
// create a navigation link
public ODataEntity createNavigation(final ODataPubFormat format, final int id, final String contenttype,
public CommonODataEntity createNavigation(final ODataPubFormat format, final int id, final String contenttype,
final String prefer) {
final String name = "Customer Navigation test";
final ODataEntity original = getNewCustomer(id, name, false);
final CommonODataEntity original = getNewCustomer(id, name, false);
original.addLink(client.getObjectFactory().newEntityNavigationLink(
"Info", URI.create(testStaticServiceRootURL + "/CustomerInfo(11)")));
final ODataEntity created = createNav(testStaticServiceRootURL, format, original, "Customer", contenttype,
final CommonODataEntity created = createNav(testStaticServiceRootURL, format, original, "Customer", contenttype,
prefer);
final ODataEntity actual = validateEntities(testStaticServiceRootURL, format, created, id, null, "Customer");
final CommonODataEntity actual = validateEntities(testStaticServiceRootURL, format, created, id, null, "Customer");
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
req.setContentType(contenttype);
req.setPrefer(prefer);
@ -175,7 +175,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
}
// create a navigation link
public ODataEntity createNav(final String url, final ODataPubFormat format, final ODataEntity original,
public CommonODataEntity createNav(final String url, final ODataPubFormat format, final CommonODataEntity original,
final String entitySetName, final String contentType, final String prefer) {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(url);
uriBuilder.appendEntitySetSegment(entitySetName);
@ -189,30 +189,32 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
assertEquals("Created", createRes.getStatusMessage());
final ODataEntity created = createRes.getBody();
final CommonODataEntity created = createRes.getBody();
assertNotNull(created);
return created;
}
// create collection navigation link
public ODataEntity createCollectionNavigation(final ODataPubFormat format, final int id,
public CommonODataEntity createCollectionNavigation(final ODataPubFormat format, final int id,
final String contentType, final String prefer) throws EdmPrimitiveTypeException {
{
final String name = "Collection Navigation Key Customer";
final ODataEntity original = getNewCustomer(id, name, false);
final CommonODataEntity original = getNewCustomer(id, name, false);
final Set<Integer> navigationKeys = new HashSet<Integer>();
navigationKeys.add(-118);
navigationKeys.add(-119);
for (Integer key : navigationKeys) {
final ODataEntity orderEntity =
final CommonODataEntity orderEntity =
client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId",
getClient().getBinder().add(orderEntity,
client.getObjectFactory().newPrimitiveProperty("OrderId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(key).
setType(EdmPrimitiveTypeKind.Int32).build()));
orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
getClient().getBinder().add(orderEntity,
client.getObjectFactory().newPrimitiveProperty("CustomerId",
client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).
setType(EdmPrimitiveTypeKind.Int32).build()));
@ -225,26 +227,27 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
"Orders",
createReq.execute().getBody().getEditLink()));
}
final ODataEntity createdEntity = createNav(testStaticServiceRootURL, format, original, "Customer",
final CommonODataEntity createdEntity = createNav(testStaticServiceRootURL, format, original, "Customer",
contentType, prefer);
final ODataEntity actualEntity =
final CommonODataEntity actualEntity =
validateEntities(testStaticServiceRootURL, format, createdEntity, id, null, "Customer");
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Orders");
final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
assertEquals(200, res.getStatusCode());
final ODataEntitySet entitySet = res.getBody();
final CommonODataEntitySet entitySet = res.getBody();
assertNotNull(entitySet);
assertEquals(2, entitySet.getCount());
for (ODataEntity entity : entitySet.getEntities()) {
for (CommonODataEntity entity : entitySet.getEntities()) {
final Integer key = entity.getProperty("OrderId").getPrimitiveValue().toCastValue(Integer.class);
final Integer customerId = entity.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class);
assertTrue(navigationKeys.contains(key));
@ -262,20 +265,22 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
}
// get a Customer entity to be created
public ODataEntity getNewCustomer(
public CommonODataEntity getNewCustomer(
final int id, final String name, final boolean withInlineInfo) {
final ODataEntity entity =
final CommonODataEntity entity =
client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
// add name attribute
entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Name",
getClient().getBinder().add(entity,
client.getObjectFactory().newPrimitiveProperty("Name",
client.getObjectFactory().newPrimitiveValueBuilder().setText(name).
setType(EdmPrimitiveTypeKind.String).build()));
// add key attribute
if (id != 0) {
entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
getClient().getBinder().add(entity,
client.getObjectFactory().newPrimitiveProperty("CustomerId",
client.getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)).
setType(EdmPrimitiveTypeKind.Int32).build()));
}
@ -319,8 +324,8 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
contactDetails.add(client.getObjectFactory().newComplexProperty("HomePhone", homePhone));
backupContactInfoValue.add(contactDetails);
entity.getProperties().add(client.getObjectFactory().newCollectionProperty("BackupContactInfo",
backupContactInfoValue));
getClient().getBinder().add(entity,
client.getObjectFactory().newCollectionProperty("BackupContactInfo", backupContactInfoValue));
if (withInlineInfo) {
final ODataInlineEntity inlineInfo = client.getObjectFactory().newInlineEntity("Info", URI.create(
"Customer(" + id
@ -333,7 +338,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
}
//delete an entity and associated links after creation
public void delete(final ODataPubFormat format, final ODataEntity created, final boolean includeInline,
public void delete(final ODataPubFormat format, final CommonODataEntity created, final boolean includeInline,
final String baseUri) {
final Set<URI> toBeDeleted = new HashSet<URI>();
toBeDeleted.add(created.getEditLink());
@ -341,15 +346,15 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
if (includeInline) {
for (ODataLink link : created.getNavigationLinks()) {
if (link instanceof ODataInlineEntity) {
final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
if (inline.getEditLink() != null) {
toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
}
}
if (link instanceof ODataInlineEntitySet) {
final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
for (ODataEntity entity : inline.getEntities()) {
final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
for (CommonODataEntity entity : inline.getEntities()) {
if (entity.getEditLink() != null) {
toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
}
@ -371,21 +376,21 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
}
// add Information property
public ODataEntity getInfo(final int id, final String info) {
final ODataEntity entity =
public CommonODataEntity getInfo(final int id, final String info) {
final CommonODataEntity entity =
client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
entity.setMediaEntity(true);
entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Information",
getClient().getBinder().add(entity, client.getObjectFactory().newPrimitiveProperty("Information",
client.getObjectFactory().newPrimitiveValueBuilder().setText(info).
setType(EdmPrimitiveTypeKind.String).build()));
return entity;
}
// validate newly created entities
public ODataEntity validateEntities(final String serviceRootURL,
public CommonODataEntity validateEntities(final String serviceRootURL,
final ODataPubFormat format,
final ODataEntity original,
final CommonODataEntity original,
final int actualObjectId,
final Collection<String> expands, final String entitySetName) {
@ -397,7 +402,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
uriBuilder.expand(expand);
}
}
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -438,10 +443,10 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
assertNotNull(foundActual);
if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
final ODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
final CommonODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
assertNotNull(originalInline);
final ODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
final CommonODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
assertNotNull(actualInline);
checkProperties(originalInline.getProperties(), actualInline.getProperties());
@ -451,22 +456,24 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
// compares properties of the newly created entity with the properties that were originally provided
@Override
public void checkProperties(final Collection<ODataProperty> original, final Collection<ODataProperty> actual) {
public void checkProperties(final Collection<? extends CommonODataProperty> original,
final Collection<? extends CommonODataProperty> actual) {
assertTrue(original.size() <= actual.size());
final Map<String, ODataProperty> actualProperties = new HashMap<String, ODataProperty>(actual.size());
final Map<String, CommonODataProperty> actualProperties = new HashMap<String, CommonODataProperty>(actual.size());
for (ODataProperty prop : actual) {
for (CommonODataProperty prop : actual) {
assertFalse(actualProperties.containsKey(prop.getName()));
actualProperties.put(prop.getName(), prop);
}
assertTrue(actual.size() <= actualProperties.size());
for (ODataProperty prop : original) {
for (CommonODataProperty prop : original) {
assertNotNull(prop);
if (actualProperties.containsKey(prop.getName())) {
final ODataProperty actualProp = actualProperties.get(prop.getName());
final CommonODataProperty actualProp = actualProperties.get(prop.getName());
assertNotNull(actualProp);
if (prop.getValue() != null && actualProp.getValue() != null) {
@ -488,13 +495,13 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
original.getClass().getSimpleName(), actual.getClass().getSimpleName());
if (original.isComplex()) {
final List<ODataProperty> originalPropertyValue = new ArrayList<ODataProperty>();
for (ODataProperty prop : original.asComplex()) {
final List<CommonODataProperty> originalPropertyValue = new ArrayList<CommonODataProperty>();
for (CommonODataProperty prop : original.asComplex()) {
originalPropertyValue.add(prop);
}
final List<ODataProperty> actualPropertyValue = new ArrayList<ODataProperty>();
for (ODataProperty prop : (ODataComplexValue) actual) {
final List<CommonODataProperty> actualPropertyValue = new ArrayList<CommonODataProperty>();
for (CommonODataProperty prop : (ODataComplexValue) actual) {
actualPropertyValue.add(prop);
}

View File

@ -29,7 +29,7 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateR
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.edm.Edm;
@ -61,14 +61,14 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
// assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
}
private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
private CommonODataEntity readRow(final ODataPubFormat format, final String uuid) {
final CommonURIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
return read(format, builder.build());
}
private void read(final ODataPubFormat format) {
ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
CommonODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
@ -91,32 +91,39 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
private void cud(final ODataPubFormat format) {
final UUID guid = UUID.randomUUID();
ODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row");
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Id",
CommonODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row");
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("Id",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Guid).setValue(guid).
build()));
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aString",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aString",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.String).setValue("string").
build()));
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aBoolean",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aBoolean",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Boolean).setValue(true).
build()));
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLong",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aLong",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Int64).setValue(15L).
build()));
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDouble",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aDouble",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Double).setValue(1.5D).
build()));
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aByte",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aByte",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE).
build()));
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDate",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aDate",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.DateTime).setValue(new Date()).
build()));
@ -124,26 +131,33 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
final Point point = new Point(Geospatial.Dimension.GEOGRAPHY, null);
point.setX(1.2);
point.setY(2.1);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPoint",
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aPoint",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint).
setValue(point).build()));
final List<Point> points = new ArrayList<Point>();
points.add(point);
points.add(point);
final MultiPoint multipoint = new MultiPoint(Geospatial.Dimension.GEOMETRY, null, points);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiPoint",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiPoint).
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aMultiPoint",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.GeometryMultiPoint).
setValue(multipoint).build()));
final LineString lineString = new LineString(Geospatial.Dimension.GEOMETRY, null, points);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLineString",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeometryLineString).
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aLineString",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.GeometryLineString).
setValue(lineString).build()));
final List<LineString> lineStrings = new ArrayList<LineString>();
lineStrings.add(lineString);
lineStrings.add(lineString);
final MultiLineString multiLineString = new MultiLineString(Geospatial.Dimension.GEOGRAPHY, null, lineStrings);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiLineString",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiLineString).
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aMultiLineString",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.GeometryMultiLineString).
setValue(multiLineString).build()));
final Point otherPoint = new Point(Geospatial.Dimension.GEOGRAPHY, null);
otherPoint.setX(3.4);
@ -152,15 +166,19 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
points.add(otherPoint);
points.add(point);
final Polygon polygon = new Polygon(Geospatial.Dimension.GEOGRAPHY, null, points, points);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPolygon",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPolygon).
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aPolygon",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.GeographyPolygon).
setValue(polygon).build()));
final List<Polygon> polygons = new ArrayList<Polygon>();
polygons.add(polygon);
polygons.add(polygon);
final MultiPolygon multiPolygon = new MultiPolygon(Geospatial.Dimension.GEOGRAPHY, null, polygons);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiPolygon",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyMultiPolygon).
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aMultiPolygon",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.GeographyMultiPolygon).
setValue(multiPolygon).build()));
final List<Geospatial> geospatials = new ArrayList<Geospatial>();
geospatials.add(otherPoint);
@ -168,8 +186,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
geospatials.add(multiLineString);
geospatials.add(multiPolygon);
final GeospatialCollection geoColl = new GeospatialCollection(Geospatial.Dimension.GEOGRAPHY, null, geospatials);
row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aCollection",
client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyCollection).
getClient().getBinder().add(row,
client.getObjectFactory().newPrimitiveProperty("aCollection",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.GeographyCollection).
setValue(geoColl).build()));
final ODataComplexValue contactDetails = client.getObjectFactory().newComplexValue(
@ -210,7 +230,8 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Long",
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Int64).setValue(Long.MAX_VALUE).build()));
row.getProperties().add(client.getObjectFactory().newComplexProperty("aContact", contactDetails));
getClient().getBinder().add(row,
client.getObjectFactory().newComplexProperty("aContact", contactDetails));
final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().
getEntityCreateRequest(client.getURIBuilder(testStaticServiceRootURL).

View File

@ -25,21 +25,23 @@ import java.math.BigDecimal;
import java.util.UUID;
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.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.junit.Test;
public class PrimitiveKeysTestITCase extends AbstractTestITCase {
private void readEntity(final String entityType, final Object key, final ODataPubFormat format) {
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(
client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType).
appendKeySegment(key).
build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
final ODataEntity entity = res.getBody();
final CommonODataEntity entity = res.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperty("Id"));
}

View File

@ -18,25 +18,26 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.List;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
public class PropertyRetrieveTestITCase extends AbstractTestITCase {
@ -44,7 +45,8 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase {
private void retreivePropertyTest(final ODataFormat format, String entitySegment, String structuralSegment) {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment(entitySegment).appendPropertySegment(structuralSegment);
final ODataPropertyRequest req = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
req.setFormat(format);
try {
final ODataProperty property = req.execute().getBody();
@ -210,13 +212,14 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase {
public void navigationMediaLink() {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photos");
ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setAccept("application/json");
ODataRetrieveResponse<ODataEntitySet> res = req.execute();
assertEquals(200, res.getStatusCode());
ODataEntitySet entitySet = res.getBody();
CommonODataEntitySet entitySet = res.getBody();
assertNotNull(entitySet);
List<ODataEntity> entity = entitySet.getEntities();
List<? extends CommonODataEntity> entity = entitySet.getEntities();
assertNotNull(entity);
assertEquals(entity.size(), 2);
assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-3,ProductId=-3)",
@ -233,14 +236,15 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase {
public void navigationMediaLinkInvalidQuery() {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photo");
ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setAccept("application/json");
try {
ODataRetrieveResponse<ODataEntitySet> res = req.execute();
assertEquals(200, res.getStatusCode());
ODataEntitySet entitySet = res.getBody();
CommonODataEntitySet entitySet = res.getBody();
assertNotNull(entitySet);
List<ODataEntity> entity = entitySet.getEntities();
List<? extends CommonODataEntity> entity = entitySet.getEntities();
assertNotNull(entity);
assertEquals(entity.size(), 2);
assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-3,ProductId=-3)", entity.get(0).
@ -256,7 +260,8 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase {
public void navigationMediaLinkInvalidFormat() {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photos");
ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setAccept("application/atom+xml");
try {
ODataRetrieveResponse<ODataEntitySet> res = req.execute();

View File

@ -18,10 +18,6 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
@ -35,15 +31,19 @@ import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateRe
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
@ -206,7 +206,8 @@ public class PropertyTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customer").appendKeySegment(-9).appendPropertySegment("PrimaryContactInfo");
ODataPropertyRequest retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
ODataPropertyRequest<ODataProperty> retrieveReq = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
retrieveReq.setFormat(format);
ODataRetrieveResponse<ODataProperty> retrieveRes = retrieveReq.execute();
@ -253,7 +254,8 @@ public class PropertyTestITCase extends AbstractTestITCase {
uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(-9).
appendPropertySegment("PrimaryContactInfo").appendPropertySegment("AlternativeNames");
ODataPropertyRequest retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
ODataPropertyRequest<ODataProperty> retrieveReq = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
retrieveReq.setFormat(format);
ODataRetrieveResponse<ODataProperty> retrieveRes = retrieveReq.execute();
@ -301,13 +303,14 @@ public class PropertyTestITCase extends AbstractTestITCase {
appendPropertySegment("PrimaryContactInfo").
appendPropertySegment("HomePhone").appendPropertySegment("PhoneNumber");
ODataPropertyRequest retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
ODataPropertyRequest<ODataProperty> retrieveReq = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
retrieveReq.setFormat(format);
ODataRetrieveResponse<ODataProperty> retrieveRes = retrieveReq.execute();
assertEquals(200, retrieveRes.getStatusCode());
ODataProperty phoneNumber = retrieveRes.getBody();
CommonODataProperty phoneNumber = retrieveRes.getBody();
final String oldMsg = phoneNumber.getPrimitiveValue().toCastValue(String.class);
final String newMsg = "new item " + System.currentTimeMillis();
@ -349,7 +352,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ODataProperty property = res.getBodyAs(ODataProperty.class);
final CommonODataProperty property = res.getBodyAs(CommonODataProperty.class);
assertNotNull(property);
}
}

View File

@ -18,16 +18,16 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.*;
import java.io.IOException;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import static org.junit.Assert.*;
import org.junit.Test;
public class PropertyValueTestITCase extends AbstractTestITCase {
@ -96,7 +96,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
public void retrieveBinaryPropertyValueTest() throws IOException {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendNavigationSegment("ProductPhoto(PhotoId=-3,ProductId=-3)").appendPropertySegment("Photo");
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setAccept("application/json");
ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
@ -111,7 +111,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
public void retrieveBinaryPropertyValueTestWithAtom() throws IOException {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendNavigationSegment("ProductPhoto(PhotoId=-3,ProductId=-3)").appendPropertySegment("Photo");
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setAccept("application/atom+xml");
ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
@ -126,7 +126,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
public void retrieveBinaryPropertyValueTestWithXML() throws IOException {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendNavigationSegment("ProductPhoto(PhotoId=-3,ProductId=-3)").appendPropertySegment("Photo");
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setAccept("application/xml");
ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());

View File

@ -18,25 +18,26 @@
*/
package org.apache.olingo.client.core.it.v3;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
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.Entry;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.api.uri.v3.URIBuilder.InlineCount;
import org.apache.olingo.commons.core.data.AtomEntryImpl;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.core.data.AtomEntryImpl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
@ -64,14 +65,15 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Car").filter("(VIN lt 16)");
// 1. check that filtered entity set looks as expected
ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(5, feed.getEntities().size());
// 2. extract VIN values - sorted ASC by default
final List<Integer> vinsASC = new ArrayList<Integer>(5);
for (ODataEntity entity : feed.getEntities()) {
for (CommonODataEntity entity : feed.getEntities()) {
final Integer vin = entity.getProperty("VIN").getPrimitiveValue().toCastValue(Integer.class);
assertTrue(vin < 16);
vinsASC.add(vin);
@ -85,7 +87,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
// 4. extract again VIN value - now they were required to be sorted DESC
final List<Integer> vinsDESC = new ArrayList<Integer>(5);
for (ODataEntity entity : feed.getEntities()) {
for (CommonODataEntity entity : feed.getEntities()) {
vinsDESC.add(entity.getProperty("VIN").getPrimitiveValue().toCastValue(Integer.class));
}
@ -102,7 +104,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customer").appendKeySegment(-10).format("json");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.ATOM);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -137,7 +139,8 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("Customer").skipToken("-10");
final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
final ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(2, feed.getEntities().size());
@ -155,7 +158,8 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").
inlineCount(InlineCount.allpages);
final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.ATOM);
final ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
@ -170,7 +174,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customer").appendKeySegment(-10).select("CustomerId,Orders").expand("Orders");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntity customer = req.execute().getBody();
assertEquals(1, customer.getProperties().size());
assertEquals(1, customer.getNavigationLinks().size());
@ -182,7 +186,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customer").appendKeySegment(-7).select("Name");
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.ATOM);
final ODataEntity customer = req.execute().getBody();

View File

@ -19,11 +19,6 @@
package org.apache.olingo.client.core.it.v4;
import java.net.URI;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.LinkedHashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
@ -31,17 +26,24 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import static org.apache.olingo.client.core.it.v4.AbstractTestITCase.client;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import static org.apache.olingo.client.core.it.v4.AbstractTestITCase.client;
import org.apache.olingo.commons.core.op.ResourceFactory;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.core.op.ResourceFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
@ -58,11 +60,12 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final CommonODataEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("#Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getName());
@ -75,13 +78,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntity) {
final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
assertNotNull(inline);
debugEntry(client.getBinder().getEntry(
inline, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
final List<ODataProperty> properties = inline.getProperties();
final List<? extends CommonODataProperty> properties = inline.getProperties();
assertEquals(5, properties.size());
assertTrue(properties.get(0).getName().equals("CompanyID")
@ -118,18 +121,19 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final CommonODataEntity entity = res.getBody();
assertNotNull(entity);
boolean found = false;
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntitySet) {
final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
assertNotNull(inline);
debugFeed(client.getBinder().getFeed(inline, ResourceFactory.feedClassForFormat(
@ -191,11 +195,11 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey);
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final CommonODataEntity entity = res.getBody();
assertNotNull(entity);
assertEquals(Integer.valueOf(1),
entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class));
@ -227,7 +231,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder =
client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Orders").appendKeySegment(8);
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
@ -236,7 +240,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final String etag = res.getEtag();
assertTrue(StringUtils.isNotBlank(etag));
final ODataEntity order = res.getBody();
final CommonODataEntity order = res.getBody();
assertEquals(etag, order.getETag());
}
@ -245,7 +249,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
public void issue99() {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Car");
final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.JSON);
// this statement should cause an IllegalArgumentException bearing JsonParseException
@ -269,7 +273,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
appendRefSegment();
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
ODataRetrieveResponse<ODataEntity> res = req.execute();

View File

@ -18,10 +18,6 @@
*/
package org.apache.olingo.client.core.it.v4;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
@ -32,9 +28,14 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.core.op.ResourceFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
@ -96,11 +97,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
uriBuilder.appendEntitySetSegment("People");
final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
final ODataEntitySet feed = res.getBody();
final CommonODataEntitySet feed = res.getBody();
assertNotNull(feed);
@ -151,7 +153,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ODataEntitySet entitySet = res.getBodyAs(ODataEntitySet.class);
final CommonODataEntitySet entitySet = res.getBodyAs(CommonODataEntitySet.class);
assertNotNull(entitySet);
assertTrue(res.getContextURL().toASCIIString().endsWith("$metadata#People"));
}

View File

@ -18,20 +18,20 @@
*/
package org.apache.olingo.client.core.it.v4;
import static org.junit.Assert.*;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import static org.junit.Assert.*;
import org.junit.Test;
public class PropertyValueTestITCase extends AbstractTestITCase {
@ -124,7 +124,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
public void retrieveCollectionPropertyValueTest() {
CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
final ODataPropertyRequest req = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
req.setFormat(ODataFormat.XML);
final ODataProperty property = req.execute().getBody();
assertTrue(property.getValue().isCollection());

View File

@ -24,7 +24,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.InputStream;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.commons.core.op.ResourceFactory;
@ -39,14 +39,14 @@ public class EntitySetTest extends AbstractTest {
private void read(final ODataPubFormat format) throws IOException {
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
final CommonODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
getClient().getDeserializer().toFeed(input, format).getObject());
assertNotNull(entitySet);
assertEquals(2, entitySet.getEntities().size());
assertNotNull(entitySet.getNext());
final ODataEntitySet written = getClient().getBinder().getODataEntitySet(getClient().
final CommonODataEntitySet written = getClient().getBinder().getODataEntitySet(getClient().
getBinder().getFeed(entitySet, ResourceFactory.feedClassForFormat(format == ODataPubFormat.ATOM)));
assertEquals(entitySet, written);
}

View File

@ -24,9 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
@ -45,7 +45,7 @@ public class EntityTest extends AbstractTest {
private void readAndWrite(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("Customer_-10." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
final CommonODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer().toEntry(input, format).getObject());
assertNotNull(entity);
@ -64,7 +64,7 @@ public class EntityTest extends AbstractTest {
assertTrue(check);
final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
final CommonODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
assertEquals(entity, written);
}
@ -81,12 +81,12 @@ public class EntityTest extends AbstractTest {
private void readGeospatial(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-8." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
final CommonODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer().toEntry(input, format).getObject());
assertNotNull(entity);
boolean found = false;
for (ODataProperty property : entity.getProperties()) {
for (CommonODataProperty property : entity.getProperties()) {
if ("GeogMultiLine".equals(property.getName())) {
found = true;
assertTrue(property.hasPrimitiveValue());
@ -95,7 +95,7 @@ public class EntityTest extends AbstractTest {
}
assertTrue(found);
final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
final CommonODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
assertEquals(entity, written);
}
@ -113,14 +113,14 @@ public class EntityTest extends AbstractTest {
private void withActions(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("ComputerDetail_-10." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
final CommonODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer().toEntry(input, format).getObject());
assertNotNull(entity);
assertEquals(1, entity.getOperations().size());
assertEquals("ResetComputerDetailsSpecifications", entity.getOperations().get(0).getTitle());
final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
final CommonODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
entity.getOperations().clear();
assertEquals(entity, written);
@ -139,14 +139,14 @@ public class EntityTest extends AbstractTest {
private void mediaEntity(final ODataPubFormat format) {
final InputStream input = getClass().getResourceAsStream("Car_16." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
final CommonODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer().toEntry(input, format).getObject());
assertNotNull(entity);
assertTrue(entity.isMediaEntity());
assertNotNull(entity.getMediaContentSource());
assertNotNull(entity.getMediaContentType());
final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
final CommonODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
assertEquals(entity, written);
}
@ -163,11 +163,11 @@ public class EntityTest extends AbstractTest {
private void issue128(final ODataPubFormat format) throws EdmPrimitiveTypeException {
final InputStream input = getClass().getResourceAsStream("AllGeoTypesSet_-5." + getSuffix(format));
final ODataEntity entity = getClient().getBinder().getODataEntity(
final CommonODataEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer().toEntry(input, format).getObject());
assertNotNull(entity);
final ODataProperty geogCollection = entity.getProperty("GeogCollection");
final CommonODataProperty geogCollection = entity.getProperty("GeogCollection");
assertEquals(EdmPrimitiveTypeKind.GeographyCollection, geogCollection.getPrimitiveValue().getTypeKind());
int count = 0;

View File

@ -31,7 +31,7 @@ import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
@ -57,15 +57,15 @@ public class PropertyTest extends AbstractTest {
assertEquals("-10", value.toString());
}
private ODataProperty primitive(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
private CommonODataProperty primitive(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
final InputStream input = getClass().getResourceAsStream("Customer_-10_CustomerId." + getSuffix(format));
final ODataProperty property = getClient().getReader().readProperty(input, format);
final CommonODataProperty property = getClient().getReader().readProperty(input, format);
assertNotNull(property);
assertTrue(property.hasPrimitiveValue());
assertTrue(-10 == property.getPrimitiveValue().toCastValue(Integer.class));
ODataProperty comparable;
final ODataProperty written = getClient().getReader().readProperty(
CommonODataProperty comparable;
final CommonODataProperty written = getClient().getReader().readProperty(
getClient().getWriter().writeProperty(property, format), format);
if (format == ODataFormat.XML) {
comparable = written;
@ -93,15 +93,15 @@ public class PropertyTest extends AbstractTest {
primitive(ODataFormat.JSON);
}
private ODataProperty complex(final ODataFormat format) throws IOException {
private CommonODataProperty complex(final ODataFormat format) throws IOException {
final InputStream input = getClass().getResourceAsStream("Customer_-10_PrimaryContactInfo." + getSuffix(format));
final ODataProperty property = getClient().getReader().readProperty(input, format);
final CommonODataProperty property = getClient().getReader().readProperty(input, format);
assertNotNull(property);
assertTrue(property.hasComplexValue());
assertEquals(6, property.getComplexValue().size());
ODataProperty comparable;
final ODataProperty written = getClient().getReader().readProperty(
CommonODataProperty comparable;
final CommonODataProperty written = getClient().getReader().readProperty(
getClient().getWriter().writeProperty(property, format), format);
if (format == ODataFormat.XML) {
comparable = written;
@ -109,8 +109,8 @@ public class PropertyTest extends AbstractTest {
// This is needed because type information gets lost with JSON serialization
final ODataComplexValue typedValue = getClient().getObjectFactory().
newComplexValue(property.getComplexValue().getTypeName());
for (final Iterator<ODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
final ODataProperty prop = itor.next();
for (final Iterator<CommonODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
final CommonODataProperty prop = itor.next();
typedValue.add(prop);
}
comparable = getClient().getObjectFactory().newComplexProperty(written.getName(), typedValue);
@ -131,15 +131,15 @@ public class PropertyTest extends AbstractTest {
complex(ODataFormat.JSON);
}
private ODataProperty collection(final ODataFormat format) throws IOException {
private CommonODataProperty collection(final ODataFormat format) throws IOException {
final InputStream input = getClass().getResourceAsStream("Customer_-10_BackupContactInfo." + getSuffix(format));
final ODataProperty property = getClient().getReader().readProperty(input, format);
final CommonODataProperty property = getClient().getReader().readProperty(input, format);
assertNotNull(property);
assertTrue(property.hasCollectionValue());
assertEquals(9, property.getCollectionValue().size());
ODataProperty comparable;
final ODataProperty written = getClient().getReader().readProperty(
CommonODataProperty comparable;
final CommonODataProperty written = getClient().getReader().readProperty(
getClient().getWriter().writeProperty(property, format), format);
if (format == ODataFormat.XML) {
comparable = written;

View File

@ -24,7 +24,7 @@ import java.util.List;
/**
* OData entity.
*/
public interface ODataEntity extends ODataInvokeResult {
public interface CommonODataEntity extends ODataInvokeResult {
String getName();
@ -65,14 +65,14 @@ public interface ODataEntity extends ODataInvokeResult {
* @param name property to look for
* @return property if found with given name, <tt>null</tt> otherwise
*/
ODataProperty getProperty(String name);
CommonODataProperty getProperty(String name);
/**
* Returns OData entity properties.
*
* @return OData entity properties.
*/
List<ODataProperty> getProperties();
List<? extends CommonODataProperty> getProperties();
/**
* Puts the given link into one of available lists, based on its type.
@ -174,24 +174,4 @@ public interface ODataEntity extends ODataInvokeResult {
*/
void setMediaContentSource(String mediaContentSource);
/**
* To request entity references in place of the actual entities, the client issues a GET request with /$ref appended
* to the resource path.
* <br />
* If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found.
* <br />
* If the resource path terminates on a collection, the response MUST be the format-specific representation of a
* collection of entity references pointing to the related entities. If no entities are related, the response is the
* format-specific representation of an empty collection.
* <br />
* If the resource path terminates on a single entity, the response MUST be the format-specific representation of an
* entity reference pointing to the related single entity. If the resource path terminates on a single entity and no
* such entity exists, the service returns 404 Not Found.
*
* @return entity reference.
*/
String getReference();
void setReference(String reference);
}

View File

@ -24,7 +24,7 @@ import java.util.List;
/**
* OData entity collection. If pagination was used to get this instance, forward page navigation URI will be available.
*/
public interface ODataEntitySet extends ODataInvokeResult {
public interface CommonODataEntitySet extends ODataInvokeResult {
/**
* Gets next page link.
@ -38,7 +38,7 @@ public interface ODataEntitySet extends ODataInvokeResult {
*
* @return feed entries.
*/
List<ODataEntity> getEntities();
List<? extends CommonODataEntity> getEntities();
/**
* Gets in-line count.

View File

@ -23,14 +23,14 @@ import java.net.URI;
/**
* Entry point for generating OData domain objects.
*/
public interface ODataObjectFactory {
public interface CommonODataObjectFactory {
/**
* Instantiates a new entity set.
*
* @return entity set.
*/
ODataEntitySet newEntitySet();
CommonODataEntitySet newEntitySet();
/**
* Instantiates a new entity set.
@ -38,7 +38,7 @@ public interface ODataObjectFactory {
* @param next next link.
* @return entity set.
*/
ODataEntitySet newEntitySet(URI next);
CommonODataEntitySet newEntitySet(URI next);
/**
* Instantiates a new entity.
@ -46,7 +46,7 @@ public interface ODataObjectFactory {
* @param name OData entity name.
* @return entity.
*/
ODataEntity newEntity(String name);
CommonODataEntity newEntity(String name);
/**
* Instantiates a new entity.
@ -55,7 +55,7 @@ public interface ODataObjectFactory {
* @param link self link.
* @return entity.
*/
ODataEntity newEntity(String name, URI link);
CommonODataEntity newEntity(String name, URI link);
/**
* Instantiates a new in-line entity set.
@ -65,7 +65,7 @@ public interface ODataObjectFactory {
* @param entitySet entity set.
* @return in-line entity set.
*/
ODataInlineEntitySet newInlineEntitySet(String name, URI link, ODataEntitySet entitySet);
ODataInlineEntitySet newInlineEntitySet(String name, URI link, CommonODataEntitySet entitySet);
/**
* Instantiates a new in-line entity set.
@ -76,7 +76,7 @@ public interface ODataObjectFactory {
* @param entitySet entity set.
* @return in-line entity set.
*/
ODataInlineEntitySet newInlineEntitySet(String name, URI baseURI, String href, ODataEntitySet entitySet);
ODataInlineEntitySet newInlineEntitySet(String name, URI baseURI, String href, CommonODataEntitySet entitySet);
/**
* Instantiates a new in-line entity.
@ -86,7 +86,7 @@ public interface ODataObjectFactory {
* @param entity entity.
* @return in-line entity.
*/
ODataInlineEntity newInlineEntity(String name, URI link, ODataEntity entity);
ODataInlineEntity newInlineEntity(String name, URI link, CommonODataEntity entity);
/**
* Instantiates a new in-line entity.
@ -97,7 +97,7 @@ public interface ODataObjectFactory {
* @param entity entity.
* @return in-line entity.
*/
ODataInlineEntity newInlineEntity(String name, URI baseURI, String href, ODataEntity entity);
ODataInlineEntity newInlineEntity(String name, URI baseURI, String href, CommonODataEntity entity);
/**
* Instantiates a new entity navigation link.
@ -188,7 +188,7 @@ public interface ODataObjectFactory {
* @param value primitive value.
* @return primitive property.
*/
ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
CommonODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
/**
* Instantiates a new complex property.
@ -197,7 +197,7 @@ public interface ODataObjectFactory {
* @param value value.
* @return complex property.
*/
ODataProperty newComplexProperty(String name, ODataComplexValue value);
CommonODataProperty newComplexProperty(String name, ODataComplexValue value);
/**
* Instantiates a new collection property.
@ -206,5 +206,5 @@ public interface ODataObjectFactory {
* @param value value.
* @return collection property.
*/
ODataProperty newCollectionProperty(String name, ODataCollectionValue value);
CommonODataProperty newCollectionProperty(String name, ODataCollectionValue value);
}

View File

@ -23,7 +23,7 @@ import java.io.Serializable;
/**
* OData entity property.
*/
public interface ODataProperty extends ODataInvokeResult, Serializable {
public interface CommonODataProperty extends ODataInvokeResult, Serializable {
/**
* Returns property name.

View File

@ -21,14 +21,14 @@ package org.apache.olingo.commons.api.domain;
/**
* OData complex property value.
*/
public interface ODataComplexValue extends ODataValue, Iterable<ODataProperty> {
public interface ODataComplexValue extends ODataValue, Iterable<CommonODataProperty> {
/**
* Adds field to the complex type.
*
* @param field field to be added.
*/
void add(ODataProperty field);
void add(CommonODataProperty field);
/**
* Gets field.
@ -36,7 +36,7 @@ public interface ODataComplexValue extends ODataValue, Iterable<ODataProperty> {
* @param name name of the field to be retrieved.
* @return requested field.
*/
ODataProperty get(String name);
CommonODataProperty get(String name);
/**
* Gets number of fields.

View File

@ -28,7 +28,7 @@ public class ODataInlineEntity extends ODataLink {
private static final long serialVersionUID = -4763341581843700743L;
private final ODataEntity entity;
private final CommonODataEntity entity;
/**
* Constructor.
@ -40,7 +40,7 @@ public class ODataInlineEntity extends ODataLink {
* @param entity entity.
*/
public ODataInlineEntity(final ODataServiceVersion version,
final URI uri, final ODataLinkType type, final String title, final ODataEntity entity) {
final URI uri, final ODataLinkType type, final String title, final CommonODataEntity entity) {
super(version, uri, type, title);
this.entity = entity;
@ -57,7 +57,7 @@ public class ODataInlineEntity extends ODataLink {
* @param entity entity.
*/
public ODataInlineEntity(final ODataServiceVersion version, final URI baseURI, final String href,
final ODataLinkType type, final String title, final ODataEntity entity) {
final ODataLinkType type, final String title, final CommonODataEntity entity) {
super(version, baseURI, href, type, title);
this.entity = entity;
@ -68,7 +68,7 @@ public class ODataInlineEntity extends ODataLink {
*
* @return wrapped entity.
*/
public ODataEntity getEntity() {
public CommonODataEntity getEntity() {
return entity;
}
}

View File

@ -28,7 +28,7 @@ public class ODataInlineEntitySet extends ODataLink {
private static final long serialVersionUID = -77628001615355449L;
private ODataEntitySet entitySet;
private CommonODataEntitySet entitySet;
/**
* Constructor.
@ -40,7 +40,7 @@ public class ODataInlineEntitySet extends ODataLink {
* @param entitySet entity set.
*/
public ODataInlineEntitySet(final ODataServiceVersion version, final URI uri, final ODataLinkType type,
final String title, final ODataEntitySet entitySet) {
final String title, final CommonODataEntitySet entitySet) {
super(version, uri, type, title);
this.entitySet = entitySet;
@ -57,7 +57,7 @@ public class ODataInlineEntitySet extends ODataLink {
* @param entitySet entity set.
*/
public ODataInlineEntitySet(final ODataServiceVersion version, final URI baseURI, final String href,
final ODataLinkType type, final String title, final ODataEntitySet entitySet) {
final ODataLinkType type, final String title, final CommonODataEntitySet entitySet) {
super(version, baseURI, href, type, title);
this.entitySet = entitySet;
@ -68,7 +68,7 @@ public class ODataInlineEntitySet extends ODataLink {
*
* @return wrapped entity set.
*/
public ODataEntitySet getEntitySet() {
public CommonODataEntitySet getEntitySet() {
return entitySet;
}
}

View File

@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v3;
import java.util.List;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
public interface ODataEntity extends CommonODataEntity {
@Override
ODataProperty getProperty(String name);
@Override
List<ODataProperty> getProperties();
}

View File

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v3;
import java.util.List;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
public interface ODataEntitySet extends CommonODataEntitySet {
@Override
List<ODataEntity> getEntities();
}

View File

@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v3;
import java.net.URI;
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
public interface ODataObjectFactory extends CommonODataObjectFactory {
@Override
ODataEntitySet newEntitySet();
@Override
ODataEntitySet newEntitySet(URI next);
@Override
ODataEntity newEntity(String name);
@Override
ODataEntity newEntity(String name, URI link);
@Override
ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
@Override
ODataProperty newComplexProperty(String name, ODataComplexValue value);
@Override
ODataProperty newCollectionProperty(String name, ODataCollectionValue value);
}

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v3;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
public interface ODataProperty extends CommonODataProperty {
}

View File

@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v4;
import java.util.List;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
public interface ODataEntity extends CommonODataEntity {
@Override
ODataProperty getProperty(String name);
@Override
List<ODataProperty> getProperties();
/**
* To request entity references in place of the actual entities, the client issues a GET request with /$ref appended
* to the resource path.
* <br />
* If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found.
* <br />
* If the resource path terminates on a collection, the response MUST be the format-specific representation of a
* collection of entity references pointing to the related entities. If no entities are related, the response is the
* format-specific representation of an empty collection.
* <br />
* If the resource path terminates on a single entity, the response MUST be the format-specific representation of an
* entity reference pointing to the related single entity. If the resource path terminates on a single entity and no
* such entity exists, the service returns 404 Not Found.
*
* @return entity reference.
*/
String getReference();
void setReference(String reference);
}

View File

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v4;
import java.util.List;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
public interface ODataEntitySet extends CommonODataEntitySet {
@Override
List<ODataEntity> getEntities();
}

View File

@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v4;
public interface ODataEnumValue extends ODataValue {
String getValue();
}

View File

@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v4;
import java.net.URI;
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
public interface ODataObjectFactory extends CommonODataObjectFactory {
@Override
ODataEntitySet newEntitySet();
@Override
ODataEntitySet newEntitySet(URI next);
@Override
ODataEntity newEntity(String name);
@Override
ODataEntity newEntity(String name, URI link);
@Override
ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
ODataProperty newEnumProperty(String name, ODataEnumValue value);
@Override
ODataProperty newComplexProperty(String name, ODataComplexValue value);
@Override
ODataProperty newCollectionProperty(String name, ODataCollectionValue value);
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v4;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
public interface ODataProperty extends CommonODataProperty {
/**
* Checks if has enum value.
*
* @return 'TRUE' if has enum value; 'FALSE' otherwise.
*/
boolean hasEnumValue();
/**
* Gets enum value.
*
* @return enum value if exists; null otherwise.
*/
ODataEnumValue getEnumValue();
}

View File

@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.domain.v4;
public interface ODataValue extends org.apache.olingo.commons.api.domain.ODataValue {
/**
* Check is is an enum value.
*
* @return 'TRUE' if enum; 'FALSE' otherwise.
*/
boolean isEnum();
/**
* Casts to enum value.
*
* @return enum value.
*/
ODataEnumValue asEnum();
}

View File

@ -23,23 +23,18 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.domain.AbstractODataPayload;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataOperation;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData entity.
*/
public class ODataEntityImpl extends AbstractODataPayload implements ODataEntity {
public abstract class AbstractODataEntity extends AbstractODataPayload implements CommonODataEntity {
private static final long serialVersionUID = 8360640095932811034L;
/**
* Entity reference.
*/
private String reference;
/**
* ETag.
*/
@ -85,46 +80,15 @@ public class ODataEntityImpl extends AbstractODataPayload implements ODataEntity
*/
private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
/**
* Entity properties.
*/
private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
/**
* Constructor.
*
* @param name OData entity name.
*/
public ODataEntityImpl(final String name) {
public AbstractODataEntity(final String name) {
super(name);
}
/**
* To request entity references in place of the actual entities, the client issues a GET request with /$ref appended
* to the resource path.
* <br />
* If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found.
* <br />
* If the resource path terminates on a collection, the response MUST be the format-specific representation of a
* collection of entity references pointing to the related entities. If no entities are related, the response is the
* format-specific representation of an empty collection.
* <br />
* If the resource path terminates on a single entity, the response MUST be the format-specific representation of an
* entity reference pointing to the related single entity. If the resource path terminates on a single entity and no
* such entity exists, the service returns 404 Not Found.
*
* @return entity reference.
*/
@Override
public String getReference() {
return reference;
}
@Override
public void setReference(final String reference) {
this.reference = reference;
}
/**
* Gets ETag.
*
@ -180,11 +144,11 @@ public class ODataEntityImpl extends AbstractODataPayload implements ODataEntity
* @return property if found with given name, <tt>null</tt> otherwise
*/
@Override
public ODataProperty getProperty(final String name) {
ODataProperty result = null;
public CommonODataProperty getProperty(final String name) {
CommonODataProperty result = null;
if (StringUtils.isNotBlank(name)) {
for (ODataProperty property : properties) {
for (CommonODataProperty property : getProperties()) {
if (name.equals(property.getName())) {
result = property;
}
@ -194,16 +158,6 @@ public class ODataEntityImpl extends AbstractODataPayload implements ODataEntity
return result;
}
/**
* Returns OData entity properties.
*
* @return OData entity properties.
*/
@Override
public List<ODataProperty> getProperties() {
return properties;
}
/**
* Puts the given link into one of available lists, based on its type.
*

View File

@ -19,13 +19,10 @@
package org.apache.olingo.commons.core.domain;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.domain.AbstractODataPayload;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
public class ODataEntitySetImpl extends AbstractODataPayload implements ODataEntitySet {
public abstract class AbstractODataEntitySet extends AbstractODataPayload implements CommonODataEntitySet {
private static final long serialVersionUID = 9039605899821494024L;
@ -40,15 +37,10 @@ public class ODataEntitySetImpl extends AbstractODataPayload implements ODataEnt
*/
private Integer count;
/**
* OData entities contained in this feed.
*/
private List<ODataEntity> entities = new ArrayList<ODataEntity>();
/**
* Constructor.
*/
public ODataEntitySetImpl() {
public AbstractODataEntitySet() {
super(null);
}
@ -57,46 +49,23 @@ public class ODataEntitySetImpl extends AbstractODataPayload implements ODataEnt
*
* @param next next link.
*/
public ODataEntitySetImpl(final URI next) {
public AbstractODataEntitySet(final URI next) {
super(null);
this.next = next;
}
/**
* Gets next page link.
*
* @return next page link; null value if single page or last page reached.
*/
@Override
public URI getNext() {
return next;
}
/**
* Gets contained entities.
*
* @return feed entries.
*/
@Override
public List<ODataEntity> getEntities() {
return entities;
}
protected abstract int getEntitiesSize();
/**
* Gets in-line count.
*
* @return in-line count value.
*/
@Override
public int getCount() {
return count == null ? entities.size() : count;
return count == null ? getEntitiesSize() : count;
}
/**
* Sets in-line count.
*
* @param count in-line count value.
*/
@Override
public void setCount(final int count) {
this.count = count;

View File

@ -22,70 +22,47 @@ import java.net.URI;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class ODataObjectFactoryImpl implements ODataObjectFactory {
public abstract class AbstractODataObjectFactory implements CommonODataObjectFactory {
private static final long serialVersionUID = -3769695665946919447L;
protected final ODataServiceVersion version;
public ODataObjectFactoryImpl(final ODataServiceVersion version) {
public AbstractODataObjectFactory(final ODataServiceVersion version) {
this.version = version;
}
@Override
public ODataEntitySet newEntitySet() {
return new ODataEntitySetImpl();
}
@Override
public ODataEntitySet newEntitySet(final URI next) {
return new ODataEntitySetImpl(next);
}
@Override
public ODataEntity newEntity(final String name) {
return new ODataEntityImpl(name);
}
@Override
public ODataEntity newEntity(final String name, final URI link) {
final ODataEntityImpl result = new ODataEntityImpl(name);
result.setLink(link);
return result;
}
@Override
public ODataInlineEntitySet newInlineEntitySet(final String name, final URI link,
final ODataEntitySet entitySet) {
final CommonODataEntitySet entitySet) {
return new ODataInlineEntitySet(version, link, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
}
@Override
public ODataInlineEntitySet newInlineEntitySet(final String name, final URI baseURI, final String href,
final ODataEntitySet entitySet) {
final CommonODataEntitySet entitySet) {
return new ODataInlineEntitySet(version, baseURI, href, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
}
@Override
public ODataInlineEntity newInlineEntity(final String name, final URI link, final ODataEntity entity) {
public ODataInlineEntity newInlineEntity(final String name, final URI link, final CommonODataEntity entity) {
return new ODataInlineEntity(version, link, ODataLinkType.ENTITY_NAVIGATION, name, entity);
}
@Override
public ODataInlineEntity newInlineEntity(final String name, final URI baseURI, final String href,
final ODataEntity entity) {
final CommonODataEntity entity) {
return new ODataInlineEntity(version, baseURI, href, ODataLinkType.ENTITY_NAVIGATION, name, entity);
}
@ -153,19 +130,4 @@ public class ODataObjectFactoryImpl implements ODataObjectFactory {
return new ODataCollectionValueImpl(typeName);
}
@Override
public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
return new ODataPropertyImpl(name, value);
}
}

View File

@ -25,13 +25,10 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
/**
* OData entity property.
*/
public class ODataPropertyImpl implements ODataProperty {
public abstract class AbstractODataProperty implements CommonODataProperty {
private static final long serialVersionUID = 926939448778950450L;
@ -43,7 +40,7 @@ public class ODataPropertyImpl implements ODataProperty {
/**
* Property value.
*/
private ODataValue value;
private final ODataValue value;
/**
* Constructor.
@ -51,7 +48,7 @@ public class ODataPropertyImpl implements ODataProperty {
* @param name property name.
* @param value property value.
*/
public ODataPropertyImpl(final String name, final ODataValue value) {
public AbstractODataProperty(final String name, final ODataValue value) {
this.name = name;
this.value = value;
}

View File

@ -23,7 +23,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.olingo.commons.api.domain.AbstractODataValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData complex property value.
@ -35,7 +35,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
/**
* Complex type fields.
*/
private final Map<String, ODataProperty> fields = new LinkedHashMap<String, ODataProperty>();
private final Map<String, CommonODataProperty> fields = new LinkedHashMap<String, CommonODataProperty>();
/**
* Constructor.
@ -52,7 +52,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
* @param field field to be added.
*/
@Override
public void add(final ODataProperty field) {
public void add(final CommonODataProperty field) {
fields.put(field.getName(), field);
}
@ -63,7 +63,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
* @return requested field.
*/
@Override
public ODataProperty get(final String name) {
public CommonODataProperty get(final String name) {
return fields.get(name);
}
@ -73,7 +73,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
* @return fields iterator.
*/
@Override
public Iterator<ODataProperty> iterator() {
public Iterator<CommonODataProperty> iterator() {
return fields.values().iterator();
}

View File

@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v3;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.core.domain.AbstractODataEntity;
public class ODataEntityImpl extends AbstractODataEntity implements ODataEntity {
private static final long serialVersionUID = 1728326493032709855L;
private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
public ODataEntityImpl(final String name) {
super(name);
}
@Override
public ODataProperty getProperty(final String name) {
return (ODataProperty) super.getProperty(name);
}
@Override
public List<ODataProperty> getProperties() {
return properties;
}
}

View File

@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v3;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.core.domain.AbstractODataEntitySet;
public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataEntitySet {
private static final long serialVersionUID = -8127933181196033586L;
private final List<ODataEntity> entities = new ArrayList<ODataEntity>();
public ODataEntitySetImpl() {
}
public ODataEntitySetImpl(final URI next) {
super(next);
}
@Override
protected int getEntitiesSize() {
return entities.size();
}
@Override
public List<ODataEntity> getEntities() {
return entities;
}
}

View File

@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v3;
import java.net.URI;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.domain.AbstractODataObjectFactory;
public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implements ODataObjectFactory {
public ODataObjectFactoryImpl(final ODataServiceVersion version) {
super(version);
}
@Override
public ODataEntitySet newEntitySet() {
return new ODataEntitySetImpl();
}
@Override
public ODataEntitySet newEntitySet(final URI next) {
return new ODataEntitySetImpl(next);
}
@Override
public ODataEntity newEntity(final String name) {
return new ODataEntityImpl(name);
}
@Override
public ODataEntity newEntity(final String name, final URI link) {
final ODataEntityImpl result = new ODataEntityImpl(name);
result.setLink(link);
return result;
}
@Override
public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
return new ODataPropertyImpl(name, value);
}
}

View File

@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v3;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.core.domain.AbstractODataProperty;
public class ODataPropertyImpl extends AbstractODataProperty implements ODataProperty {
private static final long serialVersionUID = 4851331227420757747L;
public ODataPropertyImpl(final String name, final ODataValue value) {
super(name, value);
}
}

View File

@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v4;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.core.domain.AbstractODataEntity;
public class ODataEntityImpl extends AbstractODataEntity implements ODataEntity {
private static final long serialVersionUID = -3997704808753685990L;
/**
* Entity reference.
*/
private String reference;
private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
public ODataEntityImpl(final String name) {
super(name);
}
@Override
public String getReference() {
return reference;
}
@Override
public void setReference(final String reference) {
this.reference = reference;
}
@Override
public ODataProperty getProperty(final String name) {
return (ODataProperty) super.getProperty(name);
}
@Override
public List<ODataProperty> getProperties() {
return properties;
}
}

View File

@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v4;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.core.domain.AbstractODataEntitySet;
public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataEntitySet {
private static final long serialVersionUID = -8127933181196033586L;
private final List<ODataEntity> entities = new ArrayList<ODataEntity>();
public ODataEntitySetImpl() {
}
public ODataEntitySetImpl(final URI next) {
super(next);
}
@Override
protected int getEntitiesSize() {
return entities.size();
}
@Override
public List<ODataEntity> getEntities() {
return entities;
}
}

View File

@ -0,0 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v4;
import java.net.URI;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.domain.AbstractODataObjectFactory;
public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implements ODataObjectFactory {
public ODataObjectFactoryImpl(final ODataServiceVersion version) {
super(version);
}
@Override
public ODataEntitySet newEntitySet() {
return new ODataEntitySetImpl();
}
@Override
public ODataEntitySet newEntitySet(final URI next) {
return new ODataEntitySetImpl(next);
}
@Override
public ODataEntity newEntity(final String name) {
return new ODataEntityImpl(name);
}
@Override
public ODataEntity newEntity(final String name, final URI link) {
final ODataEntityImpl result = new ODataEntityImpl(name);
result.setLink(link);
return result;
}
@Override
public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
return new ODataPropertyImpl(name, value);
}
@Override
public ODataProperty newEnumProperty(final String name, final ODataEnumValue value) {
return new ODataPropertyImpl(name, value);
}
}

View File

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.domain.v4;
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.core.domain.AbstractODataProperty;
public class ODataPropertyImpl extends AbstractODataProperty implements ODataProperty {
private static final long serialVersionUID = 4851331227420757747L;
public ODataPropertyImpl(final String name, final org.apache.olingo.commons.api.domain.ODataValue value) {
super(name, value);
}
@Override
public boolean hasEnumValue() {
return !hasNullValue() && getValue() instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
&& ((org.apache.olingo.commons.api.domain.v4.ODataValue) getValue()).isEnum();
}
@Override
public ODataEnumValue getEnumValue() {
return hasEnumValue() ? ((org.apache.olingo.commons.api.domain.v4.ODataValue) getValue()).asEnum() : null;
}
}