Package moise.oe
Class OEAgent
- java.lang.Object
-
- moise.common.MoiseElement
-
- moise.oe.OEAgent
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable
,Identifiable
,ToXML
public class OEAgent extends MoiseElement implements ToXML
Represents an agent that belongs to the OE.- Author:
- Jomi Fred Hubner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
protected java.util.Map<java.lang.String,MissionPlayer>
missions
protected OE
oe
protected java.util.Map<java.lang.String,RolePlayer>
roles
private static long
serialVersionUID
-
Fields inherited from class moise.common.MoiseElement
debug
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OEAgent(java.lang.String name)
-
Method Summary
Modifier and Type Method Description protected void
abort()
remove the roles/missions of this agent without checking (in the case the agent leaves the society without finishing its commitments)void
abortMission(java.lang.String missionId, SchemeInstance sch)
removes a mission commitment without checkingvoid
abortRole(RolePlayer rp)
removes a role of an agent without checkingRolePlayer
adoptRole(java.lang.String roleId, java.lang.String grId)
adds a role for an agent.RolePlayer
adoptRole(java.lang.String roleId, GroupInstance gr)
adds a role for an agent.private void
checkDS(Mission mis, SchemeInstance sch)
checks if this agent's roles (in the scheme groups) gives him permission for the missionMissionPlayer
commitToMission(java.lang.String missionId, java.lang.String schId)
adds a mission for an agent.MissionPlayer
commitToMission(java.lang.String missionId, SchemeInstance sch)
adds a mission for an agent.private void
compatibilityCheck(Role newRole, GroupInstance newRoleGr)
java.util.Set<SchemeInstance>
getAllMySchemes()
returns a set of SCH where this agents has a missionorg.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
java.lang.String
getDeonticStatus()
returns a string describing this agent status regarding its obligationsGoalInstance
getLeafestPossibleGoal()
get the left first leaf possible goal in the agent's schemesprivate GoalInstance
getLeafestPossibleGoal(PlanInstance p)
GoalInstance
getLeafestPossibleGoal(SchemeInstance sch)
get the left first leaf possible goal in the scheme schMissionPlayer
getMission(java.lang.String missionId)
finds a mission player object for the mission "missionId" in some schemeprotected MissionPlayer
getMission(java.lang.String missionId, SchemeInstance sch)
finds a mission player object for the mission "missionId" in scheme schjava.util.Collection<MissionPlayer>
getMissions()
returns an Iterator for MissionPlayers objectsint
getNumberOfMissions()
int
getNumberOfRoles()
java.util.Collection<Permission>
getObligations()
returns a collection of mission i am obligated to commit to.java.util.Collection<Permission>
getPermissions()
returns a collection of mission i am permitted to commit to.java.util.Collection<GoalInstance>
getPossibleGoals()
returns the possible global goals for this agent (see GoalInstance.isPossible method).java.util.Collection<RolePlayer>
getRoles()
returns an Iterator for RolePlayers objectsjava.lang.String
getXMLTag()
boolean
hasLink(java.lang.String type, OEAgent other)
returns true if this agent has a role with atype
link toother
agent.boolean
isMyGoal(GoalInstance g, SchemeInstance sch)
returns true if i am committed to the goal g.protected void
missionMaxCardinalityCheck(Mission mis, SchemeInstance sch)
protected boolean
missionMinCardinalityCheck(Mission mis, SchemeInstance sch)
java.util.Collection<GroupInstance>
playsRole(java.lang.String roleId)
returns the set of groups (class Group) where the roleId is being playedRolePlayer
playsRole(java.lang.String roleId, GroupInstance gr)
returns an object representing the roleId played by this agent in the group gr.java.util.Collection<RolePlayer>
playsRole(GroupInstance gr)
returns a collection of RolePlayer objects representing the roles this agent plays in the group grprivate void
removeAllMissions()
removes all missions without checkingprivate void
removeAllRoles()
removes the roles without checkingMissionPlayer
removeMission(java.lang.String missionId, java.lang.String schId)
removes a mission from an agent.MissionPlayer
removeMission(java.lang.String missionId, SchemeInstance sch)
removes a mission from an agent.RolePlayer
removeRole(java.lang.String roleId, java.lang.String grId)
removes a role from an agent.RolePlayer
removeRole(java.lang.String roleId, GroupInstance gr)
removes a role from an agent.private void
roleCardinalityCheck(Role role, GroupInstance newRoleGr)
void
setOE(OE oe)
-
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
-
roles
protected java.util.Map<java.lang.String,RolePlayer> roles
-
missions
protected java.util.Map<java.lang.String,MissionPlayer> missions
-
oe
protected OE oe
-
logger
private static java.util.logging.Logger logger
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
abort
protected void abort() throws MoiseException
remove the roles/missions of this agent without checking (in the case the agent leaves the society without finishing its commitments)- Throws:
MoiseException
-
adoptRole
public RolePlayer adoptRole(java.lang.String roleId, java.lang.String grId) throws MoiseConsistencyException, MoiseCardinalityException
adds a role for an agent.Example:
jaime.adoptRole("leader", att.getId())
- Parameters:
roleId
- the role identification (from OS)grId
- the instance group id (from OE) where the role will be played- Throws:
MoiseConsistencyException
- many errors: grId does not exist, the roleId does no exist in grId, the role is not compatible with other agent's role, ...MoiseCardinalityException
- the number of roleId players already has the max value in grId
-
adoptRole
public RolePlayer adoptRole(java.lang.String roleId, GroupInstance gr) throws MoiseConsistencyException, MoiseCardinalityException
adds a role for an agent.Example:
jaime.adoptRole("leader", att)
wherejaime
is an handler for an agent,"leader"
is the role id, andatt
is the group handler.- Parameters:
roleId
- the role identification (from OS)gr
- the instance group object where the role will be played- Throws:
MoiseConsistencyException
- many errors: the roleId does no exist in grId, the role is not compatible with other agent's role, ...MoiseCardinalityException
- the number of roleId players already has the max value in gr
-
compatibilityCheck
private void compatibilityCheck(Role newRole, GroupInstance newRoleGr) throws MoiseConsistencyException
- Throws:
MoiseConsistencyException
-
roleCardinalityCheck
private void roleCardinalityCheck(Role role, GroupInstance newRoleGr) throws MoiseCardinalityException
- Throws:
MoiseCardinalityException
-
removeRole
public RolePlayer removeRole(java.lang.String roleId, java.lang.String grId) throws MoiseConsistencyException
removes a role from an agent.Example:
jaime.removeRole("leader", "gr_att2")
wherejaime
is an handler for an agent,"leader"
is the role id, and"gr_att2"
is the group id.- Parameters:
roleId
- the role identification (from OS)gr
- the instance group id where the role will not be played anymore- Throws:
MoiseConsistencyException
- the role is necessary for some mission, ...
-
removeRole
public RolePlayer removeRole(java.lang.String roleId, GroupInstance gr) throws MoiseConsistencyException
removes a role from an agent.Example:
jaime.removeRole("leader", att)
wherejaime
is an handler for an agent,"leader"
is the role id, andatt
is the group handler.- Parameters:
roleId
- the role identification (from OS)gr
- the instance group object where the role will not be played anymore- Throws:
MoiseConsistencyException
- the role is necessary for some mission, ...
-
abortRole
public void abortRole(RolePlayer rp) throws MoiseConsistencyException
removes a role of an agent without checking- Throws:
MoiseConsistencyException
-
removeAllRoles
private void removeAllRoles()
removes the roles without checking
-
getRoles
public java.util.Collection<RolePlayer> getRoles()
returns an Iterator for RolePlayers objects
-
playsRole
public java.util.Collection<GroupInstance> playsRole(java.lang.String roleId)
returns the set of groups (class Group) where the roleId is being played
-
playsRole
public RolePlayer playsRole(java.lang.String roleId, GroupInstance gr)
returns an object representing the roleId played by this agent in the group gr. returns null if roleId is not played by this agent.
-
playsRole
public java.util.Collection<RolePlayer> playsRole(GroupInstance gr)
returns a collection of RolePlayer objects representing the roles this agent plays in the group gr
-
getNumberOfRoles
public int getNumberOfRoles()
-
commitToMission
public MissionPlayer commitToMission(java.lang.String missionId, java.lang.String schId) throws MoiseConsistencyException, MoiseCardinalityException
adds a mission for an agent.Example:
gomi.commitToMission("m7", sch.getId());
- Parameters:
missionId
- the mission id (from OS)schId
- the scheme id (from OE)- Throws:
MoiseConsistencyException
MoiseCardinalityException
-
commitToMission
public MissionPlayer commitToMission(java.lang.String missionId, SchemeInstance sch) throws MoiseConsistencyException, MoiseCardinalityException
adds a mission for an agent.Example:
gomi.commitToMission("m7", sch);
- Parameters:
missionId
- the mission id (from OS)sch
- the scheme object- Throws:
MoiseConsistencyException
MoiseCardinalityException
-
removeMission
public MissionPlayer removeMission(java.lang.String missionId, java.lang.String schId) throws MoiseException
removes a mission from an agent.Example:
gomi.removeMission("m7", "sch_test4");
- Parameters:
missionId
- the mission id (from OS)sch
- the scheme identification- Throws:
MoiseConsistencyException
- when the agent tries to give up a mission with unsatisfied goalsMoiseException
-
removeMission
public MissionPlayer removeMission(java.lang.String missionId, SchemeInstance sch) throws MoiseException
removes a mission from an agent.Example:
gomi.removeMission("m7", sch);
or
gomi.removeMission("test.m7", sch);
(the mission id is prefixed by the scheme id separated by ".")- Parameters:
missionId
- the mission id (from OS)sch
- the scheme object- Throws:
MoiseConsistencyException
- when the agent tries to give up a mission with unsatisfied goalsMoiseException
-
abortMission
public void abortMission(java.lang.String missionId, SchemeInstance sch) throws MoiseException
removes a mission commitment without checking- Throws:
MoiseException
-
getMission
protected MissionPlayer getMission(java.lang.String missionId, SchemeInstance sch)
finds a mission player object for the mission "missionId" in scheme sch
-
getMission
public MissionPlayer getMission(java.lang.String missionId)
finds a mission player object for the mission "missionId" in some scheme
-
checkDS
private void checkDS(Mission mis, SchemeInstance sch) throws MoiseConsistencyException
checks if this agent's roles (in the scheme groups) gives him permission for the mission- Throws:
MoiseConsistencyException
-
missionMaxCardinalityCheck
protected void missionMaxCardinalityCheck(Mission mis, SchemeInstance sch) throws MoiseCardinalityException
- Throws:
MoiseCardinalityException
-
missionMinCardinalityCheck
protected boolean missionMinCardinalityCheck(Mission mis, SchemeInstance sch)
-
getMissions
public java.util.Collection<MissionPlayer> getMissions()
returns an Iterator for MissionPlayers objects
-
removeAllMissions
private void removeAllMissions() throws MoiseException
removes all missions without checking- Throws:
MoiseException
-
getNumberOfMissions
public int getNumberOfMissions()
-
getPossibleGoals
public java.util.Collection<GoalInstance> getPossibleGoals()
returns the possible global goals for this agent (see GoalInstance.isPossible method).
-
getAllMySchemes
public java.util.Set<SchemeInstance> getAllMySchemes()
returns a set of SCH where this agents has a mission
-
getLeafestPossibleGoal
public GoalInstance getLeafestPossibleGoal()
get the left first leaf possible goal in the agent's schemes
-
getLeafestPossibleGoal
public GoalInstance getLeafestPossibleGoal(SchemeInstance sch)
get the left first leaf possible goal in the scheme sch
-
getLeafestPossibleGoal
private GoalInstance getLeafestPossibleGoal(PlanInstance p)
-
isMyGoal
public boolean isMyGoal(GoalInstance g, SchemeInstance sch)
returns true if i am committed to the goal g.
-
getObligations
public java.util.Collection<Permission> getObligations()
returns a collection of mission i am obligated to commit to. each element in the returned collection is an Permission Object where: getRolePlayer() is the RolePlayer (rp), in this case "this" role player; getMission() is the Mission (m); and getScheme() is the Scheme instance (sch) where the rp is obligated to commit to m.
-
getPermissions
public java.util.Collection<Permission> getPermissions()
returns a collection of mission i am permitted to commit to. each element in the returned collection is an Permission Object where: getRolePlayer() is the RolePlayer (rp), in this case "this" role player; getMission() is the Mission (m); and getScheme() is the Scheme instance (sch) where the rp is obligated to commit to m.
-
getDeonticStatus
public java.lang.String getDeonticStatus()
returns a string describing this agent status regarding its obligations
-
hasLink
public boolean hasLink(java.lang.String type, OEAgent other)
returns true if this agent has a role with atype
link toother
agent. Iftype = null
, any kind of link can be considered.
-
setOE
public void setOE(OE oe)
-
getXMLTag
public java.lang.String getXMLTag()
-
-