org.universAAL.middleware.service
Class ServiceRequest

Package class diagram package ServiceRequest
java.lang.Object
  extended by org.universAAL.middleware.rdf.Resource
      extended by org.universAAL.middleware.rdf.FinalizedResource
          extended by org.universAAL.middleware.service.ServiceRequest
All Implemented Interfaces:
Matchable, Request, Requirement
Direct Known Subclasses:
AapiServiceRequest, Request

public class ServiceRequest
extends FinalizedResource
implements Request

A class that represents a service request resource, which is used by the ServiceCaller-s when performing synchronous or asynchronous requests.

Author:
mtazari - Saied Tazari

Field Summary
static String MY_URI
          A resource URI that specifies the resource as a service request.
static String PROP_AGGREGATING_FILTER
          A property key for adding of the list of aggregating filters.
static String PROP_REQUESTED_SERVICE
          A property key for adding of the requested service.
static String PROP_REQUIRED_PROCESS_RESULT
          A property key for adding of the process result.
static String PROP_uAAL_SERVICE_CALLER
          A property key for adding of the related service caller.
 
Fields inherited from class org.universAAL.middleware.rdf.Resource
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, ns_delim_index, PROP_RDF_FIRST, PROP_RDF_REST, PROP_RDF_TYPE, PROP_RDFS_COMMENT, PROP_RDFS_LABEL, PROP_SERIALIZATION_FULL, PROP_SERIALIZATION_OPTIONAL, PROP_SERIALIZATION_REDUCED, PROP_SERIALIZATION_UNDEFINED, PROP_uAAL_INVOLVED_HUMAN_USER, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uAAL_NAMESPACE_PREFIX, uAAL_SERVICE_NAMESPACE, uAAL_VOCABULARY_NAMESPACE, uri
 
Constructor Summary
ServiceRequest()
          Constructor for usage by de-serializers, as an anonymous node without a URI.
ServiceRequest(Service requestedService, Resource involvedHumanUser)
          The constructor to be used by ServiceCallers.
ServiceRequest(String uri)
          Constructor for usage by de-serializers, as a node with a URI.
ServiceRequest(String uriPrefix, int numProps, Service requestedService, Resource involvedHumanUser)
          Creates an instance of ServiceRequest with a URI that is created by appending a unique ID to the given 'uriPrefix'.
ServiceRequest(String uri, Service requestedService, Resource involvedHumanUser)
          Creates a service request with a specified URI.
 
Method Summary
 boolean acceptsRandomSelection()
          Help function for the service bus to quickly decide if a coordination with other peers is necessary or not.
 void addAddEffect(String[] ppath, Object value)
          Adds the requirement that the requested service must have the effect of adding the given value to the property reachable by the given ppath.
 void addAggregatingFilter(AggregatingFilter f)
          Adds filtering functions such as max(aProp) to the request as criteria to be used by the service bus for match-making and service selection.
 void addAggregatingOutputBinding(ProcessOutput toParam, AggregatingFilter f)
          Adds the requirement that the service must deliver an output with type restrictions bound to the given toParam and that the service bus then must select the result set that passes the given aggregating filter f.
 void addChangeEffect(String[] ppath, Object value)
          Adds the requirement that the requested service must have the effect of changing the value of the property reachable by the given ppath to the given value.
 void addRemoveEffect(String[] ppath)
          Adds the requirement that the requested service must have the effect of removing the value of the property reachable by the given ppath.
 void addRequiredOutput(String paramURI, String[] fromProp)
          Adds the requirement that the service must deliver an output with type restrictions bound to the given toParam and that this must reflect the value of a property reachable by the given property path sourceProp.
 void addSimpleOutputBinding(ProcessOutput toParam, String[] sourceProp)
          Adds the requirement that the service must deliver an output with type restrictions bound to the given toParam and that this must reflect the value of a property reachable by the given property path sourceProp.
 void addTypeFilter(String[] refPath, String typeURI)
          Restrict the scope of process results by selecting only those resources whose property reachable by refPath is of type typeURI.
 void addValueFilter(String[] refPath, Object hasValue)
          Restrict the scope of process results by selecting only those resources whose property reachable by refPath has a value equal to the given hasValue.
 List<AggregatingFilter> getFilters()
          Returns the list of aggregating filters added previously by calls to addAggregatingFilter(AggregatingFilter).
 List getOutputAggregations()
          Help function for the service bus to quickly decide which aggregations must be performed on outputs.
 int getPropSerializationType(String propURI)
          Answers if the given property has to be considered when serializing this individual in a minimized way, and if not ignore-able, whether its value should be presented in its full form or can be reduced.
 Service getRequestedService()
          Returns the requested service.
 Resource[] getRequiredEffects()
          Returns the list of required process effects.
 Resource[] getRequiredOutputs()
          Returns the list of required process outputs.
 boolean isWellFormed()
          Returns true, if the state of the resource is valid, otherwise false.
 boolean matches(Matchable other)
           
 boolean setProperty(String propURI, Object value)
          Overrides Resource.setProperty(String, Object).
 
