Package moise.oe

Class OE

java.lang.Object
moise.common.Event
moise.oe.OE
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ToXML

public class OE
extends Event
implements java.lang.Cloneable, ToXML
Represents an Organisational Entity
Author:
Jomi Fred Hubner
See Also:
Serialized Form
  • Field Details

    • serialVersionUID

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

      protected GoalInstance purpose
    • os

      protected OS os
    • agents

      protected java.util.Map<java.lang.String,​OEAgent> agents
    • groups

      protected java.util.Map<java.lang.String,​GroupInstance> groups
    • schs

      protected java.util.Map<java.lang.String,​SchemeInstance> schs
  • Constructor Details

  • Method Details

    • createOE

      public static OE createOE​(java.lang.String purpose, java.lang.String OSxmlURI) throws MoiseConsistencyException
      Creates a new organisational entity with purpose and organisation specification as state in the file OSxmlURI. This XML file must be written in accordance with the XML Schema specified in file os.xsd.

      Example:

      OE currentOE = OE.createOE("winGame", "jojOS.xml");
      Parameters:
      purpose - the purpose of the entity
      OSxmlURI - the organisation specification
      Returns:
      an OE object representing this new entity
      Throws:
      MoiseConsistencyException - in case the XML file is not well formed
    • partialOE

      public OE partialOE​(OEAgent ag) throws MoiseConsistencyException
      gets a partial view of this OE, only entities allowed for the ag will be shown.
      Throws:
      MoiseConsistencyException
    • clone

      public java.lang.Object clone()
      the clone object is a full/independent copy of this object,i.e., all OE inner objects are also cloned.
      Overrides:
      clone in class java.lang.Object
    • rebuildHash

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

      public void changePurpose​(java.lang.String newPurpose)
    • getPurpose

      public GoalInstance getPurpose()
    • getOS

      public OS getOS()
      gets the OS of this entity
      Returns:
      the OS of this entity
    • addAgent

      public OEAgent addAgent​(java.lang.String agName) throws MoiseException
      Adds an agent in the OE.

      Example: OEAgent jaime = currentOE.addAgent("Jaime");

      Parameters:
      agName - the agent name
      Returns:
      an OEAgent object reference
      Throws:
      MoiseException
    • removeAgent

      public void removeAgent​(java.lang.String agId, boolean check) throws MoiseException
      Removes an agent from the OE.

      Example: currentOE.removeAgent("Jomi");

      Parameters:
      agId - the agent id (the id is in OE)
      check - if true, the moise consistencies will be checked
      Throws:
      MoiseConsistencyException - the must not have roles or missions
      MoiseException
    • getAgent

      public OEAgent getAgent​(java.lang.String agId)
    • getAgents

      public java.util.Collection<OEAgent> getAgents()
    • getAgents

      public java.util.Collection<OEAgent> getAgents​(GroupInstance gr, java.lang.String roleId)
      gets all agents that plays role in gr. if gr == null, does not consider the group
    • getAgents

      public java.util.Collection<OEAgent> getAgents​(GroupInstance gr, Role role)
      gets all agents that plays role in gr. if gr == null, the group is not considered
    • addGroup

      public GroupInstance addGroup​(java.lang.String grSpecId) throws MoiseException
      Creates a new root group instance from the specification denoted by grSpecId.

      Example:

      Group   team    = currentOE.addGroup("team");
      Parameters:
      grSpecId - the group specification id (the id is in OS)
      Returns:
      a reference for the new Group
      Throws:
      MoiseConsistencyException - the grSpecId is not a root group
      MoiseCardinalityException - the cardinality (the max subgroup is already achieved)
      MoiseException
    • addGroup

      public GroupInstance addGroup​(java.lang.String grId, java.lang.String grSpecId) throws MoiseException
      Creates a new root group instance (identified by grId) from the specification denoted by grSpecId.

      Example:

      Group   team    = currentOE.addGroup("g1", "team");
      Parameters:
      grId - the id of the new group
      grSpecId - the group specification id (the id is in OS)
      Returns:
      a reference for the new Group
      Throws:
      MoiseConsistencyException - the grSpecId is not a root group
      MoiseCardinalityException - the cardinality (the max subgroup is already achieved)
      MoiseException
    • removeGroup

      public void removeGroup​(java.lang.String grId) throws MoiseConsistencyException
      Removes a group instance from this OE. It works for subgroups and root groups.

      Example: currentOE.removeGroup("gr_team0");

      Parameters:
      grId - the group instance id
      Throws:
      MoiseConsistencyException - the group has players, the group has subgroups
    • getGroups

      public java.util.Collection<GroupInstance> getGroups()
      returns the root groups
    • getAllSubGroupsTree

      public java.util.Collection<GroupInstance> getAllSubGroupsTree()
      return all groups of the OE, even subgroups
    • getSubGroupInstancesQty

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

      public GroupInstance findGroup​(java.lang.String grId)
      looks for a group with grId in this OE (and inside all its groups)
    • findInstancesOf

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

      public java.util.Collection<GroupInstance> findInstancesOf​(java.lang.String grSpec)
      finds all groups (and subgroups) that instantiates grSpec
    • startScheme

      public SchemeInstance startScheme​(java.lang.String schSpecId) throws MoiseException
      Creates a new scheme instance.

      Example: Scheme sch = currentOE.startScheme("sideAttack");

      Parameters:
      schSpecId - the scheme specification (from OS)
      Returns:
      a SCH object
      Throws:
      MoiseException
    • startScheme

      public SchemeInstance startScheme​(java.lang.String schId, java.lang.String schSpecId) throws MoiseException
      Creates a new scheme instance with a particular id.

      Example: Scheme sch = currentOE.startScheme("s1", "sideAttack");

      Parameters:
      schId - the name of the new scheme
      schSpecId - the scheme specification (from OS)
      Returns:
      a SCH object
      Throws:
      MoiseException
    • finishScheme

      public void finishScheme​(SchemeInstance sch) throws MoiseException
      Removes the scheme instance from the OE's Schemes.

      Example: currentOE.finischScheme(satt);
      where satt is a Scheme handler.

      Parameters:
      sch - the scheme instance object handler
      Throws:
      MoiseException - only schemes without players can be normally finished
    • abortScheme

      public void abortScheme​(SchemeInstance sch) throws MoiseException
      Aborts (and removes) the scheme instance from the OE's Schemes. All agents committed to this scheme missions will lost their commitment.

      Example: currentOE.abortScheme(satt);
      where satt is a Scheme handler.

      Parameters:
      sch - the scheme instance object handler
      Throws:
      MoiseException
    • findScheme

      public SchemeInstance findScheme​(java.lang.String schId)
      looks for a Scheme with schId
    • findInstancesOfSchSpec

      public java.util.Collection<SchemeInstance> findInstancesOfSchSpec​(java.lang.String schSpecId)
      finds all schemes that instantiates schSpecId
    • getSchemes

      public java.util.Collection<SchemeInstance> getSchemes()
    • getXMLTag

      public java.lang.String getXMLTag()
    • getAsDOM

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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object