olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From archana...@apache.org
Subject olingo-odata4 git commit: [OLINGO-1279]OData V4.0: Client returns CsdlPath for CsdlAnnotationPath attribute
Date Thu, 26 Jul 2018 11:54:26 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master a9aaa9355 -> 1da33a385


[OLINGO-1279]OData V4.0: Client returns CsdlPath for CsdlAnnotationPath attribute


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/1da33a38
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/1da33a38
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/1da33a38

Branch: refs/heads/master
Commit: 1da33a385315fef97fe6b1d3791a996fb195de3a
Parents: a9aaa93
Author: Archana Rai <archana.rai@sap.com>
Authored: Thu Jul 26 17:24:06 2018 +0530
Committer: Archana Rai <archana.rai@sap.com>
Committed: Thu Jul 26 17:24:06 2018 +0530

----------------------------------------------------------------------
 .../annotation/ClientCsdlDynamicExpression.java |  3 +-
 .../apache/olingo/client/core/MetadataTest.java | 26 ++++++++++++++
 .../client/core/edmxWithCsdlAnnotationPath.xml  | 37 ++++++++++++++++++++
 3 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1da33a38/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java
index 8e41a64..1afbca5 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.Serializable;
 
 import org.apache.olingo.client.core.edm.xml.AbstractClientCsdlEdmDeserializer;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlAnnotationPath;
 import org.apache.olingo.commons.api.edm.provider.annotation.CsdlDynamicExpression;
 import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
 import org.apache.olingo.commons.api.edm.provider.annotation.CsdlIf;
@@ -120,7 +121,7 @@ public abstract class ClientCsdlDynamicExpression extends CsdlDynamicExpression
       } else if (PROPERTY_PATH.equals(jp.getCurrentName())) {
         expression = new CsdlPropertyPath().setValue(jp.nextTextValue());
       } else if (ANNOTATION_PATH.equals(jp.getCurrentName())) {
-        expression = new CsdlPath().setValue(jp.nextTextValue());
+        expression = new CsdlAnnotationPath().setValue(jp.nextTextValue());
       } else if (APPLY.equals(jp.getCurrentName())) {
         jp.nextToken();
         expression = jp.readValueAs(ClientCsdlApply.class);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1da33a38/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
index 23ef55f..0e2dd0f 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
@@ -499,4 +499,30 @@ public class MetadataTest extends AbstractTest {
     assertEquals("Value", record.getPropertyValues().get(0).getProperty());
     assertEquals("image", record.getPropertyValues().get(0).getValue().asDynamic().asPath().getValue());
   }
+  
+  @Test
+  public void readPropertyAnnotationsTest() {
+    List<InputStream> streams = new ArrayList<InputStream>();
+    streams.add(getClass().getResourceAsStream("VOC_Core.xml"));
+    final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("edmxWithCsdlAnnotationPath.xml"),
+        streams);
+    assertNotNull(edm);
+    
+    final EdmEntityType person = edm.getEntityType(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Person"));
+    assertNotNull(person);
+    EdmProperty userName = (EdmProperty) person.getProperty("UserName");
+    List<EdmAnnotation> userNameAnnotations = userName.getAnnotations();
+    for (EdmAnnotation annotation : userNameAnnotations) {
+      EdmTerm term = annotation.getTerm();
+      assertNotNull(term);
+      assertEquals("Permissions", term.getName());
+      assertEquals("Org.OData.Core.V1.Permissions",
+          term.getFullQualifiedName().getFullQualifiedNameAsString());
+      EdmExpression expression = annotation.getExpression();
+      assertNotNull(expression);
+      assertTrue(expression.isDynamic());
+      assertEquals("AnnotationPath", expression.asDynamic().getExpressionName());
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1da33a38/lib/client-core/src/test/resources/org/apache/olingo/client/core/edmxWithCsdlAnnotationPath.xml
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/edmxWithCsdlAnnotationPath.xml
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/edmxWithCsdlAnnotationPath.xml
new file mode 100644
index 0000000..c32a843
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/edmxWithCsdlAnnotationPath.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+   <!-- 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. -->
+   <edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
+           <edmx:DataServices m:DataServiceVersion="4.0"
+                   m:MaxDataServiceVersion="4.0" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata">
+                   <Schema Namespace="Microsoft.Exchange.Services.OData.Model"
+                           xmlns="http://docs.oasis-open.org/odata/ns/edm">
+                           <EntityType Name="Person" OpenType="true">
+                                   <Key>
+                                           <PropertyRef Name="UserName" />
+                                   </Key>
+                                   <Property Name="UserName" Type="Edm.String" Nullable="false">
+                                           <Annotation Term="Org.OData.Core.V1.Permissions">
+                                                   <AnnotationPath>Org.OData.Core.V1.Permission/Read</AnnotationPath>
+                                           </Annotation>
+                                   </Property>
+                                   <Property Name="FirstName" Type="Edm.String" Nullable="false"
/>
+                                   <Property Name="LastName" Type="Edm.String" Nullable="false"
/>
+                                   <Property Name="Emails" Type="Collection(Edm.String)"
/>
+                           </EntityType>
+                                   <EntityContainer Name="EntityContainer"
+                                           m:IsDefaultEntityContainer="true">
+                                           <EntitySet Name="People"
+                                                   EntityType="Microsoft.Exchange.Services.OData.Model.Person"
/>
+                                   </EntityContainer>
+                   </Schema>
+           </edmx:DataServices>
+   </edmx:Edmx>
\ No newline at end of file


Mime
View raw message