From 4ead5f41b8a8467075509ec8dae1b6bd93b943cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global> Date: Thu, 31 Jul 2014 11:08:13 +0200 Subject: [PATCH] [OLINGO-365] Better handling of derived types in entity and complex type collections --- .../olingo/ext/proxy/AbstractService.java | 2 + .../AbstractCollectionInvocationHandler.java | 1 - ...ractEntityCollectionInvocationHandler.java | 14 +++++-- .../ComplexCollectionInvocationHandler.java | 11 +++++- .../PrimitiveCollectionInvocationHandler.java | 4 +- .../ext/pojogen/AbstractPOJOGenMojo.java | 11 ++++-- .../src/main/resources/service.vm | 10 +++++ .../proxy/v3/actionoverloading/Service.java | 39 +++++++++++++++++++ .../olingo/fit/proxy/v3/opentype/Service.java | 10 +++++ .../fit/proxy/v3/primitivekeys/Service.java | 22 +++++++++++ .../fit/proxy/v3/staticservice/Service.java | 39 +++++++++++++++++++ .../olingo/fit/proxy/v4/demo/Service.java | 17 ++++++++ .../olingo/fit/proxy/v4/opentype/Service.java | 10 +++++ .../fit/proxy/v4/staticservice/Service.java | 29 ++++++++++++++ 14 files changed, 208 insertions(+), 11 deletions(-) diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java index a2a05fd6a..958494f4f 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java @@ -91,6 +91,8 @@ public abstract class AbstractService> this.context = new Context(); } + public abstract Class getEntityTypeClass(String name); + public abstract Class getComplexTypeClass(String name); public abstract Class getEnumTypeClass(String name); diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java index d276302f8..a24565c35 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java @@ -93,7 +93,6 @@ public abstract class AbstractCollectionInvocationHandler execute() { if (this.uri != null) { final Triple, URI, List> res = fetchPartial(this.uri.build(), itemRef); diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java index 9a15c78e0..b7e436048 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java @@ -129,23 +129,31 @@ public abstract class AbstractEntityCollectionInvocationHandler< final List res = new ArrayList(entities.size()); for (CommonODataEntity entity : entities) { + Class actualRef = null; + if (entity.getTypeName() != null) { + actualRef = service.getEntityTypeClass(entity.getTypeName().toString()); + } + if (actualRef == null) { + actualRef = typeRef; + } + final EntityInvocationHandler handler = this instanceof EntitySetInvocationHandler ? EntityInvocationHandler.getInstance( entity, EntitySetInvocationHandler.class.cast(this), - typeRef) + actualRef) : EntityInvocationHandler.getInstance( entity, targetEntitySetURI, - typeRef, + actualRef, service); final EntityInvocationHandler handlerInTheContext = getContext().entityContext().getEntity(handler.getUUID()); res.add((T) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), - new Class[] {typeRef}, + new Class[] {actualRef}, handlerInTheContext == null ? handler : handlerInTheContext)); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexCollectionInvocationHandler.java index 1fe242bcf..342a2a650 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexCollectionInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexCollectionInvocationHandler.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest; @@ -110,7 +111,15 @@ public class ComplexCollectionInvocationHandler> final CommonODataProperty property = res.getBody(); if (property != null && property.hasCollectionValue()) { for (ODataValue item : (ODataCollectionValue) property.getValue()) { - resItems.add((T) getComplex(property.getName(), item, typeRef, null, null, true)); + Class actualRef = null; + if (StringUtils.isNotBlank(item.getTypeName())) { + actualRef = service.getComplexTypeClass(item.getTypeName()); + } + if (actualRef == null) { + actualRef = typeRef; + } + + resItems.add((T) getComplex(property.getName(), item, actualRef, null, null, true)); } } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/PrimitiveCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/PrimitiveCollectionInvocationHandler.java index 48908c9b1..650e36951 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/PrimitiveCollectionInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/PrimitiveCollectionInvocationHandler.java @@ -101,9 +101,9 @@ public class PrimitiveCollectionInvocationHandler final ODataRetrieveResponse res = req.execute(); - List resItems = new ArrayList(); + final List resItems = new ArrayList(); - org.apache.olingo.commons.api.domain.v4.ODataProperty property = res.getBody(); + final org.apache.olingo.commons.api.domain.v4.ODataProperty property = res.getBody(); if (property != null && !property.hasNullValue()) { for (ODataValue item : property.getCollectionValue()) { resItems.add((T) item.asPrimitive().toValue()); diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java index df3d0d31e..aff8559e3 100644 --- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java +++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java @@ -247,6 +247,7 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo { namespaces.add(schema.getNamespace().toLowerCase()); } + final Map entityTypeNames = new HashMap(); final Map complexTypeNames = new HashMap(); final Map enumTypeNames = new HashMap(); final Map termNames = new HashMap(); @@ -298,6 +299,9 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo { } for (EdmEntityType entity : schema.getEntityTypes()) { + final String className = utility.capitalize(entity.getName()); + entityTypeNames.put(entity.getFullQualifiedName().toString(), typesPkg + "." + className); + objs.clear(); objs.put("entityType", entity); @@ -328,10 +332,8 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo { } } - parseObj(typesBaseDir, typesPkg, "entityType", - utility.capitalize(entity.getName()) + ".java", objs); - parseObj(typesBaseDir, typesPkg, "entityCollection", - utility.capitalize(entity.getName()) + "Collection.java", objs); + parseObj(typesBaseDir, typesPkg, "entityType", className + ".java", objs); + parseObj(typesBaseDir, typesPkg, "entityCollection", className + "Collection.java", objs); } // write container and top entity sets into the base package @@ -366,6 +368,7 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo { objs.clear(); objs.put("metadata", new String(Base64.encodeBase64(baos.toByteArray()), "UTF-8")); objs.put("metadataETag", metadata.getMiddle()); + objs.put("entityTypes", entityTypeNames); objs.put("complexTypes", complexTypeNames); objs.put("enumTypes", enumTypeNames); objs.put("terms", termNames); diff --git a/ext/pojogen-maven-plugin/src/main/resources/service.vm b/ext/pojogen-maven-plugin/src/main/resources/service.vm index 6078c108e..e17289269 100644 --- a/ext/pojogen-maven-plugin/src/main/resources/service.vm +++ b/ext/pojogen-maven-plugin/src/main/resources/service.vm @@ -100,6 +100,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -112,6 +114,9 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) +#foreach ($entityType in $entityTypes.entrySet()) + entityTypes.put("$entityType.key", ${entityType.value}.class); +#end #foreach ($complexType in $complexTypes.entrySet()) complexTypes.put("$complexType.key", ${complexType.value}.class); #end @@ -124,6 +129,11 @@ public class Service> extends AbstractS //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java index 076f6c014..18a280705 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,6 +112,38 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductDetail", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ProductDetail.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.License", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.License.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductReview", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ProductReview.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Customer.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialCollectionTypes_Simple", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes_Simple.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialTypes", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypes.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.DiscontinuedProduct", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.DiscontinuedProduct.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Driver", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Driver.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Login", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Login.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.PageView", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.PageView.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.PersonMetadata", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.PersonMetadata.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.LastLogin", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.LastLogin.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.SpecialEmployee.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Car", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Car.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductPageView", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ProductPageView.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.MappedEntityType", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.MappedEntityType.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.MessageAttachment", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.MessageAttachment.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Employee.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.BackOrderLine2", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.BackOrderLine2.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Computer", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Computer.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Message", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Message.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductPhoto", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ProductPhoto.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ComputerDetail", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ComputerDetail.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.CustomerInfo.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Product", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Product.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.OrderLine", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.OrderLine.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Contractor", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Contractor.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Person", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Person.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Order", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Order.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.RSAToken", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.RSAToken.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialCollectionTypes", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.BackOrderLine", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.BackOrderLine.class); complexTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ComplexToCategory", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ComplexToCategory.class); complexTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ContactDetails.class); complexTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Dimensions", org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Dimensions.class); @@ -120,6 +154,11 @@ public class Service> extends AbstractS //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/opentype/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/opentype/Service.java index 95e51b711..abc7a3074 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/opentype/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/opentype/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,10 +112,18 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV3.Row", org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.Row.class); + entityTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV3.RowIndex", org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.RowIndex.class); + entityTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV3.IndexedRow", org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.IndexedRow.class); complexTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV3.ContactDetails", org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.ContactDetails.class); //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/primitivekeys/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/primitivekeys/Service.java index 581d4a94c..98b1fc871 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/primitivekeys/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/primitivekeys/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,9 +112,29 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmDateTime", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmDateTime.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmDouble", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmDouble.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmString", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmString.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.Folder", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.Folder.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmByte", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmByte.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmGuid", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmGuid.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmTime", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmTime.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmDateTimeOffset", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmDateTimeOffset.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmInt64", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmInt64.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmBoolean", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmBoolean.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmInt16", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmInt16.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmDecimal", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmDecimal.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmSingle", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmSingle.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmBinary", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmBinary.class); + entityTypes.put("Microsoft.Test.OData.Services.PrimitiveKeysService.EdmInt32", org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.types.EdmInt32.class); //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/staticservice/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/staticservice/Service.java index c224e15ae..e42373925 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/staticservice/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/staticservice/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,6 +112,38 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductDetail", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ProductDetail.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.License", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.License.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductReview", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ProductReview.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialCollectionTypes_Simple", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes_Simple.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Customer.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialTypes", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypes.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.DiscontinuedProduct", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.DiscontinuedProduct.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Driver", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Driver.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Login", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Login.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.PageView", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.PageView.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.LastLogin", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.LastLogin.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.PersonMetadata", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.PersonMetadata.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.SpecialEmployee.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductPageView", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ProductPageView.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Car", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Car.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.MappedEntityType", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.MappedEntityType.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.MessageAttachment", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.MessageAttachment.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Employee.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.BackOrderLine2", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.BackOrderLine2.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Computer", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Computer.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Message", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Message.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ProductPhoto", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ProductPhoto.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ComputerDetail", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ComputerDetail.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.CustomerInfo.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Product", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Product.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.OrderLine", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.OrderLine.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Contractor", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Contractor.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Person", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Person.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.Order", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Order.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.RSAToken", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.RSAToken.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialCollectionTypes", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes.class); + entityTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.BackOrderLine", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.BackOrderLine.class); complexTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ComplexToCategory", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ComplexToCategory.class); complexTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ContactDetails.class); complexTypes.put("Microsoft.Test.OData.Services.AstoriaDefaultService.ComplexWithAllPrimitiveTypes", org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ComplexWithAllPrimitiveTypes.class); @@ -121,6 +155,11 @@ public class Service> extends AbstractS //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/Service.java index 2f790950d..02375ca78 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,10 +112,25 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("ODataDemo.Customer", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Customer.class); + entityTypes.put("ODataDemo.PersonDetail", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.PersonDetail.class); + entityTypes.put("ODataDemo.ProductDetail", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.ProductDetail.class); + entityTypes.put("ODataDemo.Employee", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Employee.class); + entityTypes.put("ODataDemo.Product", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Product.class); + entityTypes.put("ODataDemo.Advertisement", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Advertisement.class); + entityTypes.put("ODataDemo.Category", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Category.class); + entityTypes.put("ODataDemo.Person", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Person.class); + entityTypes.put("ODataDemo.Supplier", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Supplier.class); + entityTypes.put("ODataDemo.FeaturedProduct", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.FeaturedProduct.class); complexTypes.put("ODataDemo.Address", org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Address.class); //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/Service.java index 6823b5edc..f2ab7eaac 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,12 +112,20 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV4.Row", org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row.class); + entityTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV4.IndexedRow", org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.IndexedRow.class); + entityTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV4.RowIndex", org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.RowIndex.class); complexTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV4.AccountInfo", org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.AccountInfo.class); complexTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV4.ContactDetails", org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.ContactDetails.class); enumTypes.put("Microsoft.Test.OData.Services.OpenTypesServiceV4.Color", org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Color.class); //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/Service.java index 6b1965c24..445de0158 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/Service.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/Service.java @@ -98,6 +98,8 @@ public class Service> extends AbstractS return getInstance(ODataServiceVersion.V40, serviceRoot, transactional); } + private final Map> entityTypes = new HashMap>(); + private final Map> complexTypes = new HashMap>(); private final Map> enumTypes = new HashMap>(); @@ -110,6 +112,28 @@ public class Service> extends AbstractS super(compressedMetadata, metadataETag,version, serviceRoot, transactional); //CHECKSTYLE:OFF (Maven checkstyle) + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CreditCardPI.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Account", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Account.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetail.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Order", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Statement", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Statement.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Subscription", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Subscription.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Person", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.GiftCard", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.GiftCard.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.OrderDetail", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Product", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Customer", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Club", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Club.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.ProductReview", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductReview.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Department", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Department.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Asset", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Asset.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Employee", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.StoredPI", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Company", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.CreditRecord", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CreditRecord.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.LabourUnion", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.LabourUnion.class); + entityTypes.put("Microsoft.Test.OData.Services.ODataWCFService.PublicCompany", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PublicCompany.class); complexTypes.put("Microsoft.Test.OData.Services.ODataWCFService.Address", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address.class); complexTypes.put("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress.class); complexTypes.put("Microsoft.Test.OData.Services.ODataWCFService.AccountInfo", org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo.class); @@ -121,6 +145,11 @@ public class Service> extends AbstractS //CHECKSTYLE:ON (Maven checkstyle) } + @Override + public Class getEntityTypeClass(final String name) { + return entityTypes.get(name); + } + @Override public Class getComplexTypeClass(final String name) { return complexTypes.get(name);