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/10 10:49:57 UTC
[5/6] Merge from master
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/ConcurrencyMode.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/edm/ConcurrencyMode.java
index 0000000,0000000..90a8f7b
new file mode 100644
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/ConcurrencyMode.java
@@@ -1,0 -1,0 +1,26 @@@
++/*
++ * 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;
++
++public enum ConcurrencyMode {
++
++ None,
++ Fixed
++
++}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/StoreGeneratedPattern.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/edm/StoreGeneratedPattern.java
index 0000000,0000000..c081bdf
new file mode 100644
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/StoreGeneratedPattern.java
@@@ -1,0 -1,0 +1,27 @@@
++/*
++ * 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;
++
++public enum StoreGeneratedPattern {
++
++ None,
++ Identity,
++ Computed
++
++}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java
index 0000000,28688ab..b11de10
mode 000000,100644..100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java
@@@ -1,0 -1,49 +1,39 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.api.edm.xml;
+
-import org.apache.olingo.commons.api.edm.constants.ConcurrencyMode;
-import org.apache.olingo.commons.api.edm.constants.StoreGeneratedPattern;
-
+ public interface CommonProperty extends Named {
+
+ String getType();
+
+ boolean isNullable();
+
+ String getDefaultValue();
+
+ Integer getMaxLength();
+
- boolean isFixedLength();
-
+ Integer getPrecision();
+
+ Integer getScale();
+
+ boolean isUnicode();
+
- String getCollation();
-
+ String getSrid();
+
- ConcurrencyMode getConcurrencyMode();
-
- StoreGeneratedPattern getStoreGeneratedPattern();
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Property.java
----------------------------------------------------------------------
diff --cc lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Property.java
index 0000000,c254f9a..6536a21
mode 000000,100644..100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Property.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Property.java
@@@ -1,0 -1,38 +1,48 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.api.edm.xml.v3;
+
+ import org.apache.olingo.client.api.edm.xml.CommonProperty;
+ import org.apache.olingo.commons.api.edm.constants.EdmContentKind;
++import org.apache.olingo.odata4.client.api.edm.ConcurrencyMode;
++import org.apache.olingo.odata4.client.api.edm.StoreGeneratedPattern;
+
+ public interface Property extends CommonProperty {
+
++ String getCollation();
++
++ boolean isFixedLength();
++
++ ConcurrencyMode getConcurrencyMode();
++
++ StoreGeneratedPattern getStoreGeneratedPattern();
++
+ String getFcSourcePath();
+
+ String getFcTargetPath();
+
+ EdmContentKind getFcContentKind();
+
+ String getFcNSPrefix();
+
+ String getFcNSURI();
+
+ boolean isFcKeepInContent();
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java
index 0000000,ad1fb68..3827418
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java
@@@ -1,0 -1,45 +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.client.core.edm;
+
+ import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
++import org.apache.olingo.client.core.edm.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmAction;
+ import org.apache.olingo.commons.api.edm.EdmActionImport;
+ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+
+ 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.getEntitySet());
+ this.actionImport = actionImport;
+ }
+
+ @Override
+ public EdmAction getAction() {
- return edm.getAction(
- new EdmTypeInfo(actionImport.getAction(), container.getNamespace()).getFullQualifiedName(), null, null);
++ return edm.getAction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(actionImport.getAction()).
++ setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(), null, null);
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
index 0000000,332e673..bcc89dc
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
@@@ -1,0 -1,371 +1,374 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import java.util.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.client.api.UnsupportedInV3Exception;
+ import org.apache.olingo.client.api.edm.xml.CommonParameter;
+ import org.apache.olingo.client.api.edm.xml.ComplexType;
+ import org.apache.olingo.client.api.edm.xml.EntityContainer;
+ import org.apache.olingo.client.api.edm.xml.EntityType;
+ import org.apache.olingo.client.api.edm.xml.EnumType;
+ import org.apache.olingo.client.api.edm.xml.Schema;
+ import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+ import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
+ import org.apache.olingo.client.api.edm.xml.v4.Action;
+ import org.apache.olingo.client.api.edm.xml.v4.Function;
+ import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.client.core.edm.v3.EdmActionProxy;
+ import org.apache.olingo.client.core.edm.v3.EdmFunctionProxy;
+ import org.apache.olingo.client.core.edm.v3.V3FunctionImportUtils;
+ import org.apache.olingo.commons.api.edm.EdmAction;
+ import org.apache.olingo.commons.api.edm.EdmComplexType;
+ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+ import org.apache.olingo.commons.api.edm.EdmEntityType;
+ import org.apache.olingo.commons.api.edm.EdmEnumType;
+ import org.apache.olingo.commons.api.edm.EdmFunction;
+ import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+ import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.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 = schema.getDefaultEntityContainer();
+ if (xmlEntityContainer != null) {
+ result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer, xmlMetadata);
+ }
+ }
+
+ 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 org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ final TypeDefinition xmlTypeDefinition = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
+ getTypeDefinition(typeDefinitionName.getName());
+ if (xmlTypeDefinition != null) {
+ result = new EdmTypeDefinitionImpl(this, typeDefinitionName, xmlTypeDefinition);
+ }
+ } else {
+ throw new UnsupportedInV3Exception();
+ }
+
+ return result;
+ }
+
+ @Override
+ protected EdmEntityType createEntityType(final FullQualifiedName entityTypeName) {
+ EdmEntityType result = null;
+
+ final Schema schema = xmlMetadata.getSchema(entityTypeName.getNamespace());
+ final EntityType xmlEntityType = schema.getEntityType(entityTypeName.getName());
+ if (xmlEntityType != null) {
+ result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlEntityType);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected EdmComplexType createComplexType(final FullQualifiedName complexTypeName) {
+ EdmComplexType result = null;
+
+ final Schema schema = xmlMetadata.getSchema(complexTypeName.getNamespace());
+ final ComplexType xmlComplexType = schema.getComplexType(complexTypeName.getName());
+ if (xmlComplexType != null) {
+ result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlComplexType);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected EdmAction createUnboundAction(final FullQualifiedName actionName) {
+ EdmAction result = null;
+
+ final Schema schema = xmlMetadata.getSchema(actionName.getNamespace());
+ if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ final List<Action> actions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
+ getActions(actionName.getName());
+ boolean found = false;
+ for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
+ final Action action = itor.next();
+ if (!action.isBound()) {
+ found = true;
+ result = EdmActionImpl.getInstance(this, actionName, action);
+ }
+ }
+ } else {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ @SuppressWarnings("unchecked")
+ final List<FunctionImport> functionImports = (List<FunctionImport>) entityContainer.
+ getFunctionImports(actionName.getName());
+ boolean found = false;
+ for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext() && !found;) {
+ final FunctionImport functionImport = itor.next();
+ if (!V3FunctionImportUtils.canProxyFunction(functionImport) && !functionImport.isBindable()) {
+ found = functionImport.getParameters().isEmpty();
+ result = EdmActionProxy.getInstance(this, actionName, functionImport);
+ }
+ }
+ }
+ }
+
+ 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 org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
+ getFunctions(functionName.getName());
+ boolean found = false;
+ for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
+ final Function function = itor.next();
+ if (!function.isBound()) {
+ final Set<String> functionParamNames = new HashSet<String>();
+ for (CommonParameter param : function.getParameters()) {
+ functionParamNames.add(param.getName());
+ }
+ found = parameterNames == null
+ ? functionParamNames.isEmpty()
+ : functionParamNames.containsAll(parameterNames);
+ result = EdmFunctionImpl.getInstance(this, functionName, function);
+ }
+ }
+ } else {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ @SuppressWarnings("unchecked")
+ final List<FunctionImport> functionImports = (List<FunctionImport>) entityContainer.
+ getFunctionImports(functionName.getName());
+ boolean found = false;
+ for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext() && !found;) {
+ final FunctionImport functionImport = itor.next();
+ if (V3FunctionImportUtils.canProxyFunction(functionImport) && !functionImport.isBindable()) {
+ final Set<String> functionParamNames = new HashSet<String>();
+ for (CommonParameter param : functionImport.getParameters()) {
+ functionParamNames.add(param.getName());
+ }
+ found = parameterNames == null
+ ? functionParamNames.isEmpty()
+ : functionParamNames.containsAll(parameterNames);
+ result = EdmFunctionProxy.getInstance(this, functionName, functionImport);
+ }
+ }
+ }
+ }
+
+ 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 org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ final List<Action> actions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
+ getActions(actionName.getName());
+ boolean found = false;
+ for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
+ final Action action = itor.next();
+ if (action.isBound()) {
- final EdmTypeInfo boundParam = new EdmTypeInfo(action.getParameters().get(0).getType());
++ final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
++ setTypeExpression(action.getParameters().get(0).getType()).build();
+ if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+ && isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
+
+ found = true;
+ result = EdmActionImpl.getInstance(this, actionName, action);
+ }
+ }
+ }
+ } else {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ @SuppressWarnings("unchecked")
+ final List<FunctionImport> functionImports = (List<FunctionImport>) entityContainer.
+ getFunctionImports(actionName.getName());
+ boolean found = false;
+ for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext() && !found;) {
+ final FunctionImport functionImport = itor.next();
+ if (!V3FunctionImportUtils.canProxyFunction(functionImport) && functionImport.isBindable()) {
- final EdmTypeInfo boundParam = new EdmTypeInfo(functionImport.getParameters().get(0).getType());
++ final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
++ setTypeExpression(functionImport.getParameters().get(0).getType()).build();
+ if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+ && isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
+
+ found = true;
+ result = EdmActionProxy.getInstance(this, actionName, functionImport);
+ }
+ }
+ }
+ }
+ }
+
+ 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 org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).
+ getFunctions(functionName.getName());
+ boolean found = false;
+ for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
+ final Function function = itor.next();
+ if (function.isBound()) {
- final EdmTypeInfo boundParam = new EdmTypeInfo(function.getParameters().get(0).getType());
++ final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
++ setTypeExpression(function.getParameters().get(0).getType()).build();
+ if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+ && isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
+
+ final Set<String> functionParamNames = new HashSet<String>();
+ for (CommonParameter param : function.getParameters()) {
+ functionParamNames.add(param.getName());
+ }
+ found = parameterNames == null
+ ? functionParamNames.isEmpty()
+ : functionParamNames.containsAll(parameterNames);
+ result = EdmFunctionImpl.getInstance(this, functionName, function);
+ }
+ }
+ }
+ } else {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ @SuppressWarnings("unchecked")
+ final List<FunctionImport> functionImports = (List<FunctionImport>) entityContainer.
+ getFunctionImports(functionName.getName());
+ boolean found = false;
+ for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext() && !found;) {
+ final FunctionImport functionImport = itor.next();
+ if (!V3FunctionImportUtils.canProxyFunction(functionImport) && functionImport.isBindable()) {
- final EdmTypeInfo boundParam = new EdmTypeInfo(functionImport.getParameters().get(0).getType());
++ final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
++ setTypeExpression(functionImport.getParameters().get(0).getType()).build();
+ if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+ && isBindingParameterCollection.booleanValue() == boundParam.isCollection()) {
+
+ final Set<String> functionParamNames = new HashSet<String>();
+ for (CommonParameter param : functionImport.getParameters()) {
+ functionParamNames.add(param.getName());
+ }
+ found = parameterNames == null
+ ? functionParamNames.isEmpty()
+ : functionParamNames.containsAll(parameterNames);
+ result = EdmFunctionProxy.getInstance(this, functionName, functionImport);
+ }
+ }
+ }
+ }
+ }
+
+ 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/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
index 0000000,7f126f9..43f5357
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
@@@ -1,0 -1,68 +1,66 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import java.util.Map;
-
+ import org.apache.olingo.client.api.edm.xml.ComplexType;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+ import org.apache.olingo.commons.api.edm.EdmProperty;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmComplexType;
+ import org.apache.olingo.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) {
+
+ FullQualifiedName baseTypeName = null;
+ if (complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType) {
+ final String baseType = ((org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType).getBaseType();
+ baseTypeName = baseType == null
- ? null : new EdmTypeInfo(baseType).getFullQualifiedName();
++ ? null : new EdmTypeInfo.Builder().setTypeExpression(baseType).build().getFullQualifiedName();
+ }
+ final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, fqn, baseTypeName, complexType);
+ instance.baseType = instance.buildBaseType(baseTypeName);
+
+ return instance;
+ }
+
+ private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
+ final ComplexType complexType) {
+
+ super(edm, fqn, baseTypeName);
+ this.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/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
index 0000000,fdbbed2..871bfb2
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
@@@ -1,0 -1,125 +1,123 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import org.apache.olingo.client.api.UnsupportedInV3Exception;
+ import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
+ import org.apache.olingo.client.api.edm.xml.EntityContainer;
+ import org.apache.olingo.client.api.edm.xml.EntitySet;
+ import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+ import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
+ import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
+ import org.apache.olingo.client.api.edm.xml.v4.Singleton;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.client.core.edm.v3.EdmActionImportProxy;
+ import org.apache.olingo.client.core.edm.v3.EdmEntitySetProxy;
+ import org.apache.olingo.client.core.edm.v3.EdmFunctionImportProxy;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmActionImport;
+ import org.apache.olingo.commons.api.edm.EdmEntitySet;
+ import org.apache.olingo.commons.api.edm.EdmException;
+ import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+ import org.apache.olingo.commons.api.edm.EdmSingleton;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmEntityContainer;
+
+ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
+
+ private final EntityContainer xmlEntityContainer;
+
+ private final XMLMetadata xmlMetadata;
+
+ public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
+ final EntityContainer xmlEntityContainer, final XMLMetadata xmlMetadata) {
+
+ super(edm, entityContainerName);
+
+ this.xmlEntityContainer = xmlEntityContainer;
+ this.xmlMetadata = xmlMetadata;
+ }
+
+ @Override
+ protected EdmSingleton createSingleton(final String singletonName) {
+ if (!(xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer)) {
+ throw new UnsupportedInV3Exception();
+ }
+
+ final Singleton singleton = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) 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);
++ return new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder().
++ setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()).
++ build().getFullQualifiedName(), singleton);
+ }
+
+ @Override
+ protected EdmEntitySet createEntitySet(final String entitySetName) {
+ final EntitySet entitySet = xmlEntityContainer.getEntitySet(entitySetName);
+ if (entitySet == null) {
+ throw new EdmException("EntitySet named '" + entitySetName + "' not found in " + entityContainerName);
+ }
+
++ final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()).
++ setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
+ if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) {
- return new EdmEntitySetImpl(edm, this, entitySetName,
- new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
++ return new EdmEntitySetImpl(edm, this, entitySetName, entityType,
+ (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
+ } else {
- return new EdmEntitySetProxy(edm, this, entitySetName,
- new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
- xmlMetadata);
++ return new EdmEntitySetProxy(edm, this, entitySetName, entityType, xmlMetadata);
+ }
+ }
+
+ @Override
+ protected EdmActionImport createActionImport(final String actionImportName) {
+ if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) {
- final ActionImport actionImport
- = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
++ final ActionImport actionImport =
++ ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
+ getActionImport(actionImportName);
+ if (actionImport == null) {
+ throw new EdmException("ActionImport named '" + actionImportName + "' not found in " + entityContainerName);
+ }
+ return new EdmActionImportImpl(edm, this, actionImportName, actionImport);
+ } else {
+ final FunctionImport functionImport = (FunctionImport) xmlEntityContainer.getFunctionImport(actionImportName);
+ if (functionImport == null) {
+ throw new EdmException("FunctionImport named '" + actionImportName + "' not found in " + entityContainerName);
+ }
+ return new EdmActionImportProxy(edm, this, actionImportName, functionImport);
+ }
+ }
+
+ @Override
+ protected EdmFunctionImport createFunctionImport(final String functionImportName) {
+ final CommonFunctionImport functionImport = xmlEntityContainer.getFunctionImport(functionImportName);
+ if (functionImport == null) {
+ throw new EdmException("FunctionImport named '" + functionImportName + "' not found in " + entityContainerName);
+ }
+
+ if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) {
+ return new EdmFunctionImportImpl(edm, this, functionImportName,
+ (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
+ } else {
+ return new EdmFunctionImportProxy(edm, this, functionImportName,
+ (org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
index 0000000,218c5cb..914ad1c
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
@@@ -1,0 -1,80 +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.client.core.edm;
+
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Map;
+
+ import org.apache.olingo.client.api.edm.xml.EntityType;
+ import org.apache.olingo.client.api.edm.xml.PropertyRef;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmEntityType;
+ import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
+ import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+ import org.apache.olingo.commons.api.edm.EdmProperty;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmEntityType;
+ import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
+
+ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
+
+ private final EdmStructuredTypeHelper helper;
+
+ public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, final EntityType entityType) {
+ final FullQualifiedName baseTypeName = entityType.getBaseType() == null
- ? null : new EdmTypeInfo(entityType.getBaseType()).getFullQualifiedName();
++ ? null
++ : new EdmTypeInfo.Builder().setTypeExpression(entityType.getBaseType()).build().getFullQualifiedName();
+ final EdmEntityTypeImpl instance = new EdmEntityTypeImpl(edm, fqn, baseTypeName, entityType);
+ instance.baseType = instance.buildBaseType(baseTypeName);
+
+ if (instance.baseType == null) {
+ instance.entityBaseType = null;
+
+ final List<EdmKeyPropertyRef> edmKey = new ArrayList<EdmKeyPropertyRef>(
+ entityType.getKey().getPropertyRefs().size());
+ for (PropertyRef ref : entityType.getKey().getPropertyRefs()) {
+ edmKey.add(new EdmKeyPropertyRefImpl(instance, ref));
+ }
+ instance.setEdmKeyPropertyRef(edmKey);
+ } else {
+ instance.entityBaseType = (EdmEntityType) instance.baseType;
+ }
+
+ return instance;
+ }
+
+ private EdmEntityTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
+ final EntityType entityType) {
+
+ super(edm, fqn, baseTypeName, entityType.isHasStream());
+ this.helper = new EdmStructuredTypeHelperImpl(edm, entityType);
+ }
+
+ @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/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
index 0000000,3260802..10a1b2e
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java
@@@ -1,0 -1,84 +1,96 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import org.apache.olingo.client.api.edm.xml.EnumType;
+ import org.apache.olingo.client.api.edm.xml.Member;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmEnumType;
+ import org.apache.olingo.commons.api.edm.EdmMember;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmEnumType;
+ import org.apache.olingo.commons.core.edm.EdmMemberImpl;
+ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+
+ import java.util.ArrayList;
+ import java.util.Collection;
+ import java.util.Collections;
+ import java.util.LinkedHashMap;
+ import java.util.List;
+ import java.util.Map;
++import org.apache.commons.lang3.ArrayUtils;
++import org.apache.olingo.commons.api.edm.EdmException;
+
+ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType {
+
++ private static final EdmPrimitiveTypeKind[] VALID_UNDERLYING_TYPES = new EdmPrimitiveTypeKind[] {
++ EdmPrimitiveTypeKind.Byte,
++ EdmPrimitiveTypeKind.SByte,
++ EdmPrimitiveTypeKind.Int16,
++ EdmPrimitiveTypeKind.Int32,
++ EdmPrimitiveTypeKind.Int64
++ };
++
+ private final EdmPrimitiveType underlyingType;
+
+ private final List<String> memberNames;
+
+ private final Map<String, EdmMember> members;
+
+ public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName fqn, final EnumType xmlEnumType) {
+ super(edm, fqn, xmlEnumType.isFlags());
+
+ if (xmlEnumType.getUnderlyingType() == null) {
+ this.underlyingType = EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance();
+ } else {
- this.underlyingType = EdmPrimitiveTypeKind.fromString(
- xmlEnumType.getUnderlyingType()).getEdmPrimitiveTypeInstance();
- // TODO: Should we validate that the underlying type is of byte, sbyte, in16, int32 or int64?
++ this.underlyingType = EdmPrimitiveTypeKind.valueOfFQN(xmlEnumType.getUnderlyingType()).
++ getEdmPrimitiveTypeInstance();
++ if (!ArrayUtils.contains(VALID_UNDERLYING_TYPES, this.underlyingType.getKind())) {
++ throw new EdmException("Not allowed as underlying type: " + this.underlyingType.getKind());
++ }
+ }
+
+ final List<? extends Member> xmlMembers = xmlEnumType.getMembers();
+ final List<String> _memberNames = new ArrayList<String>();
+ final Map<String, EdmMember> _members = new LinkedHashMap<String, EdmMember>(xmlMembers.size());
+ for (Member xmlMember : xmlMembers) {
+ _memberNames.add(xmlMember.getName());
+ _members.put(xmlMember.getName(), new EdmMemberImpl(edm, xmlMember.getName(), xmlMember.getValue()));
+ }
+ this.memberNames = Collections.unmodifiableList(_memberNames);
+ this.members = Collections.unmodifiableMap(_members);
+ }
+
+ @Override
+ public EdmPrimitiveType getUnderlyingType() {
+ return underlyingType;
+ }
+
+ @Override
+ public List<String> getMemberNames() {
+ return memberNames;
+ }
+
+ @Override
+ protected Collection<? extends EdmMember> getMembers() {
+ return members.values();
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
index 0000000,d3004cb..ced5ae4
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
@@@ -1,0 -1,48 +1,46 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import java.util.List;
+
+ import org.apache.olingo.client.api.edm.xml.v4.FunctionImport;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+ import org.apache.olingo.commons.api.edm.EdmFunction;
+ import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+
+ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport {
+
+ private final FunctionImport functionImport;
+
+ public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
+ final FunctionImport functionImport) {
+
+ super(edm, container, name, functionImport.getEntitySet());
+ this.functionImport = functionImport;
+ }
+
+ @Override
+ public EdmFunction getFunction(final List<String> parameterNames) {
- return edm.getFunction(
- new EdmTypeInfo(functionImport.getFunction(), container.getNamespace()).getFullQualifiedName(),
- null, null, parameterNames);
++ return edm.getFunction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getFunction()).
++ setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(), null, null, parameterNames);
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java
index 0000000,cab0297..19df620
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java
@@@ -1,0 -1,75 +1,74 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import java.util.List;
+
+ import org.apache.olingo.client.api.edm.xml.v4.NavigationProperty;
+ import org.apache.olingo.client.api.edm.xml.v4.ReferentialConstraint;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmNavigationProperty;
+
+ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
+
+ private final NavigationProperty navigationProperty;
+
+ private final EdmTypeInfo edmTypeInfo;
+
+ public EdmNavigationPropertyImpl(final Edm edm, final NavigationProperty navigationProperty) {
+ super(edm, navigationProperty.getName());
+ this.navigationProperty = navigationProperty;
- this.edmTypeInfo = new EdmTypeInfo(navigationProperty.getType());
++ this.edmTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(navigationProperty.getType()).build();
+ }
+
+ @Override
+ protected FullQualifiedName getTypeFQN() {
+ return edmTypeInfo.getFullQualifiedName();
+ }
+
+ @Override
+ protected String internatGetPartner() {
+ return navigationProperty.getPartner();
+ }
+
+ @Override
+ public boolean isCollection() {
+ return edmTypeInfo.isCollection();
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return navigationProperty.isNullable();
+ }
+
+ @Override
+ public String getReferencingPropertyName(final String referencedPropertyName) {
+ final List<? extends ReferentialConstraint> referentialConstraints = navigationProperty.getReferentialConstraints();
+ if (referentialConstraints != null) {
+ for (ReferentialConstraint constraint : referentialConstraints) {
+ if (constraint.getReferencedProperty().equals(referencedPropertyName)) {
+ return constraint.getProperty();
+ }
+ }
+ }
+ return null;
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
index 0000000,33dfad3..e912ecb
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
@@@ -1,0 -1,74 +1,73 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import org.apache.olingo.client.api.edm.xml.CommonParameter;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmMapping;
+ import org.apache.olingo.commons.core.edm.AbstractEdmParameter;
+
+ public class EdmParameterImpl extends AbstractEdmParameter {
+
+ private final CommonParameter parameter;
+
+ private final EdmTypeInfo parameterInfo;
+
+ public static EdmParameterImpl getInstance(final Edm edm, final CommonParameter parameter) {
- final EdmTypeInfo paramTypeInfo = new EdmTypeInfo(parameter.getType());
++ final EdmTypeInfo paramTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(parameter.getType()).build();
+ return new EdmParameterImpl(edm, parameter, paramTypeInfo);
+ }
+
+ private EdmParameterImpl(final Edm edm, final CommonParameter parameter, final EdmTypeInfo parameterInfo) {
+ super(edm, parameter.getName(), parameterInfo.getFullQualifiedName());
+ this.parameter = parameter;
+ this.parameterInfo = parameterInfo;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return parameterInfo.isCollection();
+ }
+
+ @Override
+ public EdmMapping getMapping() {
+ throw new UnsupportedOperationException("Not supported in client code.");
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return parameter.isNullable();
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return parameter.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return parameter.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return parameter.getScale();
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
index 0000000,399b344..8e3eba6
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
@@@ -1,0 -1,91 +1,90 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import org.apache.olingo.client.api.edm.xml.CommonProperty;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmMapping;
+ import org.apache.olingo.commons.api.edm.EdmProperty;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmProperty;
+
+ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty {
+
+ private final CommonProperty property;
+
+ private final EdmTypeInfo edmTypeInfo;
+
+ public EdmPropertyImpl(final Edm edm, final CommonProperty property) {
+ super(edm, property.getName());
+ this.property = property;
- this.edmTypeInfo = new EdmTypeInfo(property.getType());
++ this.edmTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
+ }
+
+ @Override
+ protected FullQualifiedName getTypeFQN() {
+ return edmTypeInfo.getFullQualifiedName();
+ }
+
+ @Override
+ public boolean isCollection() {
+ return edmTypeInfo.isCollection();
+ }
+
+ @Override
+ public EdmMapping getMapping() {
+ throw new UnsupportedOperationException("Not supported in client code.");
+ }
+
+ @Override
+ public String getMimeType() {
+ throw new UnsupportedOperationException("Not supported in client code.");
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return property.isNullable();
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return property.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return property.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return property.getScale();
+ }
+
+ @Override
+ public Boolean isUnicode() {
+ return property.isUnicode();
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return property.getDefaultValue();
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java
index 0000000,72d6626..b559c71
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java
@@@ -1,0 -1,68 +1,67 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import org.apache.olingo.client.api.edm.xml.v4.ReturnType;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.core.edm.AbstractEdmReturnType;
+
+ public class EdmReturnTypeImpl extends AbstractEdmReturnType {
+
+ private final ReturnType returnType;
+
+ private final EdmTypeInfo returnTypeInfo;
+
+ public static EdmReturnTypeImpl getInstance(final Edm edm, final ReturnType returnType) {
- final EdmTypeInfo returnTypeInfo = new EdmTypeInfo(returnType.getType());
++ final EdmTypeInfo returnTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(returnType.getType()).build();
+ return new EdmReturnTypeImpl(edm, returnType, returnTypeInfo);
+ }
+
+ private EdmReturnTypeImpl(final Edm edm, final ReturnType returnType, final EdmTypeInfo returnTypeInfo) {
+ super(edm, returnTypeInfo.getFullQualifiedName());
+ this.returnType = returnType;
+ this.returnTypeInfo = returnTypeInfo;
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return returnType.isNullable();
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return returnType.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return returnType.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return returnType.getScale();
+ }
+
+ @Override
+ public boolean isCollection() {
+ return returnTypeInfo.isCollection();
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java
index 0000000,afe6512..cf2ad47
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java
@@@ -1,0 -1,74 +1,73 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm;
+
+ import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmException;
+ import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+ import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+ import org.apache.olingo.commons.api.edm.FullQualifiedName;
+ import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition;
+ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+
+ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements EdmTypeDefinition {
+
+ private TypeDefinition typeDefinition;
+
+ private EdmPrimitiveType edmPrimitiveTypeInstance;
+
+ public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
+ final TypeDefinition typeDefinition) {
+
+ super(edm, typeDefinitionName);
+ this.typeDefinition = typeDefinition;
- // TODO: Should we check for edmNamespace in the underlying type name?
+ try {
- edmPrimitiveTypeInstance = EdmPrimitiveTypeKind.fromString(
- typeDefinition.getUnderlyingType()).getEdmPrimitiveTypeInstance();
++ edmPrimitiveTypeInstance = EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType()).
++ getEdmPrimitiveTypeInstance();
+ } catch (IllegalArgumentException e) {
+ throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
+ }
+ }
+
+ @Override
+ public EdmPrimitiveType getUnderlyingType() {
+ return edmPrimitiveTypeInstance;
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return typeDefinition.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return typeDefinition.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return typeDefinition.getScale();
+ }
+
+ @Override
+ public Boolean isUnicode() {
+ return typeDefinition.isUnicode();
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
index 0000000,0000000..b8e930f
new file mode 100644
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
@@@ -1,0 -1,0 +1,174 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing,
++ * software distributed under the License is distributed on an
++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++ * KIND, either express or implied. See the License for the
++ * specific language governing permissions and limitations
++ * under the License.
++ */
++package org.apache.olingo.client.core.edm;
++
++import org.apache.commons.lang3.StringUtils;
++import org.apache.olingo.commons.api.edm.Edm;
++import org.apache.olingo.commons.api.edm.EdmComplexType;
++import org.apache.olingo.commons.api.edm.EdmEntityType;
++import org.apache.olingo.commons.api.edm.EdmEnumType;
++import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
++import org.apache.olingo.commons.api.edm.FullQualifiedName;
++import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class EdmTypeInfo {
++
++ private static final Logger LOG = LoggerFactory.getLogger(EdmTypeInfo.class);
++
++ public static class Builder {
++
++ private String typeExpression;
++
++ private String defaultNamespace;
++
++ private Edm edm;
++
++ public Builder setTypeExpression(final String typeExpression) {
++ this.typeExpression = typeExpression;
++ return this;
++ }
++
++ public Builder setDefaultNamespace(final String defaultNamespace) {
++ this.defaultNamespace = defaultNamespace;
++ return this;
++ }
++
++ public Builder setEdm(final Edm edm) {
++ this.edm = edm;
++ return this;
++ }
++
++ public EdmTypeInfo build() {
++ return new EdmTypeInfo(edm, typeExpression.indexOf('.') == -1
++ ? defaultNamespace + "." + typeExpression
++ : typeExpression);
++ }
++ }
++
++ private final Edm edm;
++
++ private final String typeExpression;
++
++ private final boolean collection;
++
++ private final FullQualifiedName fullQualifiedName;
++
++ private EdmPrimitiveType primitiveType;
++
++ private EdmEnumType enumType;
++
++ private EdmComplexType complexType;
++
++ private EdmEntityType entityType;
++
++ private EdmTypeInfo(final Edm edm, final String typeExpression) {
++ this.edm = edm;
++ 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);
++
++ try {
++ this.primitiveType = EdmPrimitiveTypeKind.valueOf(this.fullQualifiedName.getName()).
++ getEdmPrimitiveTypeInstance();
++ } catch (IllegalArgumentException e) {
++ LOG.debug("{} does not appear to refer to an Edm primitive type", this.fullQualifiedName);
++ }
++ if (this.primitiveType == null && this.edm != null) {
++ this.enumType = this.edm.getEnumType(this.fullQualifiedName);
++ if (this.enumType == null) {
++ this.complexType = this.edm.getComplexType(this.fullQualifiedName);
++ if (this.complexType == null) {
++ this.entityType = this.edm.getEntityType(this.fullQualifiedName);
++ }
++ }
++ }
++ }
++
++ public String getTypeExpression() {
++ return typeExpression;
++ }
++
++ public boolean isCollection() {
++ return collection;
++ }
++
++ public FullQualifiedName getFullQualifiedName() {
++ return fullQualifiedName;
++ }
++
++ public boolean isPrimitiveType() {
++ return this.primitiveType != null;
++ }
++
++ public EdmPrimitiveType getPrimitiveType() {
++ return primitiveType;
++ }
++
++ public boolean isEnumType() {
++ return this.enumType != null;
++ }
++
++ public EdmEnumType getEnumType() {
++ return enumType;
++ }
++
++ public boolean isComplexType() {
++ return this.complexType != null;
++ }
++
++ public EdmComplexType getComplexType() {
++ return complexType;
++ }
++
++ public boolean isEntityType() {
++ return this.entityType != null;
++ }
++
++ public EdmEntityType getEntityType() {
++ return entityType;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java
index 0000000,576623e..32429c0
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java
@@@ -1,0 -1,45 +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.client.core.edm.v3;
+
+ import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.client.core.edm.EdmOperationImportImpl;
++import org.apache.olingo.client.core.edm.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmAction;
+ import org.apache.olingo.commons.api.edm.EdmActionImport;
+ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+
+ public class EdmActionImportProxy extends EdmOperationImportImpl implements EdmActionImport {
+
+ private final FunctionImport functionImport;
+
+ public EdmActionImportProxy(final Edm edm, final EdmEntityContainer container, final String name,
+ final FunctionImport functionImport) {
+
+ super(edm, container, name, functionImport.getEntitySet());
+ this.functionImport = functionImport;
+ }
+
+ @Override
+ public EdmAction getAction() {
- return edm.getAction(
- new EdmTypeInfo(functionImport.getName(), container.getNamespace()).getFullQualifiedName(), null, null);
++ return edm.getAction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getName()).
++ setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(), null, null);
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
index 0000000,c7d1de2..9076a52
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
@@@ -1,0 -1,48 +1,47 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm.v3;
+
+ import java.util.List;
+
+ import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
-import org.apache.olingo.client.api.utils.EdmTypeInfo;
+ import org.apache.olingo.client.core.edm.EdmOperationImportImpl;
++import org.apache.olingo.client.core.edm.EdmTypeInfo;
+ import org.apache.olingo.commons.api.edm.Edm;
+ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+ import org.apache.olingo.commons.api.edm.EdmFunction;
+ import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+
+ public class EdmFunctionImportProxy extends EdmOperationImportImpl implements EdmFunctionImport {
+
+ private final FunctionImport functionImport;
+
+ public EdmFunctionImportProxy(final Edm edm, final EdmEntityContainer container, final String name,
+ final FunctionImport functionImport) {
+
+ super(edm, container, name, functionImport.getEntitySet());
+ this.functionImport = functionImport;
+ }
+
+ @Override
+ public EdmFunction getFunction(final List<String> parameterNames) {
- return edm.getFunction(
- new EdmTypeInfo(functionImport.getName(), container.getNamespace()).getFullQualifiedName(),
- null, null, parameterNames);
++ return edm.getFunction(new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(functionImport.getName()).
++ setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(), null, null, parameterNames);
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java
index 0000000,198e50f..8d4da80
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java
@@@ -1,0 -1,174 +1,128 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm.xml;
+
+ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+
+ import org.apache.olingo.client.api.edm.xml.CommonProperty;
-import org.apache.olingo.commons.api.edm.constants.ConcurrencyMode;
-import org.apache.olingo.commons.api.edm.constants.StoreGeneratedPattern;
+
+ @JsonDeserialize(using = PropertyDeserializer.class)
+ public abstract class AbstractProperty extends AbstractEdmItem implements CommonProperty {
+
+ private static final long serialVersionUID = -6004492361142315153L;
+
+ private String name;
+
+ private String type;
+
+ private boolean nullable = true;
+
+ private String defaultValue;
+
+ private Integer maxLength;
+
- private boolean fixedLength;
-
+ private Integer precision;
+
+ private Integer scale;
+
+ private boolean unicode = true;
+
- private String collation;
-
+ private String srid;
+
- private ConcurrencyMode concurrencyMode;
-
- private StoreGeneratedPattern storeGeneratedPattern = StoreGeneratedPattern.None;
-
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ @Override
+ public boolean isNullable() {
+ return nullable;
+ }
+
+ public void setNullable(final boolean nullable) {
+ this.nullable = nullable;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(final String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return maxLength;
+ }
+
+ public void setMaxLength(final Integer maxLength) {
+ this.maxLength = maxLength;
+ }
+
+ @Override
- public boolean isFixedLength() {
- return fixedLength;
- }
-
- public void setFixedLength(final boolean fixedLength) {
- this.fixedLength = fixedLength;
- }
-
- @Override
+ public Integer getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(final Integer precision) {
+ this.precision = precision;
+ }
+
+ @Override
+ public Integer getScale() {
+ return scale;
+ }
+
+ public void setScale(final Integer scale) {
+ this.scale = scale;
+ }
+
+ @Override
+ public boolean isUnicode() {
+ return unicode;
+ }
+
+ public void setUnicode(final boolean unicode) {
+ this.unicode = unicode;
+ }
+
+ @Override
- public String getCollation() {
- return collation;
- }
-
- public void setCollation(final String collation) {
- this.collation = collation;
- }
-
- @Override
+ public String getSrid() {
+ return srid;
+ }
+
+ public void setSrid(final String srid) {
+ this.srid = srid;
+ }
-
- @Override
- public ConcurrencyMode getConcurrencyMode() {
- return concurrencyMode;
- }
-
- public void setConcurrencyMode(final ConcurrencyMode concurrencyMode) {
- this.concurrencyMode = concurrencyMode;
- }
-
- @Override
- public StoreGeneratedPattern getStoreGeneratedPattern() {
- return storeGeneratedPattern;
- }
-
- public void setStoreGeneratedPattern(final StoreGeneratedPattern storeGeneratedPattern) {
- this.storeGeneratedPattern = storeGeneratedPattern;
- }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/f70d3f0b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java
----------------------------------------------------------------------
diff --cc lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java
index 0000000,db5b6c1..2587bce
mode 000000,100644..100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java
@@@ -1,0 -1,71 +1,72 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.olingo.client.core.edm.xml;
+
+ import com.fasterxml.jackson.core.JsonParser;
+ import com.fasterxml.jackson.core.JsonProcessingException;
+ import com.fasterxml.jackson.core.JsonToken;
+ import com.fasterxml.jackson.databind.DeserializationContext;
+
+ import java.io.IOException;
+
+ import org.apache.commons.lang3.BooleanUtils;
+ import org.apache.olingo.client.api.edm.xml.v3.ParameterMode;
+ import org.apache.olingo.client.core.op.impl.AbstractEdmDeserializer;
+ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+ public class ParameterDeserializer extends AbstractEdmDeserializer<AbstractParameter> {
+
+ @Override
+ protected AbstractParameter doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractParameter parameter = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.client.core.edm.xml.v3.ParameterImpl()
+ : new org.apache.olingo.client.core.edm.xml.v4.ParameterImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ parameter.setName(jp.nextTextValue());
+ } else if ("Type".equals(jp.getCurrentName())) {
+ parameter.setType(jp.nextTextValue());
+ } else if ("Nullable".equals(jp.getCurrentName())) {
+ parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("MaxLength".equals(jp.getCurrentName())) {
+ final String maxLenght = jp.nextTextValue();
+ parameter.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght));
+ } else if ("Precision".equals(jp.getCurrentName())) {
+ parameter.setPrecision(Integer.valueOf(jp.nextTextValue()));
+ } else if ("Scale".equals(jp.getCurrentName())) {
- parameter.setScale(Integer.valueOf(jp.nextTextValue()));
++ final String scale = jp.nextTextValue();
++ parameter.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale));
+ } else if ("Mode".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.client.core.edm.xml.v3.ParameterImpl) parameter).
+ setMode(ParameterMode.valueOf(jp.nextTextValue()));
+ } else if ("SRID".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.client.core.edm.xml.v4.ParameterImpl) parameter).setSrid(jp.nextTextValue());
+ }
+ }
+ }
+
+ return parameter;
+ }
+
+ }