4 Replies Latest reply on Jul 25, 2016 10:01 AM by Sajid Patel RSS
    ishrivastava-2 Newbie

    Multiple User Data

    Hi,

     

    I have been trying to display multiple user data on single mashup.I have created Thing which contain multiple infotable properties .I am using a repeater widget to display multiple players name.While clicking on the link it should display data related to players name(like particular player name,age,weight..etc).For that i am creating an infotable property which contain one datashape having field definations as (age,height,address).I am getting two problems:-

    1)I am not aware of how to send data from edge level to infotable property.

    2)How to map infotable rows result data to all widgets and single mashup.

      • Re: Multiple User Data
        meghan Communicator

        1)I am not aware of how to send data from edge level to infotable property.

        - What Edge device are you using?

        - The code you will need to write on the Edge side will need to package all the property values you want to send into an InfoTable you create on the Edge side. From that point you should be able to just bind the local Thing property to the RemoteThing property defined on the Edge.

         

        2)How to map infotable rows result data to all widgets and single mashup.

        - If you are trying to get a property value for an InfoTable into a Mashup you should use the service "GetPropertyValues" on the Thing that holds the InfoTable property. After that service is added to the services pane of the Mashup you should expand the "All Data" option under that service and drag and drop the InfoTable property onto the Widget you want to display values on (ie. a Grid Widget).

         

        Meghan

        • Re: Multiple User Data
          Sajid Patel Apprentice

          Disclaimer: This response contains my views and opinions expressed and not R&D's or company's.

           

              Here is an example of sending infotable data to platform from Java SDK:

              From your description, I am assuming that you prefer using a single Remote Thing that is bound to a Virtual Thing on Edge SDK. You can create a single remote thing that can facilitate this.

           

               On Java SDK side, code similar to this may be written:

           

          // This code may be called from overridden processScanRequest of a Virtual Thing that is bound

          // to Remote Thing on the platform

           

          InfoTable myInfoTable = new InfoTable();

          FieldDefinitionCollection fields1 = new FieldDefinitionCollection();

          fields1.addFieldDefinition(new FieldDefinition("playerName", BaseTypes.STRING));

          fields1.addFieldDefinition(new FieldDefinition("playerAge", BaseTypes.NUMBER));

          fields1.addFieldDefinition(new FieldDefinition("playerWeight", BaseTypes.NUMBER));

           

          DataShapeDefinition fields = new DataShapeDefinition(fields1);

          myInfoTable.setDataShape(fields);

           

          for (int iUser = 0; iUser < userCount; iUser++) {

           

          // Retrieve user data and set on to the info table

           

                      ValueCollection row = new ValueCollection();

                      row.put("playerName", new StringPrimitive("Tom"));

                      row.put("playerAge", new NumberPrimitive(30));

                      row.put("playerWeight", new NumberPrimitive(120));

           

                      myInfoTable.addRow(row);

          }

           

          // Call setProperty to set an infotable property

                  super.setProperty(MY_INFOTABLE_NAME, myInfoTable);

           

               On Platform side:

                    Say the name of the remote thing is PlayerDataRetriever and it has a remote infotable property that is populated from Edge SDK.

                    You could use this infotable directly in your mashup or you can even choose to explode it into multiple player things which may not even be remote things using a event subscription to DataChange event on the above infotable property.

                    The service can iterate through the infotable rows and create player things and/or set player properties.

            • Re: Multiple User Data
              ishrivastava-2 Newbie

              Thank you for the code and information.I am not able to pass those data to Datashape. When i run the edge SDK and bind those properties with the thing infotable properties i am not getting the infotable data from the edge SDK. Can you suggest how to set data to datashape from edge side.

                • Re: Multiple User Data
                  Sajid Patel Apprentice

                  If you are using a datashape, you can use the snippet 'Create Infotable from datashape' which will result in the following code:

                   

                  var params = {

                  infoTableName : "<myInfoTable>",

                  dataShapeName : "<myDataShape>"

                  };

                   

                  var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

                   

                  Look for any errors in the application logs. If it's successful, you will see pushed properties reported in the application logs.