You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/07 10:09:36 UTC
[47/57] [abbrv] git commit: [OLINGO-186] client-side implementation
of commons Edm interfaces completed: some refactoring on server-side
performed to extract common abstract implementation
[OLINGO-186] client-side implementation of commons Edm interfaces completed: some refactoring on server-side performed to extract common abstract implementation
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/bae3d847
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/bae3d847
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/bae3d847
Branch: refs/heads/master
Commit: bae3d847a866bf1376627b09e55b65f4570c9f24
Parents: a8c0e9e
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Mar 5 16:06:00 2014 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Mar 5 16:06:00 2014 +0100
----------------------------------------------------------------------
.../odata4/client/api/edm/EdmMetadata.java | 60 ---
.../client/api/edm/xml/CommonParameter.java | 14 +-
.../client/api/edm/xml/CommonProperty.java | 13 +-
.../odata4/client/api/edm/xml/Member.java | 2 +-
.../odata4/client/api/edm/xml/Schema.java | 1 -
.../odata4/client/api/edm/xml/XMLMetadata.java | 59 +++
.../client/api/edm/xml/v4/BindingTarget.java | 31 ++
.../client/api/edm/xml/v4/EntityContainer.java | 4 +
.../odata4/client/api/edm/xml/v4/EntitySet.java | 6 +-
.../client/api/edm/xml/v4/ReturnType.java | 14 +-
.../odata4/client/api/edm/xml/v4/Singleton.java | 9 +-
.../client/api/edm/xml/v4/TypeDefinition.java | 12 +-
.../odata4/client/api/op/ODataDeserializer.java | 4 +-
.../odata4/client/api/op/ODataReader.java | 4 +-
.../odata4/client/api/utils/EdmTypeInfo.java | 81 ++++
.../client/core/edm/AbstractEdmMetadata.java | 105 -----
.../edm/AbstractEdmServiceMetadataImpl.java | 115 +++++
.../odata4/client/core/edm/AbstractEdmType.java | 265 -----------
.../odata4/client/core/edm/EdmActionImpl.java | 37 ++
.../client/core/edm/EdmActionImportImpl.java | 45 ++
.../client/core/edm/EdmBindingTargetImpl.java | 80 ++++
.../odata4/client/core/edm/EdmClientImpl.java | 285 ++++++++++++
.../client/core/edm/EdmComplexTypeImpl.java | 63 +++
.../client/core/edm/EdmEntityContainerImpl.java | 87 ++++
.../client/core/edm/EdmEntitySetImpl.java | 35 ++
.../client/core/edm/EdmEntityTypeImpl.java | 79 ++++
.../odata4/client/core/edm/EdmEnumTypeImpl.java | 83 ++++
.../odata4/client/core/edm/EdmFunctionImpl.java | 44 ++
.../client/core/edm/EdmFunctionImportImpl.java | 47 ++
.../client/core/edm/EdmKeyPropertyRefImpl.java | 49 ++
.../core/edm/EdmNavigationPropertyImpl.java | 74 +++
.../client/core/edm/EdmOperationImpl.java | 63 +++
.../client/core/edm/EdmOperationImportImpl.java | 35 ++
.../client/core/edm/EdmParameterImpl.java | 74 +++
.../odata4/client/core/edm/EdmPropertyImpl.java | 91 ++++
.../client/core/edm/EdmReturnTypeImpl.java | 68 +++
.../client/core/edm/EdmSingletonImpl.java | 35 ++
.../core/edm/EdmStructuredTypeHelperImpl.java | 71 +++
.../client/core/edm/EdmTypeDefinitionImpl.java | 74 +++
.../client/core/edm/v3/EdmMetadataImpl.java | 51 ---
.../core/edm/v3/EdmServiceMetadataImpl.java | 52 +++
.../odata4/client/core/edm/v3/EdmTypeImpl.java | 5 +-
.../client/core/edm/v4/EdmMetadataImpl.java | 56 ---
.../core/edm/v4/EdmServiceMetadataImpl.java | 83 ++++
.../odata4/client/core/edm/v4/EdmTypeImpl.java | 5 +-
.../annotation/AbstractElOrAttrConstruct.java | 37 --
.../annotation/AnnotatedDynExprConstruct.java | 40 --
.../core/edm/v4/annotation/AnnotationPath.java | 25 -
.../client/core/edm/v4/annotation/Apply.java | 53 ---
.../edm/v4/annotation/ApplyDeserializer.java | 55 ---
.../client/core/edm/v4/annotation/Cast.java | 90 ----
.../edm/v4/annotation/CastDeserializer.java | 62 ---
.../core/edm/v4/annotation/Collection.java | 37 --
.../v4/annotation/CollectionDeserializer.java | 50 --
.../v4/annotation/ConstExprConstructImpl.java | 51 ---
.../DynExprConstructDeserializer.java | 145 ------
.../edm/v4/annotation/DynExprConstructImpl.java | 29 --
.../edm/v4/annotation/DynExprDoubleParamOp.java | 73 ---
.../edm/v4/annotation/DynExprSingleParamOp.java | 69 ---
.../edm/v4/annotation/ExprConstructImpl.java | 28 --
.../client/core/edm/v4/annotation/If.java | 57 ---
.../client/core/edm/v4/annotation/IsOf.java | 90 ----
.../edm/v4/annotation/IsOfDeserializer.java | 62 ---
.../core/edm/v4/annotation/LabeledElement.java | 49 --
.../annotation/LabeledElementDeserializer.java | 53 ---
.../v4/annotation/LabeledElementReference.java | 25 -
.../v4/annotation/NavigationPropertyPath.java | 25 -
.../client/core/edm/v4/annotation/Null.java | 28 --
.../edm/v4/annotation/NullDeserializer.java | 49 --
.../client/core/edm/v4/annotation/Path.java | 25 -
.../core/edm/v4/annotation/PropertyPath.java | 25 -
.../core/edm/v4/annotation/PropertyValue.java | 49 --
.../annotation/PropertyValueDeserializer.java | 55 ---
.../client/core/edm/v4/annotation/Record.java | 46 --
.../edm/v4/annotation/RecordDeserializer.java | 53 ---
.../client/core/edm/v4/annotation/UrlRef.java | 39 --
.../edm/v4/annotation/UrlRefDeserializer.java | 50 --
.../client/core/edm/xml/AbstractEdmType.java | 262 +++++++++++
.../client/core/edm/xml/AbstractMember.java | 6 +-
.../client/core/edm/xml/AbstractParameter.java | 28 +-
.../client/core/edm/xml/AbstractProperty.java | 35 +-
.../core/edm/xml/AbstractXMLMetadata.java | 95 ++++
.../core/edm/xml/ParameterDeserializer.java | 69 +++
.../core/edm/xml/PropertyDeserializer.java | 102 +++++
.../client/core/edm/xml/v3/ParameterImpl.java | 2 -
.../client/core/edm/xml/v3/PropertyImpl.java | 19 +-
.../client/core/edm/xml/v3/XMLMetadataImpl.java | 48 ++
.../core/edm/xml/v4/AnnotationDeserializer.java | 2 +-
.../client/core/edm/xml/v4/AnnotationImpl.java | 4 +-
.../core/edm/xml/v4/EntityContainerImpl.java | 2 +
.../client/core/edm/xml/v4/EntitySetImpl.java | 6 +-
.../client/core/edm/xml/v4/ParameterImpl.java | 2 -
.../client/core/edm/xml/v4/PropertyImpl.java | 2 -
.../core/edm/xml/v4/ReturnTypeDeserializer.java | 60 +++
.../client/core/edm/xml/v4/ReturnTypeImpl.java | 28 +-
.../client/core/edm/xml/v4/SchemaImpl.java | 4 +
.../core/edm/xml/v4/SingletonDeserializer.java | 2 +-
.../client/core/edm/xml/v4/SingletonImpl.java | 16 +-
.../edm/xml/v4/TypeDefinitionDeserializer.java | 9 +-
.../core/edm/xml/v4/TypeDefinitionImpl.java | 21 +-
.../client/core/edm/xml/v4/XMLMetadataImpl.java | 51 +++
.../annotation/AbstractElOrAttrConstruct.java | 37 ++
.../annotation/AnnotatedDynExprConstruct.java | 40 ++
.../edm/xml/v4/annotation/AnnotationPath.java | 25 +
.../core/edm/xml/v4/annotation/Apply.java | 53 +++
.../xml/v4/annotation/ApplyDeserializer.java | 55 +++
.../client/core/edm/xml/v4/annotation/Cast.java | 90 ++++
.../edm/xml/v4/annotation/CastDeserializer.java | 62 +++
.../core/edm/xml/v4/annotation/Collection.java | 37 ++
.../v4/annotation/CollectionDeserializer.java | 50 ++
.../v4/annotation/ConstExprConstructImpl.java | 51 +++
.../DynExprConstructDeserializer.java | 145 ++++++
.../xml/v4/annotation/DynExprConstructImpl.java | 29 ++
.../xml/v4/annotation/DynExprDoubleParamOp.java | 73 +++
.../xml/v4/annotation/DynExprSingleParamOp.java | 69 +++
.../xml/v4/annotation/ExprConstructImpl.java | 28 ++
.../client/core/edm/xml/v4/annotation/If.java | 57 +++
.../client/core/edm/xml/v4/annotation/IsOf.java | 90 ++++
.../edm/xml/v4/annotation/IsOfDeserializer.java | 62 +++
.../edm/xml/v4/annotation/LabeledElement.java | 49 ++
.../annotation/LabeledElementDeserializer.java | 53 +++
.../v4/annotation/LabeledElementReference.java | 25 +
.../v4/annotation/NavigationPropertyPath.java | 25 +
.../client/core/edm/xml/v4/annotation/Null.java | 28 ++
.../edm/xml/v4/annotation/NullDeserializer.java | 49 ++
.../client/core/edm/xml/v4/annotation/Path.java | 25 +
.../edm/xml/v4/annotation/PropertyPath.java | 25 +
.../edm/xml/v4/annotation/PropertyValue.java | 49 ++
.../annotation/PropertyValueDeserializer.java | 55 +++
.../core/edm/xml/v4/annotation/Record.java | 46 ++
.../xml/v4/annotation/RecordDeserializer.java | 53 +++
.../core/edm/xml/v4/annotation/UrlRef.java | 39 ++
.../xml/v4/annotation/UrlRefDeserializer.java | 50 ++
.../core/op/impl/AbstractEdmDeserializer.java | 2 +-
.../core/op/impl/v3/ODataDeserializerImpl.java | 5 +-
.../client/core/op/impl/v3/ODataReaderImpl.java | 7 +-
.../core/op/impl/v4/ODataDeserializerImpl.java | 5 +-
.../client/core/op/impl/v4/ODataReaderImpl.java | 7 +-
.../odata4/client/core/v3/MetadataTest.java | 22 +-
.../odata4/client/core/v4/MetadataTest.java | 157 ++++---
.../odata4/client/core/v4/demo-metadata.xml | 143 +++++-
.../odata4/client/core/v4/fromdoc1-metadata.xml | 10 +
.../client/core/v4/northwind-metadata.xml | 451 ++++++++++++++++++-
.../olingo/odata4/commons/api/edm/Edm.java | 12 +-
.../commons/api/edm/EdmActionImportInfo.java | 40 ++
.../odata4/commons/api/edm/EdmComplexType.java | 2 +-
.../odata4/commons/api/edm/EdmEntityType.java | 2 +-
.../commons/api/edm/EdmFunctionImportInfo.java | 7 +-
.../commons/api/edm/EdmOperationImportInfo.java | 31 ++
.../commons/api/edm/EdmServiceMetadata.java | 5 +
.../commons/api/edm/EdmStructuralType.java | 66 ---
.../commons/api/edm/EdmStructuredType.java | 82 ++++
.../olingo/odata4/commons/api/edm/Target.java | 71 +++
.../core/edm/AbstractEdmBindingTarget.java | 55 +++
.../core/edm/AbstractEdmComplexType.java | 50 ++
.../core/edm/AbstractEdmEntityContainer.java | 101 +++++
.../commons/core/edm/AbstractEdmEntityType.java | 113 +++++
.../commons/core/edm/AbstractEdmEnumType.java | 205 +++++++++
.../commons/core/edm/AbstractEdmImpl.java | 2 +-
.../core/edm/AbstractEdmKeyPropertyRef.java | 80 ++++
.../core/edm/AbstractEdmNavigationProperty.java | 76 ++++
.../commons/core/edm/AbstractEdmOperation.java | 113 +++++
.../core/edm/AbstractEdmOperationImport.java | 63 +++
.../commons/core/edm/AbstractEdmParameter.java | 87 ++++
.../commons/core/edm/AbstractEdmProperty.java | 70 +++
.../commons/core/edm/AbstractEdmReturnType.java | 85 ++++
.../core/edm/AbstractEdmStructuredType.java | 128 ++++++
.../core/edm/AbstractEdmTypeDefinition.java | 107 +++++
.../core/edm/EdmActionImportInfoImpl.java | 45 ++
.../odata4/commons/core/edm/EdmElementImpl.java | 29 ++
.../commons/core/edm/EdmEntitySetInfoImpl.java | 52 +++
.../core/edm/EdmFunctionImportInfoImpl.java | 45 ++
.../odata4/commons/core/edm/EdmMemberImpl.java | 38 ++
.../odata4/commons/core/edm/EdmNamedImpl.java | 40 ++
.../core/edm/EdmOperationImportInfoImpl.java | 36 ++
.../commons/core/edm/EdmSingletonInfoImpl.java | 52 +++
.../core/edm/EdmStructuredTypeHelper.java | 30 ++
.../odata4/commons/core/edm/EdmTypeImpl.java | 48 ++
.../edm/primitivetype/EdmPrimitiveTypeKind.java | 16 +
.../server/api/edm/provider/ActionImport.java | 1 +
.../server/api/edm/provider/ComplexType.java | 2 +-
.../server/api/edm/provider/EntityType.java | 2 +-
.../server/api/edm/provider/FunctionImport.java | 1 +
.../edm/provider/NavigationPropertyBinding.java | 2 +
.../api/edm/provider/OperationImport.java | 3 +
.../server/api/edm/provider/StructuralType.java | 93 ----
.../server/api/edm/provider/StructuredType.java | 93 ++++
.../odata4/server/api/edm/provider/Target.java | 47 --
.../server/core/edm/provider/EdmActionImpl.java | 7 +-
.../core/edm/provider/EdmActionImportImpl.java | 8 +-
.../core/edm/provider/EdmBindingTargetImpl.java | 55 +--
.../core/edm/provider/EdmComplexTypeImpl.java | 43 +-
.../core/edm/provider/EdmElementImpl.java | 28 --
.../edm/provider/EdmEntityContainerImpl.java | 119 ++---
.../core/edm/provider/EdmEntitySetImpl.java | 3 +-
.../core/edm/provider/EdmEntitySetInfoImpl.java | 53 ---
.../core/edm/provider/EdmEntityTypeImpl.java | 98 ++--
.../server/core/edm/provider/EdmEnumImpl.java | 228 ----------
.../core/edm/provider/EdmEnumTypeImpl.java | 61 +++
.../core/edm/provider/EdmFunctionImpl.java | 11 +-
.../edm/provider/EdmFunctionImportImpl.java | 8 +-
.../edm/provider/EdmFunctionImportInfoImpl.java | 53 ---
.../edm/provider/EdmKeyPropertyRefImpl.java | 49 +-
.../server/core/edm/provider/EdmMemberImpl.java | 38 --
.../server/core/edm/provider/EdmNamedImpl.java | 39 --
.../edm/provider/EdmNavigationPropertyImpl.java | 47 +-
.../core/edm/provider/EdmOperationImpl.java | 85 +---
.../edm/provider/EdmOperationImportImpl.java | 41 +-
.../core/edm/provider/EdmParameterImpl.java | 44 +-
.../core/edm/provider/EdmPropertyImpl.java | 44 +-
.../core/edm/provider/EdmProviderImpl.java | 96 ++--
.../core/edm/provider/EdmReturnTypeImpl.java | 46 +-
.../edm/provider/EdmServiceMetadataImpl.java | 66 ++-
.../core/edm/provider/EdmSingletonImpl.java | 3 +-
.../core/edm/provider/EdmSingletonInfoImpl.java | 53 ---
.../edm/provider/EdmStructuralTypeImpl.java | 129 ------
.../provider/EdmStructuredTypeHelperImpl.java | 72 +++
.../edm/provider/EdmTypeDefinitionImpl.java | 72 +--
.../server/core/edm/provider/EdmTypeImpl.java | 46 --
.../server/core/uri/UriResourceTypedImpl.java | 4 +-
.../core/uri/parser/UriParseTreeVisitor.java | 16 +-
.../core/edm/provider/EdmActionImplTest.java | 6 +-
.../edm/provider/EdmActionImportImplTest.java | 17 +-
.../edm/provider/EdmComplexTypeImplTest.java | 8 +-
.../core/edm/provider/EdmEntitySetImplTest.java | 2 +-
.../edm/provider/EdmEntitySetInfoImplTest.java | 51 ---
.../edm/provider/EdmEntityTypeImplTest.java | 14 +-
.../server/core/edm/provider/EdmEnumTest.java | 4 +-
.../core/edm/provider/EdmFunctionImplTest.java | 4 +-
.../edm/provider/EdmFunctionImportImplTest.java | 2 +-
.../provider/EdmFunctionImportInfoImplTest.java | 50 --
.../edm/provider/EdmKeyPropertyRefImplTest.java | 18 +-
.../core/edm/provider/EdmMemberImplTest.java | 3 +-
.../core/edm/provider/EdmNamedImplTest.java | 1 +
.../core/edm/provider/EdmSingletonImplTest.java | 2 +-
.../edm/provider/EdmSingletonInfoImplTest.java | 51 ---
.../core/edm/provider/EdmTypeImplTest.java | 1 +
.../server/core/testutil/EdmTechProvider.java | 2 +-
238 files changed, 7710 insertions(+), 4121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmMetadata.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmMetadata.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmMetadata.java
deleted file mode 100644
index 9fef9c5..0000000
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmMetadata.java
+++ /dev/null
@@ -1,60 +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.odata4.client.api.edm;
-
-import java.util.List;
-import org.apache.olingo.odata4.client.api.edm.xml.Schema;
-
-/**
- * Entry point for access information about EDM metadata.
- */
-public interface EdmMetadata {
-
- /**
- * Checks whether the given key is a valid namespace or alias in the EdM metadata document.
- *
- * @param key namespace or alias
- * @return true if key is valid namespace or alias
- */
- boolean isNsOrAlias(String key);
-
- /**
- * Returns the Schema at the specified position in the EdM metadata document.
- *
- * @param index index of the Schema to return
- * @return the Schema at the specified position in the EdM metadata document
- */
- Schema getSchema(final int index);
-
- /**
- * Returns the Schema with the specified key (namespace or alias) in the EdM metadata document.
- *
- * @param key namespace or alias
- * @return the Schema with the specified key in the EdM metadata document
- */
- Schema getSchema(final String key);
-
- /**
- * Returns all Schema objects defined in the EdM metadata document.
- *
- * @return all Schema objects defined in the EdM metadata document
- */
- List<? extends Schema> getSchemas();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonParameter.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonParameter.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonParameter.java
index 1366289..6d39a8d 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonParameter.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonParameter.java
@@ -18,8 +18,6 @@
*/
package org.apache.olingo.odata4.client.api.edm.xml;
-import java.math.BigInteger;
-
public interface CommonParameter extends Named {
String getType();
@@ -30,16 +28,16 @@ public interface CommonParameter extends Named {
void setNullable(boolean nullable);
- String getMaxLength();
+ Integer getMaxLength();
- void setMaxLength(String maxLength);
+ void setMaxLength(Integer maxLength);
- BigInteger getPrecision();
+ Integer getPrecision();
- void setPrecision(BigInteger precision);
+ void setPrecision(Integer precision);
- BigInteger getScale();
+ Integer getScale();
- void setScale(BigInteger scale);
+ void setScale(Integer scale);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonProperty.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonProperty.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonProperty.java
index 1621cd2..cc362a5 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonProperty.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/CommonProperty.java
@@ -18,7 +18,6 @@
*/
package org.apache.olingo.odata4.client.api.edm.xml;
-import java.math.BigInteger;
import org.apache.olingo.odata4.commons.api.edm.constants.ConcurrencyMode;
import org.apache.olingo.odata4.commons.api.edm.constants.StoreGeneratedPattern;
@@ -36,21 +35,21 @@ public interface CommonProperty extends Named {
void setDefaultValue(String defaultValue);
- String getMaxLength();
+ Integer getMaxLength();
- void setMaxLength(String maxLength);
+ void setMaxLength(Integer maxLength);
boolean isFixedLength();
void setFixedLength(boolean fixedLength);
- BigInteger getPrecision();
+ Integer getPrecision();
- void setPrecision(BigInteger precision);
+ void setPrecision(Integer precision);
- BigInteger getScale();
+ Integer getScale();
- void setScale(BigInteger scale);
+ void setScale(Integer scale);
boolean isUnicode();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Member.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Member.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Member.java
index cf1e258..d6292c9 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Member.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Member.java
@@ -22,5 +22,5 @@ public interface Member {
String getName();
- Integer getValue();
+ String getValue();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Schema.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Schema.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Schema.java
index 1856f8e..8229234 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Schema.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/Schema.java
@@ -18,7 +18,6 @@
*/
package org.apache.olingo.odata4.client.api.edm.xml;
-import org.apache.olingo.odata4.client.api.edm.xml.v3.Annotations;
import java.util.List;
public interface Schema {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/XMLMetadata.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/XMLMetadata.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/XMLMetadata.java
new file mode 100644
index 0000000..2350214
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/XMLMetadata.java
@@ -0,0 +1,59 @@
+/*
+ * 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.odata4.client.api.edm.xml;
+
+import java.util.List;
+
+/**
+ * Entry point for access information about EDM metadata.
+ */
+public interface XMLMetadata {
+
+ /**
+ * Checks whether the given key is a valid namespace or alias in the EdM metadata document.
+ *
+ * @param key namespace or alias
+ * @return true if key is valid namespace or alias
+ */
+ boolean isNsOrAlias(String key);
+
+ /**
+ * Returns the Schema at the specified position in the EdM metadata document.
+ *
+ * @param index index of the Schema to return
+ * @return the Schema at the specified position in the EdM metadata document
+ */
+ Schema getSchema(final int index);
+
+ /**
+ * Returns the Schema with the specified key (namespace or alias) in the EdM metadata document.
+ *
+ * @param key namespace or alias
+ * @return the Schema with the specified key in the EdM metadata document
+ */
+ Schema getSchema(final String key);
+
+ /**
+ * Returns all Schema objects defined in the EdM metadata document.
+ *
+ * @return all Schema objects defined in the EdM metadata document
+ */
+ List<? extends Schema> getSchemas();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/BindingTarget.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/BindingTarget.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/BindingTarget.java
new file mode 100644
index 0000000..c2c4aba
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/BindingTarget.java
@@ -0,0 +1,31 @@
+/*
+ * 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.odata4.client.api.edm.xml.v4;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.edm.xml.Named;
+
+public interface BindingTarget extends Named, AnnotatedEdmItem {
+
+ String getEntityType();
+
+ void setEntityType(String entityType);
+
+ List<? extends NavigationPropertyBinding> getNavigationPropertyBindings();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntityContainer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntityContainer.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntityContainer.java
index 6acf741..d3a7611 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntityContainer.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntityContainer.java
@@ -22,6 +22,10 @@ import java.util.List;
public interface EntityContainer extends org.apache.olingo.odata4.client.api.edm.xml.EntityContainer {
+ List<? extends Singleton> getSingletons();
+
+ Singleton getSingleton(String name);
+
/**
* Gets the first action import with given name.
*
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntitySet.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntitySet.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntitySet.java
index c6754c7..abdd598 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntitySet.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/EntitySet.java
@@ -18,13 +18,9 @@
*/
package org.apache.olingo.odata4.client.api.edm.xml.v4;
-import java.util.List;
-
-public interface EntitySet extends org.apache.olingo.odata4.client.api.edm.xml.EntitySet, AnnotatedEdmItem {
+public interface EntitySet extends org.apache.olingo.odata4.client.api.edm.xml.EntitySet, BindingTarget {
boolean isIncludeInServiceDocument();
void setIncludeInServiceDocument(boolean includeInServiceDocument);
-
- List<? extends NavigationPropertyBinding> getNavigationPropertyBindings();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/ReturnType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/ReturnType.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/ReturnType.java
index 8e3c1f2..b6cd912 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/ReturnType.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/ReturnType.java
@@ -18,15 +18,13 @@
*/
package org.apache.olingo.odata4.client.api.edm.xml.v4;
-import java.math.BigInteger;
-
public interface ReturnType {
- String getMaxLength();
+ Integer getMaxLength();
- BigInteger getPrecision();
+ Integer getPrecision();
- BigInteger getScale();
+ Integer getScale();
String getSrid();
@@ -34,13 +32,13 @@ public interface ReturnType {
boolean isNullable();
- void setMaxLength(String maxLength);
+ void setMaxLength(Integer maxLength);
void setNullable(boolean nullable);
- void setPrecision(BigInteger precision);
+ void setPrecision(Integer precision);
- void setScale(BigInteger scale);
+ void setScale(Integer scale);
void setSrid(String srid);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/Singleton.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/Singleton.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/Singleton.java
index a706f89..41145e5 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/Singleton.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/Singleton.java
@@ -18,15 +18,8 @@
*/
package org.apache.olingo.odata4.client.api.edm.xml.v4;
-import java.util.List;
import org.apache.olingo.odata4.client.api.edm.xml.Named;
-public interface Singleton extends Named {
-
- String getType();
-
- void setType(String type);
-
- List<? extends NavigationPropertyBinding> getNavigationPropertyBindings();
+public interface Singleton extends Named, BindingTarget {
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/TypeDefinition.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/TypeDefinition.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/TypeDefinition.java
index aaad5e7..531cf45 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/TypeDefinition.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/xml/v4/TypeDefinition.java
@@ -26,11 +26,11 @@ public interface TypeDefinition extends Named {
List<? extends Annotation> getAnnotations();
- String getMaxLength();
+ Integer getMaxLength();
- BigInteger getPrecision();
+ Integer getPrecision();
- BigInteger getScale();
+ Integer getScale();
String getSrid();
@@ -38,11 +38,11 @@ public interface TypeDefinition extends Named {
boolean isUnicode();
- void setMaxLength(String maxLength);
+ void setMaxLength(Integer maxLength);
- void setPrecision(BigInteger precision);
+ void setPrecision(Integer precision);
- void setScale(BigInteger scale);
+ void setScale(Integer scale);
void setSrid(String srid);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
index fe6872c..8d6fc62 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
@@ -20,7 +20,7 @@ package org.apache.olingo.odata4.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
-import org.apache.olingo.odata4.client.api.edm.xml.Edmx;
+import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
import org.w3c.dom.Element;
/**
@@ -28,7 +28,7 @@ import org.w3c.dom.Element;
*/
public interface ODataDeserializer extends Serializable {
- Edmx toMetadata(InputStream input);
+ XMLMetadata toMetadata(InputStream input);
/**
* Gets the ServiceDocumentResource object represented by the given InputStream.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
index e6f59db..a933919 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
@@ -20,7 +20,7 @@ package org.apache.olingo.odata4.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
-import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
/**
* OData reader.
@@ -37,7 +37,7 @@ public interface ODataReader extends Serializable {
* @param input stream to de-serialize.
* @return metadata representation.
*/
- EdmMetadata readMetadata(InputStream input);
+ Edm readMetadata(InputStream input);
/**
* Parses an OData service document.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/EdmTypeInfo.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/EdmTypeInfo.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/EdmTypeInfo.java
new file mode 100644
index 0000000..33dd468
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/EdmTypeInfo.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.api.utils;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+
+public class EdmTypeInfo {
+
+ private final String typeExpression;
+
+ private final boolean collection;
+
+ private final FullQualifiedName fullQualifiedName;
+
+ public EdmTypeInfo(final String typeExpression, final String defaultNamespace) {
+ this(typeExpression.indexOf('.') == -1
+ ? defaultNamespace + "." + typeExpression
+ : typeExpression);
+ }
+
+ public EdmTypeInfo(final String typeExpression) {
+ this.typeExpression = typeExpression;
+
+ String baseType;
+ final int collStartIdx = typeExpression.indexOf("Collection(");
+ final int collEndIdx = typeExpression.lastIndexOf(')');
+ if (collStartIdx == -1) {
+ baseType = typeExpression;
+ this.collection = false;
+ } else {
+ if (collEndIdx == -1) {
+ throw new IllegalArgumentException("Malformed type: " + typeExpression);
+ }
+
+ this.collection = true;
+ baseType = typeExpression.substring(collStartIdx + 11, collEndIdx);
+ }
+
+ final int lastDotIdx = baseType.lastIndexOf('.');
+ if (lastDotIdx == -1) {
+ throw new IllegalArgumentException("Cannot find namespace or alias in " + typeExpression);
+ }
+ final String namespace = baseType.substring(0, lastDotIdx);
+ final String typeName = baseType.substring(lastDotIdx + 1);
+ if (StringUtils.isBlank(typeName)) {
+ throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
+ }
+
+ this.fullQualifiedName = new FullQualifiedName(namespace, typeName);
+ }
+
+ public String getTypeExpression() {
+ return typeExpression;
+ }
+
+ public boolean isCollection() {
+ return collection;
+ }
+
+ public FullQualifiedName getFullQualifiedName() {
+ return fullQualifiedName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmMetadata.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmMetadata.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmMetadata.java
deleted file mode 100644
index 2e6cc1a..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmMetadata.java
+++ /dev/null
@@ -1,105 +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.odata4.client.core.edm;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.odata4.client.api.ODataClient;
-import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
-import org.apache.olingo.odata4.client.api.edm.xml.Edmx;
-import org.apache.olingo.odata4.client.api.edm.xml.Schema;
-import org.apache.olingo.odata4.client.core.edm.xml.AbstractEdmItem;
-
-/**
- * Entry point for access information about EDM metadata.
- */
-public abstract class AbstractEdmMetadata extends AbstractEdmItem implements EdmMetadata {
-
- private static final long serialVersionUID = -1214173426671503187L;
-
- protected final Edmx edmx;
-
- protected final Map<String, Schema> schemaByNsOrAlias;
-
- /**
- * Constructor.
- *
- * @param client OData client
- * @param inputStream source stream.
- */
- @SuppressWarnings("unchecked")
- public AbstractEdmMetadata(final ODataClient client, final InputStream inputStream) {
- edmx = client.getDeserializer().toMetadata(inputStream);
-
- this.schemaByNsOrAlias = new HashMap<String, Schema>();
- for (Schema schema : edmx.getDataServices().getSchemas()) {
- this.schemaByNsOrAlias.put(schema.getNamespace(), schema);
- if (StringUtils.isNotBlank(schema.getAlias())) {
- this.schemaByNsOrAlias.put(schema.getAlias(), schema);
- }
- }
- }
-
- /**
- * Checks whether the given key is a valid namespace or alias in the EdM metadata document.
- *
- * @param key namespace or alias
- * @return true if key is valid namespace or alias
- */
- @Override
- public boolean isNsOrAlias(final String key) {
- return this.schemaByNsOrAlias.keySet().contains(key);
- }
-
- /**
- * Returns the Schema at the specified position in the EdM metadata document.
- *
- * @param index index of the Schema to return
- * @return the Schema at the specified position in the EdM metadata document
- */
- @Override
- public Schema getSchema(final int index) {
- return this.edmx.getDataServices().getSchemas().get(index);
- }
-
- /**
- * Returns the Schema with the specified key (namespace or alias) in the EdM metadata document.
- *
- * @param key namespace or alias
- * @return the Schema with the specified key in the EdM metadata document
- */
- @Override
- public Schema getSchema(final String key) {
- return this.schemaByNsOrAlias.get(key);
- }
-
- /**
- * Returns all Schema objects defined in the EdM metadata document.
- *
- * @return all Schema objects defined in the EdM metadata document
- */
- @Override
- public List<? extends Schema> getSchemas() {
- return this.edmx.getDataServices().getSchemas();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmServiceMetadataImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmServiceMetadataImpl.java
new file mode 100644
index 0000000..d036e9f
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmServiceMetadataImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+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.odata4.client.api.edm.xml.CommonFunctionImport;
+import org.apache.olingo.odata4.client.api.edm.xml.EntityContainer;
+import org.apache.olingo.odata4.client.api.edm.xml.EntitySet;
+import org.apache.olingo.odata4.client.api.edm.xml.Schema;
+import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImportInfo;
+import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata4.commons.core.edm.EdmEntitySetInfoImpl;
+import org.apache.olingo.odata4.commons.core.edm.EdmFunctionImportInfoImpl;
+
+public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetadata {
+
+ protected final XMLMetadata xmlMetadata;
+
+ private List<EdmEntitySetInfo> entitySetInfos;
+
+ private List<EdmFunctionImportInfo> functionImportInfos;
+
+ public static EdmServiceMetadata getInstance(final XMLMetadata xmlMetadata) {
+ return xmlMetadata instanceof org.apache.olingo.odata4.client.core.edm.xml.v3.XMLMetadataImpl
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EdmServiceMetadataImpl(
+ (org.apache.olingo.odata4.client.core.edm.xml.v3.XMLMetadataImpl) xmlMetadata)
+ : new org.apache.olingo.odata4.client.core.edm.v4.EdmServiceMetadataImpl(
+ (org.apache.olingo.odata4.client.core.edm.xml.v4.XMLMetadataImpl) xmlMetadata);
+
+ }
+
+ public AbstractEdmServiceMetadataImpl(final XMLMetadata xmlMetadata) {
+ this.xmlMetadata = xmlMetadata;
+ }
+
+ @Override
+ public InputStream getMetadata() {
+ throw new UnsupportedOperationException("Not supported in client code.");
+ }
+
+ @Override
+ public List<EdmEntitySetInfo> getEntitySetInfos() {
+ synchronized (this) {
+ if (entitySetInfos == null) {
+ entitySetInfos = new ArrayList<EdmEntitySetInfo>();
+ for (Schema schema : xmlMetadata.getSchemas()) {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ for (EntitySet entitySet : entityContainer.getEntitySets()) {
+ entitySetInfos.add(
+ new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
+ }
+ }
+ }
+ }
+ return entitySetInfos;
+ }
+ }
+
+ @Override
+ public List<EdmFunctionImportInfo> getFunctionImportInfos() {
+ synchronized (this) {
+ if (functionImportInfos == null) {
+ functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
+ for (Schema schema : xmlMetadata.getSchemas()) {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
+ functionImportInfos.add(
+ new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
+ }
+ }
+ }
+ }
+ }
+ return functionImportInfos;
+ }
+
+ @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/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmType.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmType.java
deleted file mode 100644
index 2d4dccf..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/AbstractEdmType.java
+++ /dev/null
@@ -1,265 +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.odata4.client.core.edm;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.odata4.client.api.data.EdmSimpleType;
-import org.apache.olingo.odata4.client.api.edm.xml.ComplexType;
-import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
-import org.apache.olingo.odata4.client.api.edm.EdmType;
-import org.apache.olingo.odata4.client.api.edm.EdmTypeNotFoundException;
-import org.apache.olingo.odata4.client.api.edm.xml.EntityType;
-import org.apache.olingo.odata4.client.api.edm.xml.EnumType;
-import org.apache.olingo.odata4.client.api.edm.xml.Schema;
-import org.apache.olingo.odata4.client.core.edm.xml.AbstractComplexType;
-import org.apache.olingo.odata4.client.core.edm.xml.AbstractEntityType;
-import org.apache.olingo.odata4.client.core.edm.xml.AbstractEnumType;
-
-/**
- * Parse type information from metadata into semantic data.
- */
-public abstract class AbstractEdmType implements EdmType {
-
- private final String typeExpression;
-
- private final String baseType;
-
- private final String namespaceOrAlias;
-
- private boolean collection;
-
- private EdmSimpleType simpleType;
-
- private EnumType enumType;
-
- private ComplexType complexType;
-
- private EntityType entityType;
-
- /**
- * Constructor.
- *
- * @param typeExpression type expression.
- */
- public AbstractEdmType(final String typeExpression) {
- this(null, typeExpression);
- }
-
- /**
- * Constructor.
- *
- * @param metadata metadata.
- * @param typeExpression type expression.
- */
- public AbstractEdmType(final EdmMetadata metadata, final String typeExpression) {
- this.typeExpression = typeExpression;
-
- final int collectionStartIdx = typeExpression.indexOf("Collection(");
- final int collectionEndIdx = typeExpression.lastIndexOf(')');
- if (collectionStartIdx == -1) {
- baseType = typeExpression;
- } else {
- if (collectionEndIdx == -1) {
- throw new IllegalArgumentException("Malformed type: " + typeExpression);
- }
-
- this.collection = true;
- baseType = typeExpression.substring(collectionStartIdx + 11, collectionEndIdx);
- }
-
- final int lastDotIdx = baseType.lastIndexOf('.');
- if (lastDotIdx == -1) {
- throw new IllegalArgumentException("Cannot find namespace or alias in " + typeExpression);
- }
- namespaceOrAlias = baseType.substring(0, lastDotIdx);
- final String typeName = baseType.substring(lastDotIdx + 1);
- if (StringUtils.isBlank(typeName)) {
- throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
- }
-
- if (namespaceOrAlias.equals(EdmSimpleType.namespace())) {
- this.simpleType = EdmSimpleType.fromValue(EdmSimpleType.namespace() + "." + typeName);
- } else if (metadata != null) {
- if (!metadata.isNsOrAlias(namespaceOrAlias)) {
- throw new IllegalArgumentException("Illegal namespace or alias: " + namespaceOrAlias);
- }
- final Schema schema = metadata.getSchema(namespaceOrAlias);
-
- for (EnumType type : schema.getEnumTypes()) {
- if (typeName.equals(type.getName())) {
- this.enumType = type;
- }
- }
- if (this.enumType == null) {
- for (ComplexType type : schema.getComplexTypes()) {
- if (typeName.equals(type.getName())) {
- this.complexType = type;
- }
- }
- if (this.complexType == null) {
- for (EntityType type : schema.getEntityTypes()) {
- if (typeName.equals(type.getName())) {
- this.entityType = type;
- }
- }
- }
- }
-
- if (!isSimpleType() && !isEnumType() && !isComplexType() && !isEntityType()) {
- throw new IllegalArgumentException("Could not parse type information out of " + typeExpression);
- }
- }
- }
-
- /**
- * Checks if is a collection.
- *
- * @return 'TRUE' if is a collection; 'FALSE' otherwise.
- */
- @Override
- public final boolean isCollection() {
- return this.collection;
- }
-
- /**
- * Checks if is a simple type.
- *
- * @return 'TRUE' if is a simple type; 'FALSE' otherwise.
- */
- @Override
- public final boolean isSimpleType() {
- return this.simpleType != null;
- }
-
- /**
- * Gets type as a simple type.
- *
- * @return simple type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not a simple type.
- */
- @Override
- public final EdmSimpleType getSimpleType() {
- if (!isSimpleType()) {
- throw new EdmTypeNotFoundException(EdmSimpleType.class, this.typeExpression);
- }
-
- return this.simpleType;
- }
-
- /**
- * Checks if is an enum type.
- *
- * @return 'TRUE' if is an enum type; 'FALSE' otherwise.
- */
- @Override
- public final boolean isEnumType() {
- return this.enumType != null;
- }
-
- /**
- * Gets type as enum type.
- *
- * @return enum type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not an enum type.
- */
- @Override
- public EnumType getEnumType() {
- if (!isEnumType()) {
- throw new EdmTypeNotFoundException(AbstractEnumType.class, this.typeExpression);
- }
-
- return this.enumType;
- }
-
- /**
- * Checks if is a complex type.
- *
- * @return 'TRUE' if is a complex type; 'FALSE' otherwise.
- */
- @Override
- public final boolean isComplexType() {
- return this.complexType != null;
- }
-
- /**
- * Gets type as complex type.
- *
- * @return complex type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not a complex type.
- */
- @Override
- public ComplexType getComplexType() {
- if (!isComplexType()) {
- throw new EdmTypeNotFoundException(AbstractComplexType.class, this.typeExpression);
- }
-
- return this.complexType;
- }
-
- /**
- * Checks if is an entity type.
- *
- * @return 'TRUE' if is an entity type; 'FALSE' otherwise.
- */
- @Override
- public final boolean isEntityType() {
- return this.entityType != null;
- }
-
- /**
- * Gets type as entity type.
- *
- * @return entity type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not an entity type.
- */
- @Override
- public EntityType getEntityType() {
- if (!isEntityType()) {
- throw new EdmTypeNotFoundException(AbstractEntityType.class, this.typeExpression);
- }
-
- return this.entityType;
- }
-
- /**
- * Gets base type.
- *
- * @return base type.
- */
- @Override
- public String getBaseType() {
- return baseType;
- }
-
- /**
- * Gets type expression.
- *
- * @return type expression.
- */
- @Override
- public String getTypeExpression() {
- return typeExpression;
- }
-
- /**
- * Gets namespace or alias retrieved from the provided type expression.
- *
- * @return namespace or alias.
- */
- @Override
- public String getNamespaceOrAlias() {
- return namespaceOrAlias;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImpl.java
new file mode 100644
index 0000000..8cf1eed
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImpl.java
@@ -0,0 +1,37 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import org.apache.olingo.odata4.client.api.edm.xml.v4.Action;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
+
+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/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImportImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImportImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImportImpl.java
new file mode 100644
index 0000000..a133578
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmActionImportImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import org.apache.olingo.odata4.client.api.edm.xml.v4.ActionImport;
+import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+
+public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport {
+
+ private final ActionImport actionImport;
+
+ public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
+ final ActionImport actionImport) {
+
+ super(edm, container, name, actionImport);
+ this.actionImport = actionImport;
+ }
+
+ @Override
+ public EdmAction getAction() {
+ return edm.getAction(
+ new EdmTypeInfo(actionImport.getAction(), container.getNamespace()).getFullQualifiedName(), null, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmBindingTargetImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmBindingTargetImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmBindingTargetImpl.java
new file mode 100644
index 0000000..26f70e9
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmBindingTargetImpl.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.odata4.client.core.edm;
+
+import java.util.Iterator;
+import java.util.List;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.BindingTarget;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.NavigationPropertyBinding;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.Target;
+import org.apache.olingo.odata4.commons.core.edm.AbstractEdmBindingTarget;
+
+public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
+
+ private final BindingTarget target;
+
+ 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;
+ }
+
+ @Override
+ public EdmBindingTarget getRelatedBindingTarget(final String path) {
+ EdmBindingTarget bindingTarget = null;
+
+ final List<? extends NavigationPropertyBinding> navigationPropertyBindings = target.getNavigationPropertyBindings();
+ if (navigationPropertyBindings != null) {
+ boolean found = false;
+ for (final Iterator<? extends NavigationPropertyBinding> itor = navigationPropertyBindings.iterator();
+ itor.hasNext() && !found;) {
+
+ final NavigationPropertyBinding binding = itor.next();
+ if (binding.getPath().equals(path)) {
+ final Target edmTarget = new Target.Builder(binding.getTarget(), container).build();
+
+ final EdmEntityContainer entityContainer = edm.getEntityContainer(edmTarget.getEntityContainer());
+ if (entityContainer == null) {
+ throw new EdmException("Cant find entity container with name: " + edmTarget.getEntityContainer());
+ }
+ bindingTarget = entityContainer.getEntitySet(edmTarget.getTargetName());
+ if (bindingTarget == null) {
+ bindingTarget = entityContainer.getSingleton(edmTarget.getTargetName());
+ if (bindingTarget == null) {
+ throw new EdmException("Cant find target with name: " + edmTarget.getTargetName());
+ }
+
+ found = true;
+ } else {
+ found = true;
+ }
+ }
+ }
+ }
+
+ return bindingTarget;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmClientImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmClientImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmClientImpl.java
new file mode 100644
index 0000000..ab15e7d
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmClientImpl.java
@@ -0,0 +1,285 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+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.odata4.client.api.edm.xml.EnumType;
+import org.apache.olingo.odata4.client.api.edm.xml.Schema;
+import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.ComplexType;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityContainer;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityType;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.TypeDefinition;
+import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
+import org.apache.olingo.odata4.client.core.edm.xml.v4.ActionImpl;
+import org.apache.olingo.odata4.client.core.edm.xml.v4.FunctionImpl;
+import org.apache.olingo.odata4.client.core.edm.xml.v4.ParameterImpl;
+import org.apache.olingo.odata4.client.core.edm.xml.v4.SchemaImpl;
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
+import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.odata4.commons.core.edm.AbstractEdmImpl;
+
+public class EdmClientImpl extends AbstractEdmImpl {
+
+ private final XMLMetadata xmlMetadata;
+
+ private final EdmServiceMetadata serviceMetadata;
+
+ public EdmClientImpl(final XMLMetadata xmlMetadata) {
+ this.xmlMetadata = xmlMetadata;
+ this.serviceMetadata = AbstractEdmServiceMetadataImpl.getInstance(xmlMetadata);
+ }
+
+ public XMLMetadata getXMLMetadata() {
+ return xmlMetadata;
+ }
+
+ @Override
+ protected EdmServiceMetadata createServiceMetadata() {
+ return serviceMetadata;
+ }
+
+ @Override
+ protected Map<String, String> createAliasToNamespaceInfo() {
+ final Map<String, String> aliasToNamespace = new HashMap<String, String>();
+
+ for (Schema schema : xmlMetadata.getSchemas()) {
+ aliasToNamespace.put(null, schema.getNamespace());
+ if (StringUtils.isNotBlank(schema.getAlias())) {
+ aliasToNamespace.put(schema.getAlias(), schema.getNamespace());
+ }
+ }
+
+ return aliasToNamespace;
+ }
+
+ @Override
+ protected EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) {
+ EdmEntityContainer result = null;
+
+ final Schema schema = xmlMetadata.getSchema(containerName.getNamespace());
+ if (schema != null) {
+ final EntityContainer xmlEntityContainer = (EntityContainer) schema.getDefaultEntityContainer();
+ if (xmlEntityContainer != null) {
+ result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer);
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ protected EdmEnumType createEnumType(final FullQualifiedName enumName) {
+ EdmEnumType result = null;
+
+ final Schema schema = xmlMetadata.getSchema(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 = xmlMetadata.getSchema(typeDefinitionName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final TypeDefinition xmlTypeDefinition = ((SchemaImpl) 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 = xmlMetadata.getSchema(entityTypeName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final EntityType xmlEntityType = ((SchemaImpl) 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 = xmlMetadata.getSchema(complexTypeName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final ComplexType xmlComplexType = ((SchemaImpl) 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 = xmlMetadata.getSchema(actionName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final List<ActionImpl> actions = ((SchemaImpl) schema).getActions(actionName.getName());
+ boolean found = false;
+ for (Iterator<ActionImpl> itor = actions.iterator(); itor.hasNext() && !found;) {
+ final ActionImpl action = itor.next();
+ if (!action.isBound()) {
+ found = true;
+ result = EdmActionImpl.getInstance(this, actionName, action);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
+ EdmFunction result = null;
+
+ final Schema schema = xmlMetadata.getSchema(functionName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final List<FunctionImpl> functions = ((SchemaImpl) schema).getFunctions(functionName.getName());
+ boolean found = false;
+ for (Iterator<FunctionImpl> itor = functions.iterator(); itor.hasNext() && !found;) {
+ final FunctionImpl function = itor.next();
+ if (!function.isBound()) {
+ final Set<String> functionParamNames = new HashSet<String>();
+ for (ParameterImpl 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 = xmlMetadata.getSchema(actionName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final List<ActionImpl> actions = ((SchemaImpl) schema).getActions(actionName.getName());
+ boolean found = false;
+ for (Iterator<ActionImpl> itor = actions.iterator(); itor.hasNext() && !found;) {
+ final ActionImpl action = itor.next();
+ if (action.isBound()) {
+ final EdmTypeInfo boundParam = new EdmTypeInfo(action.getParameters().get(0).getType());
+ if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+ && 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 = xmlMetadata.getSchema(functionName.getNamespace());
+ if (schema instanceof SchemaImpl) {
+ final List<FunctionImpl> functions = ((SchemaImpl) schema).getFunctions(functionName.getName());
+ boolean found = false;
+ for (Iterator<FunctionImpl> itor = functions.iterator(); itor.hasNext() && !found;) {
+ final FunctionImpl function = itor.next();
+ if (function.isBound()) {
+ final EdmTypeInfo boundParam = new EdmTypeInfo(function.getParameters().get(0).getType());
+ if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+ && isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
+
+ final Set<String> functionParamNames = new HashSet<String>();
+ for (ParameterImpl param : function.getParameters()) {
+ functionParamNames.add(param.getName());
+ }
+ found = parameterNames == null
+ ? functionParamNames.isEmpty()
+ : functionParamNames.containsAll(parameterNames);
+ result = EdmFunctionImpl.getInstance(this, functionName, function);
+ }
+ }
+ }
+ }
+
+ 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/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmComplexTypeImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmComplexTypeImpl.java
new file mode 100644
index 0000000..c036172
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmComplexTypeImpl.java
@@ -0,0 +1,63 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import java.util.Map;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.ComplexType;
+import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.odata4.commons.core.edm.AbstractEdmComplexType;
+import org.apache.olingo.odata4.commons.core.edm.EdmStructuredTypeHelper;
+
+public class EdmComplexTypeImpl extends AbstractEdmComplexType {
+
+ private final EdmStructuredTypeHelper helper;
+
+ public static EdmComplexTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn,
+ final ComplexType complexType) {
+
+ final FullQualifiedName baseTypeName = complexType.getBaseType() == null
+ ? null : new EdmTypeInfo(complexType.getBaseType()).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.helper = new EdmStructuredTypeHelperImpl(edm, complexType);
+ }
+
+ @Override
+ protected Map<String, EdmProperty> getProperties() {
+ return helper.getProperties();
+ }
+
+ @Override
+ protected Map<String, EdmNavigationProperty> getNavigationProperties() {
+ return helper.getNavigationProperties();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntityContainerImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntityContainerImpl.java
new file mode 100644
index 0000000..31269a2
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntityContainerImpl.java
@@ -0,0 +1,87 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import org.apache.olingo.odata4.client.api.edm.xml.v4.ActionImport;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityContainer;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.EntitySet;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.FunctionImport;
+import org.apache.olingo.odata4.client.api.edm.xml.v4.Singleton;
+import org.apache.olingo.odata4.client.api.utils.EdmTypeInfo;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.odata4.commons.core.edm.AbstractEdmEntityContainer;
+
+public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
+
+ private final EntityContainer xmlEntityContainer;
+
+ public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
+ final EntityContainer xmlEntityContainer) {
+
+ super(edm, entityContainerName);
+ this.xmlEntityContainer = xmlEntityContainer;
+ }
+
+ @Override
+ protected EdmSingleton createSingleton(final String singletonName) {
+ final Singleton singleton = xmlEntityContainer.getSingleton(singletonName);
+ if (singleton == null) {
+ throw new EdmException("Singleton named '" + singletonName + "' not found in " + entityContainerName);
+ }
+ return new EdmSingletonImpl(edm, this, singletonName,
+ new EdmTypeInfo(singleton.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ singleton);
+ }
+
+ @Override
+ protected EdmEntitySet createEntitySet(final String entitySetName) {
+ final EntitySet entitySet = (EntitySet) xmlEntityContainer.getEntitySet(entitySetName);
+ if (entitySet == null) {
+ throw new EdmException("EntitySet named '" + entitySetName + "' not found in " + entityContainerName);
+ }
+ return new EdmEntitySetImpl(edm, this, entitySetName,
+ new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ entitySet);
+ }
+
+ @Override
+ protected EdmActionImport createActionImport(final String actionImportName) {
+ final ActionImport actionImport = xmlEntityContainer.getActionImport(actionImportName);
+ if (actionImport == null) {
+ throw new EdmException("ActionImport named '" + actionImportName + "' not found in " + entityContainerName);
+ }
+ return new EdmActionImportImpl(edm, this, actionImportName, actionImport);
+ }
+
+ @Override
+ protected EdmFunctionImport createFunctionImport(final String functionImportName) {
+ final FunctionImport functionImport = (FunctionImport) xmlEntityContainer.getFunctionImport(functionImportName);
+ if (functionImport == null) {
+ throw new EdmException("FunctionImport named '" + functionImportName + "' not found in " + entityContainerName);
+ }
+ return new EdmFunctionImportImpl(edm, this, functionImportName, functionImport);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntitySetImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntitySetImpl.java
new file mode 100644
index 0000000..669e431
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/EdmEntitySetImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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.odata4.client.core.edm;
+
+import org.apache.olingo.odata4.client.api.edm.xml.v4.EntitySet;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
+
+public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
+
+ public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final String name,
+ final FullQualifiedName type, final EntitySet entitySet) {
+
+ super(edm, container, name, type, entitySet);
+ }
+
+}