Methods inherited from class org.universAAL.middleware.rdf.FinalizedResource
addType, getLocalName, getNamespace, getProperty, getPropertyURIs, getType, getTypes, getURI, hasQualifiedName, isAnon, numberOfProperties
 
Methods inherited from class org.universAAL.middleware.rdf.Resource
addMultiLangProp, asList, asList, asRDFList, changeProperty, copy, deepCopy, equals, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getResource, getResourceComment, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isClosedCollection, isQualifiedName, literal, representsQualifiedURI, serializesAsXMLLiteral, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toString, toStringRecursive, toStringRecursive, unliteral
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MY_URI

public static final String MY_URI
A resource URI that specifies the resource as a service request.

See Also:
Constant Field Values

PROP_AGGREGATING_FILTER

public static final String PROP_AGGREGATING_FILTER
A property key for adding of the list of aggregating filters.

See Also:
Constant Field Values

PROP_REQUESTED_SERVICE

public static final String PROP_REQUESTED_SERVICE
A property key for adding of the requested service.

See Also:
Constant Field Values

PROP_REQUIRED_PROCESS_RESULT

public static final String PROP_REQUIRED_PROCESS_RESULT
A property key for adding of the process result.

See Also:
Constant Field Values

PROP_uAAL_SERVICE_CALLER

public static final String PROP_uAAL_SERVICE_CALLER
A property key for adding of the related service caller.

See Also:
Constant Field Values
Constructor Detail

ServiceRequest

public ServiceRequest()
Constructor for usage by de-serializers, as an anonymous node without a URI.


ServiceRequest

public ServiceRequest(String uri)
Constructor for usage by de-serializers, as a node with a URI.


ServiceRequest

public ServiceRequest(Service requestedService,
                      Resource involvedHumanUser)
The constructor to be used by ServiceCallers. The given parameter will be used by the middleware for finding a matching service through extracting the following info set from it:

Parameters:
requestedService - the requested service. It is added as a property of the ServiceRequest with key PROP_REQUESTED_SERVICE.
involvedHumanUser - the human user that is related to this service request. May be null. If not null or anonymous, then it is added as a property of the ServiceRequest with key Resource.PROP_uAAL_INVOLVED_HUMAN_USER.

ServiceRequest

public ServiceRequest(String uriPrefix,
                      int numProps,
                      Service requestedService,
                      Resource involvedHumanUser)
Creates an instance of ServiceRequest with a URI that is created by appending a unique ID to the given 'uriPrefix'. This constructor has a pseudo parameter 'numProps' in order to make it distinct from the other constructor that also takes a string. Later versions of ServiceRequest may decide to make some use of numProps in some way, however.

Parameters:
uriPrefix - Prefix of the URI.
numProps - Not used.
requestedService - the requested service. It is added as a property of the ServiceRequest with key PROP_REQUESTED_SERVICE.
involvedHumanUser - the human user that is related to this service request. May be null. If not null or anonymous, then it is added as a property of the ServiceRequest with key Resource.PROP_uAAL_INVOLVED_HUMAN_USER.

ServiceRequest

public ServiceRequest(String uri,
                      Service requestedService,
                      Resource involvedHumanUser)
Creates a service request with a specified URI. This constructor is more appropriate for AvailabilitySubscribers, because they will be notified later only with the URI.

Parameters:
uri - The URI of the ServiceRequest.
requestedService - the requested service. It is added as a property of the ServiceRequest with key PROP_REQUESTED_SERVICE.
involvedHumanUser - the human user that is related to this service request. May be null. If not null or anonymous, then it is added as a property of the ServiceRequest with key Resource.PROP_uAAL_INVOLVED_HUMAN_USER.
Method Detail

acceptsRandomSelection

public boolean acceptsRandomSelection()
Help function for the service bus to quickly decide if a coordination with other peers is necessary or not.


addAddEffect

public void addAddEffect(String[] ppath,
                         Object value)
