diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java index af904b3a7..ed0910a4a 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java @@ -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(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java index 48786be62..f05eb1a5c 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java @@ -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 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. */ - ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UT type, ODataEntity changes); + 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. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java index f613cbcab..02ca4eeb4 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java @@ -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 concrete ODataEntitySet implementation. * @param uri request URI. * @return new {@link ODataEntitySetRequest} instance. */ - ODataEntitySetRequest getEntitySetRequest(URI uri); + ODataEntitySetRequest 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 concrete ODataEntity implementation. * @param uri request URI. * @return new {@link ODataEntityRequest} instance. */ - ODataEntityRequest getEntityRequest(URI uri); + ODataEntityRequest getEntityRequest(URI uri); /** * Gets a query request returning a single OData entity property. * + * @param concrete ODataProperty implementation. * @param uri request URI. * @return new {@link ODataPropertyRequest} instance. */ - ODataPropertyRequest getPropertyRequest(URI uri); + ODataPropertyRequest getPropertyRequest(URI uri); /** * Gets a query request returning a single OData entity property value. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java index a22f82c02..aee96026e 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntityRequest.java @@ -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 { +public interface ODataEntityRequest extends ODataRetrieveRequest { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java index fbafafd42..865596cd3 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java @@ -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 { +public interface ODataEntitySetRequest + extends ODataRetrieveRequest { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java index 7492e11ab..f61783b92 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataPropertyRequest.java @@ -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 { +public interface ODataPropertyRequest extends ODataRetrieveRequest { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java index a0d667ae5..25276fe13 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java @@ -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 getEntitySetRequest(URI uri); + + @SuppressWarnings("unchecked") + @Override + ODataEntityRequest getEntityRequest(URI uri); + + @SuppressWarnings("unchecked") + @Override + ODataPropertyRequest getPropertyRequest(URI uri); + /** * Gets a query request returning a single OData link. * diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java index 55005cd68..8d8184bca 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java @@ -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 getEntitySetRequest(URI uri); + + @Override + ODataEntityRequest getEntityRequest(URI uri); + + @Override + ODataPropertyRequest getPropertyRequest(URI uri); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java index 5fd7fb81b..040742200 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java @@ -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(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityUpdateResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityUpdateResponse.java index 6b84630c6..59b011278 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityUpdateResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityUpdateResponse.java @@ -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(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityCreateResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityCreateResponse.java index ea3b8b7ce..c29193bc3 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityCreateResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityCreateResponse.java @@ -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(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityUpdateResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityUpdateResponse.java index f55dac81c..97aab03e3 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityUpdateResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataMediaEntityUpdateResponse.java @@ -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(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataPropertyUpdateResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataPropertyUpdateResponse.java index 23bfc1e09..61f5dbdb4 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataPropertyUpdateResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataPropertyUpdateResponse.java @@ -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(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java index e5eeeed73..66e347646 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java @@ -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; *
* Please don't forget to call the close()>/ method when not needed any more. */ -public class ODataEntitySetIterator implements Iterator { +public class ODataEntitySetIterator implements Iterator { /** * Logger. @@ -59,7 +59,7 @@ public class ODataEntitySetIterator implements Iterator { private Entry cached; - private ODataEntitySet entitySet; + private CommonODataEntitySet entitySet; private final ByteArrayOutputStream osFeed; @@ -127,9 +127,9 @@ public class ODataEntitySetIterator implements Iterator { * {@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; } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java index 38fe16f56..14fa946b9 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java @@ -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 Feed object. */ - Feed getFeed(ODataEntitySet feed, Class reference); + Feed getFeed(CommonODataEntitySet feed, Class reference); /** * Gets an Entry from the given OData entity. @@ -49,7 +49,7 @@ public interface CommonODataBinder extends Serializable { * @param reference reference class. * @return Entry object. */ - Entry getEntry(ODataEntity entity, Class reference); + Entry getEntry(CommonODataEntity entity, Class reference); /** * Gets an Entry from the given OData entity. @@ -59,7 +59,7 @@ public interface CommonODataBinder extends Serializable { * @param setType whether to explicitly output type information. * @return Entry object. */ - Entry getEntry(ODataEntity entity, Class reference, boolean setType); + Entry getEntry(CommonODataEntity entity, Class reference, boolean setType); /** * Gets a Link from the given OData link. @@ -78,7 +78,16 @@ public interface CommonODataBinder extends Serializable { * @param setType whether to explicitly output type information. * @return Property object. */ - Property getProperty(ODataProperty property, Class reference, boolean setType); + Property getProperty(CommonODataProperty property, Class 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 ODataServiceDocument from the given service document resource. @@ -94,7 +103,7 @@ public interface CommonODataBinder extends Serializable { * @param resource feed resource. * @return ODataEntitySet object. */ - ODataEntitySet getODataEntitySet(Feed resource); + CommonODataEntitySet getODataEntitySet(Feed resource); /** * Gets ODataEntitySet from the given feed resource. @@ -103,7 +112,7 @@ public interface CommonODataBinder extends Serializable { * @param defaultBaseURI default base URI. * @return ODataEntitySet object. */ - ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI); + CommonODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI); /** * Gets ODataEntity from the given entry resource. @@ -111,7 +120,7 @@ public interface CommonODataBinder extends Serializable { * @param resource entry resource. * @return ODataEntity object. */ - ODataEntity getODataEntity(Entry resource); + CommonODataEntity getODataEntity(Entry resource); /** * Gets ODataEntity from the given entry resource. @@ -120,7 +129,7 @@ public interface CommonODataBinder extends Serializable { * @param defaultBaseURI default base URI. * @return ODataEntity object. */ - ODataEntity getODataEntity(Entry resource, URI defaultBaseURI); + CommonODataEntity getODataEntity(Entry resource, URI defaultBaseURI); /** * Gets an ODataProperty from the given property resource. @@ -128,5 +137,5 @@ public interface CommonODataBinder extends Serializable { * @param property property resource. * @return ODataProperty object. */ - ODataProperty getODataProperty(Property property); + CommonODataProperty getODataProperty(Property property); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java index f13e0ac0a..923ac231b 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java @@ -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. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java index b83b2cd72..a7ead37b2 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java @@ -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 entities, ODataPubFormat format); + InputStream writeEntities(Collection 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 entities, ODataPubFormat format, boolean outputType); + InputStream writeEntities(Collection 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. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java index 6ea90ba0f..52cb62513 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataBinder.java @@ -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 ODataLinkCollection from the given link collection resource. * diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java index 1397c473d..f51c79898 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataBinder.java @@ -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); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java index 595979633..81bf6dcbb 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java @@ -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(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java index afe3c7008..51abf9963 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java @@ -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(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java index 405f95d83..57b24dfa9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java @@ -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; - } - } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java index e5bb42e73..ae5526903 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java @@ -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"); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java index 8b9965fbe..f8bff7e35 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java @@ -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 container = odataClient.getDeserializer().toEntry(getRawResponse(), + final Container container = odataClient.getDeserializer().toEntry(getRawResponse(), ODataPubFormat.fromString(getAccept())); - + entity = odataClient.getBinder().getODataEntity(extractFromContainer(container)); } finally { this.close(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java index 693582a48..dde98a4d9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java @@ -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 container = odataClient.getDeserializer().toEntry(getRawResponse(), diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java index 5b0f9fb30..7345d300e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java @@ -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 container = odataClient.getDeserializer().toProperty(getRawResponse(), diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java index 213a886eb..4e7be37ee 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java @@ -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 */ @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 param : parameters.entrySet()) { - ODataProperty property = null; + CommonODataProperty property = null; if (param.getValue().isPrimitive()) { property = odataClient.getObjectFactory(). @@ -128,7 +126,7 @@ public class ODataInvokeRequestImpl } if (property != null) { - tmp.getProperties().add(property); + odataClient.getBinder().add(tmp, property); } } @@ -211,15 +209,15 @@ public class ODataInvokeRequestImpl } 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())); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java index 2487dd9fa..87e8c76a4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java @@ -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) new ODataInvokeRequestImpl( - client, ODataEntitySet.class, method, uri); + result = (ODataInvokeRequest) new ODataInvokeRequestImpl( + client, CommonODataEntitySet.class, method, uri); } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - result = (ODataInvokeRequest) new ODataInvokeRequestImpl( - client, ODataEntity.class, method, uri); + result = (ODataInvokeRequest) new ODataInvokeRequestImpl( + client, CommonODataEntity.class, method, uri); } else { - result = (ODataInvokeRequest) new ODataInvokeRequestImpl( - client, ODataProperty.class, method, uri); + result = (ODataInvokeRequest) new ODataInvokeRequestImpl( + client, CommonODataProperty.class, method, uri); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java index 3eeabedd1..d8ec0f233 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java @@ -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); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java index 2c8955eed..141b82e0c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java @@ -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 - implements ODataEntityRequest { +public class ODataEntityRequestImpl + extends AbstractODataRetrieveRequest implements ODataEntityRequest { /** * Private constructor. @@ -41,7 +41,7 @@ public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest execute() { + public ODataRetrieveResponse execute() { return new ODataEntityResponseImpl(httpClient, doExecute()); } @@ -58,7 +58,7 @@ public class ODataEntityRequestImpl extends AbstractODataRetrieveRequest container = odataClient.getDeserializer().toEntry(getRawResponse(), ODataPubFormat.fromString(getContentType())); - entity = odataClient.getBinder().getODataEntity(extractFromContainer(container)); + entity = (T) odataClient.getBinder().getODataEntity(extractFromContainer(container)); } finally { this.close(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java index e6d578362..86fa45c8b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java @@ -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 - implements ODataEntitySetRequest { +public class ODataEntitySetRequestImpl + extends AbstractODataRetrieveRequest implements ODataEntitySetRequest { - private ODataEntitySet entitySet = null; + private T entitySet = null; /** * Private constructor. @@ -43,7 +43,7 @@ public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest execute() { + public ODataRetrieveResponse execute() { final HttpResponse res = doExecute(); return new ODataEntitySetResponseImpl(httpClient, res); } @@ -84,13 +84,13 @@ public class ODataEntitySetRequestImpl extends AbstractODataRetrieveRequest container = odataClient.getDeserializer().toFeed(getRawResponse(), ODataPubFormat.fromString(getContentType())); - entitySet = odataClient.getBinder().getODataEntitySet(extractFromContainer(container)); + entitySet = (T) odataClient.getBinder().getODataEntitySet(extractFromContainer(container)); } finally { this.close(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java index 4b9aa2b9d..7878805ae 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java @@ -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 - implements ODataPropertyRequest { +public class ODataPropertyRequestImpl + extends AbstractODataRetrieveRequest implements ODataPropertyRequest { /** * Private constructor. @@ -43,7 +43,7 @@ public class ODataPropertyRequestImpl extends AbstractODataRetrieveRequest execute() { + public ODataRetrieveResponse 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 container = odataClient.getDeserializer().toProperty( - res.getEntity().getContent(), ODataFormat.fromString(getContentType())); + 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 { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java index f6ba5c101..b32dd305a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java @@ -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 getEntitySetRequest(final URI query) { + return new ODataEntitySetRequestImpl(client, query); + } + + @SuppressWarnings("unchecked") + @Override + public ODataEntityRequest getEntityRequest(final URI query) { + return new ODataEntityRequestImpl(client, query); + } + + @SuppressWarnings("unchecked") + @Override + public ODataPropertyRequest getPropertyRequest(final URI query) { + return new ODataPropertyRequestImpl(client, query); + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java index 69f6f2aed..a32a1539c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java @@ -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 getEntitySetRequest(final URI query) { + return new ODataEntitySetRequestImpl(client, query); + } + + @SuppressWarnings("unchecked") + @Override + public ODataEntityRequest getEntityRequest(final URI query) { + return new ODataEntityRequestImpl(client, query); + } + + @SuppressWarnings("unchecked") + @Override + public ODataPropertyRequest getPropertyRequest(final URI query) { + return new ODataPropertyRequestImpl(client, query); + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java index f7e5ffacc..2c1dd22e4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java @@ -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 container = odataClient.getDeserializer().toEntry(getRawResponse(), getFormat()); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java index a22843fa5..614baa1c6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java @@ -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 container = odataClient.getDeserializer().toEntry(getRawResponse(), getFormat()); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java index 2a0ea4f5e..4c8660488 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java @@ -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 reference) { + public Feed getFeed(final CommonODataEntitySet entitySet, final Class 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 reference) { + public Entry getEntry(final CommonODataEntity entity, final Class reference) { return getEntry(entity, reference, true); } @Override - public Entry getEntry(final ODataEntity entity, final Class reference, final boolean setType) { + public Entry getEntry(final CommonODataEntity entity, final Class 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 reference, + public Property getProperty(final CommonODataProperty property, final Class 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 itor = _value.iterator(); itor.hasNext();) { + for (final Iterator 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()) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java index f21f16adc..4ff36f95a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java @@ -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( null, null, (T) new ODataEntitySetIterator(client, src, ODataPubFormat.fromString(format))); - } else if (ODataEntitySet.class.isAssignableFrom(reference)) { + } else if (CommonODataEntitySet.class.isAssignableFrom(reference)) { final Container container = client.getDeserializer().toFeed(src, ODataPubFormat.fromString(format)); res = new Container( container.getContextURL(), container.getMetadataETag(), (T) client.getBinder().getODataEntitySet(container.getObject())); - } else if (ODataEntity.class.isAssignableFrom(reference)) { + } else if (CommonODataEntity.class.isAssignableFrom(reference)) { final Container container = client.getDeserializer().toEntry(src, ODataPubFormat.fromString(format)); res = new Container( container.getContextURL(), container.getMetadataETag(), (T) client.getBinder().getODataEntity(container.getObject())); - } else if (ODataProperty.class.isAssignableFrom(reference)) { + } else if (CommonODataProperty.class.isAssignableFrom(reference)) { final Container container = client.getDeserializer().toProperty(src, ODataFormat.fromString(format)); res = new Container( container.getContextURL(), diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java index 2b914b4ae..7ea9c99b1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java @@ -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 entities, final ODataPubFormat format) { + public InputStream writeEntities(final Collection entities, final ODataPubFormat format) { return writeEntities(entities, format, true); } @Override public InputStream writeEntities( - final Collection entities, final ODataPubFormat format, final boolean outputType) { + final Collection 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.singleton(entity), format, outputType); + public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format, + final boolean outputType) { + + return writeEntities(Collections.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( diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java index 3c5f5a45c..28887dce0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java @@ -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()); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java index 9c81baf90..0acc7d1d3 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java @@ -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 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)); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java index d6d5e3651..f1b5d239c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java @@ -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; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java index a5aafabac..d379bcf53 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java @@ -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; diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java index bba68de0e..0a3b53dd4 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java @@ -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 original, final Collection actual) { + protected void checkProperties(final Collection original, + final Collection actual) { + assertTrue(original.size() <= actual.size()); // re-organize actual properties into a Map - final Map actualProps = new HashMap(actual.size()); + final Map actualProps = new HashMap(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 originalFileds = new ArrayList(); - for (ODataProperty prop : original.asComplex()) { + final List originalFileds = new ArrayList(); + for (CommonODataProperty prop : original.asComplex()) { originalFileds.add(prop); } - final List actualFileds = new ArrayList(); - for (ODataProperty prop : (ODataComplexValue) actual) { + final List actualFileds = new ArrayList(); + 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 res = getClient().getRetrieveRequestFactory(). + final ODataRetrieveResponse 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 req = getClient().getRetrieveRequestFactory(). + getEntityRequest(editLink); req.setFormat(format); - final ODataRetrieveResponse res = req.execute(); - final ODataEntity entity = res.getBody(); + final ODataRetrieveResponse 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 expands) { @@ -405,13 +411,14 @@ public abstract class AbstractTestITCase { } } - final ODataEntityRequest req = getClient().getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + final ODataEntityRequest req = getClient().getRetrieveRequestFactory(). + getEntityRequest(uriBuilder.build()); req.setFormat(format); - final ODataRetrieveResponse res = req.execute(); + final ODataRetrieveResponse 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 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().getObjectFactory().newPrimitiveValueBuilder().setText(newm).build())); + 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()) { diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AsyncTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AsyncTestITCase.java index b77ebf8fc..01e0d7b53 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AsyncTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AsyncTestITCase.java @@ -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,14 +69,15 @@ public class AsyncTestITCase extends AbstractTestITCase { final ODataRetrieveResponse 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", - client.getObjectFactory().newPrimitiveValueBuilder().setText("AsyncTest#updateEntity").build())); + getClient().getBinder().add(entity, + client.getObjectFactory().newPrimitiveProperty("Description", + client.getObjectFactory().newPrimitiveValueBuilder().setText("AsyncTest#updateEntity").build())); final ODataEntityUpdateRequest updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(uri, UpdateType.MERGE, entity); @@ -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()); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java index 1ebe190ec..bd1419f54 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java @@ -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.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.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.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.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 keys = new HashSet(); 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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(id). - setType(EdmPrimitiveTypeKind.Int32).build())); - order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(id). - setType(EdmPrimitiveTypeKind.Int32).build())); + getClient().getBinder().add(order, + 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(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 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 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 req = client.getRetrieveRequestFactory().getEntityRequest( URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "?$expand=Orders")); req.setFormat(format); @@ -444,27 +451,33 @@ 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", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(1000). - setType(EdmPrimitiveTypeKind.Int32).build())); - message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FromUsername", - client.getObjectFactory().newPrimitiveValueBuilder().setValue("1"). - setType(EdmPrimitiveTypeKind.String).build())); - message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("ToUsername", - client.getObjectFactory().newPrimitiveValueBuilder().setValue("xlodhxzzusxecbzptxlfxprneoxkn"). - setType(EdmPrimitiveTypeKind.String).build())); - message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Subject", - client.getObjectFactory().newPrimitiveValueBuilder().setValue("Test subject"). - setType(EdmPrimitiveTypeKind.String).build())); - message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Body", - client.getObjectFactory().newPrimitiveValueBuilder().setValue("Test body"). - setType(EdmPrimitiveTypeKind.String).build())); - message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(false). - setType(EdmPrimitiveTypeKind.Boolean).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("MessageId", + client.getObjectFactory().newPrimitiveValueBuilder().setValue(1000). + setType(EdmPrimitiveTypeKind.Int32).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("FromUsername", + client.getObjectFactory().newPrimitiveValueBuilder().setValue("1"). + setType(EdmPrimitiveTypeKind.String).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("ToUsername", + client.getObjectFactory().newPrimitiveValueBuilder().setValue("xlodhxzzusxecbzptxlfxprneoxkn"). + setType(EdmPrimitiveTypeKind.String).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("Subject", + client.getObjectFactory().newPrimitiveValueBuilder().setValue("Test subject"). + setType(EdmPrimitiveTypeKind.String).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("Body", + client.getObjectFactory().newPrimitiveValueBuilder().setValue("Test body"). + setType(EdmPrimitiveTypeKind.String).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("IsRead", + client.getObjectFactory().newPrimitiveValueBuilder().setValue(false). + setType(EdmPrimitiveTypeKind.Boolean).build())); final CommonURIBuilder builder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Message"); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java index ddcd3421a..1b43c4730 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java @@ -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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 properties = inline.getProperties(); + final List 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataPubFormat.JSON); // this statement should cause an IllegalArgumentException bearing JsonParseException diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java index 0a1d503d8..446b41df5 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java @@ -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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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); } } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java index fed9ba423..6ed898d04 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java @@ -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 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,16 +179,17 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { final LinkedHashMap multiKey = new LinkedHashMap(); 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", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(!before). - setType(EdmPrimitiveTypeKind.Boolean).build())); + getClient().getBinder().add(message, + client.getObjectFactory().newPrimitiveProperty("IsRead", + client.getObjectFactory().newPrimitiveValueBuilder().setValue(!before). + setType(EdmPrimitiveTypeKind.Boolean).build())); return client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, message); } @@ -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); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java index ed8a776a0..04c41de26 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java @@ -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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); try { diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java index 28c354d96..de6808c88 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java @@ -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()); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java index cbcf046cd..44be0fee1 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java @@ -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()); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java index dac96e63f..4a9d05f16 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java @@ -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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java index 33502045a..03bdf00eb 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java @@ -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); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java index 5cc8770e3..fcbbe8095 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java @@ -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 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,32 +189,34 @@ 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 navigationKeys = new HashSet(); 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", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(key). - setType(EdmPrimitiveTypeKind.Int32).build())); - orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId", - client.getObjectFactory().newPrimitiveValueBuilder().setValue(id). - setType(EdmPrimitiveTypeKind.Int32).build())); + getClient().getBinder().add(orderEntity, + client.getObjectFactory().newPrimitiveProperty("OrderId", + client.getObjectFactory().newPrimitiveValueBuilder().setValue(key). + setType(EdmPrimitiveTypeKind.Int32).build())); + getClient().getBinder().add(orderEntity, + client.getObjectFactory().newPrimitiveProperty("CustomerId", + client.getObjectFactory().newPrimitiveValueBuilder().setValue(id). + setType(EdmPrimitiveTypeKind.Int32).build())); final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest( client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Order").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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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,22 +265,24 @@ 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", - client.getObjectFactory().newPrimitiveValueBuilder().setText(name). - setType(EdmPrimitiveTypeKind.String).build())); + 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", - client.getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)). - setType(EdmPrimitiveTypeKind.Int32).build())); + getClient().getBinder().add(entity, + client.getObjectFactory().newPrimitiveProperty("CustomerId", + client.getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)). + setType(EdmPrimitiveTypeKind.Int32).build())); } final ODataCollectionValue backupContactInfoValue = getClient().getObjectFactory().newCollectionValue( "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)"); @@ -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 toBeDeleted = new HashSet(); 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 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 original, final Collection actual) { + public void checkProperties(final Collection original, + final Collection actual) { + assertTrue(original.size() <= actual.size()); - final Map actualProperties = new HashMap(actual.size()); + final Map actualProperties = new HashMap(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 originalPropertyValue = new ArrayList(); - for (ODataProperty prop : original.asComplex()) { + final List originalPropertyValue = new ArrayList(); + for (CommonODataProperty prop : original.asComplex()) { originalPropertyValue.add(prop); } - final List actualPropertyValue = new ArrayList(); - for (ODataProperty prop : (ODataComplexValue) actual) { + final List actualPropertyValue = new ArrayList(); + for (CommonODataProperty prop : (ODataComplexValue) actual) { actualPropertyValue.add(prop); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java index d00bf8b58..f576a0307 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java @@ -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,60 +91,74 @@ 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", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Guid).setValue(guid). - build())); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aString", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.String).setValue("string"). - build())); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aBoolean", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Boolean).setValue(true). - build())); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLong", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Int64).setValue(15L). - build())); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDouble", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Double).setValue(1.5D). - build())); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aByte", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE). - build())); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDate", - client.getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.DateTime).setValue(new Date()). - build())); + 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())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aString", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.String).setValue("string"). + build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aBoolean", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.Boolean).setValue(true). + build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aLong", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.Int64).setValue(15L). + build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aDouble", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.Double).setValue(1.5D). + build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aByte", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE). + build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aDate", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.DateTime).setValue(new Date()). + build())); final Point point = new Point(Geospatial.Dimension.GEOGRAPHY, null); point.setX(1.2); point.setY(2.1); - row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPoint", - client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint). - setValue(point).build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aPoint", + client.getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint). + setValue(point).build())); final List points = new ArrayList(); 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). - setValue(multipoint).build())); + 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). - setValue(lineString).build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aLineString", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.GeometryLineString). + setValue(lineString).build())); final List lineStrings = new ArrayList(); 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). - setValue(multiLineString).build())); + 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); otherPoint.setY(4.3); @@ -152,25 +166,31 @@ 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). - setValue(polygon).build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aPolygon", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.GeographyPolygon). + setValue(polygon).build())); final List polygons = new ArrayList(); 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). - setValue(multiPolygon).build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aMultiPolygon", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.GeographyMultiPolygon). + setValue(multiPolygon).build())); final List geospatials = new ArrayList(); geospatials.add(otherPoint); geospatials.add(polygon); 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). - setValue(geoColl).build())); + getClient().getBinder().add(row, + client.getObjectFactory().newPrimitiveProperty("aCollection", + client.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.GeographyCollection). + setValue(geoColl).build())); final ODataComplexValue contactDetails = client.getObjectFactory().newComplexValue( "Microsoft.Test.OData.Services.OpenTypesService.ContactDetails"); @@ -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). diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java index c6763e98e..56db6fb60 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java @@ -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 req = client.getRetrieveRequestFactory().getEntityRequest( client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType). appendKeySegment(key). build()); req.setFormat(format); final ODataRetrieveResponse res = req.execute(); assertEquals(200, res.getStatusCode()); - final ODataEntity entity = res.getBody(); + final CommonODataEntity entity = res.getBody(); assertNotNull(entity); assertNotNull(entity.getProperty("Id")); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java index 314e93416..2e495dcd0 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java @@ -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 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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setAccept("application/json"); ODataRetrieveResponse res = req.execute(); assertEquals(200, res.getStatusCode()); - ODataEntitySet entitySet = res.getBody(); + CommonODataEntitySet entitySet = res.getBody(); assertNotNull(entitySet); - List entity = entitySet.getEntities(); + List 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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setAccept("application/json"); try { ODataRetrieveResponse res = req.execute(); assertEquals(200, res.getStatusCode()); - ODataEntitySet entitySet = res.getBody(); + CommonODataEntitySet entitySet = res.getBody(); assertNotNull(entitySet); - List entity = entitySet.getEntities(); + List 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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setAccept("application/atom+xml"); try { ODataRetrieveResponse res = req.execute(); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java index ddcd75f1b..9d10d2481 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java @@ -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 retrieveReq = client.getRetrieveRequestFactory(). + getPropertyRequest(uriBuilder.build()); retrieveReq.setFormat(format); ODataRetrieveResponse 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 retrieveReq = client.getRetrieveRequestFactory(). + getPropertyRequest(uriBuilder.build()); retrieveReq.setFormat(format); ODataRetrieveResponse 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 retrieveReq = client.getRetrieveRequestFactory(). + getPropertyRequest(uriBuilder.build()); retrieveReq.setFormat(format); ODataRetrieveResponse 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); } } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyValueTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyValueTestITCase.java index 3660cad7c..02a964dec 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyValueTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyValueTestITCase.java @@ -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 { @@ -72,7 +72,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase { public void retrieveDatePropertyValueTest() { CommonURIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment( - "NestedComplexConcurrency/ModifiedDate").appendValueSegment(); + "NestedComplexConcurrency/ModifiedDate").appendValueSegment(); final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); @@ -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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setAccept("application/json"); ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setAccept("application/atom+xml"); ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setAccept("application/xml"); ODataRetrieveResponse res = req.execute(); assertEquals(200, res.getStatusCode()); @@ -141,7 +141,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase { public void retrieveCollectionPropertyValueTest() { CommonURIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment( - "ComplexConcurrency/QueriedDateTime").appendValueSegment(); + "ComplexConcurrency/QueriedDateTime").appendValueSegment(); final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); @@ -155,7 +155,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase { public void retrieveNullPropertyValueTest() { CommonURIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment( - "ComplexConcurrency/Token").appendValueSegment(); + "ComplexConcurrency/Token").appendValueSegment(); final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); try { req.execute().getBody(); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java index 9f9c2c3f2..a45da3aa4 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/QueryOptionsTestITCase.java @@ -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 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 vinsASC = new ArrayList(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 vinsDESC = new ArrayList(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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataPubFormat.ATOM); final ODataRetrieveResponse 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 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 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 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataPubFormat.ATOM); final ODataEntity customer = req.execute().getBody(); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java index 6d2a89d7d..7806fd00d 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java @@ -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 req = client.getRetrieveRequestFactory(). + getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 properties = inline.getProperties(); + final List 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 req = client.getRetrieveRequestFactory(). + getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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 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 req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); ODataRetrieveResponse res = req.execute(); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java index 2d78a6d8a..a73ce7aec 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java @@ -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 req = client.getRetrieveRequestFactory(). + getEntitySetRequest(uriBuilder.build()); req.setFormat(format); final ODataRetrieveResponse 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")); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java index 93ee5fe42..cddd66d1f 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java @@ -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 req = client.getRetrieveRequestFactory(). + getPropertyRequest(uriBuilder.build()); req.setFormat(ODataFormat.XML); final ODataProperty property = req.execute().getBody(); assertTrue(property.getValue().isCollection()); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java index 0812c6d33..1f02432d3 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntitySetTest.java @@ -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); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java index 80c56c2c6..fe5b148e0 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java @@ -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; diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java index 6d463982e..4b3167ed1 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java @@ -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 itor = written.getComplexValue().iterator(); itor.hasNext();) { - final ODataProperty prop = itor.next(); + for (final Iterator 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; diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java similarity index 77% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java index 44214ac80..f4b0d2f97 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntity.java @@ -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, null otherwise */ - ODataProperty getProperty(String name); + CommonODataProperty getProperty(String name); /** * Returns OData entity properties. * * @return OData entity properties. */ - List getProperties(); + List 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. - *
- * If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found. - *
- * 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. - *
- * 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); - } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java similarity index 92% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java index 99b6962c6..39677487c 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataEntitySet.java @@ -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 getEntities(); + List getEntities(); /** * Gets in-line count. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java similarity index 87% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java index 7114c5bdd..525dc9dd6 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java @@ -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); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java similarity index 96% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java index 4cfa303a2..99a513131 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java @@ -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. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java index ea4d8327b..b34006ccb 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java @@ -21,14 +21,14 @@ package org.apache.olingo.commons.api.domain; /** * OData complex property value. */ -public interface ODataComplexValue extends ODataValue, Iterable { +public interface ODataComplexValue extends ODataValue, Iterable { /** * 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 { * @param name name of the field to be retrieved. * @return requested field. */ - ODataProperty get(String name); + CommonODataProperty get(String name); /** * Gets number of fields. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java index 46e29dd2b..67e5bb481 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java @@ -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; } } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java index 1ace20bc0..24ca836aa 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java @@ -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; } } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataEntity.java new file mode 100644 index 000000000..18ba67b4c --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataEntity.java @@ -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 getProperties(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataEntitySet.java new file mode 100644 index 000000000..dae091944 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataEntitySet.java @@ -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 getEntities(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java new file mode 100644 index 000000000..363f1de5b --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java @@ -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); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java new file mode 100644 index 000000000..266d53c16 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java @@ -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 { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java new file mode 100644 index 000000000..df9e80123 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java @@ -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 getProperties(); + + /** + * To request entity references in place of the actual entities, the client issues a GET request with /$ref appended + * to the resource path. + *
+ * If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found. + *
+ * 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. + *
+ * 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); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java new file mode 100644 index 000000000..97ac19246 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java @@ -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 getEntities(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java new file mode 100644 index 000000000..2e3699d61 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java @@ -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(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java new file mode 100644 index 000000000..8b43bc1cd --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java @@ -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); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java new file mode 100644 index 000000000..61a8193da --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java @@ -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(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java new file mode 100644 index 000000000..1535e1063 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataValue.java @@ -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(); +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java similarity index 79% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java index 62d1e42c8..a1b729fa3 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java @@ -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 operations = new ArrayList(); - /** - * Entity properties. - */ - private final List properties = new ArrayList(); - /** * 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. - *
- * If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found. - *
- * 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. - *
- * 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, null 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 getProperties() { - return properties; - } - /** * Puts the given link into one of available lists, based on its type. * diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java similarity index 62% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java index b7246d199..b2f7dc8bb 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java @@ -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 entities = new ArrayList(); - /** * 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 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; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java similarity index 75% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java index 63a47cebf..ea73910eb 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java @@ -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); - } - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java similarity index 93% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java index 4c8aea9e9..c68dfab01 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java @@ -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; } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java index 07d6055be..ba8fe567f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java @@ -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 fields = new LinkedHashMap(); + private final Map fields = new LinkedHashMap(); /** * 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 iterator() { + public Iterator iterator() { return fields.values().iterator(); } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java new file mode 100644 index 000000000..8a41e7ac8 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java @@ -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 properties = new ArrayList(); + + public ODataEntityImpl(final String name) { + super(name); + } + + @Override + public ODataProperty getProperty(final String name) { + return (ODataProperty) super.getProperty(name); + } + + @Override + public List getProperties() { + return properties; + } +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java new file mode 100644 index 000000000..83870f3fe --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java @@ -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 entities = new ArrayList(); + + public ODataEntitySetImpl() { + } + + public ODataEntitySetImpl(final URI next) { + super(next); + } + + @Override + protected int getEntitiesSize() { + return entities.size(); + } + + @Override + public List getEntities() { + return entities; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java new file mode 100644 index 000000000..2bfb8f5a2 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java @@ -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); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java new file mode 100644 index 000000000..68c44ec27 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java @@ -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); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java new file mode 100644 index 000000000..b5ac7998c --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java @@ -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 properties = new ArrayList(); + + 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 getProperties() { + return properties; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java new file mode 100644 index 000000000..cbc5a04e9 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java @@ -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 entities = new ArrayList(); + + public ODataEntitySetImpl() { + } + + public ODataEntitySetImpl(final URI next) { + super(next); + } + + @Override + protected int getEntitiesSize() { + return entities.size(); + } + + @Override + public List getEntities() { + return entities; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java new file mode 100644 index 000000000..1b6428f76 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java @@ -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); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java new file mode 100644 index 000000000..fe6bf9dd6 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java @@ -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; + } + +}