Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-1420

Unable to perform deep insert using Olingo V2 when navigation properties relationship is 1:N

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • V2 2.0.11
    • None
    • odata2-core
    • None

    Description

      Use case: perform deep insert using Olingo V2

      As described in https://issues.apache.org/jira/browse/OLINGO-1401 Olingo will not serialize navigation properties and their contents into the request if contentOnly flag is set to true.

      We set it to false but that adds metadata to the request payload as a result. In case of an update, where key properties are not present in the payload but in the URL, the metadata generation will fail (we wrote a hack to overcome this).

      The biggest problem we found is the serialization of childNavigationProperty properties described by 1:N relationship, see the following example:

      {
        "rootLevelProperty": "",
        "rootLevelNavigationProperty": [
          {
            "child": "1",
            "childNavigationProperty": [
               {
                 "grandChild": "X"
               }
             ]
          },
          {
            "child": "2",
            "childNavigationProperty": [ 
              { 
                "grandChild": "Y" 
              }
            ]
          }
        }
      }

      To serialize the navigation properties we need to specify the customExpanedLinks for every nested level. We also need to specify callbacks for every navigation property (this means also defining nested callbacks for nested navigation properties).

      When navigation property is described by 1:N relationship, we need to register a OnWriteFeedContent callback. This callback however doesn't allow us to specify nested callbacks for every item in the list, we can only register a single callback for the entire feed. This means we are not able to serialize grandChild property correctly and we have to choose either "X" or "Y" as a value for both items.

      Our code looks like this:

      writeEntry(APPLICATION_JSON, rootEntitySet, dataMap,
              serviceRoot(new URI(entitySetName))
                      .omitJsonWrapper(true)
                      .contentOnly(update) //true for updates
                      .expandSelectTree(expandSelectTreeNodeBuilder.build()) //tree of customExpanedLinks so navigation properties are serialized
                      .callbacks(createCallbacks(navigationPropertyMap, rootEntityType)) // tree of callbacks to provide data for all customExpanedLinks defined above
                      .build()
      

      How can we perform such deep insert using Olingo?
      Are we using the library as intended?
      Does Olingo V2 even supports deep inserts?

      Attachments

        Activity

          People

            Unassigned Unassigned
            sbavala Slavomír Bavala
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: