org.licas.module.c_module

## Class CM_Data

- java.lang.Object
- - java.lang.Thread
  - - org.licas.module.LicasModule
    - - org.licas.module.FrameworkModule
      - - org.licas.module.ControlModule
        - - org.licas.module.c_module.CM_Data

- All Implemented Interfaces:
    java.lang.Runnable, ServiceDef
  Direct Known Subclasses:
    CM_Auto

      public class CM_Data
      extends ControlModule

  This class provides functionality for a service to store and/or evaluate data, or send data to a distributed service.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.HashMap<java.lang.String,org.ai_heuristic.eval.metric.MetricDataset>` | `allDatasets` All retrieved datasets
    `protected DataServiceDef` | `evaluator` The evaluation service
    `protected java.util.Random` | `rnd` Random number generator
    `protected java.util.ArrayList<java.lang.String>` | `serviceIDs` The current list of service ids to try to link to

    - ### Fields inherited from class org.licas.module.ControlModule

      `dm`

    - ### Fields inherited from class org.licas.module.FrameworkModule

      `passwordHandler, service, serviceType`

    - ### Fields inherited from class org.licas.module.LicasModule

      `jarFile, syncOn, uuid`

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CM_Data(Service service, PasswordHandler pHandler)` Creates a new instance of CM_Data.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.HashMap<java.lang.String,org.ai_heuristic.eval.metric.MetricDataset>` | `getAllData()` Retrieve and store all data from a list of running services.
    `org.ai_heuristic.eval.metric.MetricDataset` | `getDataRandomID()` Randomly retrieve the next dataset for evaluation.
    `java.util.ArrayList<java.lang.String>` | `getServiceIDs()` Get the current list of active service IDs.
    `void` | `receiveDataXML(java.lang.String serviceType, org.licas_xml.abs.Element dataInfo)` This method can receive a data result as an XML-based description.
    `void` | `resetValues()` Reset variables for another test run.
    `void` | `sendDataXML(java.lang.String serviceType, org.licas_xml.abs.Element dataXml, org.licas_xml.abs.Element otherXml, boolean links)` This can be used to send data to some service using an XML-based description.
    `void` | `setAllData(java.util.HashMap<java.lang.String,org.ai_heuristic.eval.metric.MetricDataset> thisAllData)` Set the dataset for processing.

    - ### Methods inherited from class org.licas.module.ControlModule

      `getServerPassword, setDataModule`

    - ### Methods inherited from class org.licas.module.FrameworkModule

      `canAccess, canAccessTemp, getPasswordHandler, getPasswordHandler, getServicePassword, getServiceType, isAdminKey, setServiceDetails, setServiceType`

    - ### Methods inherited from class org.licas.module.LicasModule

      `getJarFile, getUUID, loadObject, setJarFile, setUUID, threadAliveState`

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.licas.def.ServiceDef

      `getUUID, setJarFile, setUUID`

- - ### Field Detail

    - #### serviceIDs

          protected java.util.ArrayList<java.lang.String> serviceIDs

      The current list of service ids to try to link to

    - #### allDatasets

          protected java.util.HashMap<java.lang.String,org.ai_heuristic.eval.metric.MetricDataset> allDatasets

      All retrieved datasets

    - #### evaluator

          protected DataServiceDef evaluator

      The evaluation service

    - #### rnd

          protected java.util.Random rnd

      Random number generator

  - ### Constructor Detail

    - #### CM_Data

          public CM_Data(Service service,
                         PasswordHandler pHandler)
                  throws java.lang.Exception

      Creates a new instance of CM_Data.
      Parameters:
        `service` - the parent service.
        `pHandler` - the parent password handler.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### resetValues

          public void resetValues()

      Reset variables for another test run.

    - #### sendDataXML

          public void sendDataXML(java.lang.String serviceType,
                                  org.licas_xml.abs.Element dataXml,
                                  org.licas_xml.abs.Element otherXml,
                                  boolean links)
                           throws PasswordException,
                                  MethodNotFoundException,
                                  java.lang.Exception

      This can be used to send data to some service using an XML-based description.

      Parameters:
        `serviceType` - the service type to receive the data, typically only one service of the type.
        `dataXml` - full xml-based description of the data.
        `otherXml` - xml-based description of other information that may be added as a second element.
        `links` - true if include linking information.
      Throws:
        `PasswordException` - incorrect password for the server or mediator service.
        `MethodNotFoundException` - the mediator does not have the calling method.
        `java.lang.Exception` - any other error.

    - #### receiveDataXML

          public void receiveDataXML(java.lang.String serviceType,
                                     org.licas_xml.abs.Element dataInfo)
                              throws java.lang.Exception

      This method can receive a data result as an XML-based description.
      Parameters:
        `serviceType` - type of service making the call, for indexing purposes.
        `dataInfo` - full xml-based description of the data.
      Throws:
        `java.lang.Exception` - any error.

    - #### getServiceIDs

          public java.util.ArrayList<java.lang.String> getServiceIDs()
                                                              throws java.lang.Exception

      Get the current list of active service IDs. If thi is empty, then query the server for a list of running services.
      Returns:
        the value of serviceIDs.
      Throws:
        `java.lang.Exception` - any error.

    - #### setAllData

          public void setAllData(java.util.HashMap<java.lang.String,org.ai_heuristic.eval.metric.MetricDataset> thisAllData)

      Set the dataset for processing.
      Parameters:
        `thisAllData` - the whole dataset.

    - #### getAllData

          public java.util.HashMap<java.lang.String,org.ai_heuristic.eval.metric.MetricDataset> getAllData()
                                                                                                    throws ServiceException,
                                                                                                           java.lang.Exception

      Retrieve and store all data from a list of running services. Also adds missing passwords if they can be obtained.
      Returns:
        the retrieved data as MetricDataset objects.
      Throws:
        `ServiceException` - probably for password or service not found.
        `java.lang.Exception` - and error.

    - #### getDataRandomID

          public org.ai_heuristic.eval.metric.MetricDataset getDataRandomID()
                                                                     throws java.lang.Exception

      Randomly retrieve the next dataset for evaluation. This is from any service on the current list. This then also removes the service from the list. Use `resetServiceIDs` to reset to the full list of other services again. This version calls `getValue` that uses the `EvaluateBase.valueFromString` method to try to parse a string-based representation of a value into a Java object, which will only automatically work for simple types, or XML.
      Returns:
        the retrieved data as a MetricDataset object.
      Throws:
        `java.lang.Exception` - any error.