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

List of all members.

Public Member Functions

 SFProxy (BaseAgent agent, String SFServiceDescriptionLocation) throws Exception
 SFProxy (BaseAgent agent) throws Exception
ArrayList< String > registerService (String serviceURL) throws DBConnectionException, AlreadyRegisteredException, InvalidServiceURLException, ServiceProfileNotFoundException, InvalidDataTypeException, MySQLException
String deregisterService (String serviceProfile) throws ServiceURINotFoundException, ServiceProfileNotFoundException, DBConnectionException, MySQLException
String removeProvider (String serviceProfile, String providerID) throws ServiceProfileNotFoundException, DBConnectionException
String getService (String serviceProfile) throws ServiceProfileNotFoundException, DBConnectionException, MySQLException
ArrayList< ArrayList< String > > searchService (ArrayList< String > inputs, ArrayList< String > outputs, ArrayList< String > keywords) throws DBConnectionException, InvalidDataTypeException, ServicesNotFoundException, MySQLException

Package Attributes

ServiceTools st = new ServiceTools()

Detailed Description

This class provides access to services that implements the SF agent.

Author:
Joan Bellver Faus GTI-IA.DSIC.UPV

Definition at line 26 of file SFProxy.java.


Constructor & Destructor Documentation

es.upv.dsic.gti_ia.organization.SFProxy.SFProxy ( BaseAgent  agent,
String  SFServiceDescriptionLocation 
) throws Exception

This class gives us the support to accede to the services of the SF

Parameters:
agentis a Magentix2 Agent, this agent implemented the communication protocol
SFServiceDescriptionLocationThe URL where the owl-s documents are located

Definition at line 39 of file SFProxy.java.

                                                                                              {

                super(agent, "SF", SFServiceDescriptionLocation);

        }

This class gives us the support to accede to the services of the SF, 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 56 of file SFProxy.java.


Member Function Documentation

The Deregister Service deregisters the specified service deleting all the related data from the SF.

Parameters:
serviceProfilethe URI representing the service profile to deregister
Returns:
A description of the result of the service execution.
Exceptions:
ServiceURINotFoundExceptionIf service URI is not found in Jena DataBase.
ServiceProfileNotFoundExceptionIf service profile is not found in Jena DataBase.
DBConnectionExceptionIf a data base connection exception occurs.
MySQLExceptionIf a MySql exception occurs.

Definition at line 131 of file SFProxy.java.

                                                                                                                                                                          {

                HashMap<String, String> inputs = new HashMap<String, String>();
                inputs.put("ServiceProfile", serviceProfile);

                call = st.buildServiceContent("DeregisterService", inputs);
                String result = new String();

                try {
                        result = (String) this.sendInform();
                } catch (ServiceURINotFoundException e){
                        throw e;
                } catch (ServiceProfileNotFoundException e) {
                        throw e;
                } catch (DBConnectionException e) {
                        throw e;
                }
                catch (MySQLException e) {
                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                }

                return result;

        }

Returns an OWL-S specification with the all data of the specified service profile as parameter.

Parameters:
serviceProfileURI of the service profile to get its OWL-S specification
Returns:
an OWL-S specification with the all data of the specified service profile as parameter
Exceptions:
ServiceProfileNotFoundExceptionIf service profile is not found in Jena DataBase.
DBConnectionExceptionIf a data base connection exception occurs.
MySQLExceptionIf a MySql exception occurs.

Definition at line 204 of file SFProxy.java.

                                                                                                                                      {

                HashMap<String, String> inputs = new HashMap<String, String>();
                inputs.put("ServiceProfile", serviceProfile);

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

                String result = new String();

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

                } catch (ServiceProfileNotFoundException e) {
                        throw e;
                } catch (DBConnectionException e) {
                        throw e;
                } 
                catch (MySQLException e) {
                        throw e;
                }catch (THOMASException e) {

                        e.printStackTrace();
                }
                return result;
        }

The Register Service tries to register the service that is specified as parameter. In the specification, if there is one or more groundings, it means that the service is provided by a Web Service. If one or more providers (agents or organization) are specified in the profile:contactInformation of the service, it means that the service is provided by agents or/and organizations

Parameters:
serviceURLthe original URL of the OWL-S specification of the service
Returns:
A description of the changes made, and an OWL-S specification of the registered services or all data of the already registered service in the SF
Exceptions:
DBConnectionExceptionIf a data base connection exception occurs.
AlreadyRegisteredExceptionIf information is already registered in service profile.
InvalidServiceURLExceptionIf service URL is not a valid OWL-S document.
ServiceProfileNotFoundExceptionIf service profile is not found in Jena DataBase.
InvalidDataTypeExceptionIf input or output data type is invalid.
MySQLExceptionIf a MySql exception occurs.

