diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/constants/EdmConcurrencyMode.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/constants/EdmConcurrencyMode.java deleted file mode 100644 index 1e93686f4..000000000 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/constants/EdmConcurrencyMode.java +++ /dev/null @@ -1,29 +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.commons.api.edm.constants; - -/** - * EdmConcurrencyMode can be applied to any primitive Entity Data Model (EDM) type. - *

Possible values are "None", which is the default, and "Fixed". - * Fixed implies that the property should be used for optimistic concurrency checks. - */ -public enum EdmConcurrencyMode { - - None, Fixed; -} \ No newline at end of file diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/constants/ODataServiceVersion.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/constants/ODataServiceVersion.java new file mode 100644 index 000000000..4b73eefd0 --- /dev/null +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/constants/ODataServiceVersion.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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.commons.api.edm.constants; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * This class is a container for the supported ODataServiceVersions. + * + * + */ +public class ODataServiceVersion { + + private static final Pattern DATASERVICEVERSIONPATTERN = Pattern.compile("(\\p{Digit}+\\.\\p{Digit}+)(:?;.*)?"); + + /** + * ODataServiceVersion 1.0 + */ + public static final String V10 = "1.0"; + /** + * ODataServiceVersion 2.0 + */ + public static final String V20 = "2.0"; + /** + * ODataServiceVersion 3.0 + */ + public static final String V30 = "3.0"; + /** + * ODataServiceVersion 4.0 + */ + public static final String V40 = "4.0"; + + /** + * Validates format and range of a data service version string. + * @param version version string + * @return true for a valid version + */ + public static boolean validateDataServiceVersion(final String version) { + final Matcher matcher = DATASERVICEVERSIONPATTERN.matcher(version); + if (matcher.matches()) { + final String possibleDataServiceVersion = matcher.group(1); + return V10.equals(possibleDataServiceVersion) + || V20.equals(possibleDataServiceVersion) + || V30.equals(possibleDataServiceVersion) + || V40.equals(possibleDataServiceVersion); + } else { + throw new IllegalArgumentException(version); + } + } + + /** + * actual > comparedTo + * @param actual + * @param comparedTo + * @return true if actual is bigger than comparedTo + */ + public static boolean isBiggerThan(final String actual, final String comparedTo) { + if (!validateDataServiceVersion(comparedTo) || !validateDataServiceVersion(actual)) { + throw new IllegalArgumentException("Illegal arguments: " + comparedTo + " and " + actual); + } + + final double me = Double.parseDouble(extractDataServiceVersionString(actual)); + final double other = Double.parseDouble(extractDataServiceVersionString(comparedTo)); + + return me > other; + } + + private static String extractDataServiceVersionString(final String rawDataServiceVersion) { + if (rawDataServiceVersion != null) { + final String[] pattern = rawDataServiceVersion.split(";"); + return pattern[0]; + } + + return null; + } + +} diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Action.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Action.java index 8ab99ae3c..b074d24e3 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Action.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Action.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import java.util.List; -//TODO: Finish public class Action extends Operation { @Override public Action setName(final String name) { diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ActionImport.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ActionImport.java index 20e27727a..bcb4e4923 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ActionImport.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ActionImport.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class ActionImport extends OperationImport { private FullQualifiedName action; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Annotation.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Annotation.java index 3440a176e..50eb7aaed 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Annotation.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Annotation.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO:finish public class Annotation { private FullQualifiedName term; // Target should be a target path diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProvider.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProvider.java index 1f0bca71c..34d56ed12 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProvider.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProvider.java @@ -25,7 +25,7 @@ import org.apache.olingo.odata4.commons.api.edm.helper.EntityContainerInfo; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; import org.apache.olingo.odata4.commons.api.exception.ODataException; -public interface EdmProvider { +public abstract class EdmProvider { /** * This method should return an {@link EnumType} or null if nothing is found @@ -33,7 +33,9 @@ public interface EdmProvider { * @return {@link EnumType} for given name * @throws ODataException */ - public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException; + public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { + return null; + }; /** * This method should return an {@link TypeDefinition} or null if nothing is found @@ -41,7 +43,9 @@ public interface EdmProvider { * @return {@link TypeDefinition} for given name * @throws ODataException */ - public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException; + public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException { + return null; + }; /** * This method should return an {@link EntityType} or null if nothing is found @@ -49,7 +53,9 @@ public interface EdmProvider { * @return {@link EntityType} for the given name * @throws ODataException */ - public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException; + public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { + return null; + }; /** * This method should return a {@link ComplexType} or null if nothing is found @@ -57,7 +63,9 @@ public interface EdmProvider { * @return {@link StructuralType} for the given name * @throws ODataException */ - public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException; + public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { + return null; + }; /** * This method should return a list of all {@link Action} for the FullQualifiedname or null if nothing is found @@ -65,7 +73,9 @@ public interface EdmProvider { * @return List of {@link Action} or null * @throws ODataException */ - public List getActions(final FullQualifiedName actionName) throws ODataException; + public List getActions(final FullQualifiedName actionName) throws ODataException { + return null; + }; /** * This method should return a list of all {@link Function} for the FullQualifiedname or null if nothing is @@ -74,10 +84,14 @@ public interface EdmProvider { * @return List of {@link Function} or null * @throws ODataException */ - public List getFunctions(final FullQualifiedName functionName) throws ODataException; + public List getFunctions(final FullQualifiedName functionName) throws ODataException { + return null; + }; // TODO: document - public Term getTerm(final FullQualifiedName termName) throws ODataException; + public Term getTerm(final FullQualifiedName termName) throws ODataException { + return null; + }; /** * This method should return an {@link EntitySet} or null if nothing is found @@ -87,7 +101,9 @@ public interface EdmProvider { * @throws ODataException */ public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName) - throws ODataException; + throws ODataException { + return null; + }; /** * This method should return an {@link Singleton} or null if nothing is found @@ -97,7 +113,9 @@ public interface EdmProvider { * @throws ODataException */ public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName) - throws ODataException; + throws ODataException { + return null; + }; /** * This method should return an {@link ActionImport} or null if nothing is found @@ -107,7 +125,9 @@ public interface EdmProvider { * @throws ODataException */ public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName) - throws ODataException; + throws ODataException { + return null; + }; /** * This method should return a {@link FunctionImport} or null if nothing is found @@ -117,7 +137,9 @@ public interface EdmProvider { * @throws ODataException */ public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName) - throws ODataException; + throws ODataException { + return null; + }; /** * This method should return an {@link EntityContainerInfo} or null if nothing is found @@ -125,19 +147,25 @@ public interface EdmProvider { * @return {@link EntityContainerInfo} for the given name * @throws ODataException */ - public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException; + public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException { + return null; + }; /** * This method should return a list of all namespaces which have an alias * @return List of alias info * @throws ODataException */ - public List getAliasInfos() throws ODataException; + public List getAliasInfos() throws ODataException { + return null; + }; /** * This method should return a collection of all {@link Schema} * @return List<{@link Schema}> * @throws ODataException */ - public List getSchemas() throws ODataException; + public List getSchemas() throws ODataException { + return null; + }; } diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProviderAdapter.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProviderAdapter.java deleted file mode 100644 index 8633ee270..000000000 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EdmProviderAdapter.java +++ /dev/null @@ -1,106 +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.commons.api.edm.provider; - -import java.util.List; - -import org.apache.olingo.odata4.commons.api.edm.helper.AliasInfo; -import org.apache.olingo.odata4.commons.api.edm.helper.EntityContainerInfo; -import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -import org.apache.olingo.odata4.commons.api.exception.ODataException; - -//TODO: Finish -/** - * Default EDM Provider which is to be extended by the application - */ -public abstract class EdmProviderAdapter implements EdmProvider { - - @Override - public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { - return null; - } - - @Override - public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException { - return null; - } - - @Override - public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { - return null; - } - - @Override - public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { - return null; - } - - @Override - public List getActions(final FullQualifiedName actionName) throws ODataException { - return null; - } - - @Override - public List getFunctions(final FullQualifiedName functionName) throws ODataException { - return null; - } - - @Override - public Term getTerm(final FullQualifiedName termName) throws ODataException { - return null; - } - - @Override - public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException { - return null; - } - - @Override - public Singleton getSingleton(final FullQualifiedName entityContainer, final String name) throws ODataException { - return null; - } - - @Override - public ActionImport getActionImport(final FullQualifiedName entityContainer, final String name) throws ODataException - { - return null; - } - - @Override - public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String name) - throws ODataException { - return null; - } - - // There are no other containers - @Override - public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException { - return null; - } - - @Override - public List getAliasInfos() throws ODataException { - return null; - } - - @Override - public List getSchemas() throws ODataException { - return null; - } -} diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityContainer.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityContainer.java index 4d43c94cd..1b24e10a7 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityContainer.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityContainer.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: finish public class EntityContainer { private String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySet.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySet.java index 435ed8af7..848d5649d 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySet.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySet.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class EntitySet extends BindingTarget { private boolean includeInServiceDocument; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySetPath.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySetPath.java index eaaae9b39..e2d48f026 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySetPath.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntitySetPath.java @@ -18,8 +18,7 @@ ******************************************************************************/ package org.apache.olingo.odata4.commons.api.edm.provider; -//TODO: finish -//DO we really need this class? +//TODO: Do we really need this class? public class EntitySetPath { private String bindingParameter; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityType.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityType.java index c5ff3d919..c04372db4 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityType.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EntityType.java @@ -22,9 +22,8 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class EntityType extends StructuralType { - // Anything except which have to be new? + private List key; private boolean hasStream; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumMember.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumMember.java index 6450793db..a25684446 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumMember.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumMember.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.commons.api.edm.provider; -//TODO: Finish public class EnumMember { private String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumType.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumType.java index 38e5bd3cc..0411101a9 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumType.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/EnumType.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class EnumType { private String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Function.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Function.java index d2539d9dc..489452429 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Function.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Function.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import java.util.List; -//TODO: Finish public class Function extends Operation { private boolean isComposable; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/FunctionImport.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/FunctionImport.java index 098e678aa..cec3ccd56 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/FunctionImport.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/FunctionImport.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class FunctionImport extends OperationImport { private FullQualifiedName function; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationProperty.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationProperty.java index 22b26ad21..e16ae3b67 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationProperty.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationProperty.java @@ -23,14 +23,12 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.constants.EdmOnDelete; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: finish public class NavigationProperty { private String name; private FullQualifiedName type; private boolean isCollection; - // Should we make the partner a path class? private String partner; private boolean containsTarget; private List referentialConstraints; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationPropertyBinding.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationPropertyBinding.java index 15517f98f..a4950077a 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationPropertyBinding.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/NavigationPropertyBinding.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.commons.api.edm.provider; -//TODO: finish public class NavigationPropertyBinding { private String path; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Operation.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Operation.java index db0f120fe..18c64fb2d 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Operation.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Operation.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import java.util.List; -//TODO: finish public abstract class Operation { protected String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/OperationImport.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/OperationImport.java index 02433eccc..47827e3a5 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/OperationImport.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/OperationImport.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.commons.api.edm.provider; -//TODO: finish public abstract class OperationImport { protected String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Parameter.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Parameter.java index 8d7a6c07c..6b34d7f7b 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Parameter.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Parameter.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: finish public class Parameter { private String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Property.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Property.java index 3936e4c1b..f5d91aba6 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Property.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Property.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class Property { private String name; @@ -28,7 +27,7 @@ public class Property { private FullQualifiedName type; private boolean collection; - // Mimetype and mapping what here + //TODO: Mimetype and mapping what here private String mimeType; private Mapping mapping; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReferentialConstraint.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReferentialConstraint.java index c9828b8ea..600b10486 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReferentialConstraint.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReferentialConstraint.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.commons.api.edm.provider; -//TODO: finish public class ReferentialConstraint { // TODO: check data type diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReturnType.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReturnType.java index 00130f5cc..a81e08d4d 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReturnType.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/ReturnType.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODDO: finish public class ReturnType { private FullQualifiedName type; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Schema.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Schema.java index 087512d9e..981db62b2 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Schema.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Schema.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import java.util.List; -//TODO: Finish public class Schema { private String namespace; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Singleton.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Singleton.java index ab5a06fde..d17b80151 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Singleton.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Singleton.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class Singleton extends BindingTarget { @Override diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/StructuralType.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/StructuralType.java index ec7a52a1b..100006b64 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/StructuralType.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/StructuralType.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public abstract class StructuralType { protected String name; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Target.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Target.java index 9cdce1a75..aa45f0362 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Target.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Target.java @@ -22,7 +22,6 @@ import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; public class Target { - // What is the name here? private String targetName; private FullQualifiedName entityContainer; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Term.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Term.java index 991a6330c..aeb638c70 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Term.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/Term.java @@ -22,12 +22,11 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class Term { private String name; private FullQualifiedName type; private FullQualifiedName baseTerm; - // AppliesTo is a list of csdl elements => should we put this list inside an enum? + //TODO: AppliesTo is a list of csdl elements => should we put this list inside an enum? private String appliesTo; private boolean isCollection; diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/TypeDefinition.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/TypeDefinition.java index 7eb978a97..e1fe0121a 100644 --- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/TypeDefinition.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/provider/TypeDefinition.java @@ -20,11 +20,10 @@ package org.apache.olingo.odata4.commons.api.edm.provider; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; -//TODO: Finish public class TypeDefinition { private String name; - // UnderlyingType can only be primitve... + // TODO: UnderlyingType can only be primitve... private FullQualifiedName underlyingType; // Facets diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java index 24248b71e..9c28775cd 100644 --- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java +++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java @@ -37,6 +37,7 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit private final List keyPredicateNames = new ArrayList(); private final HashMap keyPropertyRefs = new HashMap(); private final EdmEntityType entityBaseType; + private ArrayList keyPropertyRefsList; public EdmEntityTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name, final EntityType entityType) { super(edm, name, entityType, EdmTypeKind.ENTITY); @@ -86,8 +87,10 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit if (baseType != null) { return entityBaseType.getKeyPropertyRefs(); } else { - // TODO: Cache - return new ArrayList(keyPropertyRefs.values()); + if(keyPropertyRefsList == null){ + keyPropertyRefsList = new ArrayList(keyPropertyRefs.values()); + } + return keyPropertyRefsList; } } @@ -106,7 +109,7 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit if (baseTypeName != null) { baseType = edm.getEntityType(baseTypeName); if (baseType == null) { - throw new EdmException("Cant find base type with name: " + baseTypeName + " for entity type: " + getName()); + throw new EdmException("Cannot find base type with name: " + baseTypeName + " for entity type: " + getName()); } } return baseType; diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmFunctionImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmFunctionImpl.java index 6f610b71d..df4dbfee0 100644 --- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmFunctionImpl.java +++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmFunctionImpl.java @@ -18,7 +18,9 @@ ******************************************************************************/ package org.apache.olingo.odata4.commons.core.edm.provider; +import org.apache.olingo.odata4.commons.api.edm.EdmException; import org.apache.olingo.odata4.commons.api.edm.EdmFunction; +import org.apache.olingo.odata4.commons.api.edm.EdmReturnType; import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; import org.apache.olingo.odata4.commons.api.edm.provider.Function; @@ -37,4 +39,13 @@ public class EdmFunctionImpl extends EdmOperationImpl implements EdmFunction { return function.isComposable(); } + @Override + public EdmReturnType getReturnType() { + EdmReturnType returnType = super.getReturnType(); + if (returnType == null) { + throw new EdmException("ReturnType for a function must not be null"); + } + return returnType; + } + } diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmOperationImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmOperationImpl.java index d1b49eda9..2c8cc2643 100644 --- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmOperationImpl.java +++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmOperationImpl.java @@ -23,12 +23,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.olingo.odata4.commons.api.edm.EdmBindingTarget; 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.EdmOperation; import org.apache.olingo.odata4.commons.api.edm.EdmParameter; import org.apache.olingo.odata4.commons.api.edm.EdmReturnType; import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; +import org.apache.olingo.odata4.commons.api.edm.provider.EntitySetPath; import org.apache.olingo.odata4.commons.api.edm.provider.Operation; import org.apache.olingo.odata4.commons.api.edm.provider.Parameter; @@ -72,13 +75,31 @@ public class EdmOperationImpl extends EdmTypeImpl implements EdmOperation { @Override public EdmEntitySet getReturnedEntitySet(final EdmEntitySet bindingParameterEntitySet, final String path) { - // TODO: What here? - return null; + EntitySetPath entitySetPath = operation.getEntitySetPath(); + EdmEntitySet returnedEntitySet = null; + if (bindingParameterEntitySet != null && entitySetPath != null && entitySetPath.getBindingParameter() != null + && entitySetPath.getPath() != null) { + String finalPath = ""; + if (path != null) { + finalPath = path + "/" + entitySetPath.getPath(); + } else { + finalPath = entitySetPath.getPath(); + } + + EdmBindingTarget relatedBindingTarget = bindingParameterEntitySet.getRelatedBindingTarget(finalPath); + 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) { + if (returnType == null && operation.getReturnType() != null) { returnType = new EdmReturnTypeImpl(edm, operation.getReturnType()); } return returnType; diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java index 5a0281ff7..8baabf4f6 100644 --- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java +++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java @@ -52,7 +52,7 @@ public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty { if (kind != null) { propertyType = kind.getEdmPrimitiveTypeInstance(); } else { - throw new EdmException("Can�t find type with name: " + typeName); + throw new EdmException("Cannot find type with name: " + typeName); } } else { propertyType = edm.getComplexType(typeName); @@ -61,7 +61,7 @@ public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty { if (propertyType == null) { propertyType = edm.getTypeDefinition(typeName); if (propertyType == null) { - throw new EdmException("Can�t find type with name: " + typeName); + throw new EdmException("Cannot find type with name: " + typeName); } } } diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java index 13934cf7c..454d824a4 100644 --- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java +++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.util.List; import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata; +import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.odata4.commons.api.edm.helper.EdmEntitySetInfo; import org.apache.olingo.odata4.commons.api.edm.helper.EdmFunctionImportInfo; import org.apache.olingo.odata4.commons.api.edm.helper.EdmSingletonInfo; @@ -38,8 +39,7 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata { @Override public String getDataServiceVersion() { - // TODO: make constant - return "4.0"; + return ODataServiceVersion.V40; } @Override diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java index 0d1fd8821..05bb007ac 100644 --- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java +++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java @@ -50,8 +50,6 @@ public class EdmImplCachingTest { private final FullQualifiedName NAME2 = new FullQualifiedName("testNamespace2", "testName2"); private Edm edm; - // TODO: Test with alias - @Test public void cacheEntityContainer() { EdmEntityContainer entityContainer = edm.getEntityContainer(null); diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java index 479c87d01..663107838 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java @@ -26,7 +26,7 @@ import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName; import org.apache.olingo.odata4.commons.api.edm.provider.Action; import org.apache.olingo.odata4.commons.api.edm.provider.ActionImport; import org.apache.olingo.odata4.commons.api.edm.provider.ComplexType; -import org.apache.olingo.odata4.commons.api.edm.provider.EdmProviderAdapter; +import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider; import org.apache.olingo.odata4.commons.api.edm.provider.EntitySet; import org.apache.olingo.odata4.commons.api.edm.provider.EntityType; import org.apache.olingo.odata4.commons.api.edm.provider.EnumMember; @@ -43,7 +43,7 @@ import org.apache.olingo.odata4.commons.api.edm.provider.Singleton; import org.apache.olingo.odata4.commons.api.exception.ODataException; import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -public class EdmTechProvider extends EdmProviderAdapter { +public class EdmTechProvider extends EdmProvider { public static final String nameSpace = "com.sap.odata.test1";