In this example an Architecture Management service provider provides a pre-defined query to find all resources that have comments on them containing a keyword over a certain period of time. Since commenting is an implementation specific mechanism a server provided query is necessary to express this. This example specifies a simple resource shape resource for the query to capture the keyword and time frame parameters.
The service provider in this example includes the follow resource definition in it service provider document:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:oslc_am="http://open-services.net/ns/am#">
<oslc:ServiceProvider rdf:about="http://example.com/am-provider/Project+X">
<dcterms:title>Project X AM Provider</dcterms:title>
<oslc:service>
<oslc:Service>
<oslc:domain rdf:resource="http://open-services.net/ns/am#" />
<!-- other properties omitted for clarity -->
<oslc_am:predefinedQuery>
<oslc_am:PredefineQuery>
<dcterms:title>Commented Resources with Keyword</dcterms:title>
<oslc:label>Commented Resources with Keyword</oslc:label>
<dcterms:description>Returns all resources that have a comment made withing the
specified date range with any of the specified keywords.</dcterms:description>
<oslc:queryUrl rdf:resource="https://example.com/am-provider/Project+X/query/keywordCommented" />
<oslc:resourceShape
rdf:resource="https://example.com/am-provider/Project+X/query/shapes/keywordCommented" />
<oslc:usage rdf:resource="http://common.queries.com/usage/keywordCommented"/>
</oslc_am:PredefineQuery>
</oslc_am:predefinedQuery>
</oslc:Service>
</oslc:service>
</oslc:ServiceProvider>
</rdf:RDF>
The resource shape resource:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:ex="http://example.com/ns/"
xmlns:oslc="http://open-services.net/ns/core#" >
<oslc:ResourceShape
rdf:about="https://example.com/am-provider/Project+X/query/shapes/keywordCommented">
<dcterms:title>Keyword Commented Query Parameters</dcterms:title>
<oslc:describes rdf:resource="http://example.com/ns/KeywordCommentedParameters" />
<oslc:property>
<oslc:Property>
<dcterms:title>Start Date</dcterms:title>
<dcterms:description>The earliest date of the comment's creation.</dcterms:description>
<oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-one" />
<oslc:propertyDefinition rdf:resource="http://example.com/ns/startDate" />
<oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime" />
</oslc:Property>
</oslc:property>
<oslc:property>
<oslc:Property>
<dcterms:title>End Date</dcterms:title>
<dcterms:description>The latest date of the comment's creation.</dcterms:description>
<oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-one" />
<oslc:propertyDefinition rdf:resource="http://example.com/ns/endDate" />
<oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime" />
</oslc:Property>
</oslc:property>
<oslc:property>
<oslc:Property>
<dcterms:title>Keyword</dcterms:title>
<dcterms:description>One or more keywords to search for in the comment text.</dcterms:description>
<oslc:occurs rdf:resource="http://open-services.net/ns/core#One-or-many" />
<oslc:propertyDefinition rdf:resource="http://example.com/ns/endDate" />
<oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" />
</oslc:Property>
</oslc:property>
</oslc:ResourceShape>
</rdf:RDF>
The client executes a POST (or in this case since there is no resource shape specified for the query parameters a GET) call on the queryUrl. There are two query parameters that specify the example prefix and to select only the title and priority values of the matched resources.
Request
POST https://example.com/am-provider/Project+X/query/keywordCommented?oslc.prefix=ex=<http://example.com/ns/>&oslc;.select=dcterms:title,ex:priority HTTP/1.1
Accept: application/rdf+xml
OSLC-Core-Version: 2.0
Content-Type: application/rdf+xml
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://example.com/ns/">
<ex:KeywordCommentedParameters>
<ex:startDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
2012-05-01T00:00:00:000Z
</ex:startDate>
<ex:endDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
2012-05-31T00:00:00:000Z
</ex:endDate>
<ex:keyword>Deferred</ex:keyword>
<ex:keyword>Backlog</ex:keyword>
</ex:KeywordCommentedParameters>
</rdf:RDF>
Response
HTTP/1.1 200 OK
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#" xmlns:oslc_am="http://open-services.net/ns/am#">
<oslc:ResponseInfo
rdf:about="https://example.com/am-provider/Project+X/query/keywordCommented?oslc.prefix=ex=<http://example.com/ns/>&oslc;.select=dcterms:title,ex:priority">
<dcterms:title>Resources Commented with Keyword</dcterms:title>
<oslc:totalCount>4</oslc:totalCount>
</oslc:ResponseInfo>
<rdf:Description
rdf:about="https://example.com/am-provider/Project+X/query/keywordCommented">
<rdfs:member rdf:about="http://example.com/resources/res42" />
<rdfs:member rdf:about="http://example.com/resources/res123" />
<rdfs:member rdf:about="http://example.com/resources/res456" />
<rdfs:member rdf:about="http://example.com/resources/res89" />
</rdf:Description>
<oslc_am:Resource rdf:about="http://example.com/resources/res42">
<dcterms:title>transactions</dcterms:title>
<ex:priority>high</ex:priority>
</oslc_am:Resource>
<oslc_am:Resource rdf:about="http://example.com/resources/res123">
<dcterms:title>Overview Diagram</dcterms:title>
<ex:priority>medium</ex:priority>
</oslc_am:Resource>
<oslc_am:Resource rdf:about="http://example.com/resources/res456">
<dcterms:title>Structural View</dcterms:title>
<ex:priority>high</ex:priority>
</oslc_am:Resource>
<oslc_am:Resource rdf:about="http://example.com/resources/res89">
<dcterms:title>Log Component</dcterms:title>
<ex:priority>low</ex:priority>
</oslc_am:Resource>
</rdf:RDF>