public class ServiceRequest extends ScopedResource implements Request
ServiceCaller
-s when performing synchronous or asynchronous
requests.Modifier and Type | Field and Description |
---|---|
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_SERVICE_CALLER
A property key for adding of the related service caller.
|
ONLY_LOCAL_SCOPE, PROP_ORIG_SCOPE, PROP_SCOPES
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, NAMESPACE_PREFIX, ns_delim_index, PROP_INVOLVED_HUMAN_USER, 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, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, SERVICE_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uri, VOCABULARY_NAMESPACE
Constructor and Description |
---|
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
ServiceCaller s. |
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.
|
Modifier and Type | Method and Description |
---|---|
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 . |
ProcessOutput |
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<AggregatingFilter> |
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 that was given to the constructor during
instantiation.
|
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) . |
addScope, clearScopes, getOriginScope, getScopes, isScoped, isSerializableTo, setOriginScope, setScope
addType, getLocalName, getNamespace, getProperty, getPropertyURIs, getType, getTypes, getURI, hasQualifiedName, isAnon, numberOfProperties
addMultiLangProp, asList, asList, asRDFList, changeProperty, copy, deepCopy, equals, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getOrConstructLabel, getResource, getResourceComment, getResourceLabel, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isClosedCollection, isQualifiedName, literal, representsQualifiedURI, serializesAsXMLLiteral, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toString, toStringRecursive, toStringRecursive, unliteral
public static final String MY_URI
public static final String PROP_AGGREGATING_FILTER
public static final String PROP_REQUESTED_SERVICE
public static final String PROP_REQUIRED_PROCESS_RESULT
public static final String PROP_SERVICE_CALLER
public ServiceRequest()
public ServiceRequest(String uri)
uri
- the URI of this resource.public ServiceRequest(Service requestedService, Resource involvedHumanUser)
ServiceCaller
s. The given parameter
will be used by the middleware for finding a matching service through
extracting the following info set from it:
ManagedIndividual.getClassURI()
, all services from this class and its
sub-classes will match
Service.getRestrictedPropsOnInstanceLevel()
will be used to
fetch all the restrictions that were added by the ServiceCaller
.
These restrictions will be checked against the services matched from the
previous step to narrow down the result set.
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_INVOLVED_HUMAN_USER
.public ServiceRequest(String uriPrefix, int numProps, Service requestedService, Resource involvedHumanUser)
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.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_INVOLVED_HUMAN_USER
.public ServiceRequest(String uri, Service requestedService, Resource involvedHumanUser)
AvailabilitySubscriber
s, because they will be
notified later only with the URI.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_INVOLVED_HUMAN_USER
.public boolean acceptsRandomSelection()
AggregationFunction.oneOf
exists that determines that only one
service is called even if there is more than one service that would match
the request.public void addAddEffect(String[] ppath, Object value)
value
to the property reachable by the
given ppath
. The property should normally be a multi-valued
property.public void addAggregatingFilter(AggregatingFilter f)
f
- the filter to add.AggregatingFilterFactory
public void addAggregatingOutputBinding(ProcessOutput toParam, AggregatingFilter f)
toParam
and that the service
bus then must select the result set that passes the given aggregating
filter f
.public void addChangeEffect(String[] ppath, Object value)
ppath
to the given value
.public void addRemoveEffect(String[] ppath)
ppath
.public ProcessOutput addRequiredOutput(String paramURI, String[] fromProp)
toParam
and that this must
reflect the value of a property reachable by the given property path
sourceProp
.public void addSimpleOutputBinding(ProcessOutput toParam, String[] sourceProp)
toParam
and that this must
reflect the value of a property reachable by the given property path
sourceProp
.public void addTypeFilter(String[] refPath, String typeURI)
public void addValueFilter(String[] refPath, Object hasValue)
public List<AggregatingFilter> getFilters()
addAggregatingFilter(AggregatingFilter)
.public Service getRequestedService()
public Resource[] getRequiredEffects()
public Resource[] getRequiredOutputs()
public List<AggregatingFilter> getOutputAggregations()
public int getPropSerializationType(String propURI)
Resource
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()
. 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
.getPropSerializationType
in class Resource
Resource.getPropSerializationType(String)
public boolean isWellFormed()
Resource
Subclasses should overwrite this methods as the default implementation returns always true.
isWellFormed
in class Resource
Resource.isWellFormed()
public boolean setProperty(String propURI, Object value)
Resource.setProperty(String, Object)
. Main user of this
method are the de-serializers.setProperty
in class Resource
public boolean matches(Matchable other)
matches
in interface Matchable
Matchable.matches(Matchable)
Copyright © 2018 universAAL Consortium. All rights reserved.