Magentix2  2.1.1
es.upv.dsic.gti_ia.organization.OMSProxy Class Reference
Inheritance diagram for es.upv.dsic.gti_ia.organization.OMSProxy:
Collaboration diagram for es.upv.dsic.gti_ia.organization.OMSProxy:

List of all members.

Public Member Functions

 OMSProxy (BaseAgent agent, String OMSServiceDescriptionLocation) throws Exception
 OMSProxy (CProcessor agent, String OMSServiceDescriptionLocation)
 OMSProxy (BaseAgent agent) throws Exception
 OMSProxy (CProcessor myProcessor)
ACLMessage buildOrganizationalMessage (String OrganizationID) throws ForbiddenNormException, UnitNotExistsException, AgentNotInUnitException, NotPlaysAnyRoleException, InvalidUnitTypeException, OnlyPlaysCreatorException, EmptyParametersException, NotInUnitOrParentUnitException, AgentNotExistsException, RoleNotExistsException, VisibilityRoleException, InvalidVisibilityException
String leaveRole (String RoleID, String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, RoleNotExistsException, NotPlaysRoleException, MySQLException
ArrayList< ArrayList< String > > informAgentRole (String RequestedAgentID) throws EmptyParametersException, AgentNotExistsException, ForbiddenNormException
ArrayList< ArrayList< String > > informMembers (String UnitID, String RoleID, String PositionID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, AgentNotExistsException, AgentNotInUnitException, InvalidRolePositionException, VisibilityRoleException, RoleNotExistsException, UnitNotExistsException
ArrayList< String > informRole (String RoleID, String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, RoleNotExistsException, VisibilityRoleException
ArrayList< String > informUnit (String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, InvalidUnitTypeException, NotInUnitOrParentUnitException
ArrayList< ArrayList< String > > informUnitRoles (String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, InvalidVisibilityException
int informQuantityMembers (String UnitID, String RoleID, String PositionID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, AgentNotExistsException, AgentNotInUnitException, InvalidRolePositionException, VisibilityRoleException, RoleNotExistsException, InvalidVisibilityException, InvalidPositionException
String registerRole (String RoleID, String UnitID, String AccessibilityID, String VisibilityID, String PositionID) throws ForbiddenNormException, NotValidIdentifierException, EmptyParametersException, UnitNotExistsException, RoleExistsInUnitException, AgentNotInUnitException, NotInUnitAndNotCreatorException, InvalidUnitTypeException, NotMemberOrCreatorInUnitException, NotSupervisorOrCreatorInUnitException, InvalidPositionException, InvalidAccessibilityException, InvalidVisibilityException, MySQLException
String registerUnit (String UnitID, String TypeID, String ParentUnitID, String CreatorID) throws ForbiddenNormException, NotValidIdentifierException, EmptyParametersException, UnitExistsException, NotCreatorInParentUnitException, ParentUnitNotExistsException, InvalidVisibilityException, InvalidAccessibilityException, InvalidPositionException, InsertingTableException, InvalidUnitTypeException, MySQLException
String registerNorm (String UnitID, String NormContent) throws NotValidIdentifierException, InvalidIDException, InvalidDeonticException, InvalidTargetTypeException, InvalidTargetValueException,InvalidOMSActionException,InvalidExpressionException,RoleNotExistsException,InvalidPositionException,InvalidUnitTypeException,ForbiddenNormException,NotSupervisorOrCreatorInUnitException,NotMemberOrCreatorInUnitException,NotInUnitAndNotCreatorException,AgentNotInUnitException,NormExistsInUnitException,UnitNotExistsException,EmptyParametersException, MySQLException
String informNorm (String NormName, String UnitID) throws InvalidUnitTypeException,NotInUnitOrParentUnitException, ForbiddenNormException,NormNotExistsException,UnitNotExistsException,EmptyParametersException, MySQLException
ArrayList< ArrayList< String > > informTargetNorms (String TargetTypeName, String TargetTypeValue, String UnitID) throws ForbiddenNormException, AgentNotInUnitException,InvalidTargetTypeException,UnitNotExistsException,EmptyParametersException, MySQLException
String deregisterNorm (String NormName, String UnitID) throws RoleNotExistsException,InvalidPositionException,InvalidUnitTypeException,ForbiddenNormException,NotSupervisorOrCreatorInUnitException,NotMemberOrCreatorInUnitException,NotInUnitAndNotCreatorException,AgentNotInUnitException,NormNotExistsException,UnitNotExistsException,EmptyParametersException, MySQLException
String joinUnit (String UnitID, String ParentUnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, ParentUnitNotExistsException, AgentNotInUnitException, NotCreatorInUnitException, NotCreatorInParentUnitException, VirtualParentException, SameUnitException, MySQLException
String deregisterRole (String RoleID, String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, RoleNotExistsException, RoleContainsNormsException, RoleInUseException, AgentNotInUnitException, NotInUnitAndNotCreatorException, InvalidUnitTypeException, NotMemberOrCreatorInUnitException, NotSupervisorOrCreatorInUnitException, MySQLException
String deregisterUnit (String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, VirtualUnitException, NotCreatorInUnitOrParentUnitException, SubunitsInUnitException, NotCreatorAgentInUnitException, DeletingTableException, InvalidPositionException, MySQLException
String deallocateRole (String RoleID, String UnitID, String TargetAgentID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, RoleNotExistsException, InvalidUnitTypeException, NotInUnitAndNotCreatorException, NotMemberOrCreatorInUnitException, AgentNotInUnitException, NotSupervisorOrCreatorInUnitException, NotPlaysRoleException, SameAgentNameException, MySQLException
String allocateRole (String RoleID, String UnitID, String TargetAgentID) throws ForbiddenNormException, NotValidIdentifierException, EmptyParametersException, UnitNotExistsException, RoleNotExistsException, InvalidUnitTypeException, NotInUnitAndNotCreatorException, NotMemberOrCreatorInUnitException, AgentNotInUnitException, NotSupervisorOrCreatorInUnitException, PlayingRoleException, SameAgentNameException
String acquireRole (String RoleID, String UnitID) throws ForbiddenNormException, EmptyParametersException, UnitNotExistsException, RoleNotExistsException, NotInUnitOrParentUnitException, NotSupervisorOrCreatorInUnitException, PlayingRoleException

Package Attributes

ServiceTools st = new ServiceTools()

Detailed Description

This class gives us the support to accede to the services of the OMS. The OMS provides a group of services for registering or deregistering structural components, specific roles, norms and units. It also offers services for reporting on these components.

Author:
Joan Bellver Faus

Definition at line 70 of file OMSProxy.java.


Constructor & Destructor Documentation

es.upv.dsic.gti_ia.organization.OMSProxy.OMSProxy ( BaseAgent  agent,
String  OMSServiceDescriptionLocation 
) throws Exception

This class gives us the support to access to the services of the OMS

Parameters:
agentis a Magentix2 agent, this agent implemented the communication protocol.
OMSServiceDesciptionLocationThe URL where the owl's document is located.

Definition at line 87 of file OMSProxy.java.

                                                                                                {
                super(agent, "OMS", OMSServiceDescriptionLocation);
                l10n = new THOMASMessages();

        }
es.upv.dsic.gti_ia.organization.OMSProxy.OMSProxy ( CProcessor  agent,
String  OMSServiceDescriptionLocation 
)

Definition at line 93 of file OMSProxy.java.

                                                                                {
                super(agent, "OMS", OMSServiceDescriptionLocation);
                l10n = new THOMASMessages();

        }

This class gives us the support to accede to the services of the OMS, Checked that the data contained in the file configuration/Settings.xml, the URL ServiceDescriptionLocation is not empty and is the correct path.

Parameters:
agentis a Magentix2 Agent, this agent implemented the communication protocol

Definition at line 110 of file OMSProxy.java.

                                                          {

                super(agent, "OMS");
                ServiceDescriptionLocation = c.getOMSServiceDescriptionLocation();
                l10n = new THOMASMessages();
        }

Definition at line 117 of file OMSProxy.java.

                                                {

                super(myProcessor, "OMS");
                ServiceDescriptionLocation = c.getOMSServiceDescriptionLocation();
                l10n = new THOMASMessages();
        }

Member Function Documentation

Service used for acquiring a role inside a specific unit.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the organization unit
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleNotExistsExceptionIf role not exists.
NotInUnitOrParentUnitExceptionIf agent does not play any role in unit or parent unit.
NotSupervisorOrCreatorInUnitExceptionIf agent does not play any role with position supervisor or creator in unit.
PlayingRoleExceptionIf agent is already playing the role.

Definition at line 1598 of file OMSProxy.java.

                                                                                                                                                                                                                                                                     {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("AcquireRole", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (NotInUnitOrParentUnitException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (PlayingRoleException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Forces an agent to acquire a specific role.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the unit
TargetAgentIDIdentifier of the agent
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleNotExistsExceptionIf role not exists.
InvalidUnitTypeExceptionIf unit type is not valid.
NotInUnitAndNotCreatorExceptionIf agent does not play any role in unit and does not play any role with position creator.
NotMemberOrCreatorInUnitExceptionIf agent does not play any role with position member or creator inside the unit.
AgentNotInUnitExceptionIf agent does not play any role inside the unit.
NotSupervisorOrCreatorInUnitExceptionIf agent does not play any role with position supervisor or creator inside the unit.
PlayingRoleExceptionIf agent is already playing the role.
SameAgentNameExceptionIf the agent is the same than target agent.

Definition at line 1521 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                                                        {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);
                inputs.put("TargetAgentID", TargetAgentID);

                call = st.buildServiceContent("AllocateRole", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (NotInUnitAndNotCreatorException e) {

                        throw e;
                } catch (NotMemberOrCreatorInUnitException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (PlayingRoleException e) {

                        throw e;
                } catch (SameAgentNameException e) {

                        throw e;
                } catch (NotValidIdentifierException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Builds a new organizational message with the appropriate receivers according to the type of unit and position of the role that the agent is performing

Parameters:
OrganizationIDrepresents the ID of the organization to which the agent wants to send a message
Returns:
returns the ACL message built
Exceptions:
UnitNotExistsExceptionIf unit not exists.
AgentNotInUnitExceptionIf agent does not play any role in unit.
NotPlaysAnyRoleExceptionIf agent does not play any role.
OnlyPlaysCreatorExceptionIf agent only plays the role creator.
NotInUnitOrParentUnitExceptionIf agent does not play any role in unit or parent unit.
EmptyParametersExceptionIf any parameter is empty or null
AgentNotExistsExceptionIf agent not exists.
VisibilityRoleExceptionIf visibility role is not valid.
RoleNotExistsExceptionIf role not exists.
InvalidVisibilityExceptionIf visibility is not valid.
InvalidUnitTypeExceptionIf unit type is not valid.

Definition at line 158 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                          {
                ArrayList<String> unit;
                ArrayList<ArrayList<String>> agentRoles = null;
                ArrayList<String> agentPositions = new ArrayList<String>();

                String rol_aux;
                String unit_aux;

                boolean insideUnit = false;
                boolean containsPositonNoCreator = false;

                // Create a new ACLMessage
                ACLMessage msg = new ACLMessage();

                msg.setSender(agent.getAid());
                // agentName
                String agentName = agent.getAid().name;

                // Inform Unit
                unit = this.informUnit(OrganizationID);

                // If unit not exist
                if (unit.isEmpty()) {
                        String message = l10n.getMessage(MessageID.UNIT_NOT_EXISTS, OrganizationID);
                        throw new UnitNotExistsException(message);

                } else {
                        String unitType = unit.get(0);
                        agentRoles = this.informAgentRole(agentName);

                        if (agentRoles.isEmpty()) {
                                String message = l10n.getMessage(MessageID.NOT_PLAYS_ANY_ROLE);
                                throw new NotPlaysAnyRoleException(message);

                        } else {
                                for (ArrayList<String> agentRole : agentRoles) {
                                        rol_aux = agentRole.get(0);
                                        unit_aux = agentRole.get(1);

                                        ArrayList<String> informRole = this.informRole(rol_aux, unit_aux);
                                        String position = informRole.get(0);

                                        if (position != null) {
                                                if (!position.equals("creator"))
                                                        containsPositonNoCreator = true;
                                                agentPositions.add(position);
                                        }
                                }

                                // If only contains the role creator, then can not send a
                                // organizational message
                                if (containsPositonNoCreator) {

                                        // agentPositions.clear();
                                        // The unit type is flat
                                        if (unitType.equals("flat")) {
                                                msg.putExchangeHeader("participant", OrganizationID);
                                                msg.setReceiver(new AgentID(OrganizationID));
                                        } else {
                                                for (ArrayList<String> agentRole : agentRoles) {
                                                        // Cogemos primero el rol, para que solamente
                                                        // compruebe la unidad que es el segundo elemento.

                                                        rol_aux = agentRole.get(0);

                                                        if (agentRole.get(1).equals(OrganizationID)) {
                                                                insideUnit = true;
                                                        }

                                                }
                                                if (insideUnit) {
                                                        if (unitType.equals("team")) {
                                                                msg.putExchangeHeader("participant", OrganizationID);
                                                                msg.setReceiver(new AgentID(OrganizationID));
                                                        } else if (unitType.equals("hierarchy")) {
                                                                // Sacamos la posición del agente
                                                                // Debemos elegir el de mayor

                                                                if (agentPositions.contains("supervisor")) {
                                                                        msg.putExchangeHeader("supervisor", OrganizationID);
                                                                        msg.putExchangeHeader("participant", OrganizationID);
                                                                } else if (agentPositions.contains("subordinate")) {
                                                                        msg.putExchangeHeader("supervisor", OrganizationID);

                                                                }

                                                                msg.setReceiver(new AgentID(OrganizationID));

                                                        } else {
                                                                String message = l10n.getMessage(MessageID.INVALID_UNIT_TYPE, unitType);
                                                                throw new InvalidUnitTypeException(message);
                                                        }

                                                } else {
                                                        // The agent is not inside the unit
                                                        String message = l10n.getMessage(MessageID.AGENT_NOT_IN_UNIT, OrganizationID, agentName);
                                                        throw new AgentNotInUnitException(message);
                                                }
                                        }
                                } else {
                                        String message = l10n.getMessage(MessageID.ONLY_PLAYS_CREATOR, agentName);
                                        throw new OnlyPlaysCreatorException(message);
                                }
                        }

                }

                return msg;
        }

Forces an agent to leave a specific role.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the unit
TargetAgentIDIdentifier of the agent
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleNotExistsExceptionIf role not exists.
InvalidUnitTypeExceptionIf unit type is not valid.
NotInUnitAndNotCreatorExceptionIf agent does not play any role in unit and does not play any role with position creator.
NotMemberOrCreatorInUnitExceptionIf agent does not play any role with position member or creator inside the unit.
AgentNotInUnitExceptionIf agent does not play any role in unit.
NotSupervisorOrCreatorInUnitExceptionIf agent does not play any role with position supervisor or creator in unit.
NotPlaysRoleExceptionIf agent does not play the role.
SameAgentNameExceptionIf the agent is the same than target agent.
MySQLException

Definition at line 1432 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                                               {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("TargetAgentID", TargetAgentID);
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("DeallocateRole", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (NotInUnitAndNotCreatorException e) {

                        throw e;
                } catch (NotMemberOrCreatorInUnitException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (NotPlaysRoleException e) {

                        throw e;
                } catch (SameAgentNameException e) {

                        throw e;
                } catch (MySQLException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Definition at line 1102 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                   {


                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);
                inputs.put("NormName", NormName);


                call = st.buildServiceContent("DeregisterNorm", inputs);

                try {
                        return (String) this.sendInform();
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (InvalidPositionException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (ForbiddenNormException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (NotMemberOrCreatorInUnitException e) {

                        throw e;
                } catch (NotInUnitAndNotCreatorException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NormNotExistsException e) {

                        throw e;
                }
                catch (UnitNotExistsException e) {

                        throw e;
                }
                catch (EmptyParametersException e) {

                        throw e;
                }
                catch (MySQLException e) {

                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Removes a specific role from a unit.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the unit
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleNotExistsExceptionIf role not exists.
RoleContainsNormsExceptionIf role contains associated norms.
RoleInUseExceptionIf role is played by some agents.
AgentNotInUnitExceptionIf agent does not play any role in unit.
NotInUnitAndNotCreatorExceptionIf agent does not play any role in unit and does not play any role with position creator.
InvalidUnitTypeExceptionIf unit type is invalid.
NotMemberOrCreatorInUnitExceptionIf agent does not play any role with position member or creator inside the unit.
NotSupervisorOrCreatorInUnitExceptionIf agent does not play any role with position superverisor or creator inside the unit.
MySQLException

Definition at line 1272 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                         {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("DeregisterRole", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (RoleContainsNormsException e) {

                        throw e;
                } catch (RoleInUseException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NotInUnitAndNotCreatorException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (NotMemberOrCreatorInUnitException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (MySQLException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Removes a unit from an organization.

Parameters:
UnitIDIdentifier of the unit
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionUnit not exists.
VirtualUnitExceptionIf unit is the virtual unit.
NotCreatorInUnitOrParentUnitExceptionThe agent does not play any role with position creator in unit or parent unit.
SubunitsInUnitExceptionThe unit contains subunits.
NotCreatorAgentInUnitExceptionIf agent does not play any role with position creator in unit.
DeletingTableExceptionIf any error occurs deleting table.
InvalidPositionExceptionIf position is invalid.

Definition at line 1350 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                           {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("DeregisterUnit", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (VirtualUnitException e) {

                        throw e;
                } catch (NotCreatorInUnitOrParentUnitException e) {

                        throw e;
                } catch (SubunitsInUnitException e) {

                        throw e;
                } catch (NotCreatorAgentInUnitException e) {

                        throw e;
                } catch (DeletingTableException e) {

                        throw e;
                } catch (InvalidPositionException e) {

                        throw e;
                } catch (MySQLException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                }
                catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Requesting the list of roles and units in which an agent is in a specific moment.

Parameters:
RequestedAgentIDIdentifier of the agent requested
Returns:
ArrayList<ArrayList<String>> The array list is formed by array lists of strings, each array list is formed by the fields (strings) role and unit
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
AgentNotExistsExceptionIf agent not exists.

Definition at line 335 of file OMSProxy.java.

                                                                                                                                                                      {
                ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RequestedAgentID", RequestedAgentID);

                call = st.buildServiceContent("InformAgentRole", inputs);

                try {
                        result = (ArrayList<ArrayList<String>>) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (AgentNotExistsException e) {

                        throw e;
                }  catch (ForbiddenNormException e) {
                        
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                }
                return result;
        }

Indicates entities that are members of a specific unit. Optionally, it is possible to specify a role and position of this unit, so then only members playing this role or position are detailed.

Parameters:
UnitIDIdentifier of the unit
RoleIDIdentifier of the role
PositionIDIdentifier of the position inside the unit, such as member, supervisor or subordinate
Returns:
ArrayList<ArrayList<String>> The array list is formed by array list of strings, each array list is formed by the fields (strings) agent name and role name
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
AgentNotExistsExceptionIf agent not exists.
AgentNotInUnitExceptionIf agent is not inside the unit.
InvalidRolePositionExceptionIf role position is invalid.
VisibilityRoleExceptionIf visibility of the role is not valid.
RoleNotExistsExceptionIf role not exists.
UnitNotExistsExceptionIf unit not exists.

Definition at line 396 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                     {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);
                inputs.put("PositionID", PositionID);

                call = st.buildServiceContent("InformMembers", inputs);

                try {
                        return (ArrayList<ArrayList<String>>) this.sendInform();

                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (AgentNotExistsException e) {

                        throw e;
                }
                catch (AgentNotInUnitException e) {

                        throw e;

                }catch (InvalidRolePositionException e) {

                        throw e;
                } catch (VisibilityRoleException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }

        }

Definition at line 1014 of file OMSProxy.java.

        {
                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);
                inputs.put("NormName", NormName);


                call = st.buildServiceContent("InformNorm", inputs);

                try {
                        return (String) this.sendInform();
                } catch (NotInUnitOrParentUnitException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (ForbiddenNormException e) {

                        throw e;
                } catch (NormNotExistsException e) {

                        throw e;
                }
                catch (UnitNotExistsException e) {

                        throw e;
                }
                catch (EmptyParametersException e) {

                        throw e;
                }
                catch (MySQLException e) {

                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Provides the number of current members of a specific unit. Optionally, if a role and position is indicated then only the quantity of members playing this roles or position is detailed.

Parameters:
UnitIDIdentifier of the unit
RoleIDIdentifier of the role
PositionIDIdentifier of the position inside the unit, such as member, supervisor or subordinate
Returns:
Integer Quantity of members
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
AgentNotExistsExceptionIf agent not exists.
AgentNotInUnitExceptionIf agent is not inside the unit.
InvalidRolePositionExceptionIf role position is not valid.
VisibilityRoleExceptionIf role visibility is not valid.
RoleNotExistsExceptionIf role not exists.
InvalidVisibilityExceptionIf visibility is not valid.
InvalidPositionExceptionIf position is not valid.

Definition at line 628 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                 {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);
                inputs.put("PositionID", PositionID);

                call = st.buildServiceContent("QuantityMembers", inputs);

                try {
                        ArrayList<String> a = (ArrayList<String>) this.sendInform();

                        return Integer.parseInt(a.get(0));
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (AgentNotExistsException e) {

                        throw e;
                } 
                catch (AgentNotInUnitException e) {

                        throw e;

                }catch (InvalidRolePositionException e) {

                        throw e;
                } catch (VisibilityRoleException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (InvalidVisibilityException e) {

                        throw e;
                } catch (InvalidPositionException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return -1;
                }
        }

Provides a role description of a specific unit.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the unit
Returns:
ArrayList<String> The array list is formed by the fields (strings) position, visibility and accessibility
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleNotExistsExceptionIf role not exists.
VisibilityRoleExceptionIf visibility role is not valid.

Definition at line 462 of file OMSProxy.java.

                                                                                                                                                                                                           {

                ArrayList<String> result = new ArrayList<String>();

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);
                inputs.put("RoleID", RoleID);

                call = st.buildServiceContent("InformRole", inputs);

                try {
                        result = (ArrayList<String>) this.sendInform();

                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (VisibilityRoleException e) {

                        throw e;
                }catch (ForbiddenNormException e) {
                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                }
                return result;

        }

Definition at line 1058 of file OMSProxy.java.

        {
                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);
                inputs.put("TargetTypeName", TargetTypeName);
                inputs.put("TargetValueName", TargetTypeValue);


                call = st.buildServiceContent("InformTargetNorms", inputs);

                try {
                        return (ArrayList<ArrayList<String>>) this.sendInform();

                }catch (ForbiddenNormException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                }
                catch (InvalidTargetTypeException e) {

                        throw e;
                }
                catch (UnitNotExistsException e) {

                        throw e;
                }
                catch (EmptyParametersException e) {

                        throw e;
                }
                catch (MySQLException e) {

                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Provides unit description.

Parameters:
UnitIDIdentifier of the unit
Returns:
ArrayList<String> The array list is formed by the fields (strings) unit type and parent name
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
InvalidUnitTypeExceptionIf unit type is not valid.
NotInUnitOrParentUnitExceptionIf agent does not play any role in unit or parent unit.

Definition at line 516 of file OMSProxy.java.

                                                                                                                                                                                                     {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("InformUnit", inputs);

                try {
                        return (ArrayList<String>) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (NotInUnitOrParentUnitException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }

        }

Used for requesting the list of roles that have been registered inside a unit.

Parameters:
UnitIDIdentifier of the unit
Returns:
ArrayList<ArrayList<String>> The array list is formed by array list of strings, each array list is formed by the fields (strings) role name, position, visibility and accessibility
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
InvalidVisibilityExceptionIf visibility is not valid.

Definition at line 566 of file OMSProxy.java.

                                                                                                                                                                                       {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("InformUnitRoles", inputs);
                try {
                        return (ArrayList<ArrayList<String>>) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (InvalidVisibilityException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }

        }

Update the parent unit.

Parameters:
UnitIDIdentifier of the unit
ParentUnitIDIdentifier of the new parent unit
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
ParentUnitNotExistsExceptionIf parent unit not exists.
AgentNotInUnitExceptionIf agent is not inside the unit.
NotCreatorInUnitExceptionIf agent does not play any role with position creator inside the unit.
NotCreatorInParentUnitExceptionIf agent does not play any role with position creator inside the parent unit.
VirtualParentExceptionThe Parent Unit can not be changed.
SameUnitExceptionIf the unit and the parent unit are same.
MySQLException

Definition at line 1191 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                 {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);
                inputs.put("ParentUnitID", ParentUnitID);

                call = st.buildServiceContent("JointUnit", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (ParentUnitNotExistsException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NotCreatorInUnitException e) {

                        throw e;
                } catch (NotCreatorInParentUnitException e) {

                        throw e;
                } catch (VirtualParentException e) {

                        throw e;
                } catch (SameUnitException e) {

                        throw e;
                } catch (MySQLException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Service used for leaving a role inside a specific unit.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the organization unit
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleNotExistsExceptionIf role not exists.
NotPlaysRoleExceptionIf agent does not play the role.
MySQLExceptionIf a MySql exception occurs.

Definition at line 287 of file OMSProxy.java.

                                                                                                                                                                                                             {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);

                call = st.buildServiceContent("LeaveRole", inputs);

                String result = new String();
                try {
                        result = (String) this.sendInform();

                } catch (EmptyParametersException e) {
                        throw e;
                } catch (UnitNotExistsException e) {
                        throw e;
                } catch (RoleNotExistsException e) {
                        throw e;
                } catch (NotPlaysRoleException e) {
                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                } catch (MySQLException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                }
                return result;
        }
Parameters:
UnitID
NormContent
Returns:
Exceptions:
InvalidIDException
InvalidDeonticException
InvalidTargetTypeException
InvalidTargetValueException
InvalidOMSActionException
InvalidExpressionException
RoleNotExistsException
InvalidPositionException
InvalidUnitTypeException
ForbiddenNormException
NotSupervisorOrCreatorInUnitException
NotMemberOrCreatorInUnitException
NotInUnitAndNotCreatorException
AgentNotInUnitException
NormExistsInUnitException
UnitNotExistsException
EmptyParametersException
MySQLException

Definition at line 925 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {


                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("UnitID", UnitID);
                inputs.put("NormContent", "<!-- "+NormContent+" -->");


                call = st.buildServiceContent("RegisterNorm", inputs);

                try {
                        return (String) this.sendInform();
                } catch (RoleNotExistsException e) {

                        throw e;
                } catch (InvalidPositionException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (ForbiddenNormException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (NotMemberOrCreatorInUnitException e) {

                        throw e;
                } catch (NotInUnitAndNotCreatorException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NormExistsInUnitException e) {

                        throw e;
                }
                catch (UnitNotExistsException e) {

                        throw e;
                }
                catch (EmptyParametersException e) {

                        throw e;
                }
                catch (InvalidIDException e) {

                        throw e;
                }
                catch (InvalidDeonticException e) {

                        throw e;
                }
                catch (InvalidTargetTypeException e) {

                        throw e;
                }
                catch (InvalidTargetValueException e) {

                        throw e;
                }
                catch (InvalidOMSActionException e) {

                        throw e;
                }
                catch (InvalidExpressionException e) {

                        throw e;
                }
                catch (NotValidIdentifierException e) {

                        throw e;
                }
                catch (MySQLException e) {

                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Creates a new role inside a unit.

Parameters:
RoleIDIdentifier of the role
UnitIDIdentifier of the unit
AccessibilityIDconsiders two types of roles: (internal) internal roles, which are assigned to internal agents of the system platform; and (external) external roles, which can be enacted by any agent.
VisibilityIDindicates whether agents can obtain information of this role from outside the unit in which this role is defined (public) or from inside (private).
PositionIDdetermines its structural position inside the unit, such as member, supervisor or subordinate.
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitNotExistsExceptionIf unit not exists.
RoleExistsInUnitExceptionIf role not exists.
AgentNotInUnitExceptionIf agent is not inside the unit.
NotInUnitAndNotCreatorExceptionIf agent is not inside the unit and does not play any role with position creator.
InvalidUnitTypeExceptionIf unit type is not valid.
NotMemberOrCreatorInUnitExceptionIf agent does not play any role with position member or creator inside the unit.
NotSupervisorOrCreatorInUnitExceptionIf agent does not play any role with position supervisor or creatir inside the unit.
InvalidPositionExceptionIf position is not valid.
InvalidAccessibilityExceptionIf accessibility is not valid.
InvalidVisibilityExceptionIf visibility is not valid.
MySQLExceptionIf a MySql exception occurs.

Definition at line 728 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {

                HashMap<String, String> inputs = new HashMap<String, String>();

                inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                inputs.put("RoleID", RoleID);
                inputs.put("UnitID", UnitID);
                inputs.put("AccessibilityID", AccessibilityID);
                inputs.put("PositionID", PositionID);
                inputs.put("VisibilityID", VisibilityID);

                call = st.buildServiceContent("RegisterRole", inputs);
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitNotExistsException e) {

                        throw e;
                } catch (RoleExistsInUnitException e) {

                        throw e;
                } catch (AgentNotInUnitException e) {

                        throw e;
                } catch (NotInUnitAndNotCreatorException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                } catch (NotMemberOrCreatorInUnitException e) {

                        throw e;
                } catch (NotSupervisorOrCreatorInUnitException e) {

                        throw e;
                } catch (InvalidPositionException e) {

                        throw e;
                } catch (InvalidAccessibilityException e) {

                        throw e;
                } catch (InvalidVisibilityException e) {

                        throw e;
                }catch (NotValidIdentifierException e) {

                        throw e;
                }
                catch (MySQLException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Creates a new empty unit in the organization, with a specific structure, creatorName and parent unit.

Parameters:
UnitIDIdentifier of the unit
TypeIDindicates the topology of the new unit: (i) Hierarchy, in which a supervisor agent has control over other members; (ii) Team, which are groups of agents that share a common goal, collaborating and cooperating between them; and (iii) Flat, in which there is none agent with control over other members.
ParentUnitIDIdentifier of the parent unit
CreatorIDThe name of the new creator role
Returns:
Status if result is OK
Exceptions:
EmptyParametersExceptionIf any parameter is empty or null.
UnitExistsExceptionIf unit exists.
NotCreatorInParentUnitExceptionIf agent does not play any role with position creator inside the parent unit.
ParentUnitNotExistsExceptionIf agent parent unit not exists.
InvalidVisibilityExceptionIf visibility is not valid.
InvalidAccessibilityExceptionIf accessibility is not valid.
InvalidPositionExceptionIf position is not valid.
InsertingTableExceptionIf any error occurs inserting table.
InvalidUnitTypeExceptionIf unit type is invalid.

Definition at line 828 of file OMSProxy.java.

                                                                                                                                                                                                                                                                                                                                                                                                                                         {

                if (ParentUnitID == null) {

                        HashMap<String, String> inputs = new HashMap<String, String>();

                        inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                        inputs.put("UnitID", UnitID);
                        inputs.put("TypeID", TypeID);
                        inputs.put("CreatorID", CreatorID);

                        call = st.buildServiceContent("RegisterUnit", inputs);

                } else {

                        HashMap<String, String> inputs = new HashMap<String, String>();

                        inputs.put("AgentID", agent.getAid().name.replace('~', '@'));
                        inputs.put("UnitID", UnitID);
                        inputs.put("TypeID", TypeID);
                        inputs.put("CreatorID", CreatorID);
                        inputs.put("ParentUnitID", ParentUnitID);

                        call = st.buildServiceContent("RegisterUnit", inputs);

                }
                try {
                        return (String) this.sendInform();
                } catch (EmptyParametersException e) {

                        throw e;
                } catch (UnitExistsException e) {

                        throw e;
                } catch (NotCreatorInParentUnitException e) {

                        throw e;
                } catch (ParentUnitNotExistsException e) {

                        throw e;
                } catch (InvalidVisibilityException e) {

                        throw e;
                } catch (InvalidAccessibilityException e) {

                        throw e;
                } catch (InvalidPositionException e) {

                        throw e;
                } catch (InsertingTableException e) {

                        throw e;
                } catch (InvalidUnitTypeException e) {

                        throw e;
                }
                catch (MySQLException e) {

                        throw e;
                }
                catch (NotValidIdentifierException e) {

                        throw e;
                } catch (ForbiddenNormException e) {
                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                        return null;
                }
        }

Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables