Class ContextAwareHelper


  • public class ContextAwareHelper
    extends java.lang.Object
    Helper for the contextAware.js. This class in its full implementation should perform discovery of IoT services and create the appropriate dialog to obtain the needed context for invoking a specific REST service. The context includes the required input to the service and the expected response from the service. No dialog is implemented yet!!
    Since:
    Ptolemy II 11.0
    Version:
    $Id$, $Id$
    Author:
    Anne H. Ngu (angu@txstate.edu)
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String _selectedService
      The name of the service selected by the user.
      protected java.lang.String[] _selectedServiceParameters
      The names of the parameters for the service that was selected by the user.
      protected java.lang.String _sensorService
      The specific data that is wanted from the selected service.
    • Constructor Summary

      Constructors 
      Constructor Description
      ContextAwareHelper()
      Create an instance of a GUI object to collect details about a service.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String[] availableServices()
      Return the list of services.
      java.util.ArrayList convertXMLtoJSON​(java.lang.String response)
      Convert an XML data format to JSON data format using the XML class from org.json.xml.
      java.lang.String discoverServices()
      Return the discovered services.
      java.lang.String[] getFirebaseOutput()
      Return the list of output choices of Firebase service.
      java.lang.String[] getGsnOutput()
      Return the list of output choices of Paraimpu /** Return the list of output choices of GSN service.
      java.lang.String[] getParaimpuOutput()
      Return the list of output choices of Paraimpu service.
      java.lang.String getSelectedService()
      Return the name of the selected service.
      java.lang.String getSelectedServiceParameter​(java.lang.String selectedService)
      Return the parameters associated with the selected service.
      void setSelectedService​(java.lang.String[] list)
      Initializes the list of available iot REST services and creates a GUI for a user to make the selection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _selectedServiceParameters

        protected java.lang.String[] _selectedServiceParameters
        The names of the parameters for the service that was selected by the user.
      • _selectedService

        protected java.lang.String _selectedService
        The name of the service selected by the user.
      • _sensorService

        protected java.lang.String _sensorService
        The specific data that is wanted from the selected service.
    • Constructor Detail

      • ContextAwareHelper

        public ContextAwareHelper()
        Create an instance of a GUI object to collect details about a service.
    • Method Detail

      • availableServices

        public java.lang.String[] availableServices()
        Return the list of services. Eventually this should be replaced by querying a known registry or a discovery process. Return a list of iot REST service names that are available to the user to choose from
        Returns:
        the list of of services.
      • convertXMLtoJSON

        public java.util.ArrayList convertXMLtoJSON​(java.lang.String response)
        Convert an XML data format to JSON data format using the XML class from org.json.xml.
        Parameters:
        response - is the input in xml format
        Returns:
        the json formatted data in an array
      • discoverServices

        public java.lang.String discoverServices()
        Return the discovered services. Currently, this method sets the selected service to the list of services and then returns the string "pluto.cs.txstate.edu:22001"
        Returns:
        the discovered services
      • getFirebaseOutput

        public java.lang.String[] getFirebaseOutput()
        Return the list of output choices of Firebase service. Currently, the list of choices is hard coded. Eventually, this list should come from a discovery process
        Returns:
        The list of data type to be extracted from Firebase.
      • getGsnOutput

        public java.lang.String[] getGsnOutput()
        Return the list of output choices of Paraimpu /** Return the list of output choices of GSN service. Currently, the list of choices is hard coded. Eventually, this list should come from a discovery process
        Returns:
        The list of data type to be extracted from the service
      • getParaimpuOutput

        public java.lang.String[] getParaimpuOutput()
        Return the list of output choices of Paraimpu service. Currently, the list of choices is hard coded. Eventually, this list should come from a discovery process
        Returns:
        The list of data type to be extracted from Paraimpu.
      • getSelectedService

        public java.lang.String getSelectedService()
        Return the name of the selected service. Currently, this method returns the string "GSN". Eventually, this method will return data from the GUI.
        Returns:
        The name of the service chosen by the user.
        See Also:
        setSelectedService(String[])
      • getSelectedServiceParameter

        public java.lang.String getSelectedServiceParameter​(java.lang.String selectedService)
        Return the parameters associated with the selected service. Currently just return a hard wired url for testing.
        Parameters:
        selectedService - The name of the service that was selected.
        Returns:
        An array of service parameters. Not used now
      • setSelectedService

        public void setSelectedService​(java.lang.String[] list)
        Initializes the list of available iot REST services and creates a GUI for a user to make the selection. Not used currently Currently, this method does nothing.
        Parameters:
        list - known list of services
        See Also:
        getSelectedService()