Package moise.oe
Class SchemeInstance
- java.lang.Object
-
- moise.common.MoiseElement
-
- moise.oe.SchemeInstance
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable
,Identifiable
,ToXML
public class SchemeInstance extends MoiseElement implements ToXML
Represents the instance of one scheme Specification.- Author:
- Jomi Fred Hubner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,GoalInstance>
goals
protected java.util.Set<GroupInstance>
groups
protected OE
oe
protected java.util.Set<PlanInstance>
plans
protected java.util.Set<MissionPlayer>
players
protected GoalInstance
root
private static java.util.concurrent.atomic.AtomicInteger
schCount
private static long
serialVersionUID
protected Scheme
spec
static java.lang.String
WellFormed
-
Fields inherited from class moise.common.MoiseElement
debug
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SchemeInstance(java.lang.String id, Scheme sch)
-
Method Summary
Modifier and Type Method Description void
abort()
remove all commitments without checking goal stateprotected void
addPlayer(MissionPlayer mp)
adds a mission player for this SCHvoid
addResponsibleGroup(java.lang.String grId)
adds an instance group in the set of groups responsible for this SCH.void
addResponsibleGroup(GroupInstance g)
adds an instance group in the set of groups responsible for this SCH.java.util.Collection<OEAgent>
getAgents()
gets all agents participating in this schemeorg.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
GoalInstance
getGoal(java.lang.String goalId)
GoalInstance
getGoal(Goal gs)
java.util.Collection<GoalInstance>
getGoals()
OE
getOE()
java.util.Collection<MissionPlayer>
getPlayers()
java.util.Collection<OEAgent>
getPlayers(java.lang.String missionId)
returns the OEAgents committed to the missionId in this scheme (if missionId is null, return all agents)int
getPlayersQty()
returns the total number of players in this schint
getPlayersQty(java.lang.String missionId)
returns the number of missionId players in this schemejava.util.Collection<GroupInstance>
getResponsibleGroups()
returns a collection of groups that are responsible for this schemeGoalInstance
getRoot()
Scheme
getSpec()
returns the SCH specification for this SCH instancestatic java.lang.String
getUniqueId()
static java.lang.String
getXMLTag()
boolean
isCommitable()
returns true if this scheme's root goal is neither achieved nor impossibleboolean
isPlayer(OEAgent ag)
boolean
isWellFormed()
returns true if the sch is well formedvoid
rebuildHash()
since serialisation of maps has a bug, we need to rebuild them after serialisation!protected void
removePlayer(MissionPlayer mp)
removes a mission player from this scheme (no checks are done)void
remResponsibleGroup(java.lang.String grId)
removes an instance group in the set of groups responsible for this SCH.void
remResponsibleGroup(GroupInstance g)
removes an instance group in the set of groups responsible for this SCH.protected void
setOE(OE oe)
java.lang.String
wellFormedStatus()
returns "ok" (SchemeInstance.WellFormed) if the sch 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
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
WellFormed
public static final java.lang.String WellFormed
- See Also:
- Constant Field Values
-
spec
protected Scheme spec
-
root
protected GoalInstance root
-
oe
protected OE oe
-
players
protected java.util.Set<MissionPlayer> players
-
groups
protected java.util.Set<GroupInstance> groups
-
goals
protected java.util.Map<java.lang.String,GoalInstance> goals
-
plans
protected java.util.Set<PlanInstance> plans
-
schCount
private static java.util.concurrent.atomic.AtomicInteger schCount
-
-
Constructor Detail
-
SchemeInstance
protected SchemeInstance(java.lang.String id, Scheme sch) throws MoiseConsistencyException
- 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()
-
setOE
protected void setOE(OE oe)
-
getOE
public OE getOE()
-
getRoot
public GoalInstance getRoot()
-
getSpec
public Scheme getSpec()
returns the SCH specification for this SCH instance
-
addResponsibleGroup
public void addResponsibleGroup(java.lang.String grId) throws MoiseConsistencyException
adds an instance group in the set of groups responsible for this SCH.Example:
sch.addResponsibleGroup(def.getId());
- Parameters:
grId
- the group Id- Throws:
MoiseConsistencyException
- the grIs does not exist in the OE
-
addResponsibleGroup
public void addResponsibleGroup(GroupInstance g) throws MoiseConsistencyException
adds an instance group in the set of groups responsible for this SCH.Example:
sch.addResponsibleGroup(def);
- Parameters:
g
- the group object- Throws:
MoiseConsistencyException
- the group is not well formed
-
remResponsibleGroup
public void remResponsibleGroup(java.lang.String grId) throws MoiseConsistencyException
removes an instance group in the set of groups responsible for this SCH.Example:
sch.remResponsibleGroup("gr_def22");
- Parameters:
grId
- the group id- Throws:
MoiseConsistencyException
- no agent of group g can be committed to missions in this scheme
-
remResponsibleGroup
public void remResponsibleGroup(GroupInstance g) throws MoiseConsistencyException
removes an instance group in the set of groups responsible for this SCH.Example:
sch.remResponsibleGroup(def);
- Parameters:
g
- the group object- Throws:
MoiseConsistencyException
- no agent of group g can be committed to missions in this scheme
-
getResponsibleGroups
public java.util.Collection<GroupInstance> getResponsibleGroups()
returns a collection of groups that are responsible for this scheme
-
abort
public void abort() throws MoiseException
remove all commitments without checking goal state- Throws:
MoiseException
-
wellFormedStatus
public java.lang.String wellFormedStatus()
returns "ok" (SchemeInstance.WellFormed) if the sch is well formed, otherwise returns the problems' description
-
isWellFormed
public boolean isWellFormed()
returns true if the sch is well formed
-
isCommitable
public boolean isCommitable()
returns true if this scheme's root goal is neither achieved nor impossible
-
addPlayer
protected void addPlayer(MissionPlayer mp)
adds a mission player for this SCH
-
removePlayer
protected void removePlayer(MissionPlayer mp) throws MoiseException
removes a mission player from this scheme (no checks are done)- Throws:
MoiseException
-
getPlayers
public java.util.Collection<MissionPlayer> getPlayers()
-
isPlayer
public boolean isPlayer(OEAgent ag)
-
getPlayers
public java.util.Collection<OEAgent> getPlayers(java.lang.String missionId)
returns the OEAgents committed to the missionId in this scheme (if missionId is null, return all agents)
-
getAgents
public java.util.Collection<OEAgent> getAgents()
gets all agents participating in this scheme
-
getPlayersQty
public int getPlayersQty()
returns the total number of players in this sch
-
getPlayersQty
public int getPlayersQty(java.lang.String missionId)
returns the number of missionId players in this scheme
-
getGoal
public GoalInstance getGoal(java.lang.String goalId)
-
getGoal
public GoalInstance getGoal(Goal gs)
-
getGoals
public java.util.Collection<GoalInstance> getGoals()
-
getXMLTag
public static java.lang.String getXMLTag()
-
-