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/07/21 13:16:06 UTC

git commit: [OLINGO-375] Add type attribute for additional links

Repository: olingo-odata2
Updated Branches:
  refs/heads/master 3a1ffb426 -> 6b73a91d3


[OLINGO-375] Add type attribute for additional links


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/6b73a91d
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/6b73a91d
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/6b73a91d

Branch: refs/heads/master
Commit: 6b73a91d367e85f2235cf4fc667834e5259f33d7
Parents: 3a1ffb4
Author: Christian Amend <ch...@apache.org>
Authored: Mon Jul 21 13:15:22 2014 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Mon Jul 21 13:15:22 2014 +0200

----------------------------------------------------------------------
 .../ep/producer/AtomEntryEntityProducer.java    | 22 ++++++++++----------
 .../core/ep/producer/AtomEntryProducerTest.java |  4 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6b73a91d/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
index f2e19ea..97c606f 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
@@ -152,12 +152,14 @@ public class AtomEntryEntityProducer {
     if (links != null && !links.isEmpty()) {
       for (Entry<String, Map<String, Object>> entry : links.entrySet()) {
         Map<String, Object> navigationKeyMap = entry.getValue();
+        final boolean isFeed =
+            (eia.getNavigationPropertyInfo(entry.getKey()).getMultiplicity() == EdmMultiplicity.MANY);
         if (navigationKeyMap != null && !navigationKeyMap.isEmpty()) {
           final EntityInfoAggregator targetEntityInfo = EntityInfoAggregator.create(
               eia.getEntitySet().getRelatedEntitySet(
                   (EdmNavigationProperty) eia.getEntityType().getProperty(entry.getKey())));
           appendAtomNavigationLink(writer, createSelfLink(targetEntityInfo, navigationKeyMap, null), entry.getKey(),
-              null, eia, data);
+              isFeed, eia, data);
         }
       }
     }
@@ -219,27 +221,25 @@ public class AtomEntryEntityProducer {
       } else {
         final EntityInfoAggregator targetEntityInfo = EntityInfoAggregator.create(
             eia.getEntitySet().getRelatedEntitySet((EdmNavigationProperty) eia.getEntityType().getProperty(name)));
-        appendAtomNavigationLink(writer, createSelfLink(targetEntityInfo, key, null), name, null, eia, data);
+        appendAtomNavigationLink(writer, createSelfLink(targetEntityInfo, key, null), name, isFeed, eia, data);
       }
     }
   }
 
   private void appendAtomNavigationLink(final XMLStreamWriter writer, final String target,
-      final String navigationPropertyName, final Boolean isFeed, final EntityInfoAggregator eia,
+      final String navigationPropertyName, final boolean isFeed, final EntityInfoAggregator eia,
       final Map<String, Object> data) throws EntityProviderException, EdmException, URISyntaxException {
     try {
       writer.writeStartElement(FormatXml.ATOM_LINK);
       writer.writeAttribute(FormatXml.ATOM_HREF, target);
       writer.writeAttribute(FormatXml.ATOM_REL, Edm.NAMESPACE_REL_2007_08 + navigationPropertyName);
       writer.writeAttribute(FormatXml.ATOM_TITLE, navigationPropertyName);
-      if (isFeed != null) {
-        if (isFeed) {
-          writer.writeAttribute(FormatXml.ATOM_TYPE, ContentType.APPLICATION_ATOM_XML_FEED.toString());
-          appendInlineFeed(writer, navigationPropertyName, eia, data, target);
-        } else {
-          writer.writeAttribute(FormatXml.ATOM_TYPE, ContentType.APPLICATION_ATOM_XML_ENTRY.toString());
-          appendInlineEntry(writer, navigationPropertyName, eia, data);
-        }
+      if (isFeed) {
+        writer.writeAttribute(FormatXml.ATOM_TYPE, ContentType.APPLICATION_ATOM_XML_FEED.toString());
+        appendInlineFeed(writer, navigationPropertyName, eia, data, target);
+      } else {
+        writer.writeAttribute(FormatXml.ATOM_TYPE, ContentType.APPLICATION_ATOM_XML_ENTRY.toString());
+        appendInlineEntry(writer, navigationPropertyName, eia, data);
       }
       writer.writeEndElement();
     } catch (XMLStreamException e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6b73a91d/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
index b7a350a..7c26984 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
@@ -1026,7 +1026,7 @@ public class AtomEntryProducerTest extends AbstractProviderTest {
     assertXpathExists("/a:entry/a:link[@title='nr_Building']", xmlString);
     assertXpathNotExists("/a:entry/a:link[@href=\"Rooms('1')/nr_Building\"]", xmlString);
     assertXpathExists("/a:entry/a:link[@href=\"Buildings('1')\"]", xmlString);
-    assertXpathNotExists("/a:entry/a:link[@type='application/atom+xml;type=entry']", xmlString);
+    assertXpathExists("/a:entry/a:link[@type='application/atom+xml;type=entry']", xmlString);
   }
 
   @Test
@@ -1041,7 +1041,7 @@ public class AtomEntryProducerTest extends AbstractProviderTest {
     assertXpathExists("/a:entry/a:link[@title='nr_Employees']", xmlString);
     assertXpathNotExists("/a:entry/a:link[@href=\"Rooms('1')/nr_Employees\"]", xmlString);
     assertXpathExists("/a:entry/a:link[@href=\"Employees('1')\"]", xmlString);
-    assertXpathNotExists("/a:entry/a:link[@type='application/atom+xml;type=feed']", xmlString);
+    assertXpathExists("/a:entry/a:link[@type='application/atom+xml;type=feed']", xmlString);
   }
 
   @Test