You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/07 10:09:28 UTC
[39/57] [abbrv] [OLINGO-186] client-side implementation of commons
Edm interfaces completed: some refactoring on server-side performed to
extract common abstract implementation
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmServiceMetadataImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmServiceMetadataImpl.java
index f44f1d6..ba8a46a 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmServiceMetadataImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmServiceMetadataImpl.java
@@ -23,12 +23,18 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.odata4.commons.api.ODataException;
+import org.apache.olingo.odata4.commons.api.edm.EdmActionImportInfo;
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySetInfo;
import org.apache.olingo.odata4.commons.api.edm.EdmException;
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImportInfo;
import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
import org.apache.olingo.odata4.commons.api.edm.EdmSingletonInfo;
import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.odata4.commons.core.edm.EdmSingletonInfoImpl;
+import org.apache.olingo.odata4.commons.core.edm.EdmActionImportInfoImpl;
+import org.apache.olingo.odata4.commons.core.edm.EdmFunctionImportInfoImpl;
+import org.apache.olingo.odata4.commons.core.edm.EdmEntitySetInfoImpl;
+import org.apache.olingo.odata4.server.api.edm.provider.ActionImport;
import org.apache.olingo.odata4.server.api.edm.provider.EdmProvider;
import org.apache.olingo.odata4.server.api.edm.provider.EntityContainer;
import org.apache.olingo.odata4.server.api.edm.provider.EntitySet;
@@ -39,11 +45,17 @@ import org.apache.olingo.odata4.server.api.edm.provider.Singleton;
public class EdmServiceMetadataImpl implements EdmServiceMetadata {
private EdmProvider provider;
- private ArrayList<EdmEntitySetInfo> entitySetInfos;
- private ArrayList<EdmFunctionImportInfo> functionImportInfos;
- private ArrayList<EdmSingletonInfo> singletonInfos;
+
private List<Schema> schemas;
+ private List<EdmEntitySetInfo> entitySetInfos;
+
+ private List<EdmSingletonInfo> singletonInfos;
+
+ private List<EdmActionImportInfo> actionImportInfos;
+
+ private List<EdmFunctionImportInfo> functionImportInfos;
+
public EdmServiceMetadataImpl(final EdmProvider provider) {
this.provider = provider;
}
@@ -70,12 +82,12 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata {
}
}
for (Schema schema : schemas) {
- EntityContainer entityContainer = schema.getEntityContainer();
+ final EntityContainer entityContainer = schema.getEntityContainer();
if (entityContainer != null) {
- List<EntitySet> entitySets = entityContainer.getEntitySets();
+ final List<EntitySet> entitySets = entityContainer.getEntitySets();
if (entitySets != null) {
for (EntitySet set : entitySets) {
- entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer, set));
+ entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), set.getName()));
}
}
}
@@ -99,12 +111,12 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata {
}
}
for (Schema schema : schemas) {
- EntityContainer entityContainer = schema.getEntityContainer();
+ final EntityContainer entityContainer = schema.getEntityContainer();
if (entityContainer != null) {
- List<Singleton> singletons = entityContainer.getSingletons();
+ final List<Singleton> singletons = entityContainer.getSingletons();
if (singletons != null) {
for (Singleton singleton : singletons) {
- singletonInfos.add(new EdmSingletonInfoImpl(entityContainer, singleton));
+ singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
}
}
}
@@ -117,6 +129,35 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata {
}
@Override
+ public List<EdmActionImportInfo> getActionImportInfos() {
+ if (actionImportInfos == null) {
+ try {
+ actionImportInfos = new ArrayList<EdmActionImportInfo>();
+ if (schemas == null) {
+ schemas = provider.getSchemas();
+ if (schemas == null) {
+ throw new EdmException("Provider doe not define any schemas.");
+ }
+ }
+ for (Schema schema : schemas) {
+ final EntityContainer entityContainer = schema.getEntityContainer();
+ if (entityContainer != null) {
+ final List<ActionImport> actionImports = entityContainer.getActionImports();
+ if (actionImports != null) {
+ for (ActionImport actionImport : actionImports) {
+ actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
+ }
+ }
+ }
+ }
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+ return actionImportInfos;
+ }
+
+ @Override
public List<EdmFunctionImportInfo> getFunctionImportInfos() {
if (functionImportInfos == null) {
try {
@@ -128,12 +169,13 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata {
}
}
for (Schema schema : schemas) {
- EntityContainer entityContainer = schema.getEntityContainer();
+ final EntityContainer entityContainer = schema.getEntityContainer();
if (entityContainer != null) {
- List<FunctionImport> functionImports = entityContainer.getFunctionImports();
+ final List<FunctionImport> functionImports = entityContainer.getFunctionImports();
if (functionImports != null) {
for (FunctionImport functionImport : functionImports) {
- functionImportInfos.add(new EdmFunctionImportInfoImpl(entityContainer, functionImport));
+ functionImportInfos.add(
+ new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImpl.java
index 1ca0fc5..9fbd0b0 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImpl.java
@@ -18,13 +18,14 @@
*/
package org.apache.olingo.odata4.server.core.edm.provider;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
import org.apache.olingo.odata4.server.api.edm.provider.Singleton;
public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
- public EdmSingletonImpl(final EdmProviderImpl edm, final EdmEntityContainer container, final Singleton singleton) {
+ public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final Singleton singleton) {
super(edm, container, singleton);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImpl.java
deleted file mode 100644
index d69bc99..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImpl.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.odata4.server.core.edm.provider;
-
-import java.net.URI;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmException;
-import org.apache.olingo.odata4.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.odata4.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata4.server.api.edm.provider.Singleton;
-
-public class EdmSingletonInfoImpl implements EdmSingletonInfo {
-
- private final EntityContainer entityContainer;
- private final Singleton singleton;
-
- public EdmSingletonInfoImpl(final EntityContainer entityContainer, final Singleton singleton) {
- this.entityContainer = entityContainer;
- this.singleton = singleton;
- }
-
- @Override
- public String getEntityContainerName() {
- return entityContainer.getName();
- }
-
- @Override
- public String getSingletonName() {
- return singleton.getName();
- }
-
- @Override
- public URI getEntitySetUri() {
- throw new EdmException("Not yet implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuralTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuralTypeImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuralTypeImpl.java
deleted file mode 100644
index 8849dd0..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuralTypeImpl.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.odata4.server.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmElement;
-import org.apache.olingo.odata4.commons.api.edm.EdmException;
-import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
-import org.apache.olingo.odata4.commons.api.edm.EdmType;
-import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.odata4.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.odata4.server.api.edm.provider.Property;
-import org.apache.olingo.odata4.server.api.edm.provider.StructuralType;
-
-public abstract class EdmStructuralTypeImpl extends EdmTypeImpl implements EdmStructuralType {
-
- private final Map<String, EdmElement> properties = new HashMap<String, EdmElement>();
- private ArrayList<String> navigationPropertyNames;
- private ArrayList<String> propertyNames;
- protected final EdmStructuralType baseType;
- private final StructuralType structuralType;
-
- public EdmStructuralTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name,
- final StructuralType structuralType, final EdmTypeKind kind) {
- super(edm, name, kind);
- this.structuralType = structuralType;
- baseType = buildBaseType(structuralType.getBaseType());
- buildProperties(structuralType.getProperties());
- buildNavigationProperties(structuralType.getNavigationProperties());
- }
-
- private void buildNavigationProperties(final List<NavigationProperty> providerNavigationProperties) {
- if (providerNavigationProperties != null) {
- for (NavigationProperty navigationProperty : providerNavigationProperties) {
- properties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl(edm, navigationProperty));
- }
- }
-
- }
-
- private void buildProperties(final List<Property> providerProperties) {
- if (providerProperties != null) {
- for (Property property : providerProperties) {
- properties.put(property.getName(), new EdmPropertyImpl(edm, property));
- }
- }
-
- }
-
- @Override
- public EdmElement getProperty(final String name) {
- EdmElement property = null;
- if (baseType != null) {
- property = baseType.getProperty(name);
- }
- if (property == null) {
- property = properties.get(name);
- }
- return property;
- }
-
- @Override
- public List<String> getPropertyNames() {
- if (propertyNames == null) {
- propertyNames = new ArrayList<String>();
- if (baseType != null) {
- propertyNames.addAll(baseType.getPropertyNames());
- }
- for (Property property : structuralType.getProperties()) {
- propertyNames.add(property.getName());
- }
- }
- return propertyNames;
- }
-
- @Override
- public List<String> getNavigationPropertyNames() {
- if (navigationPropertyNames == null) {
- navigationPropertyNames = new ArrayList<String>();
- if (baseType != null) {
- navigationPropertyNames.addAll(baseType.getNavigationPropertyNames());
- }
- for (NavigationProperty navProperty : structuralType.getNavigationProperties()) {
- navigationPropertyNames.add(navProperty.getName());
- }
- }
- return navigationPropertyNames;
- }
-
- @Override
- public boolean compatibleTo(final EdmType targetType) {
- EdmStructuralType sourceType = this;
- if (targetType == null) {
- throw new EdmException("Target type must not be null");
- }
- while (sourceType.getName() != targetType.getName() ||
- sourceType.getNamespace() != targetType.getNamespace()) {
- sourceType = sourceType.getBaseType();
- if (sourceType == null) {
- return false;
- }
- }
-
- return true;
- }
-
- protected abstract EdmStructuralType buildBaseType(FullQualifiedName baseTypeName);
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuredTypeHelperImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuredTypeHelperImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuredTypeHelperImpl.java
new file mode 100644
index 0000000..cc7eac7
--- /dev/null
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmStructuredTypeHelperImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.server.core.edm.provider;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
+import org.apache.olingo.odata4.commons.core.edm.EdmStructuredTypeHelper;
+import org.apache.olingo.odata4.server.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata4.server.api.edm.provider.Property;
+import org.apache.olingo.odata4.server.api.edm.provider.StructuredType;
+
+public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
+
+ private final Edm edm;
+
+ private final StructuredType structuredType;
+
+ private Map<String, EdmProperty> properties;
+
+ private Map<String, EdmNavigationProperty> navigationProperties;
+
+ public EdmStructuredTypeHelperImpl(final Edm edm, final StructuredType structuredType) {
+ this.edm = edm;
+ this.structuredType = structuredType;
+ }
+
+ @Override
+ public Map<String, EdmProperty> getProperties() {
+ if (properties == null) {
+ properties = new LinkedHashMap<String, EdmProperty>();
+ if (structuredType.getProperties() != null) {
+ for (Property property : structuredType.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>();
+ if (structuredType.getNavigationProperties() != null) {
+ for (NavigationProperty navigationProperty : structuredType.getNavigationProperties()) {
+ navigationProperties.put(navigationProperty.getName(),
+ new EdmNavigationPropertyImpl(edm, navigationProperty));
+ }
+ }
+ }
+ return navigationProperties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeDefinitionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeDefinitionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeDefinitionImpl.java
index ad44f08..3c370e7 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeDefinitionImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeDefinitionImpl.java
@@ -18,88 +18,36 @@
*/
package org.apache.olingo.odata4.server.core.edm.provider;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmException;
import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.odata4.commons.core.edm.AbstractEdmTypeDefinition;
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
import org.apache.olingo.odata4.server.api.edm.provider.TypeDefinition;
-public class EdmTypeDefinitionImpl extends EdmNamedImpl implements EdmTypeDefinition {
+public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements EdmTypeDefinition {
- private final FullQualifiedName typeDefinitionName;
private TypeDefinition typeDefinition;
+
private EdmPrimitiveType edmPrimitiveTypeInstance;
- public EdmTypeDefinitionImpl(final EdmProviderImpl edm, final FullQualifiedName typeDefinitionName,
- final TypeDefinition typeDefinition) {
- super(edm, typeDefinitionName.getName());
- this.typeDefinitionName = typeDefinitionName;
+ public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
+ final TypeDefinition typeDefinition) {
+
+ super(edm, typeDefinitionName);
this.typeDefinition = typeDefinition;
// TODO: Should we check for edmNamespace in the underlying type name?
try {
- edmPrimitiveTypeInstance =
- EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName()).getEdmPrimitiveTypeInstance();
+ edmPrimitiveTypeInstance = EdmPrimitiveTypeKind.valueOf(
+ typeDefinition.getUnderlyingType().getName()).getEdmPrimitiveTypeInstance();
} catch (IllegalArgumentException e) {
throw new EdmException("Invalid underlying type: " + typeDefinitionName, e);
}
}
@Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return edmPrimitiveTypeInstance.isCompatible(primitiveType);
- }
-
- @Override
- public Class<?> getDefaultType() {
- return edmPrimitiveTypeInstance.getDefaultType();
- }
-
- @Override
- public boolean validate(final String value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale,
- final Boolean isUnicode) {
- return edmPrimitiveTypeInstance.validate(value, isNullable, maxLength, precision, scale, isUnicode);
- }
-
- @Override
- public <T> T valueOfString(final String value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale,
- final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- return edmPrimitiveTypeInstance
- .valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, returnType);
- }
-
- @Override
- public String valueToString(final Object value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale,
- final Boolean isUnicode) throws EdmPrimitiveTypeException {
- return edmPrimitiveTypeInstance.valueToString(value, isNullable, maxLength, precision, scale, isUnicode);
- }
-
- @Override
- public String toUriLiteral(final String literal) {
- return edmPrimitiveTypeInstance.toUriLiteral(literal);
- }
-
- @Override
- public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
- return edmPrimitiveTypeInstance.fromUriLiteral(literal);
- }
-
- @Override
- public String getNamespace() {
- return typeDefinitionName.getNamespace();
- }
-
- @Override
- public EdmTypeKind getKind() {
- return EdmTypeKind.DEFINITION;
- }
-
- @Override
public EdmPrimitiveType getUnderlyingType() {
return edmPrimitiveTypeInstance;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImpl.java
deleted file mode 100644
index 3f232c5..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImpl.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.odata4.server.core.edm.provider;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmType;
-import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
-
-public abstract class EdmTypeImpl extends EdmNamedImpl implements EdmType {
-
- private final EdmTypeKind kind;
- private final String namespace;
-
- public EdmTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name, final EdmTypeKind kind) {
- super(edm, name.getName());
- namespace = name.getNamespace();
- this.kind = kind;
- }
-
- @Override
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public EdmTypeKind getKind() {
- return kind;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriResourceTypedImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriResourceTypedImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriResourceTypedImpl.java
index 2cec8de..a5b21b1 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriResourceTypedImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriResourceTypedImpl.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.odata4.server.core.uri;
-import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
+import org.apache.olingo.odata4.commons.api.edm.EdmStructuredType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
@@ -36,7 +36,7 @@ public abstract class UriResourceTypedImpl extends UriResourceImpl implements Ur
return typeFilter;
}
- public UriResourceTypedImpl setTypeFilter(final EdmStructuralType typeFilter) {
+ public UriResourceTypedImpl setTypeFilter(final EdmStructuredType typeFilter) {
this.typeFilter = typeFilter;
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
index f13484f..1561f17 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
@@ -38,7 +38,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
-import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
+import org.apache.olingo.odata4.commons.api.edm.EdmStructuredType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
@@ -387,12 +387,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
return null;
}
- if (!(source.type instanceof EdmStructuralType)) {
+ if (!(source.type instanceof EdmStructuredType)) {
throw wrap(new UriParserSemanticException("Can not parse'" + odi
+ "'Previous path segment not a structural type."));
}
- EdmStructuralType structType = (EdmStructuralType) source.type;
+ EdmStructuredType structType = (EdmStructuredType) source.type;
EdmElement property = structType.getProperty(odi);
if (property == null) {
@@ -1815,11 +1815,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
}
- if (!(prevType instanceof EdmStructuralType)) {
+ if (!(prevType instanceof EdmStructuredType)) {
throw wrap(new UriParserSemanticException("Previous select item is not a structural type"));
}
- EdmStructuralType structType = (EdmStructuralType) prevType;
+ EdmStructuredType structType = (EdmStructuredType) prevType;
EdmElement element = structType.getProperty(odi);
if (element == null) {
throw wrap(new UriParserSemanticException("Previous select item has not property: " + odi));
@@ -1888,7 +1888,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (prevType instanceof EdmComplexType) {
EdmComplexType ct = edm.getComplexType(fullName);
if (ct != null) {
- if ((ct.compatibleTo((EdmStructuralType) prevType))) {
+ if ((ct.compatibleTo((EdmStructuredType) prevType))) {
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
resourcePart.setCollectionTypeFilter(ct);
@@ -1907,7 +1907,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
} else if (prevType instanceof EdmEntityType) {
EdmEntityType et = edm.getEntityType(fullName);
if (et != null) {
- if ((et.compatibleTo((EdmStructuralType) prevType))) {
+ if ((et.compatibleTo((EdmStructuredType) prevType))) {
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
resourcePart.setCollectionTypeFilter(et);
@@ -1938,7 +1938,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (prevType instanceof EdmComplexType) {
EdmComplexType ct = edm.getComplexType(fullName);
if (ct != null) {
- if ((ct.compatibleTo((EdmStructuralType) prevType))) {
+ if ((ct.compatibleTo((EdmStructuredType) prevType))) {
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
resourcePart.setCollectionTypeFilter(ct);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImplTest.java
index a6b5c36..866f347 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImplTest.java
@@ -57,20 +57,20 @@ public class EdmActionImplTest {
parameters.add(new Parameter().setName("Id").setType(new FullQualifiedName("namespace", "name")));
FullQualifiedName action1Name = new FullQualifiedName("namespace", "action1");
Action action1 = new Action().setName("action1").setBound(true).setParameters(parameters);
- actionImpl1 = new EdmActionImpl(provider, action1Name, action1);
+ actionImpl1 = EdmActionImpl.getInstance(provider, action1Name, action1);
FullQualifiedName action2Name = new FullQualifiedName("namespace", "action2");
FullQualifiedName returnTypeName = new FullQualifiedName("Edm", "String");
ReturnType returnType = new ReturnType().setType(returnTypeName);
Action action2 = new Action().setName("action2").setParameters(parameters).setReturnType(returnType);
- actionImpl2 = new EdmActionImpl(provider, action2Name, action2);
+ actionImpl2 = EdmActionImpl.getInstance(provider, action2Name, action2);
FullQualifiedName action3Name = new FullQualifiedName("namespace", "action3");
EntitySetPath entitySetPath = new EntitySetPath().setBindingParameter("Id").setPath("path");
Action action3 =
new Action().setName("action3").setParameters(parameters).setReturnType(returnType).setEntitySetPath(
entitySetPath);
- actionImpl3 = new EdmActionImpl(provider, action3Name, action3);
+ actionImpl3 = EdmActionImpl.getInstance(provider, action3Name, action3);
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImportImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImportImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImportImplTest.java
index a829c89..033800d 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImportImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmActionImportImplTest.java
@@ -31,15 +31,18 @@ import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
import org.apache.olingo.odata4.commons.api.edm.EdmException;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.edm.provider.ActionImport;
-import org.apache.olingo.odata4.server.api.edm.provider.Target;
+import org.apache.olingo.odata4.commons.api.edm.Target;
import org.junit.Before;
import org.junit.Test;
public class EdmActionImportImplTest {
EdmEntityContainer container;
+
EdmActionImport actionImport;
+
private EdmAction action;
+
private EdmEntitySet entitySet;
@Before
@@ -47,8 +50,8 @@ public class EdmActionImportImplTest {
FullQualifiedName actionFqn = new FullQualifiedName("namespace", "actionName");
FullQualifiedName entityContainerFqn = new FullQualifiedName("namespace", "containerName");
Target target = new Target().setEntityContainer(entityContainerFqn).setTargetName("entitySetName");
- ActionImport providerActionImport =
- new ActionImport().setName("actionImportName").setAction(actionFqn).setEntitySet(target);
+ ActionImport providerActionImport
+ = new ActionImport().setName("actionImportName").setAction(actionFqn).setEntitySet(target);
EdmProviderImpl edm = mock(EdmProviderImpl.class);
container = mock(EdmEntityContainer.class);
@@ -58,7 +61,7 @@ public class EdmActionImportImplTest {
entitySet = mock(EdmEntitySet.class);
when(container.getEntitySet("entitySetName")).thenReturn(entitySet);
- actionImport = new EdmActionImportImpl(edm, "actionImportName", container, providerActionImport);
+ actionImport = new EdmActionImportImpl(edm, container, "actionImportName", providerActionImport);
}
@Test
@@ -82,8 +85,8 @@ public class EdmActionImportImplTest {
public void getReturnedEntitySetNonExistingContainer() {
Target target = new Target();
ActionImport providerActionImport = new ActionImport().setName("actionImportName").setEntitySet(target);
- EdmActionImport actionImport =
- new EdmActionImportImpl(mock(EdmProviderImpl.class), "actionImportName", container, providerActionImport);
+ EdmActionImport actionImport
+ = new EdmActionImportImpl(mock(EdmProviderImpl.class), container, "actionImportName", providerActionImport);
actionImport.getReturnedEntitySet();
}
@@ -93,7 +96,7 @@ public class EdmActionImportImplTest {
ActionImport providerActionImport = new ActionImport().setName("actionImportName").setEntitySet(target);
EdmProviderImpl edm = mock(EdmProviderImpl.class);
when(edm.getEntityContainer(null)).thenReturn(container);
- EdmActionImport actionImport = new EdmActionImportImpl(edm, "actionImportName", container, providerActionImport);
+ EdmActionImport actionImport = new EdmActionImportImpl(edm, container, "actionImportName", providerActionImport);
actionImport.getReturnedEntitySet();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmComplexTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmComplexTypeImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmComplexTypeImplTest.java
index 33832ed..9ae780b 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmComplexTypeImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmComplexTypeImplTest.java
@@ -61,7 +61,7 @@ public class EdmComplexTypeImplTest {
.setNavigationProperties(baseNavigationProperties);
when(provider.getComplexType(baseName)).thenReturn(baseComplexType);
- baseType = new EdmComplexTypeImpl(edm, baseName, baseComplexType);
+ baseType = EdmComplexTypeImpl.getInstance(edm, baseName, baseComplexType);
FullQualifiedName name = new FullQualifiedName("namespace", "typeName");
ComplexType complexType = new ComplexType().setBaseType(baseName);
@@ -73,14 +73,14 @@ public class EdmComplexTypeImplTest {
.setNavigationProperties(navigationProperties);
when(provider.getComplexType(name)).thenReturn(complexType);
- type = new EdmComplexTypeImpl(edm, name, complexType);
+ type = EdmComplexTypeImpl.getInstance(edm, name, complexType);
}
@Test
public void noPropertiesAndNoNavPropertiesMustNotResultInException() {
EdmProviderImpl edm = mock(EdmProviderImpl.class);
ComplexType complexType = new ComplexType().setName("n");
- new EdmComplexTypeImpl(edm, new FullQualifiedName("n", "n"), complexType);
+ EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName("n", "n"), complexType);
}
@Test
@@ -158,6 +158,6 @@ public class EdmComplexTypeImplTest {
new ComplexType().setBaseType(new FullQualifiedName("wrong", "wrong"));
complexTypeForNonexistingBaseType.setName("typeName");
when(provider.getComplexType(typeWithNonexistingBaseTypeName)).thenReturn(complexTypeForNonexistingBaseType);
- new EdmComplexTypeImpl(edm, typeWithNonexistingBaseTypeName, complexTypeForNonexistingBaseType);
+ EdmComplexTypeImpl.getInstance(edm, typeWithNonexistingBaseTypeName, complexTypeForNonexistingBaseType);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetImplTest.java
index 5bd5fa3..85df520 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetImplTest.java
@@ -36,7 +36,7 @@ import org.apache.olingo.odata4.server.api.edm.provider.EntitySet;
import org.apache.olingo.odata4.server.api.edm.provider.EntityType;
import org.apache.olingo.odata4.server.api.edm.provider.NavigationPropertyBinding;
import org.apache.olingo.odata4.server.api.edm.provider.PropertyRef;
-import org.apache.olingo.odata4.server.api.edm.provider.Target;
+import org.apache.olingo.odata4.commons.api.edm.Target;
import org.junit.Test;
public class EdmEntitySetImplTest {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetInfoImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetInfoImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetInfoImplTest.java
deleted file mode 100644
index d002dd4..0000000
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntitySetInfoImplTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.odata4.server.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.odata4.commons.api.edm.EdmException;
-import org.apache.olingo.odata4.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata4.server.api.edm.provider.EntitySet;
-import org.junit.Test;
-
-public class EdmEntitySetInfoImplTest {
-
- @Test
- public void entitySetTest() {
- EntitySet providerEntitySet = new EntitySet().setName("name");
- EntityContainer providerContainer = new EntityContainer().setName("container");
-
- EdmEntitySetInfo info = new EdmEntitySetInfoImpl(providerContainer, providerEntitySet);
-
- assertEquals("name", info.getEntitySetName());
- assertEquals("container", info.getEntityContainerName());
- }
-
- @Test(expected = EdmException.class)
- public void getUriTest() {
- EntitySet providerEntitySet = new EntitySet().setName("name");
- EntityContainer providerContainer = new EntityContainer().setName("container");
-
- EdmEntitySetInfo info = new EdmEntitySetInfoImpl(providerContainer, providerEntitySet);
- info.getEntitySetUri();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntityTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntityTypeImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntityTypeImplTest.java
index 4e2ca11..a4a26d8 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntityTypeImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEntityTypeImplTest.java
@@ -72,7 +72,7 @@ public class EdmEntityTypeImplTest {
baseType.setNavigationProperties(navigationProperties);
when(provider.getEntityType(baseName)).thenReturn(baseType);
- this.baseType = new EdmEntityTypeImpl(edm, baseName, baseType);
+ this.baseType = EdmEntityTypeImpl.getInstance(edm, baseName, baseType);
FullQualifiedName typeName = new FullQualifiedName("namespace", "typeName");
EntityType type = new EntityType();
@@ -87,7 +87,7 @@ public class EdmEntityTypeImplTest {
type.setNavigationProperties(typeNavigationProperties);
when(provider.getEntityType(typeName)).thenReturn(type);
- typeWithBaseType = new EdmEntityTypeImpl(edm, typeName, type);
+ typeWithBaseType = EdmEntityTypeImpl.getInstance(edm, typeName, type);
FullQualifiedName typeWithComplexKeyName = new FullQualifiedName("namespace", "typeName");
EntityType typeWithComplexKeyProvider = new EntityType();
@@ -112,7 +112,7 @@ public class EdmEntityTypeImplTest {
typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey);
when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider);
- typeWithComplexKey = new EdmEntityTypeImpl(edm, typeWithComplexKeyName, typeWithComplexKeyProvider);
+ typeWithComplexKey = EdmEntityTypeImpl.getInstance(edm, typeWithComplexKeyName, typeWithComplexKeyProvider);
}
@Test
@@ -246,21 +246,21 @@ public class EdmEntityTypeImplTest {
public void noKeyOnTypeWithoutBaseTypeMustResultInException() {
EdmProviderImpl edm = mock(EdmProviderImpl.class);
EntityType entityType = new EntityType().setName("n");
- new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+ EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName("n", "n"), entityType);
}
@Test
public void abstractTypeDoesNotNeedKey() {
EdmProviderImpl edm = mock(EdmProviderImpl.class);
EntityType entityType = new EntityType().setName("n").setAbstract(true);
- new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+ EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName("n", "n"), entityType);
}
@Test(expected = EdmException.class)
public void invalidBaseType() {
EdmProviderImpl edm = mock(EdmProviderImpl.class);
EntityType entityType = new EntityType().setName("n").setBaseType(new FullQualifiedName("wrong", "wrong"));
- new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+ EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName("n", "n"), entityType);
}
@Test
@@ -270,7 +270,7 @@ public class EdmEntityTypeImplTest {
FullQualifiedName baseName = new FullQualifiedName("n", "base");
when(provider.getEntityType(baseName)).thenReturn(new EntityType().setName("base").setAbstract(true));
EntityType entityType = new EntityType().setName("n").setAbstract(true).setBaseType(baseName);
- new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+ EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName("n", "n"), entityType);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEnumTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEnumTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEnumTest.java
index 4c31103..b55f625 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEnumTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmEnumTest.java
@@ -51,11 +51,11 @@ public class EdmEnumTest extends PrimitiveTypeBaseTest {
EdmPrimitiveTypeKind.SByte.getFullQualifiedName());
FullQualifiedName enumName = new FullQualifiedName("namespace", "name");
- instance = new EdmEnumImpl(mock(EdmProviderImpl.class), enumName, enumType);
+ instance = new EdmEnumTypeImpl(mock(EdmProviderImpl.class), enumName, enumType);
EnumType enumType2 = new EnumType().setName("name").setMembers(memberList).setFlags(false).setUnderlyingType(
EdmPrimitiveTypeKind.SByte.getFullQualifiedName());
- nonFlagsInstance = new EdmEnumImpl(mock(EdmProviderImpl.class), enumName, enumType2);
+ nonFlagsInstance = new EdmEnumTypeImpl(mock(EdmProviderImpl.class), enumName, enumType2);
// EdmMember member1 = mock(EdmMember.class);
// when(member1.getName()).thenReturn("first");
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImplTest.java
index 6ed7ef1..f5488d3 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImplTest.java
@@ -44,9 +44,9 @@ public class EdmFunctionImplTest {
EdmProviderImpl provider = mock(EdmProviderImpl.class);
Function function1 = new Function().setReturnType(new ReturnType().setType(new FullQualifiedName("Edm", "String")));
- functionImpl1 = new EdmFunctionImpl(provider, new FullQualifiedName("namespace", "name"), function1);
+ functionImpl1 = EdmFunctionImpl.getInstance(provider, new FullQualifiedName("namespace", "name"), function1);
Function function2 = new Function().setComposable(true);
- functionImpl2 = new EdmFunctionImpl(provider, new FullQualifiedName("namespace", "name"), function2);
+ functionImpl2 = EdmFunctionImpl.getInstance(provider, new FullQualifiedName("namespace", "name"), function2);
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportImplTest.java
index 3a98a88..f7d7e59 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportImplTest.java
@@ -69,7 +69,7 @@ public class EdmFunctionImportImplTest {
when(provider.getFunctionImport(containerName, functionImportName)).thenReturn(functionImportProvider);
final EdmFunctionImport functionImport =
- new EdmFunctionImportImpl(edm, "test", entityContainer, functionImportProvider);
+ new EdmFunctionImportImpl(edm, entityContainer, "test", functionImportProvider);
assertEquals(functionImportName, entityContainer.getFunctionImport(functionImportName).getName());
assertEquals("test", functionImport.getName());
final EdmFunction function = functionImport.getFunction(Collections.<String> emptyList());
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportInfoImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportInfoImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportInfoImplTest.java
deleted file mode 100644
index 136d38c..0000000
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmFunctionImportInfoImplTest.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.odata4.server.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmException;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.odata4.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata4.server.api.edm.provider.FunctionImport;
-import org.junit.Test;
-
-public class EdmFunctionImportInfoImplTest {
-
- @Test
- public void functionImportTest() {
- FunctionImport providerFunctionImport = new FunctionImport().setName("name");
- EntityContainer providerContainer = new EntityContainer().setName("container");
-
- EdmFunctionImportInfo info = new EdmFunctionImportInfoImpl(providerContainer, providerFunctionImport);
-
- assertEquals("name", info.getFunctionImportName());
- assertEquals("container", info.getEntityContainerName());
- }
-
- @Test(expected = EdmException.class)
- public void getUriTest() {
- FunctionImport providerFunctionImport = new FunctionImport().setName("name");
- EntityContainer providerContainer = new EntityContainer().setName("container");
-
- EdmFunctionImportInfo info = new EdmFunctionImportInfoImpl(providerContainer, providerFunctionImport);
- info.getFunctionImportUri();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmKeyPropertyRefImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmKeyPropertyRefImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmKeyPropertyRefImplTest.java
index 4a356fb..ce2e374 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmKeyPropertyRefImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmKeyPropertyRefImplTest.java
@@ -41,7 +41,7 @@ public class EdmKeyPropertyRefImplTest {
PropertyRef providerRef = new PropertyRef().setPropertyName("Id");
EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class);
- when(etMock.getProperty("Id")).thenReturn(keyPropertyMock);
+ when(etMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
assertEquals("Id", ref.getKeyPropertyName());
assertNull(ref.getAlias());
@@ -58,11 +58,11 @@ public class EdmKeyPropertyRefImplTest {
PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/Id");
EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class);
- EdmElement compMock = mock(EdmProperty.class);
+ EdmProperty compMock = mock(EdmProperty.class);
EdmComplexType compTypeMock = mock(EdmComplexType.class);
- when(compTypeMock.getProperty("Id")).thenReturn(keyPropertyMock);
+ when(compTypeMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
when(compMock.getType()).thenReturn(compTypeMock);
- when(etMock.getProperty("comp")).thenReturn(compMock);
+ when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
assertEquals("alias", ref.getAlias());
assertEquals("comp/Id", ref.getPath());
@@ -103,15 +103,15 @@ public class EdmKeyPropertyRefImplTest {
PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/comp2/Id");
EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class);
- EdmElement compMock = mock(EdmProperty.class);
+ EdmProperty compMock = mock(EdmProperty.class);
EdmComplexType compTypeMock = mock(EdmComplexType.class);
- EdmElement comp2Mock = mock(EdmProperty.class);
+ EdmProperty comp2Mock = mock(EdmProperty.class);
EdmComplexType comp2TypeMock = mock(EdmComplexType.class);
- when(comp2TypeMock.getProperty("Id")).thenReturn(keyPropertyMock);
+ when(comp2TypeMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
when(comp2Mock.getType()).thenReturn(comp2TypeMock);
- when(compTypeMock.getProperty("comp2")).thenReturn(comp2Mock);
+ when(compTypeMock.getStructuralProperty("comp2")).thenReturn(comp2Mock);
when(compMock.getType()).thenReturn(compTypeMock);
- when(etMock.getProperty("comp")).thenReturn(compMock);
+ when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
EdmProperty property = ref.getProperty();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmMemberImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmMemberImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmMemberImplTest.java
index 0f249d6..26dffae 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmMemberImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmMemberImplTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.odata4.server.core.edm.provider;
+import org.apache.olingo.odata4.commons.core.edm.EdmMemberImpl;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
@@ -29,7 +30,7 @@ public class EdmMemberImplTest {
@Test
public void enumMember() {
EnumMember member = new EnumMember().setName("name").setValue("value");
- EdmMemberImpl memberImpl = new EdmMemberImpl(mock(EdmProviderImpl.class), member);
+ EdmMemberImpl memberImpl = new EdmMemberImpl(mock(EdmProviderImpl.class), member.getName(), member.getValue());
assertEquals("name", memberImpl.getName());
assertEquals("value", memberImpl.getValue());
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmNamedImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmNamedImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmNamedImplTest.java
index a777be7..986acca 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmNamedImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmNamedImplTest.java
@@ -21,6 +21,7 @@ package org.apache.olingo.odata4.server.core.edm.provider;
import static org.junit.Assert.assertEquals;
import org.apache.olingo.odata4.commons.api.edm.EdmNamed;
+import org.apache.olingo.odata4.commons.core.edm.EdmNamedImpl;
import org.junit.Test;
public class EdmNamedImplTest {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImplTest.java
index b253c55..d87e871 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonImplTest.java
@@ -37,7 +37,7 @@ import org.apache.olingo.odata4.server.api.edm.provider.EntityType;
import org.apache.olingo.odata4.server.api.edm.provider.NavigationPropertyBinding;
import org.apache.olingo.odata4.server.api.edm.provider.PropertyRef;
import org.apache.olingo.odata4.server.api.edm.provider.Singleton;
-import org.apache.olingo.odata4.server.api.edm.provider.Target;
+import org.apache.olingo.odata4.commons.api.edm.Target;
import org.junit.Test;
public class EdmSingletonImplTest {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImplTest.java
deleted file mode 100644
index a8d6175..0000000
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmSingletonInfoImplTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.odata4.server.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmException;
-import org.apache.olingo.odata4.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.odata4.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata4.server.api.edm.provider.Singleton;
-import org.junit.Test;
-
-public class EdmSingletonInfoImplTest {
-
- @Test
- public void singletonTest() {
- Singleton providerSingleton = new Singleton().setName("name");
- EntityContainer providerContainer = new EntityContainer().setName("container");
-
- EdmSingletonInfo info = new EdmSingletonInfoImpl(providerContainer, providerSingleton);
-
- assertEquals("name", info.getSingletonName());
- assertEquals("container", info.getEntityContainerName());
- }
-
- @Test(expected = EdmException.class)
- public void getUriTest() {
- Singleton providerSingleton = new Singleton().setName("name");
- EntityContainer providerContainer = new EntityContainer().setName("container");
-
- EdmSingletonInfo info = new EdmSingletonInfoImpl(providerContainer, providerSingleton);
- info.getEntitySetUri();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImplTest.java
index 1ca05ad..2a467b2 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImplTest.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/edm/provider/EdmTypeImplTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.odata4.commons.core.edm.EdmTypeImpl;
import org.junit.Test;
public class EdmTypeImplTest {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/bae3d847/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
index acedb6f..c7b0724 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
@@ -45,7 +45,7 @@ import org.apache.olingo.odata4.server.api.edm.provider.PropertyRef;
import org.apache.olingo.odata4.server.api.edm.provider.ReferentialConstraint;
import org.apache.olingo.odata4.server.api.edm.provider.ReturnType;
import org.apache.olingo.odata4.server.api.edm.provider.Singleton;
-import org.apache.olingo.odata4.server.api.edm.provider.Target;
+import org.apache.olingo.odata4.commons.api.edm.Target;
public class EdmTechProvider extends EdmProvider {