Class ManagementModel

java.lang.Object
net.simplace.client.sim.management.ManagementModel

public class ManagementModel extends Object
Editable model of the actions of a DefaultManagement (Redmine #62): a list of actions, each with a rule (when the action is done) and its management variables (mgm: id, data type, mode, default, rule). It is read from and written to the action elements of the simcomponent element; attributes and children the editor does not know (e.g. unit, min) are kept. check(Predicate) lists the problems for the editor.
Author:
Andreas Enders, Claude (Anthropic), co-author
  • Field Details

    • DATA_TYPES

      public static final String[] DATA_TYPES
      data types offered for mgm variables (see the DTD)
    • MODES

      public static final String[] MODES
      modes offered for mgm variables; empty = ITE (default)
  • Constructor Details

    • ManagementModel

      public ManagementModel()
  • Method Details

    • from

      public static ManagementModel from(org.jdom2.Element aSimComponent)
      Reads the actions of a simcomponent element.
      Parameters:
      aSimComponent - the element, or null for an empty model
      Returns:
      the model
    • getActions

      public List<ManagementModel.Action> getActions()
      Returns:
      the actions (editable, in order of execution)
    • toActionElements

      public List<org.jdom2.Element> toActionElements()
      Returns:
      the action elements
    • check

      public List<ManagementModel.Problem> check(Predicate<String> aKnownVariable)
      Checks all actions.
      Parameters:
      aKnownVariable - tells whether a variable name used in a rule is known, or null to skip this check
      Returns:
      the problems, ordered by action
    • changedRule

      public static String changedRule(String aRule, String aOriginal)
      Parameters:
      aRule - the rule as edited
      aOriginal - the rule as read, or null for a new one
      Returns:
      a new or changed rule with its texts in single quotes (see RuleText.singleQuotes(String)), an unchanged rule as it was
    • dataType

      public static net.simplace.sim.util.FWSimVariable.DATA_TYPE dataType(String aName)
      Parameters:
      aName - name of a data type
      Returns:
      the data type, or null if unknown
    • parsable

      public static boolean parsable(String aValue, net.simplace.sim.util.FWSimVariable.DATA_TYPE aDataType)
      Parameters:
      aValue - a value as text
      aDataType - the data type
      Returns:
      true if the text is a value of the data type
    • setOrRemove

      public static void setOrRemove(org.jdom2.Element aElement, String aAttribute, String aValue)
      Sets an attribute or removes it if the value is empty - unless it was already given empty in the original element (e.g. default="", an empty text as default, which differs from no default).
      Parameters:
      aElement - the element
      aAttribute - name of the attribute
      aValue - the value, empty to remove