public class OEAgent extends MoiseElement implements ToXML
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,MissionPlayer> |
missions |
protected OE |
oe |
protected java.util.Map<java.lang.String,RolePlayer> |
roles |
debug
Modifier | Constructor and Description |
---|---|
protected |
OEAgent(java.lang.String name) |
Modifier and Type | Method and 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 checking
|
void |
abortRole(RolePlayer rp)
removes a role of an agent without checking
|
RolePlayer |
adoptRole(java.lang.String roleId,
GroupInstance gr)
adds a role for an agent.
|
RolePlayer |
adoptRole(java.lang.String roleId,
java.lang.String grId)
adds a role for an agent.
|
MissionPlayer |
commitToMission(java.lang.String missionId,
SchemeInstance sch)
adds a mission for an agent.
|
MissionPlayer |
commitToMission(java.lang.String missionId,
java.lang.String schId)
adds a mission for an agent.
|
java.util.Set<SchemeInstance> |
getAllMySchemes()
returns a set of SCH where this agents has a mission
|
org.w3c.dom.Element |
getAsDOM(org.w3c.dom.Document document) |
java.lang.String |
getDeonticStatus()
returns a string describing this agent status regarding its obligations
|
GoalInstance |
getLeafestPossibleGoal()
get the left first leaf possible goal in the agent's schemes
|
GoalInstance |
getLeafestPossibleGoal(SchemeInstance sch)
get the left first leaf possible goal in the scheme sch
|
MissionPlayer |
getMission(java.lang.String missionId)
finds a mission player object for the mission "missionId" in some scheme
|
protected MissionPlayer |
getMission(java.lang.String missionId,
SchemeInstance sch)
finds a mission player object for the mission "missionId" in scheme sch
|
java.util.Collection<MissionPlayer> |
getMissions()
returns an Iterator for MissionPlayers objects
|
int |
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 objects
|
java.lang.String |
getXMLTag() |
boolean |
hasLink(java.lang.String type,
OEAgent other)
returns true if this agent has a role with a
type link to
other 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<RolePlayer> |
playsRole(GroupInstance gr)
returns a collection of RolePlayer objects representing the
roles this agent plays in the group gr
|
java.util.Collection<GroupInstance> |
playsRole(java.lang.String roleId)
returns the set of groups (class Group) where the roleId is being played
|
RolePlayer |
playsRole(java.lang.String roleId,
GroupInstance gr)
returns an object representing the roleId played by this agent
in the group gr.
|
MissionPlayer |
removeMission(java.lang.String missionId,
SchemeInstance sch)
removes a mission from an agent.
|
MissionPlayer |
removeMission(java.lang.String missionId,
java.lang.String schId)
removes a mission from an agent.
|
RolePlayer |
removeRole(java.lang.String roleId,
GroupInstance gr)
removes a role from an agent.
|
RolePlayer |
removeRole(java.lang.String roleId,
java.lang.String grId)
removes a role from an agent.
|
void |
setOE(OE oe) |
compareTo, equals, getBoolProperty, getBoolProperty, getCreationDate, getFullId, getId, getId, getOwner, getPrefix, getPrefix, getProperties, getPropertiesAsDOM, getPropertiesAsProlog, getProperty, getStrProperty, hashCode, setId, setOwner, setPrefix, setPropertiesFromDOM, setProperty, toString
protected java.util.Map<java.lang.String,RolePlayer> roles
protected java.util.Map<java.lang.String,MissionPlayer> missions
protected OE oe
protected void abort() throws MoiseException
MoiseException
public RolePlayer adoptRole(java.lang.String roleId, java.lang.String grId) throws MoiseConsistencyException, MoiseCardinalityException
Example: jaime.adoptRole("leader", att.getId())
roleId
- the role identification (from OS)grId
- the instance group id (from OE) where the role will be playedMoiseConsistencyException
- 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 grIdpublic RolePlayer adoptRole(java.lang.String roleId, GroupInstance gr) throws MoiseConsistencyException, MoiseCardinalityException
Example: jaime.adoptRole("leader", att)
where jaime
is an handler for an agent, "leader"
is
the role id, and att
is the group handler.
roleId
- the role identification (from OS)gr
- the instance group object where the role will be playedMoiseConsistencyException
- 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 grpublic RolePlayer removeRole(java.lang.String roleId, java.lang.String grId) throws MoiseConsistencyException
Example: jaime.removeRole("leader", "gr_att2")
where jaime
is an handler for an agent, "leader"
is
the role id, and "gr_att2"
is the group id.
roleId
- the role identification (from OS)gr
- the instance group id where the role will not be played anymoreMoiseConsistencyException
- the
role is necessary for some mission, ...public RolePlayer removeRole(java.lang.String roleId, GroupInstance gr) throws MoiseConsistencyException
Example: jaime.removeRole("leader", att)
where jaime
is an handler for an agent, "leader"
is
the role id, and att
is the group handler.
roleId
- the role identification (from OS)gr
- the instance group object where the role will not be played anymoreMoiseConsistencyException
- the
role is necessary for some mission, ...public void abortRole(RolePlayer rp) throws MoiseConsistencyException
MoiseConsistencyException
public java.util.Collection<RolePlayer> getRoles()
public java.util.Collection<GroupInstance> playsRole(java.lang.String roleId)
public RolePlayer playsRole(java.lang.String roleId, GroupInstance gr)
public java.util.Collection<RolePlayer> playsRole(GroupInstance gr)
public int getNumberOfRoles()
public MissionPlayer commitToMission(java.lang.String missionId, java.lang.String schId) throws MoiseConsistencyException, MoiseCardinalityException
Example: gomi.commitToMission("m7", sch.getId());
missionId
- the mission id (from OS)schId
- the scheme id (from OE)MoiseConsistencyException
MoiseCardinalityException
public MissionPlayer commitToMission(java.lang.String missionId, SchemeInstance sch) throws MoiseConsistencyException, MoiseCardinalityException
Example: gomi.commitToMission("m7", sch);
missionId
- the mission id (from OS)sch
- the scheme objectMoiseConsistencyException
MoiseCardinalityException
public MissionPlayer removeMission(java.lang.String missionId, java.lang.String schId) throws MoiseException
Example: gomi.removeMission("m7", "sch_test4");
missionId
- the mission id (from OS)sch
- the scheme identificationMoiseConsistencyException
- when the agent tries to give up a mission with unsatisfied goalsMoiseException
public MissionPlayer removeMission(java.lang.String missionId, SchemeInstance sch) throws MoiseException
Example: gomi.removeMission("m7", sch);
or
gomi.removeMission("test.m7", sch);
(the mission id is prefixed by the scheme id separated by ".")
missionId
- the mission id (from OS)sch
- the scheme objectMoiseConsistencyException
- when the agent tries to give up a mission with unsatisfied goalsMoiseException
public void abortMission(java.lang.String missionId, SchemeInstance sch) throws MoiseException
MoiseException
protected MissionPlayer getMission(java.lang.String missionId, SchemeInstance sch)
public MissionPlayer getMission(java.lang.String missionId)
protected void missionMaxCardinalityCheck(Mission mis, SchemeInstance sch) throws MoiseCardinalityException
MoiseCardinalityException
protected boolean missionMinCardinalityCheck(Mission mis, SchemeInstance sch)
public java.util.Collection<MissionPlayer> getMissions()
public int getNumberOfMissions()
public java.util.Collection<GoalInstance> getPossibleGoals()
public java.util.Set<SchemeInstance> getAllMySchemes()
public GoalInstance getLeafestPossibleGoal()
public GoalInstance getLeafestPossibleGoal(SchemeInstance sch)
public boolean isMyGoal(GoalInstance g, SchemeInstance sch)
public java.util.Collection<Permission> getObligations()
public java.util.Collection<Permission> getPermissions()
public java.lang.String getDeonticStatus()
public boolean hasLink(java.lang.String type, OEAgent other)
type
link to
other
agent. If type = null
, any kind of link
can be considered.public void setOE(OE oe)
public java.lang.String getXMLTag()