olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject [3/3] olingo-odata4 git commit: [OLINGO-786] Fix alias usage in metadata for annotations
Date Tue, 20 Oct 2015 13:52:52 GMT
[OLINGO-786] Fix alias usage in metadata for annotations


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

Branch: refs/heads/olingo786
Commit: 15164da8f1133a571481cd0d9db77c269c8e9fa1
Parents: d00e388
Author: Christian Amend <christian.amend@sap.com>
Authored: Tue Oct 20 15:51:40 2015 +0200
Committer: Christian Amend <christian.amend@sap.com>
Committed: Tue Oct 20 15:51:40 2015 +0200

----------------------------------------------------------------------
 .../xml/MetadataDocumentXmlSerializer.java          | 10 +++++-----
 .../xml/MetadataDocumentXmlSerializerTest.java      |  2 +-
 .../core/serializer/xml/MetadataDocumentTest.java   | 16 ++--------------
 3 files changed, 8 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/15164da8/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
index 356b90e..b761374 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
@@ -244,8 +244,8 @@ public class MetadataDocumentXmlSerializer {
       for (EdmAnnotation annotation : annotations) {
         writer.writeStartElement(XML_ANNOTATION);
         if (annotation.getTerm() != null) {
-          writer.writeAttribute(XML_TERM_ATT, annotation.getTerm().getFullQualifiedName()
-              .getFullQualifiedNameAsString());
+          writer.writeAttribute(XML_TERM_ATT, getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName(),
+              false));
         }
         if (annotation.getQualifier() != null) {
           writer.writeAttribute(XML_QUALIFIER_ATT, annotation.getQualifier());
@@ -315,7 +315,7 @@ public class MetadataDocumentXmlSerializer {
       break;
     case Cast:
       EdmCast asCast = dynExp.asCast();
-      writer.writeAttribute(XML_TYPE, asCast.getType().getFullQualifiedName().getFullQualifiedNameAsString());
+      writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asCast.getType(), false));
 
       if (asCast.getMaxLength() != null) {
         writer.writeAttribute(XML_MAX_LENGTH, "" + asCast.getMaxLength());
@@ -345,7 +345,7 @@ public class MetadataDocumentXmlSerializer {
       break;
     case IsOf:
       EdmIsOf asIsOf = dynExp.asIsOf();
-      writer.writeAttribute(XML_TYPE, asIsOf.getType().getFullQualifiedName().getFullQualifiedNameAsString());
+      writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asIsOf.getType(), false));
 
       if (asIsOf.getMaxLength() != null) {
         writer.writeAttribute(XML_MAX_LENGTH, "" + asIsOf.getMaxLength());
@@ -388,7 +388,7 @@ public class MetadataDocumentXmlSerializer {
       break;
     case Record:
       EdmRecord asRecord = dynExp.asRecord();
-      writer.writeAttribute(XML_TYPE, asRecord.getType().getFullQualifiedName().getFullQualifiedNameAsString());
+      writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asRecord.getType(), false));
       for (EdmPropertyValue propValue : asRecord.getPropertyValues()) {
         writer.writeStartElement(XML_PROPERTY_Value);
         writer.writeAttribute(XML_PROPERTY, propValue.getProperty());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/15164da8/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
index 7af3780..365da7a 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
@@ -333,7 +333,7 @@ public class MetadataDocumentXmlSerializerTest {
     assertTrue(metadata.contains("<Path>PathValue</Path>"));
     assertTrue(metadata.contains("<PropertyPath>PropertyPathValue</PropertyPath>"));
     assertTrue(metadata
-        .contains("<Record Type=\"namespace.ETAbstract\"><PropertyValue Property=\"PropName\"><String>value</String>"
+        .contains("<Record Type=\"Alias.ETAbstract\"><PropertyValue Property=\"PropName\"><String>value</String>"
             + "<Annotation Term=\"ns.term\"/></PropertyValue><Annotation Term=\"ns.term\"/></Record>"));
     assertTrue(metadata.contains("<UrlRef><String>URLRefValue</String><Annotation
Term=\"ns.term\"/></UrlRef>"));
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/15164da8/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 8045b63..b655e49 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -50,6 +50,7 @@ public class MetadataDocumentTest {
 
     final String metadata = IOUtils.toString(
         odata.createSerializer(ContentType.APPLICATION_XML).metadataDocument(serviceMetadata).getContent());
+    System.out.println(metadata);
     assertNotNull(metadata);
     assertThat(metadata, containsString("<edmx:Reference Uri=\"" + CORE_VOCABULARY + "\">"
             + "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>" + "</edmx:Reference>"));
@@ -76,23 +77,10 @@ public class MetadataDocumentTest {
             + "<Property Name=\"AdditionalPropertyString_5\" Type=\"Edm.String\"/>"
             + "</EntityType>"));
 
-//    assertThat(metadata, containsString("<EntitySet Name=\"ESAllPrim\" EntityType=\"Namespace1_Alias.ETAllPrim\">"
-//        + "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimOne\" Target=\"ESTwoPrim\"/>"
-//        + "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimMany\" Target=\"ESTwoPrim\"/>"
-//        + "</EntitySet>"));
-
       assertThat(metadata, containsString("<EntitySet Name=\"ESAllPrim\" EntityType=\"Namespace1_Alias.ETAllPrim\">"
         + "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimOne\" Target=\"ESTwoPrim\"/>"
         + "<NavigationPropertyBinding Path=\"NavPropertyETTwoPrimMany\" Target=\"ESTwoPrim\"/>"
-        + "<Annotation Term=\"Core.Description\" String=\"Contains entities with all primitive
types\"/>"
-        + "<Annotation Term=\"Core.LongDescription\" Qualifier=\"EnabledForEntitySet\"
String=\"System Query Options:"
-        + " $filter, $count, $orderby, $skip, $top, $expand, $select, $format; Operations:
Create, Create with Deep "
-        + "Insert, Create with Bind Operation, Read\"/>"
-        + "<Annotation Term=\"Core.LongDescription\" Qualifier=\"EnabledForEntity\" String=\"System
Query Options: "
-        + "$expand, $select, $format; Operations: Read, Update, Update with Bind Operation,
Delete\"/>"
-        + "<Annotation Term=\"Core.LongDescription\" Qualifier=\"EnabledNavigationProperties\"
"
-        + "String=\"NavPropertyETTwoPrimOne, NavPropertyETTwoPrimMany\"/>"
-        + "</EntitySet>"));
+        + "<Annotation Term=\"Core.Description\""));
 
     assertThat(metadata,
         containsString("<ComplexType Name=\"CTPrim\">"


Mime
View raw message