Visual Builder

Get Involved. Join the Conversation.

Topic

    paryul mehta
    Custom BOP issue while getting data from Database as a...
    Topic posted February 13, 2018 by paryul mehtaBlue Ribbon: 750+ Points, last edited February 26, 2018 by Arijit ChakrabortyBronze Trophy: 5,000+ Points, tagged Business Objects, Custom Code, Database 
    60 Views, 2 Comments
    Title:
    Custom BOP issue while getting data from Database as a Schema Service
    Summary:
    Custom BOP issue while getting data from Database as a Schema Service
    Content:

    Hello we  have the following tools to work with.

    1: Database as a Schema service

    2: Visual Builder Cloud service

    We're trying to do the following.

    Deploy a restful webservice created by the wizard available in APEX , deploy it , consume that as a business object in Oracle Visual Builder Cloud service.

    So we can build an app around this object. In an older post it was explained to me that for these restful webservices created in apex (ORDS) we need to create a Business Object Providers to consume

    such services. I've attached the code that we edited based on the link provided before as a reference point https://blogs.oracle.com/shay/getting-data-from-rest-services-into-oracle-application-builder-cloud-service

    We can see that the webservice is called but no data is showing up in the Visual builder cloud service. We can get the data when we call the webservice in our browser and in apps such as SOAPUI etc.

    I've attached some screenshots and also the sample code files. Can you help?

    Have a sample table test_state

    pastedImage_0.png

    we've deployed this table as a rest service from the Database as a schema service Apex console.

     

    pastedImage_1.png

     

    pastedImage_2.png

     

    pastedImage_10.png

     

    pastedImage_3.png

     

     

    pastedImage_4.png

     

    pastedImage_5.png

     

    We tried accessing the data using the steps shown below but it doesn't bring up anything.

     

    pastedImage_6.png

     

    pastedImage_7.png

     

    pastedImage_8.png

     

    pastedImage_9.png

    Comment

     

    • Shay Shmeltzer

      You'll need to modify your operation provider to drill into the "items" array.

      It should end up looking something like this:

      ----

      define([

          'bop/js/api/operation/BOPAuthenticators',

          'bop/js/api/operation/OperationBuilder',

          'bop/js/api/resource/Resource',

          'operation/js/api/Operation',

        'operation/js/api/OperationResult'

      ], function (

              BOPAuthenticators,

              OperationBuilder,

              Resource,

              Operation,

              OperationResult

              ) {

          'use strict';

          var RESTOperationProvider = function (dependencies) {

              var self = this;

              this._operations = [];

              this._resources = [];

              this._baseUri = "https://yourapexserver/acdev/health2/getTopTen";

              // Check to see if entity is registerd, and if so provide a simple

              // read operation for a list of entities

              var userEntity = Abcs.Entities().findById(RESTOperationProvider.USER_ENTITY_ID);

                   if (userEntity) {

                  this._operations.push(new OperationBuilder({

                      name: 'Fetch all users',

                      type: Operation.Type.READ_MANY,

                      performs: function (operationData) {

                          var ajaxObj = {

                  method: 'GET',

                  url: self._baseUri,

                  dataType: 'json'

              }; 

                       

                              return new Promise(function (fulfil, reject) {

                self.getAuthenticator().invoke( ajaxObj ).then(function (response) {

                      var arr = RESTOperationProvider._parseDetails(response);

                      return fulfil(OperationResult.success(arr));

                  });

              });

                      }

                  }).description('Fetch all users from the jsonplaceholder users resource')

                          .returns(userEntity)

                          .build());

               RESTOperationProvider._parseDetails = function (response) {

              var res = []; 

             var data = response.getData();

               data.items.forEach(function(items) {

                   res.push(items);

              });

              return res;

          };

               

                  // Generate the resource model required to configure the security model

                  //

                  this._resources.push(

                          Resource.create({

                              id: '1',

                              template: self._baseUri,

                              entity: RESTOperationProvider.USER_ENTITY_ID

                          })

                          );

              }

              // Create an instance of authenticator

              this._authenticator = BOPAuthenticators.getDefault(dependencies, {

                  getResources: function(   ) {

                      return self._resources;

                  }

              });

          };

          RESTOperationProvider.USER_ENTITY_ID = 'com.users.user';

          RESTOperationProvider.prototype.getOperations = function () {

              return this._operations;

          };

          RESTOperationProvider.prototype.getAuthenticator = function () {

              return this._authenticator;

          };

          return RESTOperationProvider;

      });

      ----

    • paryul mehta

      Thanks Shay

      We ended up doing something similar and it worked ...

      Really appreciate your help ...thanks

      D