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 Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicInteger
grCount
private static java.util.logging.Logger
logger
protected OE
oe
protected java.util.Set<RolePlayer>
players
private static long
serialVersionUID
protected Group
spec
protected java.util.Map<java.lang.String,GroupInstance>
subGroups
protected GroupInstance
superGroup
-
Fields inherited from class moise.common.MoiseElement
debug
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GroupInstance(java.lang.String id, Group spec)
create a new group instance identified by id
-
Method Summary
Modifier and Type Method Description void
addPlayer(RolePlayer rp)
adds a role player in this groupGroupInstance
addSubGroup(java.lang.String grSpecId)
Adds a subgroup in a group, the id of the subgroup is defined automatically.GroupInstance
addSubGroup(java.lang.String grId, java.lang.String grSpecId)
Adds a subgroup in a group.void
checkRemove()
GroupInstance
findGroup(java.lang.String grId)
looks for a group with grId in this Group (and its subgroups)java.util.Collection<GroupInstance>
findInstancesOf(Group grSpec)
get all groups (and subgroups) that instantiates grSpecjava.util.Set<OEAgent>
getAgents(boolean includeSubGroups)
returns a collection with OEAgents belonging to this groupjava.util.Collection<GroupInstance>
getAllSubGroupsTree()
gets this group and all its sub groups, the sob-groups of the subgroups, .....org.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
Group
getGrSpec()
java.util.Collection<RolePlayer>
getPlayers()
returns an iterator for RolePlayer objectsjava.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).int
getPlayersQty()
returns the total number of players in this group (does not consider players in subgroups)java.util.Collection<SchemeInstance>
getRespSchemes()
returns a set of schemes which this group is responsible forint
getSubGroupInstacesQty()
returns the number of subgroups instancesint
getSubGroupInstacesQty(java.lang.String grSpecId)
returns the number of grSpecId instancesjava.util.Collection<GroupInstance>
getSubGroups()
GroupInstance
getSuperGroup()
static java.lang.String
getUniqueId()
create a new group instance named automaticallystatic java.lang.String
getXMLTag()
boolean
isWellFormed()
void
rebuildHash()
since serialisation of maps has a bug, we need to rebuild them after serialisation!void
removePlayer(RolePlayer rp)
removes a role player from this groupprotected void
removeRelations()
void
removeSubGroup(java.lang.String grId)
Removes a subgroup instance from this group.protected void
setOE(OE oe)
returns the unique number of the group (the getId uses this number to form the unique id.protected void
setSuperGroup(GroupInstance gr)
java.lang.String
wellFormedStatus()
returns "ok" if the group is well formed, otherwise returns the problems description-
Methods inherited from class moise.common.MoiseElement
compareTo, equals, getBoolProperty, getBoolProperty, getCreationDate, getFullId, getId, getId, getOwner, getPrefix, getPrefix, getProperties, getPropertiesAsDOM, getPropertiesAsProlog, getProperty, getStrProperty, hashCode, setId, setOwner, setPrefix, setPropertiesFromDOM, setProperty, toString
-
-
-
-
Field Detail
-
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 Detail
-
GroupInstance
protected GroupInstance(java.lang.String id, Group spec) throws MoiseConsistencyException
create a new group instance identified by id- Throws:
MoiseConsistencyException
-
-
Method Detail
-
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 groupgrSpecId
- the group specification identification (from OS)- Returns:
- the Group object created
- Throws:
MoiseConsistencyException
- the grSpecId is not a subgroup of this groupMoiseCardinalityException
- 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 groupgrSpecId
- the group specification identification (from OS)- Returns:
- the Group object created
- Throws:
MoiseConsistencyException
- the grSpecId is not a subgroup of this groupMoiseCardinalityException
- 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()
-
-