org.licas.service

## Class InformationMediator

- java.lang.Object
- - java.lang.Thread
  - - org.licas.module.LicasModule
    - - org.licas.module.FrameworkModule
      - - org.licas.module.ServiceModule
        - - org.licas.Service
          - - org.licas.service.ServiceMediator
            - - org.licas.service.InformationMediator

- All Implemented Interfaces:
    java.lang.AutoCloseable, java.lang.Runnable, ServiceDef

      public class InformationMediator
      extends ServiceMediator

  This class can be used to mediate between the information services that are created, the information sources and any related centralised problem solver. A service can be created by itself, or initialised with an information source. The service then runs on the network and communicates with the problem solver classes through the licas framework.
  Author:
    Kieran Greer

- - ### 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.ArrayList<java.lang.String>` | `sourceData` Retrieved data from each source
    `protected java.util.ArrayList<java.lang.String>` | `sourceURLs` The source info urls

    - ### Fields inherited from class org.licas.service.ServiceMediator

      `serverIP, serverUri, serviceSpec, syncOn`

    - ### Fields inherited from class org.licas.Service

      `canAccessMeta, canAccessNested, dm, finalised, isRemoteCall, messageStore, serviceAdmin, serviceGrade, serviceInitialise, serviceLinks, serviceState, sm, toLoadScript`

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

      `shutDown`

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

      `passwordHandler, service, serviceType`

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

      `jarFile, uuid`

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

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InformationMediator(PasswordHandler thePasswordHandler)` Create a new instance of InformationMediator.
    `InformationMediator(java.lang.String thisPassword, java.lang.String thisAdminKey, PasswordHandler thePasswordHandler)` Creates a new instance of InformationMediator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createServices(java.lang.String serviceType)` Create an information service for each of the listed sources and initiate each one with the source information.
    `boolean` | `initialiseServerInfo(ServiceSpec theServiceSpec)` Initialise the information mediator with the server details.
    `void` | `initialiseServices(java.lang.String serviceType)` Initialise the services, primarily adding and initialising linking structures if they are included.
    `protected java.util.HashMap[]` | `sortGroupsForEach(QueryUpdate queryUpdate)` Re-sort the service list for using to update links or other based on the specification of the update model.
    `void` | `updateQueryInfo(QueryUpdate queryUpdate)` Apply a set of query update options to the list of services returned by the query result.

    - ### Methods inherited from class org.licas.service.ServiceMediator

      `createAssociationLinks, createPermanentLinks, dynamicLinksToXml, getLinkedServiceUuids, initialiseInfo, startServices, updateDynamicLinks`

    - ### Methods inherited from class org.licas.Service

      `addCommunicationID, addDefaultService, addDefaultService, addDefaultService, addDefaultService, addLinkFromService, addLinkToService, addMessageMetrics, addService, addService, addService, addService, addServiceAssociation, addServicePassword, addTempPassword, allowAddService, canAccess, canAccess, canAccess, canAccess, canAccessMeta, canAccessNested, canAccessTemp, canRun, classNameOK, clearServiceLinks, clearServices, clearServices, close, createMetaForRepos, createMetaFull, createPermanentLinkTo, createServiceWrapper, defaultAdminToRemove, dynamicLinkQuery, dynamicLinksToPermanent, dynamicLinksToXml, execute, finaliseInitialisation, finaliseInitialisation, finaliseModule, finaliseThisConfig, GET, getAllLinkToService, getAllowAddService, getAutonomicManagerConfig, getCommunicationClientURI, getData, getData, getDescription, getFullPath, getInstanceValue, getIsRemoteCall, getLinkFromService, getLinkToService, getLocalRemoteID, getParent, getParent, getPassword, getPassword, getPassword, getPasswordHandler, getPrivateMethods, getPublicMethods, getPublicServiceClassname, getServerPassword, getService, getService, getServiceAdmin, getServiceClasses, getServiceGrade, getServiceLinks, getServiceNames, getServiceNames, getServiceNames, getServiceNumber, getServiceOrWrapper, getServiceState, getServiceType, getServiceTypes, handshake, hasCommunicationID, hasLinkTo, hasServerPassword, hasService, hasServiceType, interrupt, isCorrectPassword, isPrivateMethod, isPublicMethod, isStarted, linksToXml, passwordsStateToXml, permanentLinksToXml, reflectionMethods, reflectionObject, removeAllLinksTo, removeAllServices, removeAllServices, removeCommunicationID, removeLinkFromService, removeLinkToService, removePermanentLinkTo, removeServiceAssociation, removeServiceID, removeServicePath, removeServicePath, removeTempPassword, serviceNegotiate, serviceToXml, serviceToXml, setAdminInfo, setCanAccessMeta, setCanAccessNested, setData, setDataModule, setDataModule, setDescription, setInstanceValues, setIsRemoteCall, setOtherMeta, setParent, setParent, setSerializeValues, setServerPassword, setServiceGrade, setServiceModule, setServiceState, startAllThreads, startThread, stopAllThreads, syncToAsync, syncToAsyncReply, syncToAsyncTransit, xmlToDynamicLinks, xmlToService`

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

      `getShutDown, setShutDown, setShutDown`

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

      `canAccess, 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

    - #### sourceURLs

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

      The source info urls

    - #### sourceData

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

      Retrieved data from each source

  - ### Constructor Detail

    - #### InformationMediator

          public InformationMediator(PasswordHandler thePasswordHandler)
                              throws java.lang.Exception

      Create a new instance of InformationMediator.
      Parameters:
        `thePasswordHandler` - the password handler.
      Throws:
        `java.lang.Exception` - any error.

    - #### InformationMediator

          public InformationMediator(java.lang.String thisPassword,
                                     java.lang.String thisAdminKey,
                                     PasswordHandler thePasswordHandler)
                              throws java.lang.Exception

      Creates a new instance of InformationMediator.
      Parameters:
        `thisPassword` - the component password.
        `thisAdminKey` - the unique service key.
        `thePasswordHandler` - the password handler.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### initialiseServerInfo

          public boolean initialiseServerInfo(ServiceSpec theServiceSpec)
                                       throws java.lang.Exception

      Initialise the information mediator with the server details. Also clear the network of any existing services and the password handler for this service.
      Specified by:
        `initialiseServerInfo` in class `ServiceMediator`
      Parameters:
        `theServiceSpec` - the service spec or test script, with all of the config details.
      Returns:
        true if initialised OK, false otherwise. Most likely, it would be missing server initialisation information.
      Throws:
        `java.lang.Exception` - any error.

    - #### initialiseServices

          public void initialiseServices(java.lang.String serviceType)
                                  throws java.lang.Exception

      Initialise the services, primarily adding and initialising linking structures if they are included. The initialisation could be application specific and so it is done in each version of this class.
      Specified by:
        `initialiseServices` in class `ServiceMediator`
      Parameters:
        `serviceType` - the type of service to initialise.
      Throws:
        `java.lang.Exception` - any error.

    - #### createServices

          public void createServices(java.lang.String serviceType)
                              throws java.lang.Exception

      Create an information service for each of the listed sources and initiate each one with the source information.
      Specified by:
        `createServices` in class `ServiceMediator`
      Parameters:
        `serviceType` - the type to assign to each main or base service.
      Throws:
        `java.lang.Exception` - any error.

    - #### updateQueryInfo

          public void updateQueryInfo(QueryUpdate queryUpdate)
                               throws java.lang.Exception

      Apply a set of query update options to the list of services returned by the query result.
      Parameters:
        `queryUpdate` - a description of the update process and links.
      Throws:
        `java.lang.Exception` - any error.

    - #### sortGroupsForEach

          protected java.util.HashMap[] sortGroupsForEach(QueryUpdate queryUpdate)

      Re-sort the service list for using to update links or other based on the specification of the update model.
      Parameters:
        `queryUpdate` - an update spec with separate local or remote update possibilities.
      Returns:
        the same lists sorted for creating links. For this implementation, the key in the hashtable is an entity name and the value is a list of all other entity ids. For compatibility, need to group the list inside of another one, with only that single element. For example: key: http://a1, value: [http://b1, http://c1, http://d1, http://e1, etc].