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 Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,OEAgent>agentsprotected java.util.Map<java.lang.String,GroupInstance>groupsprotected OSosprotected GoalInstancepurposeprotected java.util.Map<java.lang.String,SchemeInstance>schsprivate static longserialVersionUID -
Constructor Summary
Constructors Constructor Description OE(GoalInstance purpose, OS os) -
Method Summary
Modifier and Type Method Description voidabortScheme(SchemeInstance sch)Aborts (and removes) the scheme instance from the OE's Schemes.OEAgentaddAgent(java.lang.String agName)Adds an agent in the OE.GroupInstanceaddGroup(java.lang.String grSpecId)Creates a new root group instance from the specification denoted by grSpecId.GroupInstanceaddGroup(java.lang.String grId, java.lang.String grSpecId)Creates a new root group instance (identified by grId) from the specification denoted by grSpecId.voidchangePurpose(java.lang.String newPurpose)java.lang.Objectclone()the clone object is a full/independent copy of this object,i.e., all OE inner objects are also cloned.static OEcreateOE(java.lang.String purpose, java.lang.String OSxmlURI)Creates a new organisational entity with purpose and organisation specification as state in the file OSxmlURI.GroupInstancefindGroup(java.lang.String grId)looks for a group with grId in this OE (and inside all its groups)java.util.Collection<GroupInstance>findInstancesOf(java.lang.String grSpec)finds all groups (and subgroups) that instantiates grSpecjava.util.Collection<GroupInstance>findInstancesOf(Group grSpec)finds all groups (and subgroups) that instantiates grSpecjava.util.Collection<SchemeInstance>findInstancesOfSchSpec(java.lang.String schSpecId)finds all schemes that instantiates schSpecIdSchemeInstancefindScheme(java.lang.String schId)looks for a Scheme with schIdvoidfinishScheme(SchemeInstance sch)Removes the scheme instance from the OE's Schemes.OEAgentgetAgent(java.lang.String agId)java.util.Collection<OEAgent>getAgents()java.util.Collection<OEAgent>getAgents(GroupInstance gr, java.lang.String roleId)gets all agents that playsroleingr.java.util.Collection<OEAgent>getAgents(GroupInstance gr, Role role)gets all agents that playsroleingr.java.util.Collection<GroupInstance>getAllSubGroupsTree()return all groups of the OE, even subgroupsorg.w3c.dom.ElementgetAsDOM(org.w3c.dom.Document document)java.util.Collection<GroupInstance>getGroups()returns the root groupsOSgetOS()gets the OS of this entityGoalInstancegetPurpose()java.util.Collection<SchemeInstance>getSchemes()intgetSubGroupInstancesQty(java.lang.String grSpecId)returns the number of grSpecId instancesjava.lang.StringgetXMLTag()OEpartialOE(OEAgent ag)gets a partial view of this OE, only entities allowed for the ag will be shown.voidrebuildHash()since serialisation of maps has a bug, we need to rebuild them after serialisation!voidremoveAgent(java.lang.String agId, boolean check)Removes an agent from the OE.voidremoveGroup(java.lang.String grId)Removes a group instance from this OE.SchemeInstancestartScheme(java.lang.String schSpecId)Creates a new scheme instance.SchemeInstancestartScheme(java.lang.String schId, java.lang.String schSpecId)Creates a new scheme instance with a particular id.java.lang.StringtoString()Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
purpose
-
os
-
agents
-
groups
-
schs
-
-
Constructor Details
-
OE
- Throws:
MoiseConsistencyException
-
-
Method Details
-
createOE
public static OE createOE(java.lang.String purpose, java.lang.String OSxmlURI) throws MoiseConsistencyExceptionCreates 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 entityOSxmlURI- the organisation specification- Returns:
- an OE object representing this new entity
- Throws:
MoiseConsistencyException- in case the XML file is not well formed
-
partialOE
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:
clonein classjava.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
-
getOS
gets the OS of this entity- Returns:
- the OS of this entity
-
addAgent
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
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 missionsMoiseException
-
getAgent
-
getAgents
-
getAgents
gets all agents that playsroleingr. if gr == null, does not consider the group -
getAgents
gets all agents that playsroleingr. if gr == null, the group is not considered -
addGroup
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 groupMoiseCardinalityException- the cardinality (the max subgroup is already achieved)MoiseException
-
addGroup
public GroupInstance addGroup(java.lang.String grId, java.lang.String grSpecId) throws MoiseExceptionCreates 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 groupgrSpecId- the group specification id (the id is in OS)- Returns:
- a reference for the new Group
- Throws:
MoiseConsistencyException- the grSpecId is not a root groupMoiseCardinalityException- the cardinality (the max subgroup is already achieved)MoiseException
-
removeGroup
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
returns the root groups -
getAllSubGroupsTree
return all groups of the OE, even subgroups -
getSubGroupInstancesQty
public int getSubGroupInstancesQty(java.lang.String grSpecId)returns the number of grSpecId instances -
findGroup
looks for a group with grId in this OE (and inside all its groups) -
findInstancesOf
finds all groups (and subgroups) that instantiates grSpec -
findInstancesOf
finds all groups (and subgroups) that instantiates grSpec -
startScheme
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 MoiseExceptionCreates a new scheme instance with a particular id.Example:
Scheme sch = currentOE.startScheme("s1", "sideAttack");- Parameters:
schId- the name of the new schemeschSpecId- the scheme specification (from OS)- Returns:
- a SCH object
- Throws:
MoiseException
-
finishScheme
Removes the scheme instance from the OE's Schemes.Example:
currentOE.finischScheme(satt);wheresattis a Scheme handler.- Parameters:
sch- the scheme instance object handler- Throws:
MoiseException- only schemes without players can be normally finished
-
abortScheme
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);wheresattis a Scheme handler.- Parameters:
sch- the scheme instance object handler- Throws:
MoiseException
-
findScheme
looks for a Scheme with schId -
findInstancesOfSchSpec
finds all schemes that instantiates schSpecId -
getSchemes
-
getXMLTag
public java.lang.String getXMLTag() -
getAsDOM
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document) -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-