[OLINGO-575] Merge EdmImpl classes
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/5cef4fae Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/5cef4fae Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/5cef4fae Branch: refs/heads/master Commit: 5cef4faeb6766148dc886af87650c8715985807d Parents: 36219d3 Author: Christian Amend <[email protected]> Authored: Wed Mar 18 13:55:50 2015 +0100 Committer: Christian Amend <[email protected]> Committed: Wed Mar 18 13:55:50 2015 +0100 ---------------------------------------------------------------------- .../olingo/ext/proxy/AbstractService.java | 48 +-- .../proxy/api/annotations/EntityContainer.java | 1 - .../commons/AbstractInvocationHandler.java | 18 +- .../EntityContainerInvocationHandler.java | 7 - .../olingo/ext/proxy/utils/CoreUtils.java | 28 +- .../src/main/resources/container.vm | 3 +- .../proxy/v4/demo/odatademo/DemoService.java | 3 +- .../opentypesservicev4/DefaultContainer.java | 3 +- .../odatawcfservice/InMemoryEntities.java | 3 +- .../client/core/edm/ClientEdmProvider.java | 211 +++++++++++ .../olingo/client/core/edm/EdmActionImpl.java | 36 -- .../client/core/edm/EdmActionImportImpl.java | 77 ---- .../core/edm/EdmAnnotationHelperImpl.java | 67 ---- .../client/core/edm/EdmAnnotationImpl.java | 244 ------------ .../client/core/edm/EdmAnnotationsImpl.java | 147 -------- .../client/core/edm/EdmBindingTargetImpl.java | 75 ---- .../olingo/client/core/edm/EdmClientImpl.java | 357 ------------------ .../client/core/edm/EdmComplexTypeImpl.java | 93 ----- .../client/core/edm/EdmEntityContainerImpl.java | 173 --------- .../client/core/edm/EdmEntitySetImpl.java | 48 --- .../client/core/edm/EdmEntityTypeImpl.java | 113 ------ .../olingo/client/core/edm/EdmEnumTypeImpl.java | 98 ----- .../olingo/client/core/edm/EdmFunctionImpl.java | 44 --- .../client/core/edm/EdmFunctionImportImpl.java | 89 ----- .../client/core/edm/EdmKeyPropertyRefImpl.java | 43 --- .../olingo/client/core/edm/EdmMemberImpl.java | 54 --- .../core/edm/EdmNavigationPropertyImpl.java | 123 ------ .../client/core/edm/EdmOperationImpl.java | 113 ------ .../client/core/edm/EdmOperationImportImpl.java | 48 --- .../client/core/edm/EdmParameterImpl.java | 96 ----- .../olingo/client/core/edm/EdmPropertyImpl.java | 121 ------ .../core/edm/EdmReferentialConstraintImpl.java | 49 --- .../client/core/edm/EdmReturnTypeImpl.java | 74 ---- .../olingo/client/core/edm/EdmSchemaImpl.java | 237 ------------ .../client/core/edm/EdmSingletonImpl.java | 40 -- .../core/edm/EdmStructuredTypeHelperImpl.java | 85 ----- .../olingo/client/core/edm/EdmTermImpl.java | 170 --------- .../client/core/edm/EdmTypeDefinitionImpl.java | 98 ----- .../client/core/edm/annotation/EdmCastImpl.java | 80 ---- .../EdmConstantAnnotationExpressionImpl.java | 139 ------- .../client/core/edm/annotation/EdmIsOfImpl.java | 80 ---- .../core/edm/annotation/EdmRecordImpl.java | 55 --- .../edm/xml/NavigationPropertyDeserializer.java | 26 +- .../core/edm/xml/ParameterDeserializer.java | 10 +- .../core/edm/xml/PropertyDeserializer.java | 10 +- .../client/core/edm/xml/PropertyImpl.java | 4 +- .../core/edm/xml/ReturnTypeDeserializer.java | 10 +- .../core/serialization/ODataReaderImpl.java | 6 +- .../olingo/client/core/uri/URIEscapeTest.java | 2 +- .../client/core/uri/v4/FilterFactoryTest.java | 2 +- .../olingo/client/core/v4/MetadataTest.java | 89 ++--- .../commons/api/edm/EdmEntityContainer.java | 9 - .../commons/api/edm/provider/EdmProvider.java | 20 +- .../api/edm/provider/TypeDefinition.java | 5 +- .../core/edm/AbstractEdmEntityContainer.java | 5 - .../commons/core/edm/AbstractEdmEnumType.java | 2 +- .../core/edm/annotation/EdmCastImpl.java | 79 ++++ .../EdmConstantAnnotationExpressionImpl.java | 139 +++++++ .../core/edm/annotation/EdmIsOfImpl.java | 79 ++++ .../core/edm/annotation/EdmRecordImpl.java | 54 +++ .../core/edm/provider/EdmActionImpl.java | 36 ++ .../core/edm/provider/EdmActionImportImpl.java | 46 +++ .../edm/provider/EdmAnnotationHelperImpl.java | 67 ++++ .../core/edm/provider/EdmAnnotationImpl.java | 244 ++++++++++++ .../core/edm/provider/EdmAnnotationsImpl.java | 143 +++++++ .../core/edm/provider/EdmBindingTargetImpl.java | 71 ++++ .../core/edm/provider/EdmComplexTypeImpl.java | 82 ++++ .../edm/provider/EdmEntityContainerImpl.java | 216 +++++++++++ .../core/edm/provider/EdmEntitySetImpl.java | 44 +++ .../core/edm/provider/EdmEntityTypeImpl.java | 112 ++++++ .../core/edm/provider/EdmEnumTypeImpl.java | 87 +++++ .../core/edm/provider/EdmFunctionImpl.java | 56 +++ .../edm/provider/EdmFunctionImportImpl.java | 63 ++++ .../edm/provider/EdmKeyPropertyRefImpl.java | 43 +++ .../core/edm/provider/EdmMemberImpl.java | 50 +++ .../edm/provider/EdmNavigationPropertyImpl.java | 116 ++++++ .../core/edm/provider/EdmOperationImpl.java | 99 +++++ .../edm/provider/EdmOperationImportImpl.java | 52 +++ .../core/edm/provider/EdmParameterImpl.java | 87 +++++ .../core/edm/provider/EdmPropertyImpl.java | 119 ++++++ .../core/edm/provider/EdmProviderImpl.java | 376 +++++++++++++++++++ .../provider/EdmReferentialConstraintImpl.java | 48 +++ .../core/edm/provider/EdmReturnTypeImpl.java | 64 ++++ .../core/edm/provider/EdmSchemaImpl.java | 194 ++++++++++ .../core/edm/provider/EdmSingletonImpl.java | 36 ++ .../provider/EdmStructuredTypeHelperImpl.java | 84 +++++ .../commons/core/edm/provider/EdmTermImpl.java | 170 +++++++++ .../edm/provider/EdmTypeDefinitionImpl.java | 107 ++++++ .../olingo/server/core/ServiceMetadataImpl.java | 2 +- .../server/core/edm/provider/EdmActionImpl.java | 36 -- .../core/edm/provider/EdmActionImportImpl.java | 47 --- .../core/edm/provider/EdmBindingTargetImpl.java | 55 --- .../core/edm/provider/EdmComplexTypeImpl.java | 78 ---- .../edm/provider/EdmEntityContainerImpl.java | 208 ---------- .../core/edm/provider/EdmEntitySetImpl.java | 58 --- .../core/edm/provider/EdmEntityTypeImpl.java | 109 ------ .../core/edm/provider/EdmEnumTypeImpl.java | 71 ---- .../core/edm/provider/EdmFunctionImpl.java | 56 --- .../edm/provider/EdmFunctionImportImpl.java | 70 ---- .../edm/provider/EdmKeyPropertyRefImpl.java | 43 --- .../server/core/edm/provider/EdmMemberImpl.java | 45 --- .../edm/provider/EdmNavigationPropertyImpl.java | 117 ------ .../core/edm/provider/EdmOperationImpl.java | 97 ----- .../edm/provider/EdmOperationImportImpl.java | 48 --- .../core/edm/provider/EdmParameterImpl.java | 84 ----- .../core/edm/provider/EdmPropertyImpl.java | 118 ------ .../core/edm/provider/EdmProviderImpl.java | 343 ----------------- .../provider/EdmReferentialConstraintImpl.java | 42 --- .../core/edm/provider/EdmReturnTypeImpl.java | 64 ---- .../server/core/edm/provider/EdmSchemaImpl.java | 168 --------- .../core/edm/provider/EdmSingletonImpl.java | 50 --- .../provider/EdmStructuredTypeHelperImpl.java | 89 ----- .../edm/provider/EdmTypeDefinitionImpl.java | 95 ----- .../core/edm/provider/EdmActionImplTest.java | 2 + .../edm/provider/EdmActionImportImplTest.java | 2 + .../edm/provider/EdmComplexTypeImplTest.java | 2 + .../provider/EdmEntityContainerImplTest.java | 2 + .../core/edm/provider/EdmEntitySetImplTest.java | 3 + .../edm/provider/EdmEntityTypeImplTest.java | 2 + .../server/core/edm/provider/EdmEnumTest.java | 2 + .../core/edm/provider/EdmFunctionImplTest.java | 2 + .../edm/provider/EdmFunctionImportImplTest.java | 3 + .../edm/provider/EdmKeyPropertyRefImplTest.java | 1 + .../core/edm/provider/EdmMappingTest.java | 2 + .../core/edm/provider/EdmMemberImplTest.java | 5 +- .../provider/EdmNavigationPropertyImplTest.java | 2 + .../core/edm/provider/EdmParameterImplTest.java | 2 + .../core/edm/provider/EdmPropertyImplTest.java | 2 + .../EdmProviderImplOverloadingTest.java | 1 + .../core/edm/provider/EdmProviderImplTest.java | 1 + .../edm/provider/EdmReturnTypeImplTest.java | 2 + .../core/edm/provider/EdmSchemaImplTest.java | 8 +- .../core/edm/provider/EdmSingletonImplTest.java | 3 + .../edm/provider/EdmTypeDefinitionImplTest.java | 2 + .../core/serializer/json/ComplexTypeHelper.java | 4 +- .../serializer/utils/ContextURLBuilderTest.java | 4 +- .../xml/MetadataDocumentXmlSerializerTest.java | 3 +- .../olingo/server/core/uri/UriInfoImplTest.java | 2 +- .../server/core/uri/UriResourceImplTest.java | 8 +- .../core/uri/antlr/TestFullResourcePath.java | 2 +- .../core/uri/antlr/TestUriParserImpl.java | 2 +- .../core/uri/queryoption/QueryOptionTest.java | 2 +- .../queryoption/expression/ExpressionTest.java | 2 +- .../core/uri/validator/UriValidatorTest.java | 2 +- 144 files changed, 3712 insertions(+), 5717 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java ---------------------------------------------------------------------- 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 7fac96c..fd34aa9 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -30,11 +30,12 @@ import org.apache.commons.io.IOUtils; import org.apache.olingo.client.api.EdmEnabledODataClient; import org.apache.olingo.client.api.edm.xml.XMLMetadata; import org.apache.olingo.client.core.ODataClientFactory; -import org.apache.olingo.client.core.edm.EdmClientImpl; +import org.apache.olingo.client.core.edm.ClientEdmProvider; import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.api.format.ODataFormat; +import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl; import org.apache.olingo.ext.proxy.api.AbstractTerm; import org.apache.olingo.ext.proxy.api.PersistenceManager; import org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler; @@ -64,7 +65,7 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> { private PersistenceManager persistenceManager; protected AbstractService(final String compressedMetadata, final String metadataETag, - final ODataServiceVersion version, final String serviceRoot, final boolean transactional) { + final ODataServiceVersion version, final String serviceRoot, final boolean transactional) { ByteArrayInputStream bais = null; GZIPInputStream gzis = null; @@ -83,21 +84,26 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> { IOUtils.closeQuietly(gzis); IOUtils.closeQuietly(bais); } - - final Edm edm = metadata == null ? null : new EdmClientImpl(metadata.getSchemaByNsOrAlias()); - //TODO: check runtime exception or not - if(version.compareTo(ODataServiceVersion.V40) < 0){ + final Edm edm; + if (metadata != null) { + ClientEdmProvider provider = new ClientEdmProvider(metadata.getSchemaByNsOrAlias()); + edm = new EdmProviderImpl(provider); + }else{ + edm = null; + } + // TODO: check runtime exception or not + if (version.compareTo(ODataServiceVersion.V40) < 0) { throw new ODataRuntimeException("Only OData V4 or higher supported."); } - - this.client = ODataClientFactory.getEdmEnabledClient(serviceRoot, edm, metadataETag); + + this.client = ODataClientFactory.getEdmEnabledClient(serviceRoot, edm, metadataETag); this.client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_FULL_METADATA); this.transactional = transactional; this.context = new Context(); } public abstract Class<?> getEntityTypeClass(String name); - + public abstract Class<?> getComplexTypeClass(String name); public abstract Class<?> getEnumTypeClass(String name); @@ -121,8 +127,8 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> { synchronized (this) { if (persistenceManager == null) { persistenceManager = transactional - ? new TransactionalPersistenceManagerImpl(this) - : new NonTransactionalPersistenceManagerImpl(this); + ? new TransactionalPersistenceManagerImpl(this) + : new NonTransactionalPersistenceManagerImpl(this); } } return persistenceManager; @@ -139,9 +145,9 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> { public <T> T getEntityContainer(final Class<T> reference) throws IllegalStateException, IllegalArgumentException { if (!ENTITY_CONTAINERS.containsKey(reference)) { final Object entityContainer = Proxy.newProxyInstance( - Thread.currentThread().getContextClassLoader(), - new Class<?>[] {reference}, - EntityContainerInvocationHandler.getInstance(reference, this)); + Thread.currentThread().getContextClassLoader(), + new Class<?>[] { reference }, + EntityContainerInvocationHandler.getInstance(reference, this)); ENTITY_CONTAINERS.put(reference, entityContainer); } return reference.cast(ENTITY_CONTAINERS.get(reference)); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntityContainer.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntityContainer.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntityContainer.java index bf89784..1cb320e 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntityContainer.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntityContainer.java @@ -34,5 +34,4 @@ public @interface EntityContainer { String namespace(); - boolean isDefaultEntityContainer() default false; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java index d0d26d3..69ccdc0 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java @@ -26,7 +26,6 @@ import java.lang.reflect.UndeclaredThrowableException; import java.net.URI; import java.util.Arrays; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; @@ -35,8 +34,6 @@ import org.apache.olingo.client.api.EdmEnabledODataClient; import org.apache.olingo.client.api.uri.URIBuilder; import org.apache.olingo.commons.api.domain.ODataEntity; import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.api.ComplexType; @@ -213,15 +210,16 @@ abstract class AbstractInvocationHandler implements InvocationHandler { final String containerNS, final String entitySetName, final AbstractService<?> service) { final URIBuilder uriBuilder = service.getClient().newURIBuilder(); - final Edm edm = service.getClient().getCachedEdm(); +// final Edm edm = service.getClient().getCachedEdm(); final StringBuilder entitySetSegment = new StringBuilder(); - if (StringUtils.isNotBlank(containerNS)) { - final EdmEntityContainer container = edm.getEntityContainer(new FullQualifiedName(containerNS)); - if (!container.isDefault()) { - entitySetSegment.append(container.getFullQualifiedName().toString()).append('.'); - } - } + //TODO: Container is always default in v4 +// if (StringUtils.isNotBlank(containerNS)) { +// final EdmEntityContainer container = edm.getEntityContainer(new FullQualifiedName(containerNS)); +// if (!container.isDefault()) { +// entitySetSegment.append(container.getFullQualifiedName().toString()).append('.'); +// } +// } entitySetSegment.append(entitySetName); uriBuilder.appendEntitySetSegment(entitySetSegment.toString()); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java index e746b8f..ffb5902 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java @@ -46,8 +46,6 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa protected final String namespace; private final String name; - private final boolean defaultEC; - public static EntityContainerInvocationHandler getInstance(final Class<?> ref, final AbstractService<?> service) { final EntityContainerInvocationHandler instance = new EntityContainerInvocationHandler(ref, service); @@ -64,7 +62,6 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa } this.name = ((EntityContainer) annotation).name(); - this.defaultEC = ((EntityContainer) annotation).isDefaultEntityContainer(); this.namespace = ((EntityContainer) annotation).namespace(); } @@ -72,10 +69,6 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa return service; } - protected boolean isDefaultEntityContainer() { - return defaultEC; - } - protected String getEntityContainerName() { return name; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java index 4bb75ff..6cd82d7 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java @@ -49,9 +49,7 @@ 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.ODataValue; -import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmElement; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmTerm; @@ -655,22 +653,22 @@ public final class CoreUtils { public static URI getTargetEntitySetURI( final EdmEnabledODataClient client, final NavigationProperty property) { - final Edm edm = client.getCachedEdm(); +// final Edm edm = client.getCachedEdm(); +// +// final FullQualifiedName containerName = +// new FullQualifiedName(property.targetSchema(), property.targetContainer()); - final FullQualifiedName containerName = - new FullQualifiedName(property.targetSchema(), property.targetContainer()); - - final EdmEntityContainer container = edm.getEntityContainer(containerName); +// final EdmEntityContainer container = edm.getEntityContainer(containerName); final URIBuilder uriBuilder = client.newURIBuilder(client.getServiceRoot()); - - if (!container.isDefault()) { - final StringBuilder entitySetSegment = new StringBuilder(); - entitySetSegment.append(container.getFullQualifiedName()).append('.'); - entitySetSegment.append(property.targetEntitySet()); - uriBuilder.appendEntitySetSegment(entitySetSegment.toString()); - } else { +//TODO: Container can only be default in V4 +// if (!container.isDefault()) { +// final StringBuilder entitySetSegment = new StringBuilder(); +// entitySetSegment.append(container.getFullQualifiedName()).append('.'); +// entitySetSegment.append(property.targetEntitySet()); +// uriBuilder.appendEntitySetSegment(entitySetSegment.toString()); +// } else { uriBuilder.appendEntitySetSegment(property.targetEntitySet()); - } +// } return uriBuilder.build(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/ext/pojogen-maven-plugin/src/main/resources/container.vm ---------------------------------------------------------------------- diff --git a/ext/pojogen-maven-plugin/src/main/resources/container.vm b/ext/pojogen-maven-plugin/src/main/resources/container.vm index d8ba500..2042839 100644 --- a/ext/pojogen-maven-plugin/src/main/resources/container.vm +++ b/ext/pojogen-maven-plugin/src/main/resources/container.vm @@ -56,8 +56,7 @@ import javax.xml.datatype.Duration; @org.apache.olingo.ext.proxy.api.annotations.Namespace("$namespace") @org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "$container.Name", - namespace = "$namespace", - isDefaultEntityContainer = $container.Default) + namespace = "$namespace") public interface $utility.capitalize($container.Name) extends PersistenceManager { #foreach($entitySet in $container.EntitySets) http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/DemoService.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/DemoService.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/DemoService.java index 3ff32a0..e75b499 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/DemoService.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/DemoService.java @@ -33,8 +33,7 @@ import java.io.InputStream; @org.apache.olingo.ext.proxy.api.annotations.Namespace("ODataDemo") @org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "DemoService", - namespace = "ODataDemo", - isDefaultEntityContainer = true) + namespace = "ODataDemo") public interface DemoService extends PersistenceManager { Products getProducts(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java index 5df94ce..2dfebc8 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java @@ -32,8 +32,7 @@ import java.io.InputStream; @org.apache.olingo.ext.proxy.api.annotations.Namespace("Microsoft.Test.OData.Services.OpenTypesServiceV4") @org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "DefaultContainer", - namespace = "Microsoft.Test.OData.Services.OpenTypesServiceV4", - isDefaultEntityContainer = true) + namespace = "Microsoft.Test.OData.Services.OpenTypesServiceV4") public interface DefaultContainer extends PersistenceManager { Row getRow(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/InMemoryEntities.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/InMemoryEntities.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/InMemoryEntities.java index 0f226e0..930b789 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/InMemoryEntities.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/InMemoryEntities.java @@ -33,8 +33,7 @@ import java.io.InputStream; @org.apache.olingo.ext.proxy.api.annotations.Namespace("Microsoft.Test.OData.Services.ODataWCFService") @org.apache.olingo.ext.proxy.api.annotations.EntityContainer(name = "InMemoryEntities", - namespace = "Microsoft.Test.OData.Services.ODataWCFService", - isDefaultEntityContainer = true) + namespace = "Microsoft.Test.OData.Services.ODataWCFService") public interface InMemoryEntities extends PersistenceManager { Accounts getAccounts(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java new file mode 100644 index 0000000..4327e62 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java @@ -0,0 +1,211 @@ +/* + * 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.client.core.edm; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.olingo.commons.api.ODataException; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.provider.Action; +import org.apache.olingo.commons.api.edm.provider.ActionImport; +import org.apache.olingo.commons.api.edm.provider.AliasInfo; +import org.apache.olingo.commons.api.edm.provider.Annotatable; +import org.apache.olingo.commons.api.edm.provider.Annotations; +import org.apache.olingo.commons.api.edm.provider.ComplexType; +import org.apache.olingo.commons.api.edm.provider.EdmProvider; +import org.apache.olingo.commons.api.edm.provider.EntityContainer; +import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo; +import org.apache.olingo.commons.api.edm.provider.EntitySet; +import org.apache.olingo.commons.api.edm.provider.EntityType; +import org.apache.olingo.commons.api.edm.provider.EnumType; +import org.apache.olingo.commons.api.edm.provider.Function; +import org.apache.olingo.commons.api.edm.provider.FunctionImport; +import org.apache.olingo.commons.api.edm.provider.Schema; +import org.apache.olingo.commons.api.edm.provider.Singleton; +import org.apache.olingo.commons.api.edm.provider.Term; +import org.apache.olingo.commons.api.edm.provider.TypeDefinition; + +public class ClientEdmProvider extends EdmProvider { + + private final Map<String, Schema> xmlSchemas; + + public ClientEdmProvider(Map<String, Schema> xmlSchemas) { + this.xmlSchemas = xmlSchemas; + } + + @Override + public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { + Schema schema = xmlSchemas.get(enumTypeName.getNamespace()); + if (schema != null) { + return schema.getEnumType(enumTypeName.getName()); + } + return null; + } + + @Override + public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException { + Schema schema = xmlSchemas.get(typeDefinitionName.getNamespace()); + if (schema != null) { + return schema.getTypeDefinition(typeDefinitionName.getName()); + } + return null; + } + + @Override + public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { + Schema schema = xmlSchemas.get(entityTypeName.getNamespace()); + if (schema != null) { + return schema.getEntityType(entityTypeName.getName()); + } + return null; + } + + @Override + public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { + Schema schema = xmlSchemas.get(complexTypeName.getNamespace()); + if (schema != null) { + return schema.getComplexType(complexTypeName.getName()); + } + return null; + } + + @Override + public List<Action> getActions(final FullQualifiedName actionName) throws ODataException { + Schema schema = xmlSchemas.get(actionName.getNamespace()); + if (schema != null) { + return schema.getActions(actionName.getName()); + } + return null; + } + + @Override + public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException { + Schema schema = xmlSchemas.get(functionName.getNamespace()); + if (schema != null) { + return schema.getFunctions(functionName.getName()); + } + return null; + } + + @Override + public Term getTerm(final FullQualifiedName termName) throws ODataException { + Schema schema = xmlSchemas.get(termName.getNamespace()); + if (schema != null) { + return schema.getTerm(termName.getName()); + } + return null; + } + + @Override + public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName) + throws ODataException { + Schema schema = xmlSchemas.get(entityContainer.getNamespace()); + if (schema != null) { + return schema.getEntityContainer().getEntitySet(entitySetName); + } + return null; + } + + @Override + public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName) + throws ODataException { + Schema schema = xmlSchemas.get(entityContainer.getNamespace()); + if (schema != null) { + return schema.getEntityContainer().getSingleton(singletonName); + } + return null; + } + + @Override + public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName) + throws ODataException { + Schema schema = xmlSchemas.get(entityContainer.getNamespace()); + if (schema != null) { + return schema.getEntityContainer().getActionImport(actionImportName); + } + return null; + } + + @Override + public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName) + throws ODataException { + Schema schema = xmlSchemas.get(entityContainer.getNamespace()); + if (schema != null) { + return schema.getEntityContainer().getFunctionImport(functionImportName); + } + return null; + } + + @Override + public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException { + for (Schema schema : xmlSchemas.values()) { + if (schema.getEntityContainer() != null) { + return new EntityContainerInfo().setContainerName(entityContainerName).setExtendsContainer( + schema.getEntityContainer().getExtendsContainerFQN()); + } + } + return null; + } + + @Override + public List<AliasInfo> getAliasInfos() throws ODataException { + ArrayList<AliasInfo> aliasInfo = new ArrayList<AliasInfo>(); + for (Schema schema : xmlSchemas.values()) { + if (schema.getAlias() != null) { + aliasInfo.add(new AliasInfo().setNamespace(schema.getNamespace()).setAlias(schema.getAlias())); + } + } + return aliasInfo; + } + + @Override + public List<Schema> getSchemas() throws ODataException { + return new ArrayList<Schema>(xmlSchemas.values()); + } + + @Override + public EntityContainer getEntityContainer() throws ODataException { + for (Schema schema : xmlSchemas.values()) { + if (schema.getEntityContainer() != null) { + return schema.getEntityContainer(); + } + } + return null; + } + + @Override + public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException { + Schema schema = xmlSchemas.get(targetName.getNamespace()); + if (schema != null) { + return schema.getAnnotationGroup(targetName.getName()); + } + return null; + } + + @Override + public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException { + final Schema schema = xmlSchemas.get(annotatedName.getNamespace()); + if (schema != null) { + return schema.getAnnotatables().get(annotatedName.getName()); + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java deleted file mode 100644 index c1dcfa4..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.client.core.edm; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; -import org.apache.olingo.commons.api.edm.provider.Action; - -public class EdmActionImpl extends EdmOperationImpl implements EdmAction { - - public static EdmActionImpl getInstance(final Edm edm, final FullQualifiedName name, final Action action) { - return EdmOperationImpl.getInstance(new EdmActionImpl(edm, name, action)); - } - - private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) { - super(edm, name, action, EdmTypeKind.ACTION); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java deleted file mode 100644 index eedcb72..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.List; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmActionImport; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.provider.ActionImport; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; - -public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport { - - private final ActionImport actionImport; - - private final EdmAnnotationHelper helper; - - private FullQualifiedName actionFQN; - - public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final String name, - final ActionImport actionImport) { - - super(edm, container, name, actionImport.getEntitySet()); - this.actionImport = actionImport; - this.helper = new EdmAnnotationHelperImpl(edm, actionImport); - } - - public FullQualifiedName getActionFQN() { - if (actionFQN == null) { - actionFQN = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(actionImport.getAction()). - setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(); - } - return actionFQN; - } - - @Override - public EdmAction getUnboundAction() { - return edm.getUnboundAction(getActionFQN()); - } - - @Override - public TargetType getAnnotationsTargetType() { - return TargetType.ActionImport; - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return helper.getAnnotations(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java deleted file mode 100644 index b29d0a9..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.provider.Annotatable; -import org.apache.olingo.commons.api.edm.provider.Annotation; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; - -public class EdmAnnotationHelperImpl implements EdmAnnotationHelper { - - private final Edm edm; - - private final Annotatable annotatable; - - private List<EdmAnnotation> annotations; - - public EdmAnnotationHelperImpl(final Edm edm, final Annotatable annotatable) { - this.edm = edm; - this.annotatable = annotatable; - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - EdmAnnotation result = null; - for (EdmAnnotation annotation : getAnnotations()) { - if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) { - result = annotation; - } - } - - return result; - } - - @Override - public List<EdmAnnotation> getAnnotations() { - if (annotations == null) { - annotations = new ArrayList<EdmAnnotation>(); - for (Annotation annotation : annotatable.getAnnotations()) { - annotations.add(new EdmAnnotationImpl(edm, annotation)); - } - } - return annotations; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java deleted file mode 100644 index a8a165c..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.olingo.client.core.edm.annotation.EdmCastImpl; -import org.apache.olingo.client.core.edm.annotation.EdmConstantAnnotationExpressionImpl; -import org.apache.olingo.client.core.edm.annotation.EdmIsOfImpl; -import org.apache.olingo.client.core.edm.annotation.EdmRecordImpl; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotatable; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression; -import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; -import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue; -import org.apache.olingo.commons.api.edm.provider.Annotatable; -import org.apache.olingo.commons.api.edm.provider.Annotation; -import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.PropertyValue; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; -import org.apache.olingo.commons.core.edm.annotation.EdmAndImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmAnnotationPathImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmApplyImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmCollectionImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmEqImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmGeImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmGtImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmIfImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmLabeledElementImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmLabeledElementReferenceImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmLeImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmLtImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmNavigationPropertyPathImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmNeImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmNotImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmNullImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmOrImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmPathImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmPropertyPathImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmPropertyValueImpl; -import org.apache.olingo.commons.core.edm.annotation.EdmUrlRefImpl; - -public class EdmAnnotationImpl implements EdmAnnotation { - - private final Edm edm; - - private final Annotation annotation; - - private final EdmAnnotationHelper helper; - - private EdmTerm term; - - private EdmAnnotationExpression expression; - - public EdmAnnotationImpl(final Edm edm, final Annotation annotation) { - this.edm = edm; - this.annotation = annotation; - this.helper = new EdmAnnotationHelperImpl(edm, annotation); - } - - @Override - public EdmTerm getTerm() { - if (term == null) { - term = edm.getTerm(new FullQualifiedName(annotation.getTerm())); - } - return term; - } - - @Override - public String getQualifier() { - return annotation.getQualifier(); - } - - private EdmAnnotationExpression getExpression(final AnnotationExpression exp) { - EdmAnnotationExpression _expression = null; - - if (exp.isConstant()) { - _expression = new EdmConstantAnnotationExpressionImpl(exp.asConstant()); - } else if (annotation.getExpression().isDynamic()) { - _expression = getDynamicExpression(exp.asDynamic()); - } - - return _expression; - } - - private EdmDynamicAnnotationExpression getDynamicExpression(final DynamicAnnotationExpression exp) { - EdmDynamicAnnotationExpression _expression = null; - - if (exp.isNot()) { - _expression = new EdmNotImpl(getDynamicExpression(exp.asNot().getExpression())); - } else if (exp.isTwoParamsOp()) { - switch (exp.asTwoParamsOp().getType()) { - case And: - _expression = new EdmAndImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Or: - _expression = new EdmOrImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Eq: - _expression = new EdmEqImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Ne: - _expression = new EdmNeImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Ge: - _expression = new EdmGeImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Gt: - _expression = new EdmGtImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Le: - _expression = new EdmLeImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - case Lt: - _expression = new EdmLtImpl( - getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), - getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); - break; - - default: - } - } else if (exp.isAnnotationPath()) { - _expression = new EdmAnnotationPathImpl(exp.asAnnotationPath().getValue()); - } else if (exp.isApply()) { - final List<EdmAnnotationExpression> parameters = - new ArrayList<EdmAnnotationExpression>(exp.asApply().getParameters().size()); - for (AnnotationExpression param : exp.asApply().getParameters()) { - parameters.add(getExpression(param)); - } - _expression = new EdmApplyImpl(exp.asApply().getFunction(), parameters); - } else if (exp.isCast()) { - _expression = new EdmCastImpl(edm, exp.asCast(), getDynamicExpression(exp.asCast().getValue())); - } else if (exp.isCollection()) { - final List<EdmAnnotationExpression> items = - new ArrayList<EdmAnnotationExpression>(exp.asCollection().getItems().size()); - for (AnnotationExpression param : exp.asCollection().getItems()) { - items.add(getExpression(param)); - } - _expression = new EdmCollectionImpl(items); - } else if (exp.isIf()) { - _expression = new EdmIfImpl( - getExpression(exp.asIf().getGuard()), - getExpression(exp.asIf().getThen()), - getExpression(exp.asIf().getElse())); - } else if (exp.isIsOf()) { - _expression = new EdmIsOfImpl(edm, exp.asIsOf(), getDynamicExpression(exp.asIsOf().getValue())); - } else if (exp.isLabeledElement()) { - _expression = new EdmLabeledElementImpl( - exp.asLabeledElement().getName(), getDynamicExpression(exp.asLabeledElement().getValue())); - } else if (exp.isLabeledElementReference()) { - _expression = new EdmLabeledElementReferenceImpl(exp.asLabeledElementReference().getValue()); - } else if (exp.isNull()) { - _expression = new EdmNullImpl(); - } else if (exp.isNavigationPropertyPath()) { - _expression = new EdmNavigationPropertyPathImpl(exp.asNavigationPropertyPath().getValue()); - } else if (exp.isPath()) { - _expression = new EdmPathImpl(exp.asPath().getValue()); - } else if (exp.isPropertyPath()) { - _expression = new EdmPropertyPathImpl(exp.asPropertyPath().getValue()); - } else if (exp.isPropertyValue()) { - _expression = new EdmPropertyValueImpl( - exp.asPropertyValue().getProperty(), getExpression(exp.asPropertyValue().getValue())); - } else if (exp.isRecord()) { - final List<EdmPropertyValue> propertyValues = - new ArrayList<EdmPropertyValue>(exp.asRecord().getPropertyValues().size()); - for (PropertyValue propertyValue : exp.asRecord().getPropertyValues()) { - propertyValues.add(new EdmPropertyValueImpl( - propertyValue.getProperty(), getExpression(propertyValue.getValue()))); - } - _expression = new EdmRecordImpl(edm, exp.asRecord().getType(), propertyValues); - } else if (exp.isUrlRef()) { - _expression = new EdmUrlRefImpl(getExpression(exp.asUrlRef().getValue())); - } - - if (_expression instanceof EdmAnnotatable && exp instanceof Annotatable) { - for (Annotation _annotation : ((Annotatable) exp).getAnnotations()) { - ((EdmAnnotatable) _expression).getAnnotations().add(new EdmAnnotationImpl(edm, _annotation)); - } - } - - return _expression; - } - - @Override - public EdmAnnotationExpression getExpression() { - if (expression == null) { - expression = getExpression(annotation.getExpression()); - } - return expression; - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return helper.getAnnotations(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java deleted file mode 100644 index 91cf5fc..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmAnnotations; -import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmEnumType; -import org.apache.olingo.commons.api.edm.EdmSchema; -import org.apache.olingo.commons.api.edm.EdmStructuredType; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.provider.Annotation; -import org.apache.olingo.commons.api.edm.provider.Annotations; - -public class EdmAnnotationsImpl implements EdmAnnotations { - - private final Edm edm; - - private final EdmSchema schema; - - private final Annotations annotationGroup; - - private EdmAnnotationsTarget target; - - private List<EdmAnnotation> annotations; - - public EdmAnnotationsImpl(final Edm edm, final EdmSchema schema, final Annotations annotationGroup) { - this.edm = edm; - this.schema = schema; - this.annotationGroup = annotationGroup; - } - - private EdmAnnotationsTarget getTarget(final EdmStructuredType structured, final String path) { - EdmAnnotationsTarget _target = null; - if (structured != null) { - _target = path == null - ? structured - : structured.getStructuralProperty(path); - if (_target == null) { - _target = structured.getNavigationProperty(path); - } - } - return _target; - } - - private EdmAnnotationsTarget getTarget(final EdmEnumType enumType, final String path) { - EdmAnnotationsTarget _target = null; - if (enumType != null) { - _target = path == null - ? enumType - : enumType.getMember(path); - } - return _target; - } - - @Override - public EdmAnnotationsTarget getTarget() { - if (target == null) { - final String[] splitted = StringUtils.split(annotationGroup.getTarget(), '/'); - final FullQualifiedName base = new FullQualifiedName(splitted[0]); - final String path = splitted.length > 1 ? splitted[1] : null; - - final EdmEntityContainer baseEntityContainer = schema.getEntityContainer(base); - - target = baseEntityContainer == null? null: baseEntityContainer.getActionImport(path); - if (target == null) { - target = getTarget(edm.getComplexType(base), path); - if (target == null) { - target = baseEntityContainer; - if (target == null) { - target = baseEntityContainer == null? null: baseEntityContainer.getEntitySet(path); - if (target == null) { - target = getTarget(edm.getEntityType(base), path); - if (target == null) { - target = getTarget(edm.getEnumType(base), path); - if (target == null) { - target = baseEntityContainer == null? null: baseEntityContainer.getFunctionImport(path); - if (target == null) { - target = baseEntityContainer == null? null: baseEntityContainer.getSingleton(path); - if (target == null) { - target = edm.getTerm(base); - if (target == null) { - target = edm.getTypeDefinition(base); - } - } - } - } - } - } - } - } - } - } - return target; - } - - @Override - public String getQualifier() { - return annotationGroup.getQualifier(); - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - EdmAnnotation result = null; - for (EdmAnnotation annotation : getAnnotations()) { - if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) { - result = annotation; - } - } - return result; - } - - @Override - public List<EdmAnnotation> getAnnotations() { - if (annotations == null) { - annotations = new ArrayList<EdmAnnotation>(); - for (Annotation annotation : annotationGroup.getAnnotations()) { - annotations.add(new EdmAnnotationImpl(edm, annotation)); - } - } - return annotations; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java deleted file mode 100644 index a75ed61..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.provider.BindingTarget; -import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding; -import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; -import org.apache.olingo.commons.core.edm.EdmNavigationPropertyBindingImpl; - -public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget { - - private final BindingTarget target; - - private final EdmAnnotationHelper helper; - - private List<EdmNavigationPropertyBinding> navigationPropertyBindings; - - public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, - final String name, final FullQualifiedName type, final BindingTarget target) { - - super(edm, container, name, type); - this.target = target; - this.helper = new EdmAnnotationHelperImpl(edm, target); - } - - @Override - public List<EdmNavigationPropertyBinding> getNavigationPropertyBindings() { - if (navigationPropertyBindings == null) { - List<? extends NavigationPropertyBinding> providerBindings = target.getNavigationPropertyBindings(); - navigationPropertyBindings = new ArrayList<EdmNavigationPropertyBinding>(); - if (providerBindings != null) { - for (NavigationPropertyBinding binding : providerBindings) { - navigationPropertyBindings.add(new EdmNavigationPropertyBindingImpl(binding.getPath(), binding.getTarget())); - } - } - } - return navigationPropertyBindings; - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return helper.getAnnotations(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java deleted file mode 100644 index 409cb58..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmAnnotations; -import org.apache.olingo.commons.api.edm.EdmComplexType; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmEntityType; -import org.apache.olingo.commons.api.edm.EdmEnumType; -import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmSchema; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.EdmTypeDefinition; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.provider.Action; -import org.apache.olingo.commons.api.edm.provider.Annotatable; -import org.apache.olingo.commons.api.edm.provider.Annotation; -import org.apache.olingo.commons.api.edm.provider.Annotations; -import org.apache.olingo.commons.api.edm.provider.ComplexType; -import org.apache.olingo.commons.api.edm.provider.EntityContainer; -import org.apache.olingo.commons.api.edm.provider.EntityType; -import org.apache.olingo.commons.api.edm.provider.EnumType; -import org.apache.olingo.commons.api.edm.provider.Function; -import org.apache.olingo.commons.api.edm.provider.Parameter; -import org.apache.olingo.commons.api.edm.provider.Schema; -import org.apache.olingo.commons.api.edm.provider.Term; -import org.apache.olingo.commons.api.edm.provider.TypeDefinition; -import org.apache.olingo.commons.core.edm.AbstractEdm; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; - -public class EdmClientImpl extends AbstractEdm { - - private final List<Schema> xmlSchemas; - - private final Map<String, Schema> xmlSchemaByNamespace; - - public EdmClientImpl(final Map<String, Schema> xmlSchemas) { - this.xmlSchemaByNamespace = xmlSchemas; - - this.xmlSchemas = new ArrayList<Schema>(); - for (Schema schema : xmlSchemaByNamespace.values()) { - if (!this.xmlSchemas.contains(schema)) { - this.xmlSchemas.add(schema); - } - } - } - - @Override - protected Map<String, String> createAliasToNamespaceInfo() { - final Map<String, String> aliasToNamespace = new HashMap<String, String>(); - - for (Schema schema : xmlSchemas) { - aliasToNamespace.put(null, schema.getNamespace()); - if (StringUtils.isNotBlank(schema.getAlias())) { - aliasToNamespace.put(schema.getAlias(), schema.getNamespace()); - } - } - - return aliasToNamespace; - } - - @Override - protected Map<String, EdmSchema> createSchemas() { - final Map<String, EdmSchema> _schemas = new LinkedHashMap<String, EdmSchema>(xmlSchemas.size()); - for (Schema schema : xmlSchemas) { - _schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, schema)); - } - return _schemas; - } - - @Override - protected EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) { - EdmEntityContainer result = null; - - final Schema schema = xmlSchemaByNamespace.get(containerName.getNamespace()); - if (schema != null) { - final EntityContainer xmlEntityContainer = schema.getEntityContainer(); - if (xmlEntityContainer != null) { - result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer); - } - } - - return result; - } - - @Override - protected EdmEnumType createEnumType(final FullQualifiedName enumName) { - EdmEnumType result = null; - - final Schema schema = xmlSchemaByNamespace.get(enumName.getNamespace()); - if (schema != null) { - final EnumType xmlEnumType = schema.getEnumType(enumName.getName()); - if (xmlEnumType != null) { - result = new EdmEnumTypeImpl(this, enumName, xmlEnumType); - } - } - - return result; - } - - @Override - protected EdmTypeDefinition createTypeDefinition(final FullQualifiedName typeDefinitionName) { - EdmTypeDefinition result = null; - - final Schema schema = xmlSchemaByNamespace.get(typeDefinitionName.getNamespace()); - if (schema != null) { - final TypeDefinition xmlTypeDefinition = schema. - getTypeDefinition(typeDefinitionName.getName()); - if (xmlTypeDefinition != null) { - result = new EdmTypeDefinitionImpl(this, typeDefinitionName, xmlTypeDefinition); - } - } - return result; - } - - @Override - protected EdmEntityType createEntityType(final FullQualifiedName entityTypeName) { - EdmEntityType result = null; - - final Schema schema = xmlSchemaByNamespace.get(entityTypeName.getNamespace()); - if (schema != null) { - final EntityType xmlEntityType = schema.getEntityType(entityTypeName.getName()); - if (xmlEntityType != null) { - result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlEntityType); - } - } - - return result; - } - - @Override - protected EdmComplexType createComplexType(final FullQualifiedName complexTypeName) { - EdmComplexType result = null; - - final Schema schema = xmlSchemaByNamespace.get(complexTypeName.getNamespace()); - if (schema != null) { - final ComplexType xmlComplexType = schema.getComplexType(complexTypeName.getName()); - if (xmlComplexType != null) { - result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlComplexType); - } - } - - return result; - } - - @Override - protected EdmAction createUnboundAction(final FullQualifiedName actionName) { - EdmAction result = null; - - final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace()); - final List<Action> actions = schema. - getActions(actionName.getName()); - boolean found = false; - for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) { - final Action action = itor.next(); - if (!action.isBound()) { - found = true; - result = EdmActionImpl.getInstance(this, actionName, action); - } - } - return result; - } - - @Override - protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) { - final List<EdmFunction> result = new ArrayList<EdmFunction>(); - - final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); - final List<Function> functions = schema. - getFunctions(functionName.getName()); - for (final Iterator<Function> itor = functions.iterator(); itor.hasNext();) { - final Function function = itor.next(); - if (!function.isBound()) { - result.add(EdmFunctionImpl.getInstance(this, functionName, function)); - } - } - return result; - } - - @Override - protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) { - EdmFunction result = null; - - final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); - final List<Function> functions = schema. - getFunctions(functionName.getName()); - boolean found = false; - for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) { - final Function function = itor.next(); - if (!function.isBound()) { - final Set<String> functionParamNames = new HashSet<String>(); - for (Parameter param : function.getParameters()) { - functionParamNames.add(param.getName()); - } - found = parameterNames == null - ? functionParamNames.isEmpty() - : functionParamNames.containsAll(parameterNames); - result = EdmFunctionImpl.getInstance(this, functionName, function); - } - } - return result; - } - - @Override - protected EdmAction createBoundAction(final FullQualifiedName actionName, - final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) { - - EdmAction result = null; - - final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace()); - final List<Action> actions = - schema.getActions(actionName.getName()); - boolean found = false; - for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) { - final Action action = itor.next(); - if (action.isBound()) { - final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this). - setTypeExpression(action.getParameters().get(0).getType()).build(); - if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName()) - && (isBindingParameterCollection == null - || isBindingParameterCollection.booleanValue() == boundParam.isCollection())) { - - found = true; - result = EdmActionImpl.getInstance(this, actionName, action); - } - } - } - return result; - } - - @Override - protected EdmFunction createBoundFunction(final FullQualifiedName functionName, - final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, - final List<String> parameterNames) { - - EdmFunction result = null; - - final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); - final List<Function> functions = schema. - getFunctions(functionName.getName()); - boolean found = false; - for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) { - final Function function = itor.next(); - if (function.isBound()) { - final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this). - setTypeExpression(function.getParameters().get(0).getType()).build(); - if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName()) - && (isBindingParameterCollection == null - || isBindingParameterCollection.booleanValue() == boundParam.isCollection())) { - - final Set<String> functionParamNames = new HashSet<String>(); - for (Parameter param : function.getParameters()) { - functionParamNames.add(param.getName()); - } - found = parameterNames == null - ? functionParamNames.isEmpty() - : functionParamNames.containsAll(parameterNames); - result = EdmFunctionImpl.getInstance(this, functionName, function); - } - } - } - return result; - } - - @Override - protected EdmTerm createTerm(final FullQualifiedName termName) { - EdmTerm result = null; - - final Schema schema = xmlSchemaByNamespace.get(termName.getNamespace()); - if (schema != null) { - final Term term = schema.getTerm(termName.getName()); - if (term != null) { - result = new EdmTermImpl(this, schema.getNamespace(), term); - } - } - return result; - } - - @Override - protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) { - EdmAnnotationsImpl result = null; - - final Schema schema = xmlSchemaByNamespace.get(targetName.getNamespace()); - final Annotations annotationGroup = - schema.getAnnotationGroup(targetName.getName()); - if (annotationGroup != null) { - result = new EdmAnnotationsImpl(this, schemas.get(schema.getNamespace()), annotationGroup); - } - - return result; - } - - @Override - protected List<EdmAnnotation> createAnnotations(final FullQualifiedName annotatedName) { - List<EdmAnnotation> result = null; - - final Schema schema = xmlSchemaByNamespace.get(annotatedName.getNamespace()); - final Annotatable annotatable = - schema.getAnnotatables().get(annotatedName.getName()); - if (annotatable != null && annotatable.getAnnotations() != null) { - result = new ArrayList<EdmAnnotation>(); - for (Annotation annotation : annotatable.getAnnotations()) { - final EdmTerm term = getTerm(new FullQualifiedName(annotation.getTerm())); - result.add(new EdmAnnotationImpl(this, annotation)); - } - } - - return result; - } - - @Override - public boolean equals(final Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5cef4fae/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java deleted file mode 100644 index 5861640..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.client.core.edm; - -import java.util.List; -import java.util.Map; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; -import org.apache.olingo.commons.api.edm.EdmNavigationProperty; -import org.apache.olingo.commons.api.edm.EdmProperty; -import org.apache.olingo.commons.api.edm.EdmTerm; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.provider.ComplexType; -import org.apache.olingo.commons.core.edm.AbstractEdmComplexType; -import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; -import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; - -public class EdmComplexTypeImpl extends AbstractEdmComplexType { - - private final EdmStructuredTypeHelper typeHelper; - - private EdmAnnotationHelper annotationHelper; - - public static EdmComplexTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, - final ComplexType complexType) { - - FullQualifiedName baseTypeName = null; - final String baseType = complexType.getBaseType(); - baseTypeName = baseType == null - ? null : new EdmTypeInfo.Builder().setTypeExpression(baseType).build().getFullQualifiedName(); - final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, fqn, baseTypeName, complexType); - instance.baseType = instance.buildBaseType(baseTypeName); - - return instance; - } - - private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName, - final ComplexType complexType) { - - super(edm, fqn, baseTypeName); - this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), complexType); - this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType); - } - - @Override - protected Map<String, EdmProperty> getProperties() { - return typeHelper.getProperties(); - } - - @Override - protected Map<String, EdmNavigationProperty> getNavigationProperties() { - return typeHelper.getNavigationProperties(); - } - - @Override - public boolean isOpenType() { - return typeHelper.isOpenType(); - } - - @Override - public boolean isAbstract() { - return typeHelper.isAbstract(); - } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return annotationHelper == null ? null : annotationHelper.getAnnotation(term); - } - - @Override - public List<EdmAnnotation> getAnnotations() { - return annotationHelper == null ? null : annotationHelper.getAnnotations(); - } - -}
