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>
agents
protected java.util.Map<java.lang.String,GroupInstance>
groups
protected OS
os
protected GoalInstance
purpose
protected java.util.Map<java.lang.String,SchemeInstance>
schs
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description OE(GoalInstance purpose, OS os)
-
Method Summary
Modifier and Type Method Description void
abortScheme(SchemeInstance sch)
Aborts (and removes) the scheme instance from the OE's Schemes.OEAgent
addAgent(java.lang.String agName)
Adds an agent in the OE.GroupInstance
addGroup(java.lang.String grSpecId)
Creates a new root group instance from the specification denoted by grSpecId.GroupInstance
addGroup(java.lang.String grId, java.lang.String grSpecId)
Creates a new root group instance (identified by grId) from the specification denoted by grSpecId.void
changePurpose(java.lang.String newPurpose)
java.lang.Object
clone()
the clone object is a full/independent copy of this object,i.e., all OE inner objects are also cloned.static OE
createOE(java.lang.String purpose, java.lang.String OSxmlURI)
Creates a new organisational entity with purpose and organisation specification as state in the file OSxmlURI.GroupInstance
findGroup(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 schSpecIdSchemeInstance
findScheme(java.lang.String schId)
looks for a Scheme with schIdvoid
finishScheme(SchemeInstance sch)
Removes the scheme instance from the OE's Schemes.OEAgent
getAgent(java.lang.String agId)
java.util.Collection<OEAgent>
getAgents()
java.util.Collection<OEAgent>
getAgents(GroupInstance gr, java.lang.String roleId)
gets all agents that playsrole
ingr
.java.util.Collection<OEAgent>
getAgents(GroupInstance gr, Role role)
gets all agents that playsrole
ingr
.java.util.Collection<GroupInstance>
getAllSubGroupsTree()
return all groups of the OE, even subgroupsorg.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
java.util.Collection<GroupInstance>
getGroups()
returns the root groupsOS
getOS()
gets the OS of this entityGoalInstance
getPurpose()
java.util.Collection<SchemeInstance>
getSchemes()
int
getSubGroupInstancesQty(java.lang.String grSpecId)
returns the number of grSpecId instancesjava.lang.String
getXMLTag()
OE
partialOE(OEAgent ag)
gets a partial view of this OE, only entities allowed for the ag will be shown.void
rebuildHash()
since serialisation of maps has a bug, we need to rebuild them after serialisation!void
removeAgent(java.lang.String agId, boolean check)
Removes an agent from the OE.void
removeGroup(java.lang.String grId)
Removes a group instance from this OE.SchemeInstance
startScheme(java.lang.String schSpecId)
Creates a new scheme instance.SchemeInstance
startScheme(java.lang.String schId, java.lang.String schSpecId)
Creates a new scheme instance with a particular id.java.lang.String
toString()
-
-
-
Field Detail
-
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 Detail
-
OE
public OE(GoalInstance purpose, OS os) throws MoiseConsistencyException
- Throws:
MoiseConsistencyException
-
-
Method Detail
-
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 entityOSxmlURI
- 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 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
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 missionsMoiseException
-
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 playsrole
ingr
. if gr == null, does not consider the group
-
getAgents
public java.util.Collection<OEAgent> getAgents(GroupInstance gr, Role role)
gets all agents that playsrole
ingr
. 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 groupMoiseCardinalityException
- 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 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
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 schemeschSpecId
- 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);
wheresatt
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);
wheresatt
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)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-