Definition at line 83 of file SFProxy.java.

                                                {

                HashMap<String, String> inputs = new HashMap<String, String>();
                inputs.put("ServiceURL", serviceURL);

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

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

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

                } catch (AlreadyRegisteredException e) {
                        throw e;
                } catch (DBConnectionException e) {
                        throw e;
                } catch (InvalidDataTypeException e) {
                        throw e;
                } catch (MySQLException e) {
                        throw e;
                } 
                catch (InvalidServiceURLException e) {
                        throw e;
                }
                catch (ServiceProfileNotFoundException e) {
                        throw e;
                }
                catch (THOMASException e) {

                        e.printStackTrace();
                }

                return result;
        }

Removes a provider: agent, organization or web service (grounding); from a registered service profile.

Parameters:
serviceProfileURI of the service profile to remove the provider
providerIDof the provider to remove (provider name or grounding ID)
Returns:
A description of the result of the service execution
Exceptions:
ServiceProfileNotFoundExceptionIf service profile is not found in Jena DataBase.
DBConnectionExceptionIf a data base connection exception occurs.

Definition at line 169 of file SFProxy.java.

                                                                                                                                             {

                HashMap<String, String> inputs = new HashMap<String, String>();
                inputs.put("ServiceProfile", serviceProfile);
                inputs.put("ProviderID", providerID);

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

                String result = new String();

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

                } catch (ServiceProfileNotFoundException e) {
                        throw e;
                } catch (DBConnectionException e) {
                        throw e;
                } catch (THOMASException e) {

                        e.printStackTrace();
                }
                return result;
        }
ArrayList<ArrayList<String> > es.upv.dsic.gti_ia.organization.SFProxy.searchService ( ArrayList< String >  inputs,
ArrayList< String >  outputs,
ArrayList< String >  keywords 
) throws DBConnectionException, InvalidDataTypeException, ServicesNotFoundException, MySQLException

Searches the most similar services profiles to the given data type inputs, data type outputs and keywords in the description. Returns an ordered list of the services found with a similarity degree obtained in function of the similarity to the given parameters.

Parameters:
inputsdata type inputs to search a service with these inputs. Example: "http://127.0.0.1/ontology/books.owl#Novel"^^xsd:anyURI
outputsdata type outputs to search a service with these outputs. Example: "http://127.0.0.1/ontology/books.owl#Novel"^^xsd:anyURI
keywordslist to search in the text description of the service
Returns:
an ordered list of the services found with a similarity degree
Exceptions:
DBConnectionExceptionIf a data base connection exception occurs.
InvalidDataTypeExceptionIf input or output data type is invalid.
ServicesNotFoundExceptionIf service is not found.
MySQLExceptionIf a MySql exception occurs.

Definition at line 250 of file SFProxy.java.

                                                                                                                                                                                                                                             {

                String inputsStr = "";
                if (inputs != null && !inputs.isEmpty()) {
                        Iterator<String> iterInputs = inputs.iterator();
                        while (iterInputs.hasNext()) {
                                String in = iterInputs.next();
                                inputsStr += in + "|";
                        }
                }
                String outputsStr = "";
                if (outputs != null && !outputs.isEmpty()) {
                        Iterator<String> iterOutputs = outputs.iterator();
                        while (iterOutputs.hasNext()) {
                                String out = iterOutputs.next();
                                outputsStr += out + "|";
                        }
                }
                String keywordsStr = "";
                if (keywords != null && !keywords.isEmpty()) {
                        Iterator<String> iterKeywords = keywords.iterator();
                        while (iterKeywords.hasNext()) {
                                String key = iterKeywords.next();
                                keywordsStr += key + "|";
                        }
                }

                HashMap<String, String> inputsService = new HashMap<String, String>();
                inputsService.put("Inputs", inputsStr);
                inputsService.put("Outputs", outputsStr);
                inputsService.put("Keywords", keywordsStr);

                call = st.buildServiceContent("SearchService", inputsService);
                ArrayList<ArrayList<String>> result = new  ArrayList<ArrayList<String>> ();

                try
                {
                        result = (ArrayList<ArrayList<String>>)  this.sendInform();
                } catch (ServicesNotFoundException e) {
                        throw e;
                } catch (DBConnectionException e) {
                        throw e;
                } catch (InvalidDataTypeException e) {
                        throw e;
                }
                catch (MySQLException e) {
                        throw e;
                }
                catch (THOMASException e) {

                        e.printStackTrace();
                }
                return result;
        }

Member Data Documentation


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