Repository: olingo-odata4 Updated Branches: refs/heads/master 6ecb02643 -> c82e02127
Adding singleton tests Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/c82e0212 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/c82e0212 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/c82e0212 Branch: refs/heads/master Commit: c82e0212782135f47fe5b927350f2893a8efd935 Parents: 6ecb026 Author: Francesco Chicchiriccò <[email protected]> Authored: Thu May 8 17:30:40 2014 +0200 Committer: Francesco Chicchiriccò <[email protected]> Committed: Thu May 8 17:30:40 2014 +0200 ---------------------------------------------------------------------- .../java/org/apache/olingo/fit/V4Services.java | 18 ++++ .../fit/v4/BoundOperationInvokeTestITCase.java | 20 ++-- .../olingo/fit/v4/MediaEntityTestITCase.java | 4 +- .../olingo/fit/v4/PropertyTestITCase.java | 12 ++- .../olingo/fit/v4/PropertyValueTestITCase.java | 4 +- .../olingo/fit/v4/SingletonTestITCase.java | 102 +++++++++++++++++++ .../request/cud/v4/CUDRequestFactory.java | 8 ++ .../retrieve/v4/RetrieveRequestFactory.java | 5 +- .../request/cud/v4/CUDRequestFactoryImpl.java | 17 ++++ .../retrieve/v4/RetrieveRequestFactoryImpl.java | 6 ++ .../api/domain/v4/ODataObjectFactory.java | 2 + .../olingo/commons/api/domain/v4/Singleton.java | 22 ++++ .../commons/core/domain/v4/ODataEntityImpl.java | 3 +- .../core/domain/v4/ODataObjectFactoryImpl.java | 6 ++ 14 files changed, 213 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/fit/src/main/java/org/apache/olingo/fit/V4Services.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java index 72dd00e..6f11b19 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java @@ -34,6 +34,7 @@ import java.util.UUID; import java.util.regex.Pattern; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; +import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -42,8 +43,10 @@ import javax.ws.rs.NotFoundException; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; @@ -346,6 +349,21 @@ public class V4Services extends AbstractServices { uriInfo.getRequestUri().toASCIIString(), accept, "Company", StringUtils.EMPTY, format, null, null, false); } + @PATCH + @Path("/Company") + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + public Response patchSingletonCompany( + @Context UriInfo uriInfo, + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, + @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType, + @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer, + @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) String ifMatch, + final String changes) { + + return super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, "Company", StringUtils.EMPTY, changes); + } + @GET @Path("/Customers") public Response getCustomers( http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java index 88e1ac3..43bf52c 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java @@ -37,6 +37,7 @@ 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.ODataEnumValue; import org.apache.olingo.commons.api.domain.v4.ODataProperty; +import org.apache.olingo.commons.api.domain.v4.Singleton; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmEntityContainer; @@ -64,16 +65,16 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { // GetEmployeesCount URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); - ODataEntityRequest<ODataEntity> entityReq = - getClient().getRetrieveRequestFactory().getEntityRequest(builder.build()); - entityReq.setFormat(format); - ODataEntity entity = entityReq.execute().getBody(); - assertNotNull(entity); + final ODataEntityRequest<Singleton> singletonReq = + getClient().getRetrieveRequestFactory().getSingletonRequest(builder.build()); + singletonReq.setFormat(format); + final Singleton company = singletonReq.execute().getBody(); + assertNotNull(company); - ODataOperation boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"); + ODataOperation boundOp = company.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"); assertNotNull(boundOp); - EdmFunction func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), + EdmFunction func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), company.getTypeName(), false, null); assertNotNull(func); @@ -87,9 +88,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { // GetProductDetails builder = getClient().getURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Products").appendKeySegment(5); - entityReq = getClient().getRetrieveRequestFactory().getEntityRequest(builder.build()); + ODataEntityRequest<ODataEntity> entityReq = getClient().getRetrieveRequestFactory(). + getEntityRequest(builder.build()); entityReq.setFormat(format); - entity = entityReq.execute().getBody(); + ODataEntity entity = entityReq.execute().getBody(); assertNotNull(entity); boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java index aead4c2..63c77ac 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java @@ -47,6 +47,7 @@ import org.apache.olingo.client.api.uri.v4.URIBuilder; import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.core.ODataClientFactory; import org.apache.olingo.commons.api.domain.v4.ODataEntity; +import org.apache.olingo.commons.api.domain.v4.ODataValuable; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -65,8 +66,9 @@ public class MediaEntityTestITCase extends AbstractTestITCase { final ODataEntity entity = entityReq.execute().getBody(); assertNotNull(entity); assertTrue(entity.isMediaEntity()); + // cast to workaround JDK 6 bug, fixed in JDK 7 assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName().toString(), - entity.getProperty("AirDate").getValue().getTypeName()); + ((ODataValuable) entity.getProperty("AirDate")).getValue().getTypeName()); final ODataMediaRequest streamReq = client.getRetrieveRequestFactory(). getMediaRequest(entity.getMediaContentSource()); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java index 2b653b7..8dbeb86 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java @@ -31,6 +31,7 @@ import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.api.uri.v4.URIBuilder; import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.commons.api.domain.v4.ODataProperty; +import org.apache.olingo.commons.api.domain.v4.ODataValuable; import org.apache.olingo.commons.api.format.ODataFormat; import org.junit.Test; @@ -45,7 +46,9 @@ public class PropertyTestITCase extends AbstractTestITCase { final ODataProperty prop = req.execute().getBody(); assertNotNull(prop); - assertEquals("Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)", prop.getValue().getTypeName()); + // cast to workaround JDK 6 bug, fixed in JDK 7 + assertEquals("Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)", + ((ODataValuable) prop).getValue().getTypeName()); } @Test @@ -72,7 +75,8 @@ public class PropertyTestITCase extends AbstractTestITCase { final ODataProperty prop = req.execute().getBody(); assertNotNull(prop); - assertEquals("Edm.GeographyPoint", prop.getValue().getTypeName()); + // cast to workaround JDK 6 bug, fixed in JDK 7 + assertEquals("Edm.GeographyPoint", ((ODataValuable) prop).getValue().getTypeName()); } @Test @@ -99,7 +103,9 @@ public class PropertyTestITCase extends AbstractTestITCase { final ODataProperty prop = req.execute().getBody(); assertNotNull(prop); - assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address", prop.getValue().getTypeName()); + // cast to workaround JDK 6 bug, fixed in JDK 7 + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address", + ((ODataValuable) prop).getValue().getTypeName()); } @Test http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java index 8257bb7..5f76153 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java @@ -29,6 +29,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataValueReq import org.apache.olingo.client.api.uri.v4.URIBuilder; import org.apache.olingo.commons.api.domain.ODataPrimitiveValue; import org.apache.olingo.commons.api.domain.v4.ODataProperty; +import org.apache.olingo.commons.api.domain.v4.ODataValuable; 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; @@ -130,7 +131,8 @@ public class PropertyValueTestITCase extends AbstractTestITCase { getPropertyRequest(uriBuilder.build()); req.setFormat(ODataFormat.XML); final ODataProperty property = req.execute().getBody(); - assertTrue(property.getValue().isCollection()); + // cast to workaround JDK 6 bug, fixed in JDK 7 + assertTrue(((ODataValuable)property).getValue().isCollection()); assertEquals("555-555-5555", property.getCollectionValue().iterator().next().asPrimitive().toString()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java new file mode 100644 index 0000000..4d2df42 --- /dev/null +++ b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java @@ -0,0 +1,102 @@ +/* + * 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.fit.v4; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.URI; +import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; +import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; +import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; +import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; +import org.apache.olingo.client.api.uri.v4.URIBuilder; +import org.apache.olingo.client.api.v4.ODataClient; +import org.apache.olingo.commons.api.domain.v4.ODataValuable; +import org.apache.olingo.commons.api.domain.v4.Singleton; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.format.ODataPubFormat; +import org.junit.Test; + +public class SingletonTestITCase extends AbstractTestITCase { + + private void read(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException { + final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); + final ODataEntityRequest<Singleton> singleton = + client.getRetrieveRequestFactory().getSingletonRequest(builder.build()); + singleton.setFormat(format); + final Singleton company = singleton.execute().getBody(); + assertNotNull(company); + + assertEquals(0, company.getProperty("CompanyID").getPrimitiveValue().toCastValue(Integer.class), 0); + // cast to workaround JDK 6 bug, fixed in JDK 7 + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory", + ((ODataValuable) company.getProperty("CompanyCategory")).getValue().getTypeName()); + assertTrue(company.getProperty("CompanyCategory").hasEnumValue()); + } + + @Test + public void readfromAtom() throws EdmPrimitiveTypeException { + read(client, ODataPubFormat.ATOM); + } + + @Test + public void readfromJSON() throws EdmPrimitiveTypeException { + read(edmClient, ODataPubFormat.JSON); + } + + @Test + public void readfromJSONFull() throws EdmPrimitiveTypeException { + read(client, ODataPubFormat.JSON_FULL_METADATA); + } + + private void update(final ODataPubFormat format) throws EdmPrimitiveTypeException { + final Singleton changes = getClient().getObjectFactory().newSingleton( + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company")); + changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue", + getClient().getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.Int64).setText("132520").build())); + + final URI uri = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build(); + final ODataEntityUpdateRequest<Singleton> req = getClient().getCUDRequestFactory(). + getSingletonUpdateRequest(uri, UpdateType.PATCH, changes); + req.setFormat(format); + + final ODataEntityUpdateResponse<Singleton> res = req.execute(); + assertEquals(204, res.getStatusCode()); + + final Singleton updated = getClient().getRetrieveRequestFactory().getSingletonRequest(uri).execute().getBody(); + assertNotNull(updated); + assertEquals(132520, updated.getProperty("Revenue").getPrimitiveValue().toCastValue(Integer.class), 0); + } + + @Test + public void atomUpdate() throws EdmPrimitiveTypeException { + update(ODataPubFormat.ATOM); + } + + @Test + public void jsonUpdate() throws EdmPrimitiveTypeException { + update(ODataPubFormat.JSON); + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java ---------------------------------------------------------------------- diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java index 3e14755..975f065 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/v4/CUDRequestFactory.java @@ -18,7 +18,15 @@ */ package org.apache.olingo.client.api.communication.request.cud.v4; +import java.net.URI; import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory; +import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; +import org.apache.olingo.commons.api.domain.v4.Singleton; public interface CUDRequestFactory extends CommonCUDRequestFactory<UpdateType> { + + ODataEntityUpdateRequest<Singleton> getSingletonUpdateRequest(URI targetURI, UpdateType type, Singleton changes); + + ODataEntityUpdateRequest<Singleton> getSingletonUpdateRequest(UpdateType type, Singleton entity); + } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java ---------------------------------------------------------------------- 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 639ac68..592cbd8 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 @@ -27,6 +27,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataProperty 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.api.domain.v4.Singleton; @SuppressWarnings("unchecked") public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory { @@ -37,11 +38,13 @@ public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory { @Override ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri); + ODataEntityRequest<Singleton> getSingletonRequest(URI uri); + @Override ODataEntityRequest<ODataEntity> getEntityRequest(URI uri); @Override ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri); - + ODataDeltaRequest getDeltaRequest(URI uri); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v4/CUDRequestFactoryImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v4/CUDRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v4/CUDRequestFactoryImpl.java index 8d4e7c7..7f1dee9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v4/CUDRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v4/CUDRequestFactoryImpl.java @@ -18,10 +18,13 @@ */ package org.apache.olingo.client.core.communication.request.cud.v4; +import java.net.URI; +import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; import org.apache.olingo.client.core.communication.request.cud.AbstractCUDRequestFactory; +import org.apache.olingo.commons.api.domain.v4.Singleton; public class CUDRequestFactoryImpl extends AbstractCUDRequestFactory<UpdateType> implements CUDRequestFactory { @@ -32,4 +35,18 @@ public class CUDRequestFactoryImpl extends AbstractCUDRequestFactory<UpdateType> super(client); } + @Override + public ODataEntityUpdateRequest<Singleton> getSingletonUpdateRequest( + final UpdateType type, final Singleton entity) { + + return super.getEntityUpdateRequest(type, entity); + } + + @Override + public ODataEntityUpdateRequest<Singleton> getSingletonUpdateRequest( + final URI targetURI, final UpdateType type, final Singleton changes) { + + return super.getEntityUpdateRequest(targetURI, type, changes); + } + } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java ---------------------------------------------------------------------- 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 f766de6..804d2de 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 @@ -35,6 +35,7 @@ import org.apache.olingo.client.core.communication.request.retrieve.ODataPropert 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.api.domain.v4.Singleton; @SuppressWarnings("unchecked") public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory @@ -63,6 +64,11 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory } @Override + public ODataEntityRequest<Singleton> getSingletonRequest(final URI uri) { + return new ODataEntityRequestImpl<Singleton>(client, uri); + } + + @Override public ODataEntityRequest<ODataEntity> getEntityRequest(final URI uri) { return new ODataEntityRequestImpl<ODataEntity>(client, uri); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java ---------------------------------------------------------------------- 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 index b027027..73b2944 100644 --- 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 @@ -40,6 +40,8 @@ public interface ODataObjectFactory extends CommonODataObjectFactory { @Override ODataEntity newEntity(FullQualifiedName typeName, URI link); + Singleton newSingleton(FullQualifiedName typeName); + @Override ODataLink newEntitySetNavigationLink(String name, URI link); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/Singleton.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/Singleton.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/Singleton.java new file mode 100644 index 0000000..989b534 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/Singleton.java @@ -0,0 +1,22 @@ +/* + * 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 Singleton extends ODataEntity { +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java ---------------------------------------------------------------------- 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 index 0dd296f..f61e896 100644 --- 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 @@ -23,10 +23,11 @@ import java.util.List; import org.apache.olingo.commons.api.domain.v4.ODataAnnotation; import org.apache.olingo.commons.api.domain.v4.ODataEntity; import org.apache.olingo.commons.api.domain.v4.ODataProperty; +import org.apache.olingo.commons.api.domain.v4.Singleton; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.domain.AbstractODataEntity; -public class ODataEntityImpl extends AbstractODataEntity implements ODataEntity { +public class ODataEntityImpl extends AbstractODataEntity implements ODataEntity, Singleton { private static final long serialVersionUID = -3997704808753685990L; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c82e0212/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java ---------------------------------------------------------------------- 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 index bc3809f..8ebdaeb 100644 --- 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 @@ -33,6 +33,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataLink; import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue; import org.apache.olingo.commons.api.domain.v4.ODataProperty; import org.apache.olingo.commons.api.domain.v4.ODataValue; +import org.apache.olingo.commons.api.domain.v4.Singleton; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.core.domain.AbstractODataObjectFactory; @@ -66,6 +67,11 @@ public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implement } @Override + public Singleton newSingleton(final FullQualifiedName typeName) { + return new ODataEntityImpl(typeName); + } + + @Override public ODataLink newEntityNavigationLink(final String name, final URI link) { return new ODataLink.Builder().setVersion(version).setURI(link). setType(ODataLinkType.ENTITY_NAVIGATION).setTitle(name).build();
