You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/03/12 13:49:33 UTC
[3/5] git commit: [OLINGO-168] Enhance Edm for Service Document
serialization
[OLINGO-168] Enhance Edm for Service Document serialization
Also implemented a first version of the service document serializer. This
has still to be moved into the commons core.
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/44aadbd6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/44aadbd6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/44aadbd6
Branch: refs/heads/master
Commit: 44aadbd686ab9c5ece1c842d66ed9cc87c73d43e
Parents: 897db8e
Author: Christian Amend <ch...@apache.org>
Authored: Wed Mar 12 10:50:29 2014 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Wed Mar 12 10:50:29 2014 +0100
----------------------------------------------------------------------
.../olingo/client/api/edm/xml/v4/Parameter.java | 3 +
.../olingo/client/core/edm/EdmActionImpl.java | 1 -
.../olingo/client/core/edm/EdmClientImpl.java | 11 +
.../client/core/edm/EdmEntityContainerImpl.java | 118 +++++--
.../client/core/edm/EdmEntitySetImpl.java | 7 +
.../client/core/edm/EdmFunctionImportImpl.java | 30 +-
.../client/core/edm/EdmOperationImpl.java | 19 ++
.../olingo/client/core/edm/EdmSchemaImpl.java | 163 +++++++++
.../client/core/edm/v3/EdmEntitySetProxy.java | 6 +
.../core/edm/v3/EdmFunctionImportProxy.java | 13 +
.../client/core/edm/v3/EdmOperationProxy.java | 12 +
.../client/core/edm/xml/v4/ParameterImpl.java | 12 +
.../commons/api/ODataRuntimeException.java | 37 ++
.../org/apache/olingo/commons/api/edm/Edm.java | 6 +
.../commons/api/edm/EdmEntityContainer.java | 52 ++-
.../olingo/commons/api/edm/EdmEntitySet.java | 5 +
.../commons/api/edm/EdmFunctionImport.java | 10 +
.../olingo/commons/api/edm/EdmOperation.java | 10 +
.../olingo/commons/api/edm/EdmSchema.java | 70 ++++
.../commons/api/edm/FullQualifiedName.java | 26 +-
.../core/edm/AbstractEdmEntityContainer.java | 71 +++-
.../commons/core/edm/AbstractEdmImpl.java | 157 ++++++---
.../commons/core/edm/AbstractEdmSchemaImpl.java | 128 +++++++
.../commons/core/edm/EdmImplCachingTest.java | 21 ++
.../commons/core/edm/EdmImplCallCreateTest.java | 12 +
.../apache/olingo/server/api/ODataFormat.java | 23 ++
.../olingo/server/api/ODataSerializer.java | 31 ++
.../apache/olingo/server/api/ODataServer.java | 48 +++
.../server/api/edm/provider/EdmProvider.java | 8 +
lib/server-core/pom.xml | 135 ++++----
.../olingo/server/core/CircleStreamBuffer.java | 327 ++++++++++++++++++
.../olingo/server/core/ODataJsonSerializer.java | 147 ++++++++
.../olingo/server/core/ODataSerializerImpl.java | 38 +++
.../olingo/server/core/ODataServerImpl.java | 45 +++
.../core/edm/provider/EdmActionImportImpl.java | 5 +-
.../edm/provider/EdmEntityContainerImpl.java | 107 +++++-
.../core/edm/provider/EdmEntitySetImpl.java | 7 +
.../core/edm/provider/EdmEntityTypeImpl.java | 7 -
.../core/edm/provider/EdmEnumTypeImpl.java | 3 +-
.../edm/provider/EdmFunctionImportImpl.java | 31 +-
.../core/edm/provider/EdmOperationImpl.java | 36 +-
.../edm/provider/EdmOperationImportImpl.java | 23 +-
.../core/edm/provider/EdmProviderImpl.java | 54 +--
.../server/core/edm/provider/EdmSchemaImpl.java | 139 ++++++++
.../edm/provider/EdmTypeDefinitionImpl.java | 33 +-
.../olingo/server/core/ServiceDocumentTest.java | 133 ++++++++
.../edm/provider/EdmActionImportImplTest.java | 28 +-
.../provider/EdmEntityContainerImplTest.java | 138 +++++++-
.../edm/provider/EdmEntityTypeImplTest.java | 7 -
.../edm/provider/EdmFunctionImportImplTest.java | 4 +-
.../core/edm/provider/EdmSchemaImplTest.java | 337 +++++++++++++++++++
.../edm/provider/EdmTypeDefinitionImplTest.java | 3 +-
.../server/core/testutil/StringUtils.java | 52 +++
pom.xml | 2 +-
54 files changed, 2672 insertions(+), 279 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java
index 0b8b975..7c1d331 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java
@@ -21,4 +21,7 @@ package org.apache.olingo.client.api.edm.xml.v4;
public interface Parameter extends org.apache.olingo.client.api.edm.xml.CommonParameter {
String getSrid();
+
+ //TODO: Has this to be moved into CommonParameter?
+ boolean isCollection();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java
index acbfce9..8340ec6 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java
@@ -33,5 +33,4 @@ public class EdmActionImpl extends EdmOperationImpl implements EdmAction {
private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) {
super(edm, name, action, EdmTypeKind.ACTION);
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
index 332e673..62f7d36 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.client.core.edm;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -52,6 +53,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -368,4 +370,13 @@ public class EdmClientImpl extends AbstractEdmImpl {
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
}
+
+ @Override
+ protected List<EdmSchema> createSchemas() {
+ List<EdmSchema> schemas = new ArrayList<EdmSchema>();
+ for(Schema schema : xmlMetadata.getSchemas()){
+ schemas.add(new EdmSchemaImpl(this, xmlMetadata, schema));
+ }
+ return schemas;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
index fdbbed2..eeccd95 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
@@ -1,23 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.core.edm;
+import java.util.List;
+
import org.apache.olingo.client.api.UnsupportedInV3Exception;
import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
import org.apache.olingo.client.api.edm.xml.EntityContainer;
@@ -46,7 +48,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
private final XMLMetadata xmlMetadata;
public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
- final EntityContainer xmlEntityContainer, final XMLMetadata xmlMetadata) {
+ final EntityContainer xmlEntityContainer, final XMLMetadata xmlMetadata) {
super(edm, entityContainerName);
@@ -61,13 +63,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
final Singleton singleton = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
- getSingleton(singletonName);
+ getSingleton(singletonName);
if (singleton == null) {
throw new EdmException("Singleton named '" + singletonName + "' not found in " + entityContainerName);
}
return new EdmSingletonImpl(edm, this, singletonName,
- new EdmTypeInfo(singleton.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
- singleton);
+ new EdmTypeInfo(singleton.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ singleton);
}
@Override
@@ -79,21 +81,20 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) {
return new EdmEntitySetImpl(edm, this, entitySetName,
- new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
- (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
+ new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
} else {
return new EdmEntitySetProxy(edm, this, entitySetName,
- new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
- xmlMetadata);
+ new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ xmlMetadata);
}
}
@Override
protected EdmActionImport createActionImport(final String actionImportName) {
if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) {
- final ActionImport actionImport
- = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
- getActionImport(actionImportName);
+ final ActionImport actionImport = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).
+ getActionImport(actionImportName);
if (actionImport == null) {
throw new EdmException("ActionImport named '" + actionImportName + "' not found in " + entityContainerName);
}
@@ -116,10 +117,89 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) {
return new EdmFunctionImportImpl(edm, this, functionImportName,
- (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
+ (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
} else {
return new EdmFunctionImportProxy(edm, this, functionImportName,
+ (org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
+ }
+ }
+
+ @Override
+ protected void loadAllEntitySets() {
+ List<? extends EntitySet> localEntitySets = xmlEntityContainer.getEntitySets();
+ if (localEntitySets != null) {
+ for (EntitySet entitySet : localEntitySets) {
+ EdmEntitySet edmSet;
+ if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) {
+ edmSet = new EdmEntitySetImpl(edm, this, entitySet.getName(),
+ new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet);
+ } else {
+ edmSet = new EdmEntitySetProxy(edm, this, entitySet.getName(),
+ new EdmTypeInfo(entitySet.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ xmlMetadata);
+ }
+ entitySets.put(edmSet.getName(), edmSet);
+ }
+ }
+
+ }
+
+ @Override
+ protected void loadAllFunctionImports() {
+ List<? extends CommonFunctionImport> localFunctionImports = xmlEntityContainer.getFunctionImports();
+ if (localFunctionImports != null) {
+ for (CommonFunctionImport functionImport : localFunctionImports) {
+ EdmFunctionImport edmFunctionImport;
+ if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) {
+ edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(),
+ (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport);
+ } else {
+ edmFunctionImport = new EdmFunctionImportProxy(edm, this, functionImport.getName(),
(org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport);
+ }
+ functionImports.put(edmFunctionImport.getName(), edmFunctionImport);
+ }
+ }
+ }
+
+ @Override
+ protected void loadAllSingletons() {
+ if (!(xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer)) {
+ throw new UnsupportedInV3Exception();
+ }
+
+ List<Singleton> localSingletons =
+ ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getSingletons();
+ if (localSingletons != null) {
+ for (Singleton singleton : localSingletons) {
+ singletons.put(singleton.getName(), new EdmSingletonImpl(edm, this, singleton.getName(),
+ new EdmTypeInfo(singleton.getEntityType(), entityContainerName.getNamespace()).getFullQualifiedName(),
+ singleton));
+ }
+ }
+ }
+
+ @Override
+ protected void loadAllActionImports() {
+ if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) {
+ List<ActionImport> localActionImports =
+ ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getActionImports();
+ if (actionImports != null) {
+ for (ActionImport actionImport : localActionImports) {
+ actionImports.put(actionImport.getName(), new EdmActionImportImpl(edm, this, actionImport.getName(),
+ actionImport));
+ }
+ }
+ } else {
+ @SuppressWarnings("unchecked")
+ List<FunctionImport> localFunctionImports = (List<FunctionImport>) xmlEntityContainer.getFunctionImports();
+ if (localFunctionImports != null) {
+ for (FunctionImport functionImport : localFunctionImports) {
+ actionImports.put(functionImport.getName(), new EdmActionImportProxy(edm, this, functionImport.getName(),
+ functionImport));
+ }
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java
index 3708a45..ec9af77 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java
@@ -26,10 +26,17 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
+ private EntitySet entitySet;
+
public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final String name,
final FullQualifiedName type, final EntitySet entitySet) {
super(edm, container, name, type, entitySet);
+ this.entitySet = entitySet;
}
+ @Override
+ public boolean isIncludeInServiceDocument() {
+ return entitySet.isIncludeInServiceDocument();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
index d3004cb..edc1861 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -26,13 +26,14 @@ import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport {
private final FunctionImport functionImport;
public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final String name,
- final FunctionImport functionImport) {
+ final FunctionImport functionImport) {
super(edm, container, name, functionImport.getEntitySet());
this.functionImport = functionImport;
@@ -41,8 +42,17 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm
@Override
public EdmFunction getFunction(final List<String> parameterNames) {
return edm.getFunction(
- new EdmTypeInfo(functionImport.getFunction(), container.getNamespace()).getFullQualifiedName(),
- null, null, parameterNames);
+ new EdmTypeInfo(functionImport.getFunction(), container.getNamespace()).getFullQualifiedName(),
+ null, null, parameterNames);
}
+ @Override
+ public boolean isIncludeInServiceDocument() {
+ return functionImport.isIncludeInServiceDocument();
+ }
+
+ @Override
+ public FullQualifiedName getFunctionFqn() {
+ return new FullQualifiedName(functionImport.getFunction());
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java
index 67f9e94..667dafe 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.client.api.edm.xml.CommonParameter;
+import org.apache.olingo.client.api.edm.xml.v4.Parameter;
import org.apache.olingo.client.api.edm.xml.v4.Action;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmParameter;
@@ -58,4 +59,22 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation {
super(edm, name, kind);
this.operation = operation;
}
+
+ @Override
+ public FullQualifiedName getBindingParameterTypeFqn() {
+ if (isBound()) {
+ Parameter bindingParameter = operation.getParameters().get(0);
+ return new FullQualifiedName(getNamespace(), bindingParameter.getName());
+ }
+ return null;
+ }
+
+ @Override
+ public Boolean isBindingParameterTypeCollection() {
+ if (isBound()) {
+ Parameter bindingParameter = operation.getParameters().get(0);
+ return bindingParameter.isCollection();
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
new file mode 100644
index 0000000..40f31b7
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.client.api.edm.xml.ComplexType;
+import org.apache.olingo.client.api.edm.xml.EntityContainer;
+import org.apache.olingo.client.api.edm.xml.EntityType;
+import org.apache.olingo.client.api.edm.xml.EnumType;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
+import org.apache.olingo.client.api.edm.xml.v4.Action;
+import org.apache.olingo.client.api.edm.xml.v4.Function;
+import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition;
+import org.apache.olingo.client.core.edm.v3.EdmFunctionProxy;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.core.edm.AbstractEdmSchemaImpl;
+
+public class EdmSchemaImpl extends AbstractEdmSchemaImpl {
+
+ private final Edm edm;
+ private final XMLMetadata xmlMetadata;
+ private final Schema schema;
+
+ public EdmSchemaImpl(Edm edm, XMLMetadata xmlMetadata, Schema schema) {
+ super(schema.getNamespace(), schema.getAlias());
+ this.edm = edm;
+ this.xmlMetadata = xmlMetadata;
+ this.schema = schema;
+ }
+
+ @Override
+ protected EdmEntityContainer createEntityContainer() {
+ EntityContainer defaultContainer = schema.getDefaultEntityContainer();
+ if (defaultContainer != null) {
+ FullQualifiedName entityContainerName = new FullQualifiedName(schema.getNamespace(), defaultContainer.getName());
+ return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer, xmlMetadata);
+ }
+ return null;
+ }
+
+ @Override
+ protected List<EdmTypeDefinition> createTypeDefinitions() {
+ List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>();
+ if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ List<TypeDefinition> providerTypeDefinitions =
+ ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTypeDefinitions();
+ if (providerTypeDefinitions != null) {
+ for (TypeDefinition def : providerTypeDefinitions) {
+ typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName("namespace", def.getName()), def));
+ }
+ }
+ }
+ return typeDefinitions;
+ }
+
+ @Override
+ protected List<EdmEnumType> createEnumTypes() {
+ List<EdmEnumType> enumTypes = new ArrayList<EdmEnumType>();
+ List<EnumType> providerEnumTypes = schema.getEnumTypes();
+ if (providerEnumTypes != null) {
+ for (EnumType enumType : providerEnumTypes) {
+ enumTypes.add(new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()), enumType));
+ }
+ }
+ return enumTypes;
+ }
+
+ @Override
+ protected List<EdmEntityType> createEntityTypes() {
+ List<EdmEntityType> entityTypes = new ArrayList<EdmEntityType>();
+ List<? extends EntityType> providerEntityTypes = schema.getEntityTypes();
+ if (providerEntityTypes != null) {
+ for (EntityType entityType : providerEntityTypes) {
+ entityTypes.add(EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName(namespace, entityType.getName()),
+ entityType));
+ }
+ }
+ return entityTypes;
+ }
+
+ @Override
+ protected List<EdmComplexType> createComplexTypes() {
+ List<EdmComplexType> complexTypes = new ArrayList<EdmComplexType>();
+ List<? extends ComplexType> providerComplexTypes = schema.getComplexTypes();
+ if (providerComplexTypes != null) {
+ for (ComplexType complexType : providerComplexTypes) {
+ complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()),
+ complexType));
+ }
+ }
+ return complexTypes;
+ }
+
+ @Override
+ protected List<EdmAction> createActions() {
+ List<EdmAction> actions = new ArrayList<EdmAction>();
+ if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ List<Action> providerActions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getActions();
+ if (providerActions != null) {
+ for (Action action : providerActions) {
+ actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action));
+ }
+ }
+ }
+ return actions;
+ }
+
+ @Override
+ protected List<EdmFunction> createFunctions() {
+ List<EdmFunction> functions = new ArrayList<EdmFunction>();
+ if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) {
+ List<Function> providerFunctions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getFunctions();
+ if (providerFunctions != null) {
+ for (Function function : providerFunctions) {
+ functions.add(
+ EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
+ }
+ return functions;
+ }
+ } else {
+ for (EntityContainer providerContainer : schema.getEntityContainers()) {
+ @SuppressWarnings("unchecked")
+ List<FunctionImport> providerFunctions = (List<FunctionImport>) providerContainer.getFunctionImports();
+ if (providerFunctions != null) {
+ for (FunctionImport function : providerFunctions) {
+ functions.add(
+ EdmFunctionProxy.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
+ }
+ }
+
+ }
+ }
+ return functions;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java
index d3e0312..0cc0ff8 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java
@@ -99,4 +99,10 @@ public class EdmEntitySetProxy extends AbstractEdmBindingTarget implements EdmEn
return entityContainer.getEntitySet(targetEntitySet);
}
+ @Override
+ public boolean isIncludeInServiceDocument() {
+ //V3 states that all entity sets are included in the service document
+ return true;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
index c7d1de2..077c753 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java
@@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
public class EdmFunctionImportProxy extends EdmOperationImportImpl implements EdmFunctionImport {
@@ -45,4 +46,16 @@ public class EdmFunctionImportProxy extends EdmOperationImportImpl implements Ed
new EdmTypeInfo(functionImport.getName(), container.getNamespace()).getFullQualifiedName(),
null, null, parameterNames);
}
+
+ @Override
+ public boolean isIncludeInServiceDocument() {
+ //V3 states that all function imports are included in the service document
+ return true;
+ }
+
+ @Override
+ public FullQualifiedName getFunctionFqn() {
+ //TODO: Is this right for V3?
+ return new FullQualifiedName(container.getNamespace(), getName());
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java
index 2876bb2..353e916 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java
@@ -62,4 +62,16 @@ public class EdmOperationProxy extends AbstractEdmOperation {
this.functionImport = functionImport;
}
+ @Override
+ public FullQualifiedName getBindingParameterTypeFqn() {
+ //Not relevant for V3
+ return null;
+ }
+
+ @Override
+ public Boolean isBindingParameterTypeCollection() {
+ //Not relevant for V3
+ return null;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java
index 990cef0..be93eb9 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java
@@ -26,6 +26,8 @@ public class ParameterImpl extends AbstractParameter implements Parameter {
private static final long serialVersionUID = -1067642515116697747L;
private String srid;
+
+ private boolean isCollection;
@Override
public String getSrid() {
@@ -36,4 +38,14 @@ public class ParameterImpl extends AbstractParameter implements Parameter {
this.srid = srid;
}
+ //TODO: fill during metadata parsing
+ @Override
+ public boolean isCollection() {
+ return isCollection;
+ }
+
+ public void setCollection(boolean isCollection) {
+ this.isCollection = isCollection;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java
new file mode 100644
index 0000000..849e509
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.commons.api;
+
+public class ODataRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ODataRuntimeException(String msg) {
+ super(msg);
+ }
+
+ public ODataRuntimeException(String msg, Exception e) {
+ super(msg, e);
+ }
+
+ public ODataRuntimeException(Exception e) {
+ super(e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
index d9ee17b..c7aeff0 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
@@ -26,6 +26,12 @@ import java.util.List;
* Interface representing a Entity Data Model as described in the Conceptual Schema Definition.
*/
public interface Edm {
+
+ /**
+ * This method DOES NOT support lazy loading. All schemas are loaded completely!
+ * @return all schemas defined for this EDM
+ */
+ List<EdmSchema> getSchemas();
/**
* Get entity container by full qualified name.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java
index d30d700..00afbc8 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java
@@ -1,26 +1,28 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.edm;
+import java.util.List;
+
/**
* A CSDL EntityContainer element.
- *
+ *
* <br/>
* EdmEntityContainer hold the information of EntitySets, Singletons, ActionImports and FunctionImports contained
*/
@@ -33,7 +35,7 @@ public interface EdmEntityContainer extends EdmNamed {
/**
* Get contained Singleton by name.
- *
+ *
* @param name
* @return {@link EdmSingleton}
*/
@@ -41,7 +43,7 @@ public interface EdmEntityContainer extends EdmNamed {
/**
* Get contained EntitySet by name.
- *
+ *
* @param name
* @return {@link EdmEntitySet}
*/
@@ -49,7 +51,7 @@ public interface EdmEntityContainer extends EdmNamed {
/**
* Get contained ActionImport by name.
- *
+ *
* @param name
* @return {@link EdmActionImport}
*/
@@ -57,10 +59,34 @@ public interface EdmEntityContainer extends EdmNamed {
/**
* Get contained FunctionImport by name.
- *
+ *
* @param name
* @return {@link EdmFunctionImport}
*/
EdmFunctionImport getFunctionImport(String name);
+ /**
+ * This method <b>DOES NOT</b> support lazy loading
+ * @return returns all entity sets for this container.
+ */
+ List<EdmEntitySet> getEntitySets();
+
+ /**
+ * This method <b>DOES NOT</b> support lazy loading
+ * @return returns all function imports for this container.
+ */
+ List<EdmFunctionImport> getFunctionImports();
+
+ /**
+ * This method <b>DOES NOT</b> support lazy loading
+ * @return returns all singletons for this container.
+ */
+ List<EdmSingleton> getSingletons();
+
+ /**
+ * This method <b>DOES NOT</b> support lazy loading
+ * @return returns all action imports for this container.
+ */
+ List<EdmActionImport> getActionImports();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntitySet.java
index 3e7b66f..d75e564 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntitySet.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntitySet.java
@@ -26,4 +26,9 @@ package org.apache.olingo.commons.api.edm;
*/
public interface EdmEntitySet extends EdmBindingTarget {
+ /**
+ * @return true if entity set must be included in the service document
+ */
+ boolean isIncludeInServiceDocument();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmFunctionImport.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmFunctionImport.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmFunctionImport.java
index 31b1c2c..96c6678 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmFunctionImport.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmFunctionImport.java
@@ -26,5 +26,15 @@ import java.util.List;
public interface EdmFunctionImport extends EdmOperationImport {
EdmFunction getFunction(List<String> parameterNames);
+
+ /**
+ * @return the Fullqualified name for the function as specified in the metadata
+ */
+ FullQualifiedName getFunctionFqn();
+
+ /**
+ * @return true if the function import must be included in the service document
+ */
+ boolean isIncludeInServiceDocument();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
index c653411..28c1985 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
@@ -54,4 +54,14 @@ public interface EdmOperation extends EdmType {
*/
boolean isBound();
+ /**
+ * @return the fullqualified type name of the binding parameter
+ */
+ FullQualifiedName getBindingParameterTypeFqn();
+
+ /**
+ * @return true if binding parameter is of type collection.
+ */
+ Boolean isBindingParameterTypeCollection();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
new file mode 100644
index 0000000..d5c8a2d
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
@@ -0,0 +1,70 @@
+/*
+ * 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.commons.api.edm;
+
+import java.util.List;
+
+/**
+ * A csdl schema element
+ */
+public interface EdmSchema {
+
+ /**
+ * @return the namespace for this schema
+ */
+ String getNamespace();
+
+ /**
+ * @return the alias for this schema. May be null.
+ */
+ String getAlias();
+
+ /**
+ * @return all enum types for this schema
+ */
+ List<EdmEnumType> getEnumTypes();
+
+ /**
+ * @return all entity types for this schema
+ */
+ List<EdmEntityType> getEntityTypes();
+
+ /**
+ * @return all complex types for this schema
+ */
+ List<EdmComplexType> getComplexTypes();
+
+ /**
+ * @return all actions for this schema
+ */
+ List<EdmAction> getActions();
+
+ /**
+ * @return all functions for this schema
+ */
+ List<EdmFunction> getFunctions();
+
+ /**
+ * @return the entity container for this schema. May be null.
+ */
+ EdmEntityContainer getEntityContainer();
+
+ List<EdmTypeDefinition> getTypeDefinitions();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
index f993c23..a439e72 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/FullQualifiedName.java
@@ -1,18 +1,18 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -40,6 +40,16 @@ public class FullQualifiedName {
}
/**
+ * @param namespace.name
+ */
+ public FullQualifiedName(final String namespaceAndName) {
+ fqn = namespaceAndName;
+ String[] split = namespaceAndName.split(".");
+ namespace = split[0];
+ name = split[1];
+ }
+
+ /**
* @return namespace
*/
public String getNamespace() {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java
index 5d108cb..aba62ba 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java
@@ -1,24 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.core.edm;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.edm.Edm;
@@ -33,13 +35,17 @@ public abstract class AbstractEdmEntityContainer extends EdmNamedImpl implements
protected final FullQualifiedName entityContainerName;
- private final Map<String, EdmSingleton> singletons = new HashMap<String, EdmSingleton>();
+ protected final Map<String, EdmSingleton> singletons = new HashMap<String, EdmSingleton>();
+ private boolean allSingletonsLoaded = false;
- private final Map<String, EdmEntitySet> entitySets = new HashMap<String, EdmEntitySet>();
+ protected final Map<String, EdmEntitySet> entitySets = new HashMap<String, EdmEntitySet>();
+ private boolean allEntitySetsLoaded = false;
- private final Map<String, EdmActionImport> actionImports = new HashMap<String, EdmActionImport>();
+ protected final Map<String, EdmActionImport> actionImports = new HashMap<String, EdmActionImport>();
+ private boolean allActionImportsLoaded = false;
- private final Map<String, EdmFunctionImport> functionImports = new HashMap<String, EdmFunctionImport>();
+ protected final Map<String, EdmFunctionImport> functionImports = new HashMap<String, EdmFunctionImport>();
+ private boolean allFunctionImportsLoaded = false;
public AbstractEdmEntityContainer(final Edm edm, final FullQualifiedName entityContainerName) {
super(edm, entityContainerName.getName());
@@ -99,4 +105,47 @@ public abstract class AbstractEdmEntityContainer extends EdmNamedImpl implements
return functionImport;
}
+ @Override
+ public List<EdmEntitySet> getEntitySets() {
+ if (!allEntitySetsLoaded) {
+ loadAllEntitySets();
+ allEntitySetsLoaded = true;
+ }
+ return new ArrayList<EdmEntitySet>(entitySets.values());
+ }
+
+ protected abstract void loadAllEntitySets();
+
+ @Override
+ public List<EdmFunctionImport> getFunctionImports() {
+ if (!allFunctionImportsLoaded) {
+ loadAllFunctionImports();
+ allFunctionImportsLoaded = true;
+ }
+ return new ArrayList<EdmFunctionImport>(functionImports.values());
+ }
+
+ protected abstract void loadAllFunctionImports();
+
+ @Override
+ public List<EdmSingleton> getSingletons() {
+ if (!allSingletonsLoaded) {
+ loadAllSingletons();
+ allSingletonsLoaded = true;
+ }
+ return new ArrayList<EdmSingleton>(singletons.values());
+ }
+
+ protected abstract void loadAllSingletons();
+
+ @Override
+ public List<EdmActionImport> getActionImports() {
+ if (!allActionImportsLoaded) {
+ loadAllActionImports();
+ allActionImportsLoaded = true;
+ }
+ return new ArrayList<EdmActionImport>(actionImports.values());
+ }
+
+ protected abstract void loadAllActionImports();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmImpl.java
index 9890dac..b4c99d8 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmImpl.java
@@ -1,18 +1,18 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -29,43 +29,121 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
public abstract class AbstractEdmImpl implements Edm {
- private final Map<FullQualifiedName, EdmEntityContainer> entityContainers
- = new HashMap<FullQualifiedName, EdmEntityContainer>();
+ private final Map<FullQualifiedName, EdmEntityContainer> entityContainers =
+ new HashMap<FullQualifiedName, EdmEntityContainer>();
- private final Map<FullQualifiedName, EdmEnumType> enumTypes
- = new HashMap<FullQualifiedName, EdmEnumType>();
+ private final Map<FullQualifiedName, EdmEnumType> enumTypes = new HashMap<FullQualifiedName, EdmEnumType>();
- private final Map<FullQualifiedName, EdmTypeDefinition> typeDefinitions
- = new HashMap<FullQualifiedName, EdmTypeDefinition>();
+ private final Map<FullQualifiedName, EdmTypeDefinition> typeDefinitions =
+ new HashMap<FullQualifiedName, EdmTypeDefinition>();
- private final Map<FullQualifiedName, EdmEntityType> entityTypes
- = new HashMap<FullQualifiedName, EdmEntityType>();
+ private final Map<FullQualifiedName, EdmEntityType> entityTypes = new HashMap<FullQualifiedName, EdmEntityType>();
- private final Map<FullQualifiedName, EdmComplexType> complexTypes
- = new HashMap<FullQualifiedName, EdmComplexType>();
+ private final Map<FullQualifiedName, EdmComplexType> complexTypes = new HashMap<FullQualifiedName, EdmComplexType>();
- private final Map<FullQualifiedName, EdmAction> unboundActions
- = new HashMap<FullQualifiedName, EdmAction>();
+ private final Map<FullQualifiedName, EdmAction> unboundActions = new HashMap<FullQualifiedName, EdmAction>();
- private final Map<FunctionMapKey, EdmFunction> unboundFunctions
- = new HashMap<FunctionMapKey, EdmFunction>();
+ private final Map<FunctionMapKey, EdmFunction> unboundFunctions = new HashMap<FunctionMapKey, EdmFunction>();
- private final Map<ActionMapKey, EdmAction> boundActions
- = new HashMap<ActionMapKey, EdmAction>();
+ private final Map<ActionMapKey, EdmAction> boundActions = new HashMap<ActionMapKey, EdmAction>();
- private final Map<FunctionMapKey, EdmFunction> boundFunctions
- = new HashMap<FunctionMapKey, EdmFunction>();
+ private final Map<FunctionMapKey, EdmFunction> boundFunctions = new HashMap<FunctionMapKey, EdmFunction>();
private EdmServiceMetadata serviceMetadata;
private Map<String, String> aliasToNamespaceInfo;
-
+
+ private List<EdmSchema> schemas;
+
+ @Override
+ public List<EdmSchema> getSchemas() {
+ if (schemas == null) {
+ schemas = createSchemas();
+ if (schemas != null) {
+ aliasToNamespaceInfo = new HashMap<String, String>();
+ for (EdmSchema schema : schemas) {
+ String namespace = schema.getNamespace();
+ if (schema.getAlias() != null) {
+ aliasToNamespaceInfo.put(schema.getAlias(), namespace);
+ }
+
+ List<EdmEnumType> localEnumTypes = schema.getEnumTypes();
+ if (localEnumTypes != null) {
+ for (EdmEnumType enumType : localEnumTypes) {
+ enumTypes.put(new FullQualifiedName(namespace, enumType.getName()), enumType);
+ }
+ }
+
+ List<EdmTypeDefinition> localTypeDefinitions = schema.getTypeDefinitions();
+ if (localTypeDefinitions != null) {
+ for (EdmTypeDefinition typeDef : localTypeDefinitions) {
+ typeDefinitions.put(new FullQualifiedName(namespace, typeDef.getName()), typeDef);
+ }
+ }
+
+ List<EdmComplexType> localComplexTypes = schema.getComplexTypes();
+ if (localComplexTypes != null) {
+ for (EdmComplexType complexType : localComplexTypes) {
+ complexTypes.put(new FullQualifiedName(namespace, complexType.getName()), complexType);
+ }
+ }
+
+ List<EdmEntityType> localEntityTypes = schema.getEntityTypes();
+ if (localEntityTypes != null) {
+ for (EdmEntityType entityType : localEntityTypes) {
+ entityTypes.put(new FullQualifiedName(namespace, entityType.getName()), entityType);
+ }
+ }
+
+ List<EdmAction> localActions = schema.getActions();
+ if (localActions != null) {
+ for (EdmAction action : localActions) {
+ if (action.isBound()) {
+ ActionMapKey key = new ActionMapKey(new FullQualifiedName(namespace, action.getName()),
+ action.getBindingParameterTypeFqn(), action.isBindingParameterTypeCollection());
+ boundActions.put(key, action);
+ } else {
+ unboundActions.put(new FullQualifiedName(namespace, action.getName()), action);
+ }
+ }
+ }
+
+ List<EdmFunction> localFunctions = schema.getFunctions();
+ if (localFunctions != null) {
+ for (EdmFunction function : localFunctions) {
+ FunctionMapKey key =
+ new FunctionMapKey(new FullQualifiedName(namespace, function.getName()), function
+ .getBindingParameterTypeFqn(), function.isBindingParameterTypeCollection(), function
+ .getParameterNames());
+
+ if (function.isBound()) {
+ boundFunctions.put(key, function);
+ } else {
+ unboundFunctions.put(key, function);
+ }
+ }
+ }
+
+ EdmEntityContainer entityContainer = schema.getEntityContainer();
+ if(entityContainer != null){
+ entityContainers.put(new FullQualifiedName(namespace, entityContainer.getName()), entityContainer);
+ if(!entityContainers.containsKey(null)){
+ entityContainers.put(null, entityContainer);
+ }
+ }
+ }
+ }
+ }
+ return schemas;
+ }
+
@Override
public EdmEntityContainer getEntityContainer(final FullQualifiedName namespaceOrAliasFQN) {
final FullQualifiedName fqn = resolvePossibleAlias(namespaceOrAliasFQN);
@@ -136,7 +214,7 @@ public abstract class AbstractEdmImpl implements Edm {
@Override
public EdmAction getAction(final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName,
- final Boolean isBindingParameterCollection) {
+ final Boolean isBindingParameterCollection) {
EdmAction action = null;
@@ -166,15 +244,15 @@ public abstract class AbstractEdmImpl implements Edm {
@Override
public EdmFunction getFunction(final FullQualifiedName functionName,
- final FullQualifiedName bindingParameterTypeName,
- final Boolean isBindingParameterCollection, final List<String> parameterNames) {
+ final FullQualifiedName bindingParameterTypeName,
+ final Boolean isBindingParameterCollection, final List<String> parameterNames) {
EdmFunction function = null;
final FullQualifiedName functionFqn = resolvePossibleAlias(functionName);
if (bindingParameterTypeName == null) {
final FunctionMapKey key = new FunctionMapKey(
- functionFqn, bindingParameterTypeName, isBindingParameterCollection, parameterNames);
+ functionFqn, bindingParameterTypeName, isBindingParameterCollection, parameterNames);
function = unboundFunctions.get(key);
if (function == null) {
function = createUnboundFunction(functionFqn, parameterNames);
@@ -184,12 +262,12 @@ public abstract class AbstractEdmImpl implements Edm {
}
} else {
final FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
- final FunctionMapKey key
- = new FunctionMapKey(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection, parameterNames);
+ final FunctionMapKey key =
+ new FunctionMapKey(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection, parameterNames);
function = boundFunctions.get(key);
if (function == null) {
function = createBoundFunction(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection,
- parameterNames);
+ parameterNames);
if (function != null) {
boundFunctions.put(key, function);
}
@@ -241,12 +319,15 @@ public abstract class AbstractEdmImpl implements Edm {
protected abstract EdmFunction createUnboundFunction(FullQualifiedName functionName, List<String> parameterNames);
protected abstract EdmAction createBoundAction(FullQualifiedName actionName,
- FullQualifiedName bindingParameterTypeName,
- Boolean isBindingParameterCollection);
+ FullQualifiedName bindingParameterTypeName,
+ Boolean isBindingParameterCollection);
protected abstract EdmFunction createBoundFunction(FullQualifiedName functionName,
- FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
- List<String> parameterNames);
+ FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
+ List<String> parameterNames);
protected abstract EdmServiceMetadata createServiceMetadata();
+
+ protected abstract List<EdmSchema> createSchemas();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchemaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchemaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchemaImpl.java
new file mode 100644
index 0000000..1346054
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchemaImpl.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.edm;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+
+public abstract class AbstractEdmSchemaImpl implements EdmSchema {
+
+ protected final String namespace;
+ private final String alias;
+ private List<EdmTypeDefinition> typeDefinitions;
+ private List<EdmEnumType> enumTypes;
+ private List<EdmEntityType> entityTypes;
+ private List<EdmComplexType> complexTypes;
+ private List<EdmAction> actions;
+ private List<EdmFunction> functions;
+ private EdmEntityContainer entityContainer;
+
+ public AbstractEdmSchemaImpl(String namespace, String alias) {
+ this.namespace = namespace;
+ this.alias = alias;
+ }
+
+ protected abstract EdmEntityContainer createEntityContainer();
+
+ protected abstract List<EdmTypeDefinition> createTypeDefinitions();
+
+ protected abstract List<EdmEnumType> createEnumTypes();
+
+ protected abstract List<EdmEntityType> createEntityTypes();
+
+ protected abstract List<EdmComplexType> createComplexTypes();
+
+ protected abstract List<EdmAction> createActions();
+
+ protected abstract List<EdmFunction> createFunctions();
+
+ @Override
+ public List<EdmTypeDefinition> getTypeDefinitions() {
+ if (typeDefinitions == null) {
+ typeDefinitions = createTypeDefinitions();
+ }
+ return typeDefinitions;
+ }
+
+ @Override
+ public List<EdmEnumType> getEnumTypes() {
+ if (enumTypes == null) {
+ enumTypes = createEnumTypes();
+ }
+ return enumTypes;
+ }
+
+ @Override
+ public List<EdmEntityType> getEntityTypes() {
+ if (entityTypes == null) {
+ entityTypes = createEntityTypes();
+ }
+ return entityTypes;
+ }
+
+ @Override
+ public List<EdmComplexType> getComplexTypes() {
+ if (complexTypes == null) {
+ complexTypes = createComplexTypes();
+ }
+ return complexTypes;
+ }
+
+ @Override
+ public List<EdmAction> getActions() {
+ if (actions == null) {
+ actions = createActions();
+ }
+ return actions;
+ }
+
+ @Override
+ public List<EdmFunction> getFunctions() {
+ if (functions == null) {
+ functions = createFunctions();
+ }
+ return functions;
+ }
+
+ @Override
+ public EdmEntityContainer getEntityContainer() {
+ if (entityContainer == null) {
+ entityContainer = createEntityContainer();
+ }
+ return entityContainer;
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public String getAlias() {
+ return alias;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
index 00c8259..4eba1db 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
@@ -37,6 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -53,6 +54,18 @@ public class EdmImplCachingTest {
private Edm edm;
@Test
+ public void cacheSchema() {
+ List<EdmSchema> schemas = edm.getSchemas();
+ assertNotNull(schemas);
+
+ assertEquals(1, schemas.size());
+
+ List<EdmSchema> cachedSchemas = edm.getSchemas();
+ assertTrue(schemas == cachedSchemas );
+ assertEquals(schemas, schemas);
+ }
+
+ @Test
public void cacheEntityContainer() {
EdmEntityContainer entityContainer = edm.getEntityContainer(null);
assertNotNull(entityContainer);
@@ -385,5 +398,13 @@ public class EdmImplCachingTest {
}
return null;
}
+
+ @Override
+ public List<EdmSchema> createSchemas() {
+ List<EdmSchema> schemas = new ArrayList<EdmSchema>();
+ EdmSchema schema = mock(EdmSchema.class);
+ schemas.add(schema);
+ return schemas;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
index c908419..71e1acd 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
@@ -37,6 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -53,6 +54,12 @@ public class EdmImplCallCreateTest {
private Edm edm;
@Test
+ public void callCreateSchemas() {
+ List<EdmSchema> schemas = edm.getSchemas();
+ assertNotNull(schemas);
+ }
+
+ @Test
public void callCreateEntityContainer() {
EdmEntityContainer entityContainer = edm.getEntityContainer(FQN);
assertNotNull(entityContainer);
@@ -264,5 +271,10 @@ public class EdmImplCallCreateTest {
}
return null;
}
+
+ @Override
+ public List<EdmSchema> createSchemas() {
+ return new ArrayList<EdmSchema>();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataFormat.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataFormat.java
new file mode 100644
index 0000000..f3d4bf3
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataFormat.java
@@ -0,0 +1,23 @@
+/*
+ * 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.server.api;
+
+public enum ODataFormat {
+ XML, JSON
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataSerializer.java
new file mode 100644
index 0000000..a6cfe5d
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataSerializer.java
@@ -0,0 +1,31 @@
+/*
+ * 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.server.api;
+
+import java.io.InputStream;
+
+import org.apache.olingo.commons.api.edm.Edm;
+
+public interface ODataSerializer {
+
+ InputStream metadata(Edm edm);
+
+ InputStream serviceDocument(Edm edm, String serviceRoot);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
new file mode 100644
index 0000000..83d20fa
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api;
+
+import org.apache.olingo.commons.api.ODataRuntimeException;
+
+
+public abstract class ODataServer {
+
+ private static final String IMPLEMENTATION = "org.apache.olingo.server.core.ODataServerImpl";
+
+ public static ODataServer newInstance(){
+ try {
+ final Class<?> clazz = Class.forName(ODataServer.IMPLEMENTATION);
+
+ /*
+ * We explicitly do not use the singleton pattern to keep the server state free
+ * and avoid class loading issues also during hot deployment.
+ */
+ final Object object = clazz.newInstance();
+ return (ODataServer) object;
+
+ } catch (final Exception e) {
+ //TODO: Change to ODataRuntimeExcfeption
+ throw new ODataRuntimeException(e);
+ }
+ }
+
+
+ public abstract ODataSerializer getSerializer(ODataFormat format);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EdmProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EdmProvider.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EdmProvider.java
index ae58c52..a2a78a3 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EdmProvider.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EdmProvider.java
@@ -179,4 +179,12 @@ public abstract class EdmProvider {
public List<Schema> getSchemas() throws ODataException {
return null;
}
+
+ /**
+ * Returns the entity container of this edm
+ * @return {@link EntityContainer} of this edm
+ */
+ public EntityContainer getEntityContainer() throws ODataException {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/44aadbd6/lib/server-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml
index 5f30cf5..bffe70b 100644
--- a/lib/server-core/pom.xml
+++ b/lib/server-core/pom.xml
@@ -10,75 +10,84 @@
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>olingo-server-core-incubating</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
+ <artifactId>olingo-server-core-incubating</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-lib-incubating</artifactId>
- <version>0.1.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-lib-incubating</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-server-api-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-commons-core-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-server-api-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-commons-core-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.6</version>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>false</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-maven-plugin</artifactId>
- <version>${antlr.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>antlr4</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>${antlr.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
<!--<arguments><argument>-atn</argument></arguments> -->
- <listener>true</listener>
- <visitor>true</visitor>
+ <listener>true</listener>
+ <visitor>true</visitor>
<!--maven antlr plugin has trouble with grammer import if the grammerfiles
are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
- <libDirectory>src/main/antlr4/org/apache/olingo/server/core/uri/antlr</libDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <libDirectory>src/main/antlr4/org/apache/olingo/server/core/uri/antlr</libDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>