Package moise.oe

Class GroupInstance

java.lang.Object
moise.common.MoiseElement
moise.oe.GroupInstance
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Identifiable, ToXML

public class GroupInstance
extends MoiseElement
implements ToXML
Represents the instance group of one Group Specification
Author:
Jomi Fred Hubner
See Also:
Serialized Form
  • Field Details

    • spec

      protected Group spec
    • superGroup

      protected GroupInstance superGroup
    • oe

      protected OE oe
    • subGroups

      protected java.util.Map<java.lang.String,​GroupInstance> subGroups
    • players

      protected java.util.Set<RolePlayer> players
    • logger

      private static java.util.logging.Logger logger
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
    • grCount

      private static java.util.concurrent.atomic.AtomicInteger grCount
  • Constructor Details

  • Method Details

    • rebuildHash

      public void rebuildHash()
      since serialisation of maps has a bug, we need to rebuild them after serialisation!
    • getUniqueId

      public static java.lang.String getUniqueId()
      create a new group instance named automatically
    • getGrSpec

      public Group getGrSpec()
    • setOE

      protected void setOE​(OE oe)
      returns the unique number of the group (the getId uses this number to form the unique id.
    • setSuperGroup

      protected void setSuperGroup​(GroupInstance gr)
    • getSuperGroup

      public GroupInstance getSuperGroup()
    • isWellFormed

      public boolean isWellFormed()
    • wellFormedStatus

      public java.lang.String wellFormedStatus()
      returns "ok" if the group is well formed, otherwise returns the problems description
    • getRespSchemes

      public java.util.Collection<SchemeInstance> getRespSchemes()
      returns a set of schemes which this group is responsible for
    • addSubGroup

      public GroupInstance addSubGroup​(java.lang.String grSpecId) throws MoiseException
      Adds a subgroup in a group, the id of the subgroup is defined automatically.

      Example:

      Group def = team.addSubGroup("defense");
      Parameters:
      grId - the id of the new group
      grSpecId - the group specification identification (from OS)
      Returns:
      the Group object created
      Throws:
      MoiseConsistencyException - the grSpecId is not a subgroup of this group
      MoiseCardinalityException - the cardinality (the max subgroup is already achieved)
      MoiseException
    • addSubGroup

      public GroupInstance addSubGroup​(java.lang.String grId, java.lang.String grSpecId) throws MoiseException
      Adds a subgroup in a group.

      Example:

      Group def = team.addSubGroup("d1", "defense");
      Parameters:
      grId - the id of the new group
      grSpecId - the group specification identification (from OS)
      Returns:
      the Group object created
      Throws:
      MoiseConsistencyException - the grSpecId is not a subgroup of this group
      MoiseCardinalityException - the cardinality (the max subgroup is already achieved)
      MoiseException
    • removeSubGroup

      public void removeSubGroup​(java.lang.String grId) throws MoiseConsistencyException
      Removes a subgroup instance from this group.

      Example: att.removeSubGroup("gr_defense1");

      Parameters:
      grId - the group instance id
      Throws:
      MoiseConsistencyException - the grId is not a subgroup, the group has players, the group has subgroups
    • removeRelations

      protected void removeRelations() throws MoiseConsistencyException
      Throws:
      MoiseConsistencyException
    • checkRemove

      public void checkRemove() throws MoiseConsistencyException
      Throws:
      MoiseConsistencyException
    • getSubGroupInstacesQty

      public int getSubGroupInstacesQty()
      returns the number of subgroups instances
    • getSubGroupInstacesQty

      public int getSubGroupInstacesQty​(java.lang.String grSpecId)
      returns the number of grSpecId instances
    • getSubGroups

      public java.util.Collection<GroupInstance> getSubGroups()
    • getAllSubGroupsTree

      public java.util.Collection<GroupInstance> getAllSubGroupsTree()
      gets this group and all its sub groups, the sob-groups of the subgroups, .....
    • findGroup

      public GroupInstance findGroup​(java.lang.String grId)
      looks for a group with grId in this Group (and its subgroups)
    • findInstancesOf

      public java.util.Collection<GroupInstance> findInstancesOf​(Group grSpec)
      get all groups (and subgroups) that instantiates grSpec
    • addPlayer

      public void addPlayer​(RolePlayer rp)
      adds a role player in this group
    • removePlayer

      public void removePlayer​(RolePlayer rp)
      removes a role player from this group
    • getPlayers

      public java.util.Collection<RolePlayer> getPlayers()
      returns an iterator for RolePlayer objects
    • getPlayersQty

      public int getPlayersQty()
      returns the total number of players in this group (does not consider players in subgroups)
    • getPlayers

      public java.util.Collection<RolePlayer> getPlayers​(java.lang.String roleId, boolean includeSubGroups)
      returns the roleId players in this group (includeSubGroups==false) or in this group and its subgroups (includeSubGroups==true). It returns a collection of OEAgent objects. If roleId is null, all roles are included in the result.
    • getAgents

      public java.util.Set<OEAgent> getAgents​(boolean includeSubGroups)
      returns a collection with OEAgents belonging to this group
    • getXMLTag

      public static java.lang.String getXMLTag()
    • getAsDOM

      public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      Specified by:
      getAsDOM in interface ToXML