Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-5229

FIWARE.Question.Tech.Apps.ApplicationMashup.OrionStarterKit.FullAttributeDataFromOrion

    Details

      Description

      Created question in FIWARE Q/A platform on 04-02-2015 at 19:02
      Please, ANSWER this question AT http://stackoverflow.com/questions/28329239/querying-ocb-from-javascript-wirecloud

      Question:
      Querying OCB from JavaScript (WireCloud)

      Description:
      I'm trying to get type fields for each attribute of my entities. Quering Orion and getting entities is not the problem (I do this through NGSI Source widget) but the way getting these parameters.

      From NGSI Source (usual suscription to Orion instance):

      var doInitialSubscription = function doInitialSubscription() {

      this.subscriptionId = null;

      this.ngsi_server = MashupPlatform.prefs.get('ngsi_server');
      this.ngsi_proxy = MashupPlatform.prefs.get('ngsi_proxy');
      this.connection = new NGSI.Connection(this.ngsi_server,

      { ngsi_proxy_url: this.ngsi_proxy }

      );

      var types = MashupPlatform.prefs.get('ngsi_entities').split(new RegExp(',
      s*'));
      var entityIdList = [];
      var entityId;
      for (var i = 0; i < types.length; i++) {
      entityId =

      { id: '.*', type: types[i], isPattern: true }

      ;
      entityIdList.push(entityId);
      }
      var attributeList = null;
      var duration = 'PT3H';
      var throttling = null;
      var notifyConditions = [

      { 'type': 'ONCHANGE', 'condValues': MashupPlatform.prefs.get('ngsi_update_attributes').split(new RegExp(',\\s*')) }

      ];
      var options = {
      flat: true,
      onNotify: handlerReceiveEntity.bind(this),
      onSuccess: function (data) {
      this.subscriptionId = data.subscriptionId;
      this.refresh_interval = setInterval(refreshNGSISubscription.bind(this), 1000 * 60 * 60 * 2); // each 2 hours
      window.addEventListener("beforeunload", function ()

      { this.connection.cancelSubscription(this.subscriptionId); }

      .bind(this));
      }.bind(this)
      };
      this.connection.createSubscription(entityIdList, attributeList, duration, throttling, notifyConditions, options);
      };
      var handlerReceiveEntity = function handlerReceiveEntity(data) {
      for (var entityId in data.elements)

      { MashupPlatform.wiring.pushEvent("entityOutput", JSON.stringify(data.elements[entityId])); }

      };

      To MyWidget:

      MashupPlatform.wiring.registerCallback("entityInput", function (entityString) {
      var entity;
      entity = JSON.parse(entityString);
      id = entity.id;
      type = entity.type;
      for(var attr in entity)

      { attribute = entity[attr]; }

      I'm trying to code something similar to obtain the value of type fields. How can I do that? (I'm sure it's quite easy...)

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-10 06:05|CREATED monitor | # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-10 06:05|CREATED monitor | # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-10 09:05|UPDATED status: transition Answer| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-10 09:05|UPDATED status: transition Answer| # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-10 12:05|UPDATED status: transition Answered| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-10 12:05|UPDATED status: transition Answered| # answers= 1, accepted answer= True

          People

          • Assignee:
            aarranz Álvaro Arranz
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: