3 Replies Latest reply on Jun 22, 2020 11:35 AM by Muhammad Shaheen Akhtar

    Iterate Output Collection of DB Adaptar

    Muhammad Shaheen Akhtar

      Hi,

       

      I hope everyone is fine and in good health. I am using JDeveloper 12.2.1 for Oracle SOA and using DB Adaptar for back end and REST service for front end. My requirement is to iterate DB Adaptar output with a twist.

       

      For example the DB Adaptar returns below:

      {

        "OutputCollection" : [ {

          "DepartmentId" : 10,

          "DepartmentName" : "IT",

          "EmployeeName" : "ABC"

        }, {

          "DepartmentId" : 10,

          "DepartmentName" : "IT",

          "EmployeeName" : "DEF"

        }, {

          "DepartmentId" : 10,

          "DepartmentName" : "IT",

          "EmployeeName" : "GHI"

        }, {

          "DepartmentId" : 20,

          "DepartmentName" : "ADMIN",

          "EmployeeName" : "JKL"

        }, {

          "DepartmentId" : 20,

          "DepartmentName" : "ADMIN",

          "EmployeeName" : "MNO"

        }, {

          "DepartmentId" : 30,

          "DepartmentName" : "MARKETING",

          "EmployeeName" : "PQR"

        } ]

      }

       

      So what should i need to do in transformation file or elsewhere to return as below from REST Service:

       

      {

        "DepartmentCollection" : [ {

               "DepartmentId" : 10,

               "DepartmentName" : "IT",

                     "EmployeeCollection" : [ {

                          "EmployeeName" : "ABC"

                            }, {

                          "EmployeeName" : "DEF"

                            }, {

                          "EmployeeName" : "GHI"

                  } ], {

            "DepartmentId" : 20,

             "DepartmentName" : "ADMIN",

                          "EmployeeCollection" : [ {

                               "EmployeeName" : "JKL"

                                 }, {

                               "EmployeeName" : "MNO"

                         } ], {

            "DepartmentId" : 30,

            "DepartmentName" : "MARKETING",

                          "EmployeeCollection" : [ {

                               "EmployeeName" : "PQR"

                            } ]

        } ]

      }

       

      Thanks in advance.