Class SimpleComponentModel

java.lang.Object
net.simplace.client.sim.simple.SimpleComponentModel

public class SimpleComponentModel extends Object
The variables of a SimpleSimComponent (FWSimpleSimComponent) as edited in the GUI (Redmine #62): each variable is calculated by its rule, in order, in the process step or after the integration. Reads the variables from the configuration element (from(String, Element)), checks them (check(Predicate, Function)) and writes them as var elements (toVarElements(PHASE)); attributes not edited here (e.g. min, max, mode) are kept.
Author:
Andreas Enders, Claude (Anthropic), co-author
  • Field Details

    • DATA_TYPES

      public static final String[] DATA_TYPES
      data types of the variables
  • Constructor Details

    • SimpleComponentModel

      public SimpleComponentModel(String aComponentName)
      Parameters:
      aComponentName - id of the component (prefix of its variable names)
  • Method Details

    • from

      public static SimpleComponentModel from(String aComponentName, org.jdom2.Element aComponentElement)
      Parameters:
      aComponentName - id of the component
      aComponentElement - the simcomponent element, may be null (no variables)
      Returns:
      the model with the variables of process and integrate, in order
    • getVars

      public List<SimpleComponentModel.Var> getVars()
      Returns:
      the variables: first all of the process step, then all calculated after the integration, each in order
    • getComponentName

      public String getComponentName()
      Returns:
      the id of the component
    • sortByPhase

      public void sortByPhase()
      Sorts the variables by phase (process first), keeping the order within each phase.
    • currentNames

      public Set<String> currentNames()
      Returns:
      the full names of the variables as they are now, e.g. Component.Var
    • check

      public List<SimpleComponentModel.Problem> check(Predicate<String> aKnownVariable, Function<String, List<String>> aUsers)
      Checks all variables: no variable, invalid or duplicate id, unknown data type, empty rule, syntax error (errors); unknown variables in a rule, default not of the data type, variables removed or renamed which are used by other parts of the solution (warnings); a variable using a later (or itself) variable of the component - it gets the value of the previous step -, operator hints of the rule check (hints).
      Parameters:
      aKnownVariable - tells whether a variable of the solution is known (the variables of this component are added), or null to skip this check
      aUsers - the users (e.g. components, outputs) of a variable of the solution, or null to skip this check
      Returns:
      the problems
    • remove

      public void remove(SimpleComponentModel.Var aVar)
      Removes a variable; a variable read from the element is remembered for the check of its users.
      Parameters:
      aVar - the variable
    • toVarElements

      public List<org.jdom2.Element> toVarElements(SimpleComponentModel.PHASE aPhase)
      Parameters:
      aPhase - process or integrate
      Returns:
      the var elements of the phase, in order (copies of the read elements with the edited attributes, or new elements)
    • toComponentElement

      public org.jdom2.Element toComponentElement()
      Returns:
      a new simcomponent element of a FWSimpleSimComponent with these variables (e.g. for a new component)