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

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        2h 59m 1 Backlog Manager 10/Nov/15 9:04 AM
        In Progress In Progress Answered Answered
        3h 1 Backlog Manager 10/Nov/15 12:04 PM
        Answered Answered Closed Closed
        1d 20h 13m 1 Manuel Escriche 12/Nov/15 8:18 AM

          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: