You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/09/24 14:42:46 UTC
[19/51] [partial] Refactored project structure
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java
deleted file mode 100644
index 6df353a..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java
+++ /dev/null
@@ -1,190 +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.odata2.core.edm.provider;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmAssociationSet;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-import org.apache.olingo.odata2.api.exception.ODataException;
-
-/**
- *
- */
-public class EdmEntityContainerImplProv implements EdmEntityContainer, EdmAnnotatable {
-
- private EdmImplProv edm;
- private EntityContainerInfo entityContainer;
- private Map<String, EdmEntitySet> edmEntitySets;
- private Map<String, EdmAssociationSet> edmAssociationSets;
- private Map<String, EdmFunctionImport> edmFunctionImports;
- private EdmEntityContainer edmExtendedEntityContainer;
- private boolean isDefaultContainer;
-
- public EdmEntityContainerImplProv(final EdmImplProv edm, final EntityContainerInfo entityContainer)
- throws EdmException {
- this.edm = edm;
- this.entityContainer = entityContainer;
- edmEntitySets = new HashMap<String, EdmEntitySet>();
- edmAssociationSets = new HashMap<String, EdmAssociationSet>();
- edmFunctionImports = new HashMap<String, EdmFunctionImport>();
- isDefaultContainer = entityContainer.isDefaultEntityContainer();
-
- if (entityContainer.getExtendz() != null) {
- edmExtendedEntityContainer = edm.getEntityContainer(entityContainer.getExtendz());
- if (edmExtendedEntityContainer == null) {
- throw new EdmException(EdmException.COMMON);
- }
- }
- }
-
- @Override
- public String getName() throws EdmException {
- return entityContainer.getName();
- }
-
- @Override
- public EdmEntitySet getEntitySet(final String name) throws EdmException {
- EdmEntitySet edmEntitySet = edmEntitySets.get(name);
- if (edmEntitySet != null) {
- return edmEntitySet;
- }
-
- EntitySet entitySet;
- try {
- entitySet = edm.edmProvider.getEntitySet(entityContainer.getName(), name);
- } catch (ODataException e) {
- throw new EdmException(EdmException.PROVIDERPROBLEM, e);
- }
-
- if (entitySet != null) {
- edmEntitySet = createEntitySet(entitySet);
- edmEntitySets.put(name, edmEntitySet);
- } else if (edmExtendedEntityContainer != null) {
- edmEntitySet = edmExtendedEntityContainer.getEntitySet(name);
- if (edmEntitySet != null) {
- edmEntitySets.put(name, edmEntitySet);
- }
- }
-
- return edmEntitySet;
- }
-
- @Override
- public EdmFunctionImport getFunctionImport(final String name) throws EdmException {
- EdmFunctionImport edmFunctionImport = edmFunctionImports.get(name);
- if (edmFunctionImport != null) {
- return edmFunctionImport;
- }
-
- FunctionImport functionImport;
- try {
- functionImport = edm.edmProvider.getFunctionImport(entityContainer.getName(), name);
- } catch (ODataException e) {
- throw new EdmException(EdmException.PROVIDERPROBLEM, e);
- }
-
- if (functionImport != null) {
- edmFunctionImport = createFunctionImport(functionImport);
- edmFunctionImports.put(name, edmFunctionImport);
- } else if (edmExtendedEntityContainer != null) {
- edmFunctionImport = edmExtendedEntityContainer.getFunctionImport(name);
- if (edmFunctionImport != null) {
- edmFunctionImports.put(name, edmFunctionImport);
- }
- }
-
- return edmFunctionImport;
- }
-
- @Override
- public EdmAssociationSet getAssociationSet(final EdmEntitySet sourceEntitySet,
- final EdmNavigationProperty navigationProperty) throws EdmException {
- EdmAssociation edmAssociation = navigationProperty.getRelationship();
- String association = edmAssociation.getNamespace() + "." + edmAssociation.getName();
- String entitySetName = sourceEntitySet.getName();
- String entitySetFromRole = navigationProperty.getFromRole();
-
- String key = entitySetName + ">>" + association + ">>" + entitySetFromRole;
-
- EdmAssociationSet edmAssociationSet = edmAssociationSets.get(key);
- if (edmAssociationSet != null) {
- return edmAssociationSet;
- }
-
- AssociationSet associationSet;
- FullQualifiedName associationFQName =
- new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName());
- try {
- associationSet =
- edm.edmProvider.getAssociationSet(entityContainer.getName(), associationFQName, entitySetName,
- entitySetFromRole);
- } catch (ODataException e) {
- throw new EdmException(EdmException.PROVIDERPROBLEM, e);
- }
-
- if (associationSet != null) {
- edmAssociationSet = createAssociationSet(associationSet);
- edmAssociationSets.put(key, edmAssociationSet);
- return edmAssociationSet;
- } else if (edmExtendedEntityContainer != null) {
- edmAssociationSet = edmExtendedEntityContainer.getAssociationSet(sourceEntitySet, navigationProperty);
- edmAssociationSets.put(key, edmAssociationSet);
- return edmAssociationSet;
- } else {
- throw new EdmException(EdmException.COMMON);
- }
- }
-
- private EdmEntitySet createEntitySet(final EntitySet entitySet) throws EdmException {
- return new EdmEntitySetImplProv(edm, entitySet, this);
- }
-
- private EdmFunctionImport createFunctionImport(final FunctionImport functionImport) throws EdmException {
- return new EdmFunctionImportImplProv(edm, functionImport, this);
- }
-
- private EdmAssociationSet createAssociationSet(final AssociationSet associationSet) throws EdmException {
- return new EdmAssociationSetImplProv(edm, associationSet, this);
- }
-
- @Override
- public boolean isDefaultEntityContainer() {
- return isDefaultContainer;
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(entityContainer.getAnnotationAttributes(), entityContainer
- .getAnnotationElements());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java
deleted file mode 100644
index fda8fe8..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java
+++ /dev/null
@@ -1,88 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmAssociationSet;
-import org.apache.olingo.odata2.api.edm.EdmAssociationSetEnd;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-
-public class EdmEntitySetImplProv extends EdmNamedImplProv implements EdmEntitySet, EdmAnnotatable {
-
- private EntitySet entitySet;
- private EdmEntityContainer edmEntityContainer;
- private EdmEntityType edmEntityType;
-
- public EdmEntitySetImplProv(final EdmImplProv edm, final EntitySet entitySet,
- final EdmEntityContainer edmEntityContainer) throws EdmException {
- super(edm, entitySet.getName());
- this.entitySet = entitySet;
- this.edmEntityContainer = edmEntityContainer;
- }
-
- @Override
- public EdmEntityType getEntityType() throws EdmException {
- if (edmEntityType == null) {
- FullQualifiedName fqName = entitySet.getEntityType();
- edmEntityType = edm.getEntityType(fqName.getNamespace(), fqName.getName());
- if (edmEntityType == null) {
- throw new EdmException(EdmException.COMMON);
- }
- }
- return edmEntityType;
- }
-
- @Override
- public EdmEntitySet getRelatedEntitySet(final EdmNavigationProperty navigationProperty) throws EdmException {
- EdmAssociationSet associationSet =
- edmEntityContainer.getAssociationSet(edmEntityContainer.getEntitySet(entitySet.getName()), navigationProperty);
- EdmAssociationSetEnd toEnd = associationSet.getEnd(navigationProperty.getToRole());
- if (toEnd == null) {
- throw new EdmException(EdmException.COMMON);
- }
- EdmEntitySet targetEntitySet = toEnd.getEntitySet();
- if (targetEntitySet == null) {
- throw new EdmException(EdmException.COMMON);
- }
- return targetEntitySet;
- }
-
- @Override
- public EdmEntityContainer getEntityContainer() throws EdmException {
- return edmEntityContainer;
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(entitySet.getAnnotationAttributes(), entitySet.getAnnotationElements());
- }
-
- @Override
- public EdmMapping getMapping() throws EdmException {
- return entitySet.getMapping();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java
deleted file mode 100644
index 2d7127d..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java
+++ /dev/null
@@ -1,79 +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.odata2.core.edm.provider;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-
-public class EdmEntitySetInfoImplProv implements EdmEntitySetInfo {
-
- private final String entitySetName;
- private final URI entitySetUri;
- private final String entityContainerName;
- private final boolean isDefaultEntityContainer;
-
- public EdmEntitySetInfoImplProv(final EntitySet entitySet, final EntityContainerInfo entityContainerInfo)
- throws EdmException {
- entityContainerName = entityContainerInfo.getName();
- isDefaultEntityContainer = entityContainerInfo.isDefaultEntityContainer();
-
- entitySetName = entitySet.getName();
-
- try {
- if (isDefaultEntityContainer) {
- entitySetUri = new URI(entitySetName);
- } else {
- entitySetUri = new URI(entityContainerName + "." + entitySetName);
- }
- } catch (URISyntaxException e) {
- throw new EdmException(EdmException.COMMON, e);
- }
-
- }
-
- @Override
- public String getEntityContainerName() {
- return entityContainerName;
-
- }
-
- @Override
- public String getEntitySetName() {
- return entitySetName;
-
- }
-
- @Override
- public boolean isDefaultEntityContainer() {
- return isDefaultEntityContainer;
-
- }
-
- @Override
- public URI getEntitySetUri() {
- return entitySetUri;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java
deleted file mode 100644
index 90b273b..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.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.odata2.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
-
-public class EdmEntityTypeImplProv extends EdmStructuralTypeImplProv implements EdmEntityType {
-
- private EntityType entityType;
-
- private Map<String, EdmProperty> keyProperties;
- private List<EdmProperty> edmKeyProperties;
- private List<String> edmKeyPropertyNames;
-
- private Map<String, NavigationProperty> navigationProperties;
- private List<String> edmNavigationPropertyNames;
-
- public EdmEntityTypeImplProv(final EdmImplProv edm, final EntityType entityType, final String namespace)
- throws EdmException {
- super(edm, entityType, EdmTypeKind.ENTITY, namespace);
- this.entityType = entityType;
-
- buildNavigationPropertiesInternal();
- }
-
- private void buildNavigationPropertiesInternal() throws EdmException {
- navigationProperties = new HashMap<String, NavigationProperty>();
-
- if (entityType.getNavigationProperties() != null) {
- for (final NavigationProperty navigationProperty : entityType.getNavigationProperties()) {
- navigationProperties.put(navigationProperty.getName(), navigationProperty);
- }
- }
- }
-
- @Override
- public List<String> getKeyPropertyNames() throws EdmException {
- if (edmKeyPropertyNames == null) {
- if (edmBaseType != null) {
- return ((EdmEntityType) edmBaseType).getKeyPropertyNames();
- }
-
- edmKeyPropertyNames = new ArrayList<String>();
-
- if (entityType.getKey() != null) {
- for (final PropertyRef keyProperty : entityType.getKey().getKeys()) {
- edmKeyPropertyNames.add(keyProperty.getName());
- }
- } else {
- // Entity Type does not define a key
- throw new EdmException(EdmException.COMMON);
- }
- }
-
- return edmKeyPropertyNames;
- }
-
- @Override
- public List<EdmProperty> getKeyProperties() throws EdmException {
- if (edmKeyProperties == null) {
- if (edmBaseType != null) {
- return ((EdmEntityType) edmBaseType).getKeyProperties();
- }
-
- if (keyProperties == null) {
- keyProperties = new HashMap<String, EdmProperty>();
- edmKeyProperties = new ArrayList<EdmProperty>();
-
- for (String keyPropertyName : getKeyPropertyNames()) {
- final EdmTyped edmProperty = getProperty(keyPropertyName);
- if (edmProperty != null && edmProperty instanceof EdmProperty) {
- keyProperties.put(keyPropertyName, (EdmProperty) edmProperty);
- edmKeyProperties.add((EdmProperty) edmProperty);
- } else {
- throw new EdmException(EdmException.COMMON);
- }
- }
- }
- }
-
- return edmKeyProperties;
- }
-
- @Override
- public boolean hasStream() throws EdmException {
- return entityType.isHasStream();
- }
-
- @Override
- public EdmCustomizableFeedMappings getCustomizableFeedMappings() throws EdmException {
- return entityType.getCustomizableFeedMappings();
- }
-
- @Override
- public List<String> getNavigationPropertyNames() throws EdmException {
- if (edmNavigationPropertyNames == null) {
- edmNavigationPropertyNames = new ArrayList<String>();
- if (edmBaseType != null) {
- edmNavigationPropertyNames.addAll(((EdmEntityType) edmBaseType).getNavigationPropertyNames());
- }
- if (entityType.getNavigationProperties() != null) {
- for (final NavigationProperty navigationProperty : entityType.getNavigationProperties()) {
- edmNavigationPropertyNames.add(navigationProperty.getName());
- }
- }
- }
- return edmNavigationPropertyNames;
- }
-
- @Override
- public EdmEntityType getBaseType() throws EdmException {
- return (EdmEntityType) edmBaseType;
- }
-
- @Override
- protected EdmTyped getPropertyInternal(final String name) throws EdmException {
- EdmTyped edmProperty = super.getPropertyInternal(name);
-
- if (edmProperty != null) {
- return edmProperty;
- }
-
- if (navigationProperties.containsKey(name)) {
- edmProperty = createNavigationProperty(navigationProperties.get(name));
- edmProperties.put(name, edmProperty);
- } else if (edmBaseType != null) {
- edmProperty = edmBaseType.getProperty(name);
- if (edmProperty != null) {
- edmProperties.put(name, edmProperty);
- }
- }
-
- return edmProperty;
- }
-
- protected EdmTyped createNavigationProperty(final NavigationProperty property) throws EdmException {
- return new EdmNavigationPropertyImplProv(edm, property);
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(entityType.getAnnotationAttributes(), entityType.getAnnotationElements());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java
deleted file mode 100644
index 9ec2f34..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java
+++ /dev/null
@@ -1,143 +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.odata2.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmParameter;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImportParameter;
-import org.apache.olingo.odata2.api.edm.provider.ReturnType;
-
-/**
- *
- */
-public class EdmFunctionImportImplProv extends EdmNamedImplProv implements EdmFunctionImport, EdmAnnotatable {
-
- private FunctionImport functionImport;
- private EdmEntityContainer edmEntityContainer;
- private Map<String, EdmParameter> edmParameters;
- private Map<String, FunctionImportParameter> parameters;
- private List<String> parametersList;
-
- public EdmFunctionImportImplProv(final EdmImplProv edm, final FunctionImport functionImport,
- final EdmEntityContainer edmEntityContainer) throws EdmException {
- super(edm, functionImport.getName());
- this.functionImport = functionImport;
- this.edmEntityContainer = edmEntityContainer;
-
- buildFunctionImportParametersInternal();
-
- edmParameters = new HashMap<String, EdmParameter>();
- }
-
- private void buildFunctionImportParametersInternal() {
- parameters = new HashMap<String, FunctionImportParameter>();
-
- List<FunctionImportParameter> parameters = functionImport.getParameters();
- if (parameters != null) {
- FunctionImportParameter functionImportParameter;
- for (Iterator<FunctionImportParameter> iterator = parameters.iterator(); iterator.hasNext();) {
- functionImportParameter = iterator.next();
- this.parameters.put(functionImportParameter.getName(), functionImportParameter);
- }
- }
- }
-
- @Override
- public EdmParameter getParameter(final String name) throws EdmException {
- EdmParameter parameter = null;
- if (edmParameters.containsKey(name)) {
- parameter = edmParameters.get(name);
- } else {
- parameter = createParameter(name);
- }
-
- return parameter;
- }
-
- private EdmParameter createParameter(final String name) throws EdmException {
- EdmParameter edmParameter = null;
- if (parameters.containsKey(name)) {
- FunctionImportParameter parameter = parameters.get(name);
- edmParameter = new EdmParameterImplProv(edm, parameter);
- edmParameters.put(name, edmParameter);
- }
- return edmParameter;
- }
-
- @Override
- public List<String> getParameterNames() throws EdmException {
- if (parametersList == null) {
- parametersList = new ArrayList<String>();
-
- Set<String> keySet = parameters.keySet();
- Iterator<String> iterator = keySet.iterator();
- while (iterator.hasNext()) {
- parametersList.add(iterator.next());
- }
- }
-
- return parametersList;
- }
-
- @Override
- public EdmEntitySet getEntitySet() throws EdmException {
- return edmEntityContainer.getEntitySet(functionImport.getEntitySet());
- }
-
- @Override
- public String getHttpMethod() throws EdmException {
- return functionImport.getHttpMethod();
- }
-
- @Override
- public EdmTyped getReturnType() throws EdmException {
- final ReturnType returnType = functionImport.getReturnType();
- return new EdmTypedImplProv(edm, functionImport.getName(), returnType.getTypeName(), returnType.getMultiplicity());
- }
-
- @Override
- public EdmEntityContainer getEntityContainer() throws EdmException {
- return edmEntityContainer;
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(functionImport.getAnnotationAttributes(), functionImport.getAnnotationElements());
- }
-
- @Override
- public EdmMapping getMapping() throws EdmException {
- return functionImport.getMapping();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
deleted file mode 100644
index 60ecc83..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
+++ /dev/null
@@ -1,129 +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.odata2.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmComplexType;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.edm.provider.EdmProviderAccessor;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.core.edm.EdmImpl;
-
-public class EdmImplProv extends EdmImpl implements EdmProviderAccessor {
-
- protected EdmProvider edmProvider;
- private List<Schema> schemas;
-
- public EdmImplProv(final EdmProvider edmProvider) {
- super(new EdmServiceMetadataImplProv(edmProvider));
- this.edmProvider = edmProvider;
- }
-
- @Override
- protected EdmEntityContainer createEntityContainer(final String name) throws ODataException {
- EntityContainerInfo enitityContainerInfo = edmProvider.getEntityContainerInfo(name);
- if (enitityContainerInfo == null) {
- return null;
- }
- return new EdmEntityContainerImplProv(this, enitityContainerInfo);
- }
-
- @Override
- protected EdmEntityType createEntityType(final FullQualifiedName fqName) throws ODataException {
- EntityType entityType = edmProvider.getEntityType(fqName);
- if (entityType == null) {
- return null;
- }
-
- return new EdmEntityTypeImplProv(this, entityType, fqName.getNamespace());
- }
-
- @Override
- protected EdmComplexType createComplexType(final FullQualifiedName fqName) throws ODataException {
- ComplexType complexType = edmProvider.getComplexType(fqName);
- if (complexType == null) {
- return null;
- }
- return new EdmComplexTypeImplProv(this, complexType, fqName.getNamespace());
- }
-
- @Override
- protected EdmAssociation createAssociation(final FullQualifiedName fqName) throws ODataException {
- Association association = edmProvider.getAssociation(fqName);
- if (association == null) {
- return null;
- }
- return new EdmAssociationImplProv(this, association, fqName.getNamespace());
- }
-
- @Override
- public EdmProvider getEdmProvider() {
- return edmProvider;
- }
-
- @Override
- protected List<EdmEntitySet> createEntitySets() throws ODataException {
- List<EdmEntitySet> edmEntitySets = new ArrayList<EdmEntitySet>();
- if (schemas == null) {
- schemas = edmProvider.getSchemas();
- }
- for (Schema schema : schemas) {
- for (EntityContainer entityContainer : schema.getEntityContainers()) {
- for (EntitySet entitySet : entityContainer.getEntitySets()) {
- EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName());
- edmEntitySets.add(new EdmEntitySetImplProv(this, entitySet, edmEntityContainer));
- }
- }
- }
- return edmEntitySets;
- }
-
- @Override
- protected List<EdmFunctionImport> createFunctionImports() throws ODataException {
- List<EdmFunctionImport> edmFunctionImports = new ArrayList<EdmFunctionImport>();
- if (schemas == null) {
- schemas = edmProvider.getSchemas();
- }
- for (Schema schema : schemas) {
- for (EntityContainer entityContainer : schema.getEntityContainers()) {
- for (FunctionImport functionImport : entityContainer.getFunctionImports()) {
- EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName());
- edmFunctionImports.add(new EdmFunctionImportImplProv(this, functionImport, edmEntityContainer));
- }
- }
- }
- return edmFunctionImports;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java
deleted file mode 100644
index 81ae907..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java
+++ /dev/null
@@ -1,57 +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.odata2.core.edm.provider;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmNamed;
-
-public abstract class EdmNamedImplProv implements EdmNamed {
-
- private static final Pattern PATTERN_VALID_NAME = Pattern
- .compile("^[:A-Z_a-z\\u00C0\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02ff\\u0370-\\u037d"
- + "\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff"
- + "\\uf900-\\ufdcf\\ufdf0-\\ufffd\\x10000-\\xEFFFF]"
- + "[:A-Z_a-z\\u00C0\\u00D6\\u00D8-\\u00F6"
- + "\\u00F8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f"
- + "\\u2c00-\\u2fef\\u3001-\\udfff\\uf900-\\ufdcf\\ufdf0-\\ufffd\\-\\.0-9"
- + "\\u00b7\\u0300-\\u036f\\u203f-\\u2040]*\\Z");
- protected EdmImplProv edm;
- private String name;
-
- public EdmNamedImplProv(final EdmImplProv edm, final String name) throws EdmException {
- this.edm = edm;
- this.name = getValidatedName(name);
- }
-
- @Override
- public String getName() throws EdmException {
- return name;
- }
-
- private String getValidatedName(final String name) throws EdmException {
- Matcher matcher = PATTERN_VALID_NAME.matcher(name);
- if (matcher.matches()) {
- return name;
- }
- throw new EdmException(EdmException.COMMON);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java
deleted file mode 100644
index 0e5f474..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java
+++ /dev/null
@@ -1,78 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-
-public class EdmNavigationPropertyImplProv extends EdmTypedImplProv implements EdmNavigationProperty, EdmAnnotatable {
-
- private NavigationProperty navigationProperty;
-
- public EdmNavigationPropertyImplProv(final EdmImplProv edm, final NavigationProperty property) throws EdmException {
- super(edm, property.getName(), null, null);
- navigationProperty = property;
- }
-
- @Override
- public EdmType getType() throws EdmException {
- return getRelationship().getEnd(navigationProperty.getToRole()).getEntityType();
- }
-
- @Override
- public EdmMultiplicity getMultiplicity() throws EdmException {
- return ((EdmAssociationImplProv) getRelationship()).getEndMultiplicity(navigationProperty.getToRole());
- }
-
- @Override
- public EdmAssociation getRelationship() throws EdmException {
- final FullQualifiedName relationship = navigationProperty.getRelationship();
- return edm.getAssociation(relationship.getNamespace(), relationship.getName());
- }
-
- @Override
- public String getFromRole() throws EdmException {
- return navigationProperty.getFromRole();
- }
-
- @Override
- public String getToRole() throws EdmException {
- return navigationProperty.getToRole();
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(navigationProperty.getAnnotationAttributes(), navigationProperty
- .getAnnotationElements());
- }
-
- @Override
- public EdmMapping getMapping() throws EdmException {
- return navigationProperty.getMapping();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java
deleted file mode 100644
index f92febc..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java
+++ /dev/null
@@ -1,57 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmParameter;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImportParameter;
-import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
-
-/**
- *
- */
-public class EdmParameterImplProv extends EdmElementImplProv implements EdmParameter, EdmAnnotatable {
-
- FunctionImportParameter parameter;
-
- public EdmParameterImplProv(final EdmImplProv edm, final FunctionImportParameter parameter) throws EdmException {
- super(edm, parameter.getName(), parameter.getType().getFullQualifiedName(), parameter.getFacets(), parameter
- .getMapping());
- this.parameter = parameter;
- }
-
- @Override
- public EdmType getType() throws EdmException {
- if (edmType == null) {
- edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(parameter.getType());
- if (edmType == null) {
- throw new EdmException(EdmException.COMMON);
- }
- }
- return edmType;
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(parameter.getAnnotationAttributes(), parameter.getAnnotationElements());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java
deleted file mode 100644
index 8dcf075..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java
+++ /dev/null
@@ -1,53 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmAnnotations;
-import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-
-public abstract class EdmPropertyImplProv extends EdmElementImplProv implements EdmProperty, EdmAnnotatable {
-
- private Property property;
-
- public EdmPropertyImplProv(final EdmImplProv edm, final FullQualifiedName propertyName, final Property property)
- throws EdmException {
- super(edm, property.getName(), propertyName, property.getFacets(), property.getMapping());
- this.property = property;
- }
-
- @Override
- public EdmCustomizableFeedMappings getCustomizableFeedMappings() throws EdmException {
- return property.getCustomizableFeedMappings();
- }
-
- @Override
- public String getMimeType() throws EdmException {
- return property.getMimeType();
- }
-
- @Override
- public EdmAnnotations getAnnotations() throws EdmException {
- return new EdmAnnotationsImplProv(property.getAnnotationAttributes(), property.getAnnotationElements());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintImplProv.java
deleted file mode 100644
index a6a8286..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintImplProv.java
+++ /dev/null
@@ -1,46 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmReferentialConstraint;
-import org.apache.olingo.odata2.api.edm.EdmReferentialConstraintRole;
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole;
-
-public class EdmReferentialConstraintImplProv implements EdmReferentialConstraint {
- private ReferentialConstraint referentialConstraint;
-
- public EdmReferentialConstraintImplProv(final ReferentialConstraint referentialConstraint) throws EdmException {
- this.referentialConstraint = referentialConstraint;
- }
-
- @Override
- public EdmReferentialConstraintRole getPrincipal() throws EdmException {
- ReferentialConstraintRole principal = referentialConstraint.getPrincipal();
- return new EdmReferentialConstraintRoleImplProv(principal);
- }
-
- @Override
- public EdmReferentialConstraintRole getDependent() throws EdmException {
- ReferentialConstraintRole dependent = referentialConstraint.getDependent();
- return new EdmReferentialConstraintRoleImplProv(dependent);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintRoleImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintRoleImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintRoleImplProv.java
deleted file mode 100644
index d4def53..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmReferentialConstraintRoleImplProv.java
+++ /dev/null
@@ -1,53 +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.odata2.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmReferentialConstraintRole;
-import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole;
-
-public class EdmReferentialConstraintRoleImplProv implements EdmReferentialConstraintRole {
- private ReferentialConstraintRole role;
- private List<String> refNames;
-
- public EdmReferentialConstraintRoleImplProv(final ReferentialConstraintRole role) throws EdmException {
- this.role = role;
- }
-
- @Override
- public String getRole() {
- return role.getRole();
- }
-
- @Override
- public List<String> getPropertyRefNames() {
- if (refNames == null) {
- refNames = new ArrayList<String>();
- for (PropertyRef ref : role.getPropertyRefs()) {
- refNames.add(ref.getName());
- }
- }
- return refNames;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java
deleted file mode 100644
index 16262fc..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java
+++ /dev/null
@@ -1,163 +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.odata2.core.edm.provider;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.olingo.odata2.api.ODataServiceVersion;
-import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.odata2.api.edm.EdmServiceMetadata;
-import org.apache.olingo.odata2.api.edm.provider.DataServices;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer;
-import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer;
-
-/**
- *
- */
-public class EdmServiceMetadataImplProv implements EdmServiceMetadata {
-
- private EdmProvider edmProvider;
- private String dataServiceVersion;
- private List<Schema> schemas;
- private List<EdmEntitySetInfo> entitySetInfos;
-
- public EdmServiceMetadataImplProv(final EdmProvider edmProvider) {
- this.edmProvider = edmProvider;
- }
-
- @Override
- public InputStream getMetadata() throws ODataException {
- if (schemas == null) {
- schemas = edmProvider.getSchemas();
- }
-
- OutputStreamWriter writer = null;
- CircleStreamBuffer csb = new CircleStreamBuffer();
- EntityProviderException cachedException = null;
- DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion());
-
- try {
- writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
- XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
- XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null);
- return csb.getInputStream();
- } catch (XMLStreamException e) {
- cachedException = new EntityProviderException(EntityProviderException.COMMON, e);
- throw cachedException;
- } catch (UnsupportedEncodingException e) {
- cachedException = new EntityProviderException(EntityProviderException.COMMON, e);
- throw cachedException;
- } finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
- if (cachedException != null) {
- throw cachedException;
- } else {
- throw new EntityProviderException(EntityProviderException.COMMON, e);
- }
- }
- }
- }
- }
-
- @Override
- public String getDataServiceVersion() throws ODataException {
- if (schemas == null) {
- schemas = edmProvider.getSchemas();
- }
-
- if (dataServiceVersion == null) {
- dataServiceVersion = ODataServiceVersion.V10;
-
- if (schemas != null) {
- for (Schema schema : schemas) {
- List<EntityType> entityTypes = schema.getEntityTypes();
- if (entityTypes != null) {
- for (EntityType entityType : entityTypes) {
- List<Property> properties = entityType.getProperties();
- if (properties != null) {
- for (Property property : properties) {
- if (property.getCustomizableFeedMappings() != null) {
- if (property.getCustomizableFeedMappings().getFcKeepInContent() != null) {
- if (!property.getCustomizableFeedMappings().getFcKeepInContent()) {
- dataServiceVersion = ODataServiceVersion.V20;
- return dataServiceVersion;
- }
- }
- }
- }
- if (entityType.getCustomizableFeedMappings() != null) {
- if (entityType.getCustomizableFeedMappings().getFcKeepInContent() != null) {
- if (entityType.getCustomizableFeedMappings().getFcKeepInContent()) {
- dataServiceVersion = ODataServiceVersion.V20;
- return dataServiceVersion;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return dataServiceVersion;
- }
-
- @Override
- public List<EdmEntitySetInfo> getEntitySetInfos() throws ODataException {
- if (entitySetInfos == null) {
- entitySetInfos = new ArrayList<EdmEntitySetInfo>();
-
- if (schemas == null) {
- schemas = edmProvider.getSchemas();
- }
-
- for (Schema schema : schemas) {
- for (EntityContainer entityContainer : schema.getEntityContainers()) {
- for (EntitySet entitySet : entityContainer.getEntitySets()) {
- EdmEntitySetInfo entitySetInfo = new EdmEntitySetInfoImplProv(entitySet, entityContainer);
- entitySetInfos.add(entitySetInfo);
- }
- }
- }
-
- }
-
- return entitySetInfos;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java
deleted file mode 100644
index 8c5da45..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java
+++ /dev/null
@@ -1,50 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
-
-public class EdmSimplePropertyImplProv extends EdmPropertyImplProv {
-
- private SimpleProperty property;
-
- public EdmSimplePropertyImplProv(final EdmImplProv edm, final SimpleProperty property) throws EdmException {
- super(edm, property.getType().getFullQualifiedName(), property);
- this.property = property;
- }
-
- @Override
- public EdmType getType() throws EdmException {
- if (edmType == null) {
- edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(property.getType());
- if (edmType == null) {
- throw new EdmException(EdmException.COMMON);
- }
- }
- return edmType;
- }
-
- @Override
- public boolean isSimple() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java
deleted file mode 100644
index 08cb5af..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java
+++ /dev/null
@@ -1,173 +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.odata2.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.Edm;
-import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmStructuralType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-
-/**
- *
- */
-public abstract class EdmStructuralTypeImplProv extends EdmNamedImplProv implements EdmStructuralType, EdmAnnotatable {
-
- protected EdmStructuralType edmBaseType;
- protected ComplexType structuralType;
- private EdmTypeKind edmTypeKind;
- protected String namespace;
- protected Map<String, EdmTyped> edmProperties;
- private Map<String, Property> properties;
- private List<String> edmPropertyNames;
-
- public EdmStructuralTypeImplProv(final EdmImplProv edm, final ComplexType structuralType,
- final EdmTypeKind edmTypeKind, final String namespace) throws EdmException {
- super(edm, structuralType.getName());
- this.structuralType = structuralType;
- this.namespace = namespace;
- this.edmTypeKind = edmTypeKind;
-
- resolveBaseType();
-
- buildPropertiesInternal();
-
- edmProperties = new HashMap<String, EdmTyped>();
- }
-
- private void resolveBaseType() throws EdmException {
- FullQualifiedName fqName = structuralType.getBaseType();
- if (fqName != null) {
- if (EdmTypeKind.COMPLEX.equals(edmTypeKind)) {
- edmBaseType = edm.getComplexType(fqName.getNamespace(), fqName.getName());
- } else if (EdmTypeKind.ENTITY.equals(edmTypeKind)) {
- edmBaseType = edm.getEntityType(fqName.getNamespace(), fqName.getName());
- }
- if (edmBaseType == null) {
- throw new EdmException(EdmException.COMMON);
- }
- }
- }
-
- private void buildPropertiesInternal() throws EdmException {
- properties = new HashMap<String, Property>();
-
- if (structuralType.getProperties() != null) {
- for (final Property property : structuralType.getProperties()) {
- properties.put(property.getName(), property);
- }
- }
- }
-
- @Override
- public String getNamespace() throws EdmException {
- return namespace;
- }
-
- @Override
- public EdmTyped getProperty(final String name) throws EdmException {
- EdmTyped property = edmProperties.get(name);
- if (property == null) {
- property = getPropertyInternal(name);
- if (property == null && edmBaseType != null) {
- property = edmBaseType.getProperty(name);
- }
- }
- return property;
- }
-
- @Override
- public List<String> getPropertyNames() throws EdmException {
- if (edmPropertyNames == null) {
- edmPropertyNames = new ArrayList<String>();
- if (edmBaseType != null) {
- edmPropertyNames.addAll(edmBaseType.getPropertyNames());
- }
- if (structuralType.getProperties() != null) {
- for (final Property property : structuralType.getProperties()) {
- edmPropertyNames.add(property.getName());
- }
- }
- }
-
- return edmPropertyNames;
- }
-
- @Override
- public EdmStructuralType getBaseType() throws EdmException {
- return edmBaseType;
- }
-
- @Override
- public EdmTypeKind getKind() {
- return edmTypeKind;
- }
-
- @Override
- public EdmMapping getMapping() throws EdmException {
- return structuralType.getMapping();
- }
-
- protected EdmTyped getPropertyInternal(final String name) throws EdmException {
- EdmTyped edmProperty = null;
-
- if (properties.containsKey(name)) {
- edmProperty = createProperty(properties.get(name));
- edmProperties.put(name, edmProperty);
- } else if (edmBaseType != null) {
- edmProperty = edmBaseType.getProperty(name);
- if (edmProperty != null) {
- edmProperties.put(name, edmProperty);
- }
- }
-
- return edmProperty;
- }
-
- protected EdmTyped createProperty(final Property property) throws EdmException {
- if (property instanceof SimpleProperty) {
- return new EdmSimplePropertyImplProv(edm, (SimpleProperty) property);
- } else if (property instanceof ComplexProperty) {
- return new EdmComplexPropertyImplProv(edm, (ComplexProperty) property);
- } else {
- throw new EdmException(EdmException.COMMON);
- }
- }
-
- @Override
- public String toString() {
- try {
- return namespace + Edm.DELIMITER + getName();
- } catch (final EdmException e) {
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java
deleted file mode 100644
index 9cdf138..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java
+++ /dev/null
@@ -1,71 +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.odata2.core.edm.provider;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
-
-/**
- *
- */
-public class EdmTypedImplProv extends EdmNamedImplProv implements EdmTyped {
-
- protected EdmType edmType;
- private FullQualifiedName typeName;
- private EdmMultiplicity multiplicity;
-
- public EdmTypedImplProv(final EdmImplProv edm, final String name, final FullQualifiedName typeName,
- final EdmMultiplicity multiplicity) throws EdmException {
- super(edm, name);
- this.typeName = typeName;
- this.multiplicity = multiplicity;
- }
-
- @Override
- public EdmType getType() throws EdmException {
- if (edmType == null) {
- final String namespace = typeName.getNamespace();
- if (EdmSimpleType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
- edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.valueOf(typeName.getName()));
- } else {
- edmType = edm.getComplexType(namespace, typeName.getName());
- }
- if (edmType == null) {
- edmType = edm.getEntityType(namespace, typeName.getName());
- }
-
- if (edmType == null) {
- throw new EdmException(EdmException.COMMON);
- }
-
- }
- return edmType;
- }
-
- @Override
- public EdmMultiplicity getMultiplicity() throws EdmException {
- return multiplicity;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
deleted file mode 100644
index 8cf58f1..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
+++ /dev/null
@@ -1,191 +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.odata2.core.edm.provider;
-
-import java.io.InputStream;
-import java.util.List;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.DataServices;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.core.ep.consumer.XmlMetadataConsumer;
-
-public class EdmxProvider extends EdmProvider {
- private DataServices dataServices;
-
- public EdmxProvider parse(final InputStream in, final boolean validate) throws EntityProviderException {
- XmlMetadataConsumer parser = new XmlMetadataConsumer();
- XMLStreamReader streamReader = createStreamReader(in);
- dataServices = parser.readMetadata(streamReader, validate);
- return this;
- }
-
- @Override
- public EntityContainerInfo getEntityContainerInfo(final String name) throws ODataException {
- if (name != null) {
- for (Schema schema : dataServices.getSchemas()) {
- for (EntityContainer container : schema.getEntityContainers()) {
- if (container.getName().equals(name)) {
- return container;
- }
- }
- }
- } else {
- for (Schema schema : dataServices.getSchemas()) {
- for (EntityContainer container : schema.getEntityContainers()) {
- if (container.isDefaultEntityContainer()) {
- return container;
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public EntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException {
- for (Schema schema : dataServices.getSchemas()) {
- if (schema.getNamespace().equals(edmFQName.getNamespace())) {
- for (EntityType entityType : schema.getEntityTypes()) {
- if (entityType.getName().equals(edmFQName.getName())) {
- return entityType;
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
- for (Schema schema : dataServices.getSchemas()) {
- if (schema.getNamespace().equals(edmFQName.getNamespace())) {
- for (ComplexType complexType : schema.getComplexTypes()) {
- if (complexType.getName().equals(edmFQName.getName())) {
- return complexType;
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException {
- for (Schema schema : dataServices.getSchemas()) {
- if (schema.getNamespace().equals(edmFQName.getNamespace())) {
- for (Association association : schema.getAssociations()) {
- if (association.getName().equals(edmFQName.getName())) {
- return association;
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException {
- for (Schema schema : dataServices.getSchemas()) {
- for (EntityContainer container : schema.getEntityContainers()) {
- if (container.getName().equals(entityContainer)) {
- for (EntitySet entitySet : container.getEntitySets()) {
- if (entitySet.getName().equals(name)) {
- return entitySet;
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association,
- final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException {
- for (Schema schema : dataServices.getSchemas()) {
- for (EntityContainer container : schema.getEntityContainers()) {
- if (container.getName().equals(entityContainer)) {
- for (AssociationSet associationSet : container.getAssociationSets()) {
- if (associationSet.getAssociation().equals(association)
- && ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1()
- .getRole().equals(sourceEntitySetRole))
- || (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2()
- .getRole().equals(sourceEntitySetRole)))) {
- return associationSet;
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
- for (Schema schema : dataServices.getSchemas()) {
- for (EntityContainer container : schema.getEntityContainers()) {
- if (container.getName().equals(entityContainer)) {
- for (FunctionImport function : container.getFunctionImports()) {
- if (function.getName().equals(name)) {
- return function;
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public List<Schema> getSchemas() throws ODataException {
- return dataServices.getSchemas();
- }
-
- private XMLStreamReader createStreamReader(final InputStream in) throws EntityProviderException {
- XMLInputFactory factory = XMLInputFactory.newInstance();
- factory.setProperty(XMLInputFactory.IS_VALIDATING, false);
- factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
-
- XMLStreamReader streamReader;
- try {
- streamReader = factory.createXMLStreamReader(in);
- } catch (XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
- .getSimpleName()), e);
- }
-
- return streamReader;
- }
-}