Adds the requirement that the requested service must have the effect of adding the given value to the property reachable by the given ppath. The property should normally be a multi-valued property.


addAggregatingFilter

public void addAggregatingFilter(AggregatingFilter f)
Adds filtering functions such as max(aProp) to the request as criteria to be used by the service bus for match-making and service selection.

See Also:
AggregatingFilterFactory

addAggregatingOutputBinding

public void addAggregatingOutputBinding(ProcessOutput toParam,
                                        AggregatingFilter f)
Adds the requirement that the service must deliver an output with type restrictions bound to the given toParam and that the service bus then must select the result set that passes the given aggregating filter f.


addChangeEffect

public void addChangeEffect(String[] ppath,
                            Object value)
Adds the requirement that the requested service must have the effect of changing the value of the property reachable by the given ppath to the given value.


addRemoveEffect

public void addRemoveEffect(String[] ppath)
Adds the requirement that the requested service must have the effect of removing the value of the property reachable by the given ppath.


addRequiredOutput

public void addRequiredOutput(String paramURI,
                              String[] fromProp)
Adds the requirement that the service must deliver an output with type restrictions bound to the given toParam and that this must reflect the value of a property reachable by the given property path sourceProp.


addSimpleOutputBinding

public void addSimpleOutputBinding(ProcessOutput toParam,
                                   String[] sourceProp)
Adds the requirement that the service must deliver an output with type restrictions bound to the given toParam and that this must reflect the value of a property reachable by the given property path sourceProp.


addTypeFilter

public void addTypeFilter(String[] refPath,
                          String typeURI)
Restrict the scope of process results by selecting only those resources whose property reachable by refPath is of type typeURI.


addValueFilter

public void addValueFilter(String[] refPath,
                           Object hasValue)
Restrict the scope of process results by selecting only those resources whose property reachable by refPath has a value equal to the given hasValue.


getFilters

public List<AggregatingFilter> getFilters()
Returns the list of aggregating filters added previously by calls to addAggregatingFilter(AggregatingFilter). The service bus will be the main user of this method.


getRequestedService

public Service getRequestedService()
Returns the requested service. The service bus will be the main user of this method.


getRequiredEffects

public Resource[] getRequiredEffects()
Returns the list of required process effects. The service bus will be the main user of this method.


getRequiredOutputs

public Resource[] getRequiredOutputs()
Returns the list of required process outputs. The service bus will be the main user of this method.


getOutputAggregations

public List getOutputAggregations()
Help function for the service bus to quickly decide which aggregations must be performed on outputs.


getPropSerializationType

public int getPropSerializationType(String propURI)
Description copied from class: Resource
Answers if the given property has to be considered when serializing this individual in a minimized way, and if not ignore-able, whether its value should be presented in its full form or can be reduced. The return value must be one of Resource.PROP_SERIALIZATION_OPTIONAL, Resource.PROP_SERIALIZATION_REDUCED, or Resource.PROP_SERIALIZATION_FULL. It can be assumed that the given property is one of those returned by Resource.getPropertyURIs().
Decision criterion should be if the value of this property is absolutely necessary when this resource is being sent to a remote node. If the subclass rates it as unlikely that the receiver side would need this info, the answer should be PROP_SERIALIZATION_OPTIONAL in favor of lower communication traffic and higher performance even at risk of a possible additional query on the receiver side for fetching this info. With the same rationale, if a property should be included in the process of serialization, it is preferable to include it in a reduced form; in this case the return value should be PROP_SERIALIZATION_REDUCED, otherwise PROP_SERIALIZATION_FULL can be returned. Subclasses should normally overwrite this method as this default implementation returns always PROP_SERIALIZATION_FULL.

Overrides:
getPropSerializationType in class Resource
See Also:
Resource.getPropSerializationType(String)

isWellFormed

public boolean isWellFormed()
Description copied from class: Resource
Returns true, if the state of the resource is valid, otherwise false.

Subclasses should overwrite this methods as the default implementation returns always true.

Overrides:
isWellFormed in class Resource
See Also:
Resource.isWellFormed()

setProperty

public boolean setProperty(String propURI,
                           Object value)
Overrides Resource.setProperty(String, Object). Main user of this method are the de-serializers.

Overrides:
setProperty in class Resource
Returns:
true if the property changed as a result of the call

matches

public boolean matches(Matchable other)
Specified by:
matches in interface Matchable
Returns:
true if the other Matchable matches, false if not
See Also:
Matchable.matches(Matchable)


Copyright © 2014 universAAL Consortium. All Rights Reserved.