Class TroubleInfoFactory

java.lang.Object
com.tccc.kos.commons.core.service.trouble.TroubleInfoFactory

public class TroubleInfoFactory extends Object
Simple implementation of TroubleInfoFactory that loads an array of TroubleInfo objects from a json stream.

The will match the trouble using the simple name of the trouble class. For any case where no info is found, an entry with a name of default will be used instead.

The file format is as follows:

 {
    "PrimeTrouble" : {
        visibleRole: "CREW",
        actionRole: "TECHNICIAN",
        rank: 100,
        color: "orange"
    },
    ...
    "default" : {
        visibleRole: "CREW",
        rank: 100,
        color: "white"
    }
 }
 

The properties are intended to be used as follows:

  • visibleRole : The minimum role that can view the trouble. In some cases troubles are intended for technicians and shouldn't be shown to other users.
  • actionRole : The minimum role that can resolve the trouble. In some cases a trouble may be shown to users but only technician can resolve it. If not specified, actionRole is assumed to be the same as visibleRole.
  • rank : The sort order of the trouble. Used when the highest priority trouble must be shown to a user.
  • color : The color hint for the trouble.

The values stored in the structure are not defined and can be adjusted to match the needs of the ui. For example, color may be specified as a color code or css name. The names of the objects are the types of the troubles (the simple class name of the trouble class).

Since:
1.0
Version:
2023-01-31
  • Constructor Details

    • TroubleInfoFactory

      public TroubleInfoFactory()
  • Method Details

    • load

      public boolean load(Object key, InputStream is, Class<? extends TroubleInfo> clazz)
      Load the specified info file.
      Parameters:
      key - the key for the info data, used for remove
      is - input stream containing the info
      clazz - the TroubleInfo subclass to use
    • unload

      public void unload(Object key)
      Unload the trouble info associated with the specified key.
      Parameters:
      key - the key used to load the info
    • getTroubleInfo

      public TroubleInfo getTroubleInfo(Trouble trouble)