[OLINGO-564] Removed 'provider' package level
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/ac32d236 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/ac32d236 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/ac32d236 Branch: refs/heads/OLINGO-564 Commit: ac32d23610317ac1f43047935ff4741ffde3d706 Parents: a5c51d6 Author: Michael Bolz <[email protected]> Authored: Thu Apr 23 10:50:47 2015 +0200 Committer: Michael Bolz <[email protected]> Committed: Thu Apr 23 10:50:47 2015 +0200 ---------------------------------------------------------------------- .../olingo/ext/proxy/AbstractService.java | 2 +- .../proxy/commons/InvokerInvocationHandler.java | 2 +- .../commons/OperationInvocationHandler.java | 2 +- ...turedComposableInvokerInvocationHandler.java | 2 +- .../olingo/ext/proxy/utils/CoreUtils.java | 2 +- .../olingo/ext/pojogen/AbstractUtility.java | 2 +- .../java/org/apache/olingo/fit/V4Services.java | 2 +- .../core/serialization/ODataBinderImpl.java | 2 +- .../core/serialization/ODataReaderImpl.java | 2 +- .../olingo/client/core/uri/URIEscapeTest.java | 2 +- .../client/core/uri/v4/FilterFactoryTest.java | 2 +- .../core/edm/AbstractEdmAnnotatable.java | 69 ++++ .../core/edm/AbstractEdmBindingTarget.java | 133 +++++++ .../commons/core/edm/AbstractEdmNamed.java | 38 ++ .../commons/core/edm/AbstractEdmOperation.java | 142 +++++++ .../core/edm/AbstractEdmOperationImport.java | 80 ++++ .../core/edm/AbstractEdmStructuredType.java | 196 ++++++++++ .../olingo/commons/core/edm/EdmActionImpl.java | 32 ++ .../commons/core/edm/EdmActionImportImpl.java | 46 +++ .../commons/core/edm/EdmAnnotationImpl.java | 225 +++++++++++ .../commons/core/edm/EdmAnnotationsImpl.java | 151 ++++++++ .../commons/core/edm/EdmComplexTypeImpl.java | 65 ++++ .../core/edm/EdmEntityContainerImpl.java | 327 ++++++++++++++++ .../commons/core/edm/EdmEntitySetImpl.java | 44 +++ .../commons/core/edm/EdmEntityTypeImpl.java | 146 +++++++ .../commons/core/edm/EdmEnumTypeImpl.java | 268 +++++++++++++ .../commons/core/edm/EdmFunctionImpl.java | 52 +++ .../commons/core/edm/EdmFunctionImportImpl.java | 63 ++++ .../commons/core/edm/EdmKeyPropertyRefImpl.java | 83 ++++ .../olingo/commons/core/edm/EdmMemberImpl.java | 56 +++ .../edm/EdmNavigationPropertyBindingImpl.java | 43 +++ .../core/edm/EdmNavigationPropertyImpl.java | 142 +++++++ .../commons/core/edm/EdmParameterImpl.java | 88 +++++ .../commons/core/edm/EdmPropertyImpl.java | 127 +++++++ .../commons/core/edm/EdmProviderImpl.java | 377 ++++++++++++++++++ .../core/edm/EdmReferentialConstraintImpl.java | 43 +++ .../commons/core/edm/EdmReturnTypeImpl.java | 80 ++++ .../olingo/commons/core/edm/EdmSchemaImpl.java | 304 +++++++++++++++ .../commons/core/edm/EdmSingletonImpl.java | 36 ++ .../olingo/commons/core/edm/EdmTermImpl.java | 148 ++++++++ .../commons/core/edm/EdmTypeDefinitionImpl.java | 163 ++++++++ .../olingo/commons/core/edm/EdmTypeImpl.java | 53 +++ .../olingo/commons/core/edm/EdmTypeInfo.java | 228 +++++++++++ .../apache/olingo/commons/core/edm/Target.java | 66 ++++ .../core/edm/annotation/EdmCastImpl.java | 2 +- .../core/edm/annotation/EdmIsOfImpl.java | 2 +- .../core/edm/annotation/EdmRecordImpl.java | 2 +- .../edm/provider/AbstractEdmAnnotatable.java | 69 ---- .../edm/provider/AbstractEdmBindingTarget.java | 133 ------- .../core/edm/provider/AbstractEdmNamed.java | 38 -- .../core/edm/provider/AbstractEdmOperation.java | 142 ------- .../provider/AbstractEdmOperationImport.java | 80 ---- .../edm/provider/AbstractEdmStructuredType.java | 196 ---------- .../core/edm/provider/EdmActionImpl.java | 32 -- .../core/edm/provider/EdmActionImportImpl.java | 46 --- .../core/edm/provider/EdmAnnotationImpl.java | 225 ----------- .../core/edm/provider/EdmAnnotationsImpl.java | 151 -------- .../core/edm/provider/EdmComplexTypeImpl.java | 65 ---- .../edm/provider/EdmEntityContainerImpl.java | 327 ---------------- .../core/edm/provider/EdmEntitySetImpl.java | 44 --- .../core/edm/provider/EdmEntityTypeImpl.java | 146 ------- .../core/edm/provider/EdmEnumTypeImpl.java | 268 ------------- .../core/edm/provider/EdmFunctionImpl.java | 52 --- .../edm/provider/EdmFunctionImportImpl.java | 63 ---- .../edm/provider/EdmKeyPropertyRefImpl.java | 83 ---- .../core/edm/provider/EdmMemberImpl.java | 56 --- .../EdmNavigationPropertyBindingImpl.java | 43 --- .../edm/provider/EdmNavigationPropertyImpl.java | 142 ------- .../core/edm/provider/EdmParameterImpl.java | 88 ----- .../core/edm/provider/EdmPropertyImpl.java | 127 ------- .../core/edm/provider/EdmProviderImpl.java | 378 ------------------- .../provider/EdmReferentialConstraintImpl.java | 43 --- .../core/edm/provider/EdmReturnTypeImpl.java | 80 ---- .../core/edm/provider/EdmSchemaImpl.java | 304 --------------- .../core/edm/provider/EdmSingletonImpl.java | 36 -- .../commons/core/edm/provider/EdmTermImpl.java | 148 -------- .../edm/provider/EdmTypeDefinitionImpl.java | 163 -------- .../commons/core/edm/provider/EdmTypeImpl.java | 53 --- .../commons/core/edm/provider/EdmTypeInfo.java | 228 ----------- .../commons/core/edm/provider/Target.java | 66 ---- .../core/serialization/AtomDeserializer.java | 2 +- .../core/serialization/AtomSerializer.java | 2 +- .../core/serialization/JsonDeserializer.java | 2 +- .../serialization/JsonEntityDeserializer.java | 2 +- .../serialization/JsonEntitySerializer.java | 2 +- .../serialization/JsonGeoValueDeserializer.java | 2 +- .../serialization/JsonPropertyDeserializer.java | 2 +- .../serialization/JsonPropertySerializer.java | 2 +- .../core/serialization/JsonSerializer.java | 2 +- .../olingo/server/core/ServiceMetadataImpl.java | 2 +- .../core/edm/provider/AbstractEdmNamedTest.java | 2 +- .../core/edm/provider/EdmActionImplTest.java | 4 +- .../edm/provider/EdmActionImportImplTest.java | 4 +- .../edm/provider/EdmComplexTypeImplTest.java | 4 +- .../provider/EdmEntityContainerImplTest.java | 4 +- .../core/edm/provider/EdmEntitySetImplTest.java | 6 +- .../edm/provider/EdmEntityTypeImplTest.java | 4 +- .../server/core/edm/provider/EdmEnumTest.java | 4 +- .../core/edm/provider/EdmFunctionImplTest.java | 4 +- .../edm/provider/EdmFunctionImportImplTest.java | 6 +- .../edm/provider/EdmKeyPropertyRefImplTest.java | 2 +- .../core/edm/provider/EdmMappingTest.java | 4 +- .../core/edm/provider/EdmMemberImplTest.java | 4 +- .../provider/EdmNavigationPropertyImplTest.java | 4 +- .../core/edm/provider/EdmParameterImplTest.java | 4 +- .../core/edm/provider/EdmPropertyImplTest.java | 4 +- .../EdmProviderImplOverloadingTest.java | 2 +- .../core/edm/provider/EdmProviderImplTest.java | 2 +- .../edm/provider/EdmReturnTypeImplTest.java | 4 +- .../core/edm/provider/EdmSchemaImplTest.java | 2 +- .../core/edm/provider/EdmSingletonImplTest.java | 6 +- .../edm/provider/EdmTypeDefinitionImplTest.java | 4 +- .../core/edm/provider/EdmTypeImplTest.java | 2 +- .../core/serializer/json/ComplexTypeHelper.java | 4 +- .../serializer/utils/ContextURLBuilderTest.java | 4 +- .../xml/MetadataDocumentXmlSerializerTest.java | 2 +- .../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 +- 123 files changed, 4196 insertions(+), 4197 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/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 f353856..8770286 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 @@ -35,7 +35,7 @@ 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.commons.core.edm.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; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java index 5d2dcdd..44a2d30 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java @@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.edm.EdmOperation; import org.apache.olingo.commons.api.edm.EdmReturnType; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.http.HttpMethod; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.api.ComplexCollection; import org.apache.olingo.ext.proxy.api.EntityCollection; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java index 90873b4..73daaf3 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java @@ -39,7 +39,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmOperation; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java index 9adbd05..c909ab0 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java @@ -26,7 +26,7 @@ import java.util.Map; import org.apache.commons.lang3.ArrayUtils; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.commons.api.edm.EdmOperation; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.api.Operations; import org.apache.olingo.ext.proxy.api.annotations.Operation; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/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 682fc38..b21c45c 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 @@ -57,7 +57,7 @@ import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.domain.ODataAnnotationImpl; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.api.AbstractTerm; import org.apache.olingo.ext.proxy.api.ComplexCollection; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java ---------------------------------------------------------------------- diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java index 2e0ef80..7e0dbdd 100644 --- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java +++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java @@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import java.io.InputStream; import java.util.ArrayList; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/fit/src/main/java/org/apache/olingo/fit/V4Services.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java index 711cdf0..4b1cd1f 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java @@ -71,7 +71,7 @@ import org.apache.olingo.commons.api.data.ResWrap; import org.apache.olingo.commons.api.data.ValueType; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.api.format.ContentType; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.fit.metadata.Metadata; import org.apache.olingo.fit.methods.PATCH; import org.apache.olingo.fit.rest.ResolvingReferencesInterceptor; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java index fc295a0..25b405a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java @@ -92,7 +92,7 @@ import org.apache.olingo.commons.core.domain.ODataDeletedEntityImpl; import org.apache.olingo.commons.core.domain.ODataDeltaLinkImpl; import org.apache.olingo.commons.core.domain.ODataPropertyImpl; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.commons.core.serialization.ContextURLParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java index 39b1177..f153ddb 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java @@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.provider.Schema; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; -import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl; +import org.apache.olingo.commons.core.edm.EdmProviderImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java index 6dd7de5..f3fde9e 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java @@ -33,7 +33,7 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.geo.Geospatial; import org.apache.olingo.commons.api.edm.geo.Point; -import org.apache.olingo.commons.core.edm.provider.EdmEnumTypeImpl; +import org.apache.olingo.commons.core.edm.EdmEnumTypeImpl; import org.junit.Test; public class URIEscapeTest { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java index a9fc341..7f9b57d 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java @@ -34,7 +34,7 @@ import org.apache.olingo.client.core.edm.xml.EnumTypeImpl; import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.provider.EdmEnumTypeImpl; +import org.apache.olingo.commons.core.edm.EdmEnumTypeImpl; import org.junit.Test; public class FilterFactoryTest extends AbstractTest { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmAnnotatable.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmAnnotatable.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmAnnotatable.java new file mode 100644 index 0000000..773ca9e --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmAnnotatable.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +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.provider.Annotatable; +import org.apache.olingo.commons.api.edm.provider.Annotation; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public abstract class AbstractEdmAnnotatable implements EdmAnnotatable { + + private final Annotatable annotatable; + private List<EdmAnnotation> annotations; + protected final Edm edm; + + public AbstractEdmAnnotatable(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) { + final List<EdmAnnotation> annotationsLocal = new ArrayList<EdmAnnotation>(); + if (annotatable != null) { + for (Annotation annotation : annotatable.getAnnotations()) { + annotationsLocal.add(new EdmAnnotationImpl(edm, annotation)); + } + + annotations = Collections.unmodifiableList(annotationsLocal); + } + } + return annotations; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java new file mode 100644 index 0000000..62f12e6 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmBindingTarget; +import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding; +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; + +public abstract class AbstractEdmBindingTarget extends AbstractEdmNamed implements EdmBindingTarget { + + private final BindingTarget target; + private final EdmEntityContainer container; + + private List<EdmNavigationPropertyBinding> navigationPropertyBindings; + + public AbstractEdmBindingTarget(final Edm edm, final EdmEntityContainer container, final BindingTarget target) { + super(edm, target.getName(), target); + this.container = container; + this.target = target; + } + + @Override + public List<EdmNavigationPropertyBinding> getNavigationPropertyBindings() { + if (navigationPropertyBindings == null) { + List<NavigationPropertyBinding> providerBindings = target.getNavigationPropertyBindings(); + final List<EdmNavigationPropertyBinding> navigationPropertyBindingsLocal = + new ArrayList<EdmNavigationPropertyBinding>(); + if (providerBindings != null) { + for (NavigationPropertyBinding binding : providerBindings) { + navigationPropertyBindingsLocal.add(new EdmNavigationPropertyBindingImpl(binding.getPath(), + binding.getTarget())); + } + navigationPropertyBindings = Collections.unmodifiableList(navigationPropertyBindingsLocal); + } + } + return navigationPropertyBindings; + } + + @Override + public EdmEntityContainer getEntityContainer() { + return container; + } + + @Override + public EdmEntityType getEntityType() { + final EdmEntityType entityType = edm.getEntityType(target.getTypeFQN()); + if (entityType == null) { + throw new EdmException("Can´t find entity type: " + target.getTypeFQN() + " for entity set or singleton: " + + getName()); + } + return entityType; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return container.getFullQualifiedName(); + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } + + @Override + public EdmBindingTarget getRelatedBindingTarget(final String path) { + if (path == null) { + return null; + } + EdmBindingTarget bindingTarget = null; + boolean found = false; + for (final Iterator<EdmNavigationPropertyBinding> itor = getNavigationPropertyBindings().iterator(); itor.hasNext() + && !found;) { + + final EdmNavigationPropertyBinding binding = itor.next(); + if(binding.getPath() == null || binding.getTarget() == null){ + throw new EdmException("Path or Target in navigation property binding must not be null!"); + } + if (path.startsWith(binding.getPath())) { + final Target edmTarget = new Target(binding.getTarget(), container); + + final EdmEntityContainer entityContainer = edm.getEntityContainer(edmTarget.getEntityContainer()); + if (entityContainer == null) { + throw new EdmException("Cannot find entity container with name: " + edmTarget.getEntityContainer()); + } + try { + bindingTarget = entityContainer.getEntitySet(edmTarget.getTargetName()); + + if (bindingTarget == null) { + throw new EdmException("Cannot find EntitySet " + edmTarget.getTargetName()); + } + } catch (EdmException e) { + // try with singletons ... + bindingTarget = entityContainer.getSingleton(edmTarget.getTargetName()); + + if (bindingTarget == null) { + throw new EdmException("Cannot find Singleton " + edmTarget.getTargetName()); + } + } finally { + found = bindingTarget != null; + } + } + } + + return bindingTarget; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNamed.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNamed.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNamed.java new file mode 100644 index 0000000..ced2b92 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNamed.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmNamed; +import org.apache.olingo.commons.api.edm.provider.Annotatable; + +public abstract class AbstractEdmNamed extends AbstractEdmAnnotatable implements EdmNamed { + + private final String name; + + public AbstractEdmNamed(final Edm edm, final String name, final Annotatable annotatable) { + super(edm, annotatable); + this.name = name; + } + + @Override + public String getName() { + return name; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java new file mode 100644 index 0000000..6fc4f91 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmBindingTarget; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmOperation; +import org.apache.olingo.commons.api.edm.EdmParameter; +import org.apache.olingo.commons.api.edm.EdmReturnType; +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.Operation; +import org.apache.olingo.commons.api.edm.provider.Parameter; + +public abstract class AbstractEdmOperation extends EdmTypeImpl implements EdmOperation { + + private final Operation operation; + private Map<String, EdmParameter> parameters; + private List<String> parameterNames; + private EdmReturnType returnType; + + protected AbstractEdmOperation(final Edm edm, final FullQualifiedName name, final Operation operation, + final EdmTypeKind kind) { + + super(edm, name, kind, operation); + this.operation = operation; + } + + @Override + public EdmParameter getParameter(final String name) { + if (parameters == null) { + createParameters(); + } + return parameters.get(name); + } + + @Override + public List<String> getParameterNames() { + if (parameterNames == null) { + createParameters(); + } + return Collections.unmodifiableList(parameterNames); + } + + private void createParameters() { + if(parameters == null) { + final Map<String, EdmParameter> parametersLocal = new LinkedHashMap<String, EdmParameter>(); + final List<Parameter> providerParameters = operation.getParameters(); + if (providerParameters != null) { + final List<String> parameterNamesLocal = new ArrayList<String>(providerParameters.size()); + for (Parameter parameter : providerParameters) { + parametersLocal.put(parameter.getName(), new EdmParameterImpl(edm, parameter)); + parameterNamesLocal.add(parameter.getName()); + } + + parameters = parametersLocal; + parameterNames = parameterNamesLocal; + } else { + parameterNames = Collections.emptyList(); + } + } + } + + @Override + public EdmEntitySet getReturnedEntitySet(final EdmEntitySet bindingParameterEntitySet) { + EdmEntitySet returnedEntitySet = null; + if (bindingParameterEntitySet != null && operation.getEntitySetPath() != null) { + final EdmBindingTarget relatedBindingTarget = + bindingParameterEntitySet.getRelatedBindingTarget(operation.getEntitySetPath()); + if (relatedBindingTarget == null) { + throw new EdmException("Cannot find entity set with path: " + operation.getEntitySetPath()); + } + if (relatedBindingTarget instanceof EdmEntitySet) { + returnedEntitySet = (EdmEntitySet) relatedBindingTarget; + } else { + throw new EdmException("BindingTarget with name: " + relatedBindingTarget.getName() + + " must be an entity set"); + } + } + return returnedEntitySet; + } + + @Override + public EdmReturnType getReturnType() { + if (returnType == null && operation.getReturnType() != null) { + returnType = new EdmReturnTypeImpl(edm, operation.getReturnType()); + } + return returnType; + } + + @Override + public boolean isBound() { + return operation.isBound(); + } + + @Override + public FullQualifiedName getBindingParameterTypeFqn() { + if (isBound()) { + Parameter bindingParameter = operation.getParameters().get(0); + return bindingParameter.getTypeFQN(); + } + return null; + } + + @Override + public Boolean isBindingParameterTypeCollection() { + if (isBound()) { + Parameter bindingParameter = operation.getParameters().get(0); + return bindingParameter.isCollection(); + } + return null; + } + + @Override + public String getEntitySetPath() { + return operation.getEntitySetPath(); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java new file mode 100644 index 0000000..c36c44f --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmOperationImport; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.provider.OperationImport; + +public abstract class AbstractEdmOperationImport extends AbstractEdmNamed implements EdmOperationImport { + + protected final EdmEntityContainer container; + private final Target entitySet; + private EdmEntitySet returnedEntitySet; + + public AbstractEdmOperationImport(final Edm edm, final EdmEntityContainer container, + final OperationImport operationImport) { + super(edm, operationImport.getName(), operationImport); + this.container = container; + if (operationImport.getEntitySet() != null) { + this.entitySet = new Target(operationImport.getEntitySet(), container); + } else { + this.entitySet = null; + } + } + + @Override + public FullQualifiedName getFullQualifiedName() { + return new FullQualifiedName(container.getNamespace(), getName()); + } + + @Override + public EdmEntitySet getReturnedEntitySet() { + if (entitySet != null && returnedEntitySet == null) { + EdmEntityContainer entityContainer = edm.getEntityContainer(entitySet.getEntityContainer()); + if (entityContainer == null) { + throw new EdmException("Can´t find entity container with name: " + entitySet.getEntityContainer()); + } + returnedEntitySet = entityContainer.getEntitySet(entitySet.getTargetName()); + if (returnedEntitySet == null) { + throw new EdmException("Can´t find entity set with name: " + entitySet.getTargetName()); + } + } + return returnedEntitySet; + } + + @Override + public EdmEntityContainer getEntityContainer() { + return container; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return container.getFullQualifiedName(); + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java new file mode 100644 index 0000000..736b69b --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmElement; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmNavigationProperty; +import org.apache.olingo.commons.api.edm.EdmProperty; +import org.apache.olingo.commons.api.edm.EdmStructuredType; +import org.apache.olingo.commons.api.edm.EdmType; +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.NavigationProperty; +import org.apache.olingo.commons.api.edm.provider.Property; +import org.apache.olingo.commons.api.edm.provider.StructuralType; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements EdmStructuredType { + + protected EdmStructuredType baseType; + protected FullQualifiedName baseTypeName; + + private final StructuralType providerStructuredType; + + private List<String> propertyNames; + private Map<String, EdmProperty> properties; + private List<String> navigationPropertyNames; + private Map<String, EdmNavigationProperty> navigationProperties; + + public AbstractEdmStructuredType( + final Edm edm, + final FullQualifiedName typeName, + final EdmTypeKind kind, + final StructuralType structuredType) { + + super(edm, typeName, kind, structuredType); + this.baseTypeName = structuredType.getBaseTypeFQN(); + this.providerStructuredType = structuredType; + } + + protected abstract EdmStructuredType buildBaseType(FullQualifiedName baseTypeName); + + protected abstract void checkBaseType(); + + @Override + public List<String> getPropertyNames() { + if (propertyNames == null) { + final List<String> localPropertyNames = new ArrayList<String>(); + checkBaseType(); + if (baseType != null) { + localPropertyNames.addAll(baseType.getPropertyNames()); + } + localPropertyNames.addAll(getProperties().keySet()); + propertyNames = Collections.unmodifiableList(localPropertyNames); + } + return propertyNames; + } + + @Override + public List<String> getNavigationPropertyNames() { + if (navigationPropertyNames == null) { + final ArrayList<String> localNavigatinPropertyNames = new ArrayList<String>(); + checkBaseType(); + if (baseType != null) { + localNavigatinPropertyNames.addAll(baseType.getNavigationPropertyNames()); + } + localNavigatinPropertyNames.addAll(getNavigationProperties().keySet()); + navigationPropertyNames = Collections.unmodifiableList(localNavigatinPropertyNames); + } + return navigationPropertyNames; + } + + @Override + public EdmElement getProperty(final String name) { + EdmElement property = getStructuralProperty(name); + if (property == null) { + property = getNavigationProperty(name); + } + return property; + } + + @Override + public EdmProperty getStructuralProperty(final String name) { + EdmProperty property = null; + checkBaseType(); + if (baseType != null) { + property = baseType.getStructuralProperty(name); + } + if (property == null) { + property = getProperties().get(name); + } + return property; + } + + @Override + public EdmNavigationProperty getNavigationProperty(final String name) { + EdmNavigationProperty property = null; + checkBaseType(); + if (baseType != null) { + property = baseType.getNavigationProperty(name); + } + if (property == null) { + property = getNavigationProperties().get(name); + } + return property; + } + + @Override + public boolean compatibleTo(final EdmType targetType) { + EdmStructuredType sourceType = this; + if (targetType == null) { + throw new EdmException("Target type must not be null"); + } + while (!sourceType.getName().equals(targetType.getName()) + || !sourceType.getNamespace().equals(targetType.getNamespace())) { + + sourceType = sourceType.getBaseType(); + if (sourceType == null) { + return false; + } + } + + return true; + } + + @Override + public String getAnnotationsTargetPath() { + return null; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return getFullQualifiedName(); + } + + public Map<String, EdmProperty> getProperties() { + if (properties == null) { + final Map<String, EdmProperty> localPorperties = new LinkedHashMap<String, EdmProperty>(); + final List<Property> structureTypeProperties = providerStructuredType.getProperties(); + for (Property property : structureTypeProperties) { + localPorperties.put(property.getName(), new EdmPropertyImpl(edm, typeName, property)); + } + properties = Collections.unmodifiableMap(localPorperties); + } + return properties; + } + + public Map<String, EdmNavigationProperty> getNavigationProperties() { + if (navigationProperties == null) { + final Map<String, EdmNavigationProperty> localNavigationProperties = + new LinkedHashMap<String, EdmNavigationProperty>(); + final List<NavigationProperty> structuredTypeNavigationProperties = + providerStructuredType.getNavigationProperties(); + + if (structuredTypeNavigationProperties != null) { + for (NavigationProperty navigationProperty : structuredTypeNavigationProperties) { + localNavigationProperties.put(navigationProperty.getName(), + new EdmNavigationPropertyImpl(edm, typeName, navigationProperty)); + } + } + + navigationProperties = Collections.unmodifiableMap(localNavigationProperties); + } + return navigationProperties; + } + + public boolean isOpenType() { + return providerStructuredType.isOpenType(); + } + + public boolean isAbstract() { + return providerStructuredType.isAbstract(); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImpl.java new file mode 100644 index 0000000..91296d5 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.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 AbstractEdmOperation implements EdmAction { + + public 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/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportImpl.java new file mode 100644 index 0000000..43e2f0b --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmActionImportImpl.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +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.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.provider.ActionImport; + +public class EdmActionImportImpl extends AbstractEdmOperationImport implements EdmActionImport { + + private final ActionImport actionImport; + + public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final ActionImport actionImport) { + + super(edm, container, actionImport); + this.actionImport = actionImport; + } + + @Override + public EdmAction getUnboundAction() { + return edm.getUnboundAction(actionImport.getActionFQN()); + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.ActionImport; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationImpl.java new file mode 100644 index 0000000..8006639 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationImpl.java @@ -0,0 +1,225 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import java.util.ArrayList; +import java.util.List; + +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.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.EdmCastImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmCollectionImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmConstantAnnotationExpressionImpl; +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.EdmIsOfImpl; +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.EdmRecordImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmUrlRefImpl; + +public class EdmAnnotationImpl extends AbstractEdmAnnotatable implements EdmAnnotation { + + private final Annotation annotation; + private EdmTerm term; + private EdmAnnotationExpression expression; + + public EdmAnnotationImpl(final Edm edm, final Annotation annotation) { + super(edm, annotation); + this.annotation = 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; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java new file mode 100644 index 0000000..0b10b17 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import java.util.ArrayList; +import java.util.Collections; +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(); + + EdmAnnotationsTarget localTarget = baseEntityContainer == null ? null + : baseEntityContainer.getActionImport(path); + if (localTarget == null) { + localTarget = getTarget(edm.getComplexType(base), path); + if (localTarget == null) { + if(baseEntityContainer != null && baseEntityContainer.getFullQualifiedName().equals(base)){ + localTarget = baseEntityContainer; + } + if (localTarget == null) { + localTarget = baseEntityContainer == null ? null : baseEntityContainer.getEntitySet(path); + if (localTarget == null) { + localTarget = getTarget(edm.getEntityType(base), path); + if (localTarget == null) { + localTarget = getTarget(edm.getEnumType(base), path); + if (localTarget == null) { + localTarget = baseEntityContainer == null ? null : baseEntityContainer.getFunctionImport(path); + if (localTarget == null) { + localTarget = baseEntityContainer == null ? null : baseEntityContainer.getSingleton(path); + if (localTarget == null) { + localTarget = edm.getTerm(base); + if (localTarget == null) { + localTarget = edm.getTypeDefinition(base); + } + } + } + } + } + } + } + } + } + target = localTarget; + } + + 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) { + List<EdmAnnotation> annotationsLocal = new ArrayList<EdmAnnotation>(); + for (Annotation annotation : annotationGroup.getAnnotations()) { + annotationsLocal.add(new EdmAnnotationImpl(edm, annotation)); + } + + annotations = Collections.unmodifiableList(annotationsLocal); + } + return annotations; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmComplexTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmComplexTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmComplexTypeImpl.java new file mode 100644 index 0000000..d39d594 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmComplexTypeImpl.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmComplexType; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmStructuredType; +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.ComplexType; + +public class EdmComplexTypeImpl extends AbstractEdmStructuredType implements EdmComplexType { + + public EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final ComplexType complexType) { + super(edm, name, EdmTypeKind.COMPLEX, complexType); + } + + @Override + protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) { + EdmComplexType baseType = null; + if (baseTypeName != null) { + baseType = edm.getComplexType(baseTypeName); + if (baseType == null) { + throw new EdmException("Can't find base type with name: " + baseTypeName + " for complex type: " + + getName()); + } + } + return baseType; + } + + @Override + public EdmComplexType getBaseType() { + checkBaseType(); + return (EdmComplexType) baseType; + } + + @Override + protected void checkBaseType() { + if (baseTypeName != null && baseType == null) { + baseType = buildBaseType(baseTypeName); + } + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.ComplexType; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java new file mode 100644 index 0000000..2c6d871 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java @@ -0,0 +1,327 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.olingo.commons.api.ODataException; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmActionImport; +import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmFunctionImport; +import org.apache.olingo.commons.api.edm.EdmSingleton; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.provider.ActionImport; +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.FunctionImport; +import org.apache.olingo.commons.api.edm.provider.Singleton; + +public class EdmEntityContainerImpl extends AbstractEdmNamed implements EdmEntityContainer { + + private final EdmProvider provider; + private EntityContainer container; + + private final FullQualifiedName entityContainerName; + private final FullQualifiedName parentContainerName; + + private List<EdmSingleton> singletons; + private final Map<String, EdmSingleton> singletonCache = Collections.synchronizedMap( + new LinkedHashMap<String, EdmSingleton>()); + private List<EdmEntitySet> entitySets; + private final Map<String, EdmEntitySet> entitySetCache = Collections.synchronizedMap( + new LinkedHashMap<String, EdmEntitySet>()); + private List<EdmActionImport> actionImports; + private final Map<String, EdmActionImport> actionImportCache = Collections.synchronizedMap( + new LinkedHashMap<String, EdmActionImport>()); + private List<EdmFunctionImport> functionImports; + private final Map<String, EdmFunctionImport> functionImportCache = Collections.synchronizedMap( + new LinkedHashMap<String, EdmFunctionImport>()); + + public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, + final EntityContainerInfo entityContainerInfo) { + super(edm, entityContainerInfo.getContainerName().getName(), null); + this.provider = provider; + this.entityContainerName = entityContainerInfo.getContainerName(); + this.parentContainerName = entityContainerInfo.getExtendsContainer(); + } + + public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final FullQualifiedName containerFQN, + final EntityContainer entityContainer) { + super(edm, containerFQN.getName(), entityContainer); + this.provider = provider; + container = entityContainer; + this.entityContainerName = containerFQN; + this.parentContainerName = entityContainer.getExtendsContainerFQN(); + } + + @Override + public String getNamespace() { + return entityContainerName.getNamespace(); + } + + @Override + public FullQualifiedName getFullQualifiedName() { + return entityContainerName; + } + + @Override + public EdmSingleton getSingleton(final String singletonName) { + EdmSingleton singleton = singletonCache.get(singletonName); + if (singleton == null) { + singleton = createSingleton(singletonName); + if (singleton != null) { + singletonCache.put(singletonName, singleton); + } + } + return singleton; + } + + @Override + public EdmEntitySet getEntitySet(final String entitySetName) { + EdmEntitySet entitySet = entitySetCache.get(entitySetName); + if (entitySet == null) { + entitySet = createEntitySet(entitySetName); + if (entitySet != null) { + entitySetCache.put(entitySetName, entitySet); + } + } + return entitySet; + } + + @Override + public EdmActionImport getActionImport(final String actionImportName) { + EdmActionImport actionImport = actionImportCache.get(actionImportName); + if (actionImport == null) { + actionImport = createActionImport(actionImportName); + if (actionImport != null) { + actionImportCache.put(actionImportName, actionImport); + } + } + return actionImport; + } + + @Override + public EdmFunctionImport getFunctionImport(final String functionImportName) { + EdmFunctionImport functionImport = functionImportCache.get(functionImportName); + if (functionImport == null) { + functionImport = createFunctionImport(functionImportName); + if (functionImport != null) { + functionImportCache.put(functionImportName, functionImport); + } + } + return functionImport; + } + + @Override + public List<EdmEntitySet> getEntitySets() { + if (entitySets == null) { + loadAllEntitySets(); + } + return Collections.unmodifiableList(entitySets); + } + + @Override + public List<EdmFunctionImport> getFunctionImports() { + if (functionImports == null) { + loadAllFunctionImports(); + } + return Collections.unmodifiableList(functionImports); + } + + @Override + public List<EdmSingleton> getSingletons() { + if (singletons == null) { + loadAllSingletons(); + } + return Collections.unmodifiableList(singletons); + } + + @Override + public List<EdmActionImport> getActionImports() { + if (actionImports == null) { + loadAllActionImports(); + } + return Collections.unmodifiableList(actionImports); + } + + @Override + public FullQualifiedName getParentContainerName() { + return parentContainerName; + } + + protected EdmSingleton createSingleton(final String singletonName) { + EdmSingleton singleton = null; + + try { + final Singleton providerSingleton = provider.getSingleton(entityContainerName, singletonName); + if (providerSingleton != null) { + singleton = new EdmSingletonImpl(edm, this, providerSingleton); + } + } catch (ODataException e) { + throw new EdmException(e); + } + + return singleton; + } + + protected EdmEntitySet createEntitySet(final String entitySetName) { + EdmEntitySet entitySet = null; + + try { + final EntitySet providerEntitySet = provider.getEntitySet(entityContainerName, entitySetName); + if (providerEntitySet != null) { + entitySet = new EdmEntitySetImpl(edm, this, providerEntitySet); + } + } catch (ODataException e) { + throw new EdmException(e); + } + + return entitySet; + } + + protected EdmActionImport createActionImport(final String actionImportName) { + EdmActionImport actionImport = null; + + try { + final ActionImport providerImport = provider.getActionImport(entityContainerName, actionImportName); + if (providerImport != null) { + actionImport = new EdmActionImportImpl(edm, this, providerImport); + } + } catch (ODataException e) { + throw new EdmException(e); + } + + return actionImport; + } + + protected EdmFunctionImport createFunctionImport(final String functionImportName) { + EdmFunctionImport functionImport = null; + + try { + final FunctionImport providerImport = provider.getFunctionImport(entityContainerName, functionImportName); + if (providerImport != null) { + functionImport = new EdmFunctionImportImpl(edm, this, providerImport); + } + } catch (ODataException e) { + throw new EdmException(e); + } + + return functionImport; + } + + protected void loadAllEntitySets() { + loadContainer(); + final List<EntitySet> providerEntitySets = container.getEntitySets(); + final List<EdmEntitySet> entitySetsLocal = new ArrayList<EdmEntitySet>(); + + if (providerEntitySets != null) { + for (EntitySet entitySet : providerEntitySets) { + final EdmEntitySetImpl impl = new EdmEntitySetImpl(edm, this, entitySet); + entitySetCache.put(impl.getName(), impl); + entitySetsLocal.add(impl); + } + entitySets = entitySetsLocal; + } + } + + protected void loadAllFunctionImports() { + loadContainer(); + final List<FunctionImport> providerFunctionImports = container.getFunctionImports(); + final ArrayList<EdmFunctionImport> functionImportsLocal = new ArrayList<EdmFunctionImport>(); + + if (providerFunctionImports != null) { + for (FunctionImport functionImport : providerFunctionImports) { + EdmFunctionImportImpl impl = new EdmFunctionImportImpl(edm, this, functionImport); + functionImportCache.put(impl.getName(), impl); + functionImportsLocal.add(impl); + } + functionImports = functionImportsLocal; + } + } + + protected void loadAllSingletons() { + loadContainer(); + final List<Singleton> providerSingletons = container.getSingletons(); + final List<EdmSingleton> singletonsLocal = new ArrayList<EdmSingleton>(); + + if (providerSingletons != null) { + for (Singleton singleton : providerSingletons) { + final EdmSingletonImpl impl = new EdmSingletonImpl(edm, this, singleton); + singletonCache.put(singleton.getName(), impl); + singletonsLocal.add(impl); + } + singletons = singletonsLocal; + } + } + + protected void loadAllActionImports() { + loadContainer(); + final List<ActionImport> providerActionImports = container.getActionImports(); + final List<EdmActionImport> actionImportsLocal = new ArrayList<EdmActionImport>(); + + if (providerActionImports != null) { + for (ActionImport actionImport : providerActionImports) { + final EdmActionImportImpl impl = new EdmActionImportImpl(edm, this, actionImport); + actionImportCache.put(actionImport.getName(), impl); + actionImportsLocal.add(impl); + } + actionImports = actionImportsLocal; + } + + } + + private void loadContainer() { + if (container == null) { + try { + EntityContainer containerLocal = provider.getEntityContainer(); + if (containerLocal == null) { + containerLocal = new EntityContainer().setName(getName()); + } + + container = containerLocal; + } catch (ODataException e) { + throw new EdmException(e); + } + } + } + + @Override + public String getAnnotationsTargetPath() { + return null; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return getFullQualifiedName(); + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntityContainer; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ac32d236/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetImpl.java new file mode 100644 index 0000000..2d4bd0d --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntitySetImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.core.edm; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.provider.EntitySet; + +public class EdmEntitySetImpl extends AbstractEdmBindingTarget implements EdmEntitySet { + + private EntitySet entitySet; + + public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final EntitySet entitySet) { + super(edm, container, entitySet); + this.entitySet = entitySet; + } + + @Override + public boolean isIncludeInServiceDocument() { + return entitySet.isIncludeInServiceDocument(); + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntitySet; + } +}
