You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/03/16 04:04:05 UTC
[2/3] [OLINGO-191] change package name: part 1 of 1.edm->edm.shared, 2,
edm.v4->edm
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
deleted file mode 100644
index 58c9496..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.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.core.edm.v3.EdmFunctionProxy;
-import org.apache.olingo.commons.api.edm.Edm;
-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.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.edm.AbstractEdmSchemaImpl;
-
-public class EdmSchemaImpl extends AbstractEdmSchemaImpl {
-
- private final Edm edm;
-
- private final XMLMetadata xmlMetadata;
-
- private final Schema schema;
-
- public EdmSchemaImpl(Edm edm, XMLMetadata xmlMetadata, Schema schema) {
- super(schema.getNamespace(), schema.getAlias());
- this.edm = edm;
- this.xmlMetadata = xmlMetadata;
- this.schema = schema;
- }
-
- @Override
- protected EdmEntityContainer createEntityContainer() {
- final EntityContainer defaultContainer = schema.getDefaultEntityContainer();
- if (defaultContainer != null) {
- final FullQualifiedName entityContainerName =
- new FullQualifiedName(schema.getNamespace(), defaultContainer.getName());
- return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer, xmlMetadata);
- }
- return null;
- }
-
- @Override
- protected List<EdmTypeDefinition> createTypeDefinitions() {
- final List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>();
- if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
- final List<TypeDefinition> providerTypeDefinitions =
- ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTypeDefinitions();
- if (providerTypeDefinitions != null) {
- for (TypeDefinition def : providerTypeDefinitions) {
- typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName("namespace", def.getName()), def));
- }
- }
- }
- return typeDefinitions;
- }
-
- @Override
- protected List<EdmEnumType> createEnumTypes() {
- final List<EdmEnumType> enumTypes = new ArrayList<EdmEnumType>();
- final List<EnumType> providerEnumTypes = schema.getEnumTypes();
- if (providerEnumTypes != null) {
- for (EnumType enumType : providerEnumTypes) {
- enumTypes.add(new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()), enumType));
- }
- }
- return enumTypes;
- }
-
- @Override
- protected List<EdmEntityType> createEntityTypes() {
- final List<EdmEntityType> entityTypes = new ArrayList<EdmEntityType>();
- final List<? extends EntityType> providerEntityTypes = schema.getEntityTypes();
- if (providerEntityTypes != null) {
- for (EntityType entityType : providerEntityTypes) {
- entityTypes.add(EdmEntityTypeImpl.getInstance(edm,
- new FullQualifiedName(namespace, entityType.getName()), entityType));
- }
- }
- return entityTypes;
- }
-
- @Override
- protected List<EdmComplexType> createComplexTypes() {
- final List<EdmComplexType> complexTypes = new ArrayList<EdmComplexType>();
- final List<? extends ComplexType> providerComplexTypes = schema.getComplexTypes();
- if (providerComplexTypes != null) {
- for (ComplexType complexType : providerComplexTypes) {
- complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()),
- complexType));
- }
- }
- return complexTypes;
- }
-
- @Override
- protected List<EdmAction> createActions() {
- final List<EdmAction> actions = new ArrayList<EdmAction>();
- if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
- final List<Action> providerActions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getActions();
- if (providerActions != null) {
- for (Action action : providerActions) {
- actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action));
- }
- }
- }
- return actions;
- }
-
- @Override
- protected List<EdmFunction> createFunctions() {
- final List<EdmFunction> functions = new ArrayList<EdmFunction>();
- if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
- final List<Function> providerFunctions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getFunctions();
- if (providerFunctions != null) {
- for (Function function : providerFunctions) {
- functions.add(
- EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
- }
- return functions;
- }
- } else {
- for (EntityContainer providerContainer : schema.getEntityContainers()) {
- @SuppressWarnings("unchecked")
- final List<FunctionImport> providerFunctions = (List<FunctionImport>) providerContainer.getFunctionImports();
- if (providerFunctions != null) {
- for (FunctionImport function : providerFunctions) {
- functions.add(
- EdmFunctionProxy.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
- }
- }
-
- }
- }
- return functions;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java
deleted file mode 100644
index b91340e..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import org.apache.olingo.client.api.edm.xml.v4.Singleton;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-
-public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
-
- public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final String name,
- final FullQualifiedName type, final Singleton singleton) {
-
- super(edm, container, name, type, singleton);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
deleted file mode 100644
index 140fe89..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.olingo.client.api.edm.xml.CommonNavigationProperty;
-import org.apache.olingo.client.api.edm.xml.CommonProperty;
-import org.apache.olingo.client.api.edm.xml.ComplexType;
-import org.apache.olingo.client.api.edm.xml.v4.NavigationProperty;
-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.core.edm.EdmStructuredTypeHelper;
-
-public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
-
- private final Edm edm;
-
- private final ComplexType complexType;
-
- private Map<String, EdmProperty> properties;
-
- private Map<String, EdmNavigationProperty> navigationProperties;
-
- public EdmStructuredTypeHelperImpl(final Edm edm, final ComplexType complexType) {
- this.edm = edm;
- this.complexType = complexType;
- }
-
- @Override
- public Map<String, EdmProperty> getProperties() {
- if (properties == null) {
- properties = new LinkedHashMap<String, EdmProperty>();
- for (CommonProperty property : complexType.getProperties()) {
- properties.put(property.getName(), new EdmPropertyImpl(edm, property));
- }
- }
- return properties;
- }
-
- @Override
- public Map<String, EdmNavigationProperty> getNavigationProperties() {
- if (navigationProperties == null) {
- navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>();
- for (CommonNavigationProperty navigationProperty : complexType.getNavigationProperties()) {
- if (navigationProperty instanceof NavigationProperty) {
- navigationProperties.put(navigationProperty.getName(),
- new EdmNavigationPropertyImpl(edm, (NavigationProperty) navigationProperty));
- }
- }
- }
- return navigationProperties;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java
----------------------------------------------------------------------
diff --git 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
deleted file mode 100644
index cf2ad47..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import org.apache.olingo.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;
- try {
- 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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
deleted file mode 100644
index b8e930f..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import org.apache.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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/AbstractEdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/AbstractEdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/AbstractEdmServiceMetadataImpl.java
new file mode 100644
index 0000000..f413e51
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/AbstractEdmServiceMetadataImpl.java
@@ -0,0 +1,99 @@
+/*
+ * 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.shared;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.olingo.client.api.edm.xml.EntityContainer;
+import org.apache.olingo.client.api.edm.xml.EntitySet;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
+
+public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetadata {
+
+ protected final XMLMetadata xmlMetadata;
+
+ private List<EdmEntitySetInfo> entitySetInfos;
+
+ protected List<EdmFunctionImportInfo> functionImportInfos;
+
+ protected List<EdmActionImportInfo> actionImportInfos;
+
+ public static EdmServiceMetadata getInstance(final XMLMetadata xmlMetadata) {
+ return xmlMetadata instanceof org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl
+ ? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(
+ (org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl) xmlMetadata)
+ : new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(
+ (org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl) xmlMetadata);
+
+ }
+
+ public AbstractEdmServiceMetadataImpl(final XMLMetadata xmlMetadata) {
+ this.xmlMetadata = xmlMetadata;
+ }
+
+ @Override
+ public InputStream getMetadata() {
+ throw new UnsupportedOperationException("Not supported in client code.");
+ }
+
+ @Override
+ public List<EdmEntitySetInfo> getEntitySetInfos() {
+ synchronized (this) {
+ if (entitySetInfos == null) {
+ entitySetInfos = new ArrayList<EdmEntitySetInfo>();
+ for (Schema schema : xmlMetadata.getSchemas()) {
+ for (EntityContainer entityContainer : schema.getEntityContainers()) {
+ for (EntitySet entitySet : entityContainer.getEntitySets()) {
+ entitySetInfos.add(
+ new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
+ }
+ }
+ }
+ }
+ return entitySetInfos;
+ }
+ }
+
+ @Override
+ public 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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImpl.java
new file mode 100644
index 0000000..be927f8
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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.shared;
+
+import org.apache.olingo.client.api.edm.xml.v4.Action;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+
+public class EdmActionImpl extends EdmOperationImpl implements EdmAction {
+
+ public static EdmActionImpl getInstance(final Edm edm, final FullQualifiedName name, final Action action) {
+ return EdmOperationImpl.getInstance(new EdmActionImpl(edm, name, action));
+ }
+
+ private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) {
+ super(edm, name, action, EdmTypeKind.ACTION);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImportImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImportImpl.java
new file mode 100644
index 0000000..5301016
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmActionImportImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm.shared;
+
+import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
+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.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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmBindingTargetImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmBindingTargetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmBindingTargetImpl.java
new file mode 100644
index 0000000..0539342
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmBindingTargetImpl.java
@@ -0,0 +1,79 @@
+/*
+ * 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.shared;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.olingo.client.api.edm.xml.v4.BindingTarget;
+import org.apache.olingo.client.api.edm.xml.v4.NavigationPropertyBinding;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.Target;
+import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget;
+
+public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget {
+
+ private final BindingTarget target;
+
+ public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container,
+ final String name, final FullQualifiedName type, final BindingTarget target) {
+
+ super(edm, container, name, type);
+ this.target = target;
+ }
+
+ @Override
+ public EdmBindingTarget getRelatedBindingTarget(final String path) {
+ EdmBindingTarget bindingTarget = null;
+
+ final List<? extends NavigationPropertyBinding> navigationPropertyBindings = target.getNavigationPropertyBindings();
+ boolean found = false;
+ for (final Iterator<? extends NavigationPropertyBinding> itor = navigationPropertyBindings.iterator();
+ itor.hasNext() && !found;) {
+
+ final NavigationPropertyBinding binding = itor.next();
+ if (binding.getPath().equals(path)) {
+ final Target edmTarget = new Target.Builder(binding.getTarget(), container).build();
+
+ final EdmEntityContainer entityContainer = edm.getEntityContainer(edmTarget.getEntityContainer());
+ if (entityContainer == null) {
+ throw new EdmException("Cannot find entity container with name: " + edmTarget.getEntityContainer());
+ }
+ bindingTarget = entityContainer.getEntitySet(edmTarget.getTargetName());
+ if (bindingTarget == null) {
+ bindingTarget = entityContainer.getSingleton(edmTarget.getTargetName());
+ if (bindingTarget == null) {
+ throw new EdmException("Cannot find target with name: " + edmTarget.getTargetName());
+ }
+
+ found = true;
+ } else {
+ found = true;
+ }
+ }
+ }
+
+ return bindingTarget;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmClientImpl.java
new file mode 100644
index 0000000..f3368cd
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmClientImpl.java
@@ -0,0 +1,385 @@
+/*
+ * 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.shared;
+
+import java.util.ArrayList;
+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.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.EdmSchema;
+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.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.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.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.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);
+ }
+
+ @Override
+ protected List<EdmSchema> createSchemas() {
+ final List<EdmSchema> schemas = new ArrayList<EdmSchema>();
+ for (Schema schema : xmlMetadata.getSchemas()) {
+ schemas.add(new EdmSchemaImpl(this, xmlMetadata, schema));
+ }
+ return schemas;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmComplexTypeImpl.java
new file mode 100644
index 0000000..080e2b4
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmComplexTypeImpl.java
@@ -0,0 +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.shared;
+
+import java.util.Map;
+
+import org.apache.olingo.client.api.edm.xml.ComplexType;
+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.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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityContainerImpl.java
new file mode 100644
index 0000000..0979cce
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityContainerImpl.java
@@ -0,0 +1,204 @@
+/*
+ * 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.shared;
+
+import java.util.List;
+
+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.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.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, entityType,
+ (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
+ } else {
+ 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).
+ 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);
+ }
+ }
+
+ @Override
+ protected void loadAllEntitySets() {
+ List<? extends EntitySet> localEntitySets = xmlEntityContainer.getEntitySets();
+ if (localEntitySets != null) {
+ for (EntitySet entitySet : localEntitySets) {
+ EdmEntitySet edmSet;
+ 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) {
+ edmSet =
+ new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType,
+ (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
+ } else {
+ edmSet = new EdmEntitySetProxy(edm, this, entitySet.getName(), entityType, xmlMetadata);
+ }
+ entitySets.put(edmSet.getName(), edmSet);
+ }
+ }
+
+ }
+
+ @Override
+ protected void loadAllFunctionImports() {
+ final List<? extends CommonFunctionImport> localFunctionImports = xmlEntityContainer.getFunctionImports();
+ if (localFunctionImports != null) {
+ for (CommonFunctionImport functionImport : localFunctionImports) {
+ EdmFunctionImport edmFunctionImport;
+ if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) {
+ edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(),
+ (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
+ } else {
+ edmFunctionImport = new EdmFunctionImportProxy(edm, this, functionImport.getName(),
+ (org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
+ }
+ functionImports.put(edmFunctionImport.getName(), edmFunctionImport);
+ }
+ }
+ }
+
+ @Override
+ protected void loadAllSingletons() {
+ if (!(xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer)) {
+ throw new UnsupportedInV3Exception();
+ }
+
+ final List<Singleton> localSingletons =
+ ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getSingletons();
+ if (localSingletons != null) {
+ for (Singleton singleton : localSingletons) {
+ singletons.put(singleton.getName(), new EdmSingletonImpl(edm, this, singleton.getName(),
+ new EdmTypeInfo.Builder().
+ setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()).
+ build().getFullQualifiedName(), singleton));
+ }
+ }
+ }
+
+ @Override
+ protected void loadAllActionImports() {
+ if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) {
+ final List<ActionImport> localActionImports =
+ ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getActionImports();
+ if (actionImports != null) {
+ for (ActionImport actionImport : localActionImports) {
+ actionImports.put(actionImport.getName(),
+ new EdmActionImportImpl(edm, this, actionImport.getName(), actionImport));
+ }
+ }
+ } else {
+ @SuppressWarnings("unchecked")
+ final List<FunctionImport> localFunctionImports = (List<FunctionImport>) xmlEntityContainer.getFunctionImports();
+ if (localFunctionImports != null) {
+ for (FunctionImport functionImport : localFunctionImports) {
+ actionImports.put(functionImport.getName(),
+ new EdmActionImportProxy(edm, this, functionImport.getName(), functionImport));
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntitySetImpl.java
new file mode 100644
index 0000000..e046083
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntitySetImpl.java
@@ -0,0 +1,42 @@
+/*
+ * 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.shared;
+
+import org.apache.olingo.client.api.edm.xml.v4.EntitySet;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+
+public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
+
+ private EntitySet entitySet;
+
+ public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final String name,
+ final FullQualifiedName type, final EntitySet entitySet) {
+
+ super(edm, container, name, type, entitySet);
+ this.entitySet = entitySet;
+ }
+
+ @Override
+ public boolean isIncludeInServiceDocument() {
+ return entitySet.isIncludeInServiceDocument();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityTypeImpl.java
new file mode 100644
index 0000000..1424a71
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEntityTypeImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm.shared;
+
+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.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.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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEnumTypeImpl.java
new file mode 100644
index 0000000..d79b79f
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmEnumTypeImpl.java
@@ -0,0 +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.shared;
+
+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.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/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImpl.java
new file mode 100644
index 0000000..5dadad3
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm.shared;
+
+import org.apache.olingo.client.api.edm.xml.v4.Function;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+
+public class EdmFunctionImpl extends EdmOperationImpl implements EdmFunction {
+
+ private final Function function;
+
+ public static EdmFunctionImpl getInstance(final Edm edm, final FullQualifiedName name, final Function function) {
+ return EdmOperationImpl.getInstance(new EdmFunctionImpl(edm, name, function));
+ }
+
+ private EdmFunctionImpl(final Edm edm, final FullQualifiedName name, final Function function) {
+ super(edm, name, function, EdmTypeKind.FUNCTION);
+ this.function = function;
+ }
+
+ @Override
+ public boolean isComposable() {
+ return function.isComposable();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImportImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImportImpl.java
new file mode 100644
index 0000000..3aa5519
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmFunctionImportImpl.java
@@ -0,0 +1,56 @@
+/*
+ * 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.shared;
+
+import java.util.List;
+
+import org.apache.olingo.client.api.edm.xml.v4.FunctionImport;
+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;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+
+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.Builder().setEdm(edm).setTypeExpression(functionImport.getFunction()).
+ setDefaultNamespace(container.getNamespace()).build().getFullQualifiedName(), null, null, parameterNames);
+ }
+
+ @Override
+ public boolean isIncludeInServiceDocument() {
+ return functionImport.isIncludeInServiceDocument();
+ }
+
+ @Override
+ public FullQualifiedName getFunctionFqn() {
+ return new FullQualifiedName(functionImport.getFunction());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmKeyPropertyRefImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmKeyPropertyRefImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmKeyPropertyRefImpl.java
new file mode 100644
index 0000000..86f30fb
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmKeyPropertyRefImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.shared;
+
+import org.apache.olingo.client.api.edm.xml.PropertyRef;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.core.edm.AbstractEdmKeyPropertyRef;
+
+public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
+
+ private final PropertyRef propertyRef;
+
+ public EdmKeyPropertyRefImpl(final EdmEntityType edmEntityType, final PropertyRef propertyRef) {
+ super(edmEntityType);
+ this.propertyRef = propertyRef;
+ }
+
+ @Override
+ public String getKeyPropertyName() {
+ return propertyRef.getName();
+ }
+
+ @Override
+ public String getAlias() {
+ return propertyRef.getAlias();
+ }
+
+ @Override
+ public String getPath() {
+ throw new UnsupportedOperationException("Not supported in client code.");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/64564c2d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmNavigationPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmNavigationPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmNavigationPropertyImpl.java
new file mode 100644
index 0000000..7af8e60
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/shared/EdmNavigationPropertyImpl.java
@@ -0,0 +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.shared;
+
+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.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.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;
+ }
+
+}