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.Loggerloggerprotected java.util.Map<java.lang.String,MissionPlayer>missionsprotected OEoeprotected java.util.Map<java.lang.String,RolePlayer>rolesprivate static longserialVersionUIDFields inherited from class moise.common.MoiseElement
debug -
Constructor Summary
Constructors Modifier Constructor Description protectedOEAgent(java.lang.String name) -
Method Summary
Modifier and Type Method Description protected voidabort()remove the roles/missions of this agent without checking (in the case the agent leaves the society without finishing its commitments)voidabortMission(java.lang.String missionId, SchemeInstance sch)removes a mission commitment without checkingvoidabortRole(RolePlayer rp)removes a role of an agent without checkingRolePlayeradoptRole(java.lang.String roleId, java.lang.String grId)adds a role for an agent.RolePlayeradoptRole(java.lang.String roleId, GroupInstance gr)adds a role for an agent.private voidcheckDS(Mission mis, SchemeInstance sch)checks if this agent's roles (in the scheme groups) gives him permission for the missionMissionPlayercommitToMission(java.lang.String missionId, java.lang.String schId)adds a mission for an agent.MissionPlayercommitToMission(java.lang.String missionId, SchemeInstance sch)adds a mission for an agent.private voidcompatibilityCheck(Role newRole, GroupInstance newRoleGr)java.util.Set<SchemeInstance>getAllMySchemes()returns a set of SCH where this agents has a missionorg.w3c.dom.ElementgetAsDOM(org.w3c.dom.Document document)java.lang.StringgetDeonticStatus()returns a string describing this agent status regarding its obligationsGoalInstancegetLeafestPossibleGoal()get the left first leaf possible goal in the agent's schemesprivate GoalInstancegetLeafestPossibleGoal(PlanInstance p)GoalInstancegetLeafestPossibleGoal(SchemeInstance sch)get the left first leaf possible goal in the scheme schMissionPlayergetMission(java.lang.String missionId)finds a mission player object for the mission "missionId" in some schemeprotected MissionPlayergetMission(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 objectsintgetNumberOfMissions()intgetNumberOfRoles()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.StringgetXMLTag()booleanhasLink(java.lang.String type, OEAgent other)returns true if this agent has a role with atypelink tootheragent.booleanisMyGoal(GoalInstance g, SchemeInstance sch)returns true if i am committed to the goal g.protected voidmissionMaxCardinalityCheck(Mission mis, SchemeInstance sch)protected booleanmissionMinCardinalityCheck(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 playedRolePlayerplaysRole(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 voidremoveAllMissions()removes all missions without checkingprivate voidremoveAllRoles()removes the roles without checkingMissionPlayerremoveMission(java.lang.String missionId, java.lang.String schId)removes a mission from an agent.MissionPlayerremoveMission(java.lang.String missionId, SchemeInstance sch)removes a mission from an agent.RolePlayerremoveRole(java.lang.String roleId, java.lang.String grId)removes a role from an agent.RolePlayerremoveRole(java.lang.String roleId, GroupInstance gr)removes a role from an agent.private voidroleCardinalityCheck(Role role, GroupInstance newRoleGr)voidsetOE(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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
roles
-
missions
-
oe
-
logger
private static java.util.logging.Logger logger -
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
-
Constructor Details
-
OEAgent
protected OEAgent(java.lang.String name)
-
-
Method Details
-
abort
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, MoiseCardinalityExceptionadds 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, MoiseCardinalityExceptionadds a role for an agent.Example:
jaime.adoptRole("leader", att)
wherejaimeis an handler for an agent,"leader"is the role id, andattis 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 MoiseConsistencyExceptionremoves a role from an agent.Example:
jaime.removeRole("leader", "gr_att2")
wherejaimeis 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 MoiseConsistencyExceptionremoves a role from an agent.Example:
jaime.removeRole("leader", att)
wherejaimeis an handler for an agent,"leader"is the role id, andattis 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
removes a role of an agent without checking- Throws:
MoiseConsistencyException
-
removeAllRoles
private void removeAllRoles()removes the roles without checking -
getRoles
returns an Iterator for RolePlayers objects -
playsRole
returns the set of groups (class Group) where the roleId is being played -
playsRole
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
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, MoiseCardinalityExceptionadds 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:
MoiseConsistencyExceptionMoiseCardinalityException
-
commitToMission
public MissionPlayer commitToMission(java.lang.String missionId, SchemeInstance sch) throws MoiseConsistencyException, MoiseCardinalityExceptionadds a mission for an agent.Example:
gomi.commitToMission("m7", sch);- Parameters:
missionId- the mission id (from OS)sch- the scheme object- Throws:
MoiseConsistencyExceptionMoiseCardinalityException
-
removeMission
public MissionPlayer removeMission(java.lang.String missionId, java.lang.String schId) throws MoiseExceptionremoves 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 MoiseExceptionremoves 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
removes a mission commitment without checking- Throws:
MoiseException
-
getMission
finds a mission player object for the mission "missionId" in scheme sch -
getMission
finds a mission player object for the mission "missionId" in some scheme -
checkDS
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
-
getMissions
returns an Iterator for MissionPlayers objects -
removeAllMissions
removes all missions without checking- Throws:
MoiseException
-
getNumberOfMissions
public int getNumberOfMissions() -
getPossibleGoals
returns the possible global goals for this agent (see GoalInstance.isPossible method). -
getAllMySchemes
returns a set of SCH where this agents has a mission -
getLeafestPossibleGoal
get the left first leaf possible goal in the agent's schemes -
getLeafestPossibleGoal
get the left first leaf possible goal in the scheme sch -
getLeafestPossibleGoal
-
isMyGoal
returns true if i am committed to the goal g. -
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
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
returns true if this agent has a role with atypelink tootheragent. Iftype = null, any kind of link can be considered. -
setOE
-
getXMLTag
public java.lang.String getXMLTag() -
getAsDOM
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
-