OSLC where query returns empty rows
WE are trying to fetch data using OSLC queries. Unfortunately it returns empty rows
The API call without an OSLC select/where query returns all the rows as given below
requestURL="https://<server>:9443/qm/oslc_config/resources/com.ibm.team.vvc.Configuration"
It returns a lot of rows like this
<rdf:Description rdf:about="https://<server>:9443/qm/oslc_config/resources/com.ibm.team.vvc.Configuration/_vBi8kvbqEeu2BNm-5GKwDg">
<dcterms:identifier>_vBi8kvbqEeu2BNm-5GKwDg</dcterms:identifier>
<oslc_config:selections rdf:resource="https://<server>:9443/qm/oslc_config/resources/com.ibm.team.vvc.Configuration/_vBi8kvbqEeu2BNm-5GKwDg/selections"/>
<process:projectArea rdf:resource="https://<server>:9443/qm/process/project-areas/_dN2TEMKTEem1W-cJDHSXXQ"/>
</rdf:Description>
</rdf:RDF>
The following oslc where query returns empty rows even though record exist in the database.
requestURL="https://<server>:9443/qm/oslc_config/resources/com.ibm.team.vvc.Configuration"
String strForOslcWhere = URLEncoder.encode("?oslc.where=rdf:Description{dcterms:identifier=<_dyDvZ73dEemoq9Xh_nvV0Q>}&oslc.select=*.","UTF-8");
URI catalogUrl1 = UriBuilder.fromUri(requestURL+strForOslcWhere).build();
Is there anything wrong with our queries?
Accepted answer
Your
oslc.where
expression looks wrong.
rdf:Description{dcterms:identifier=<_dyDvZ73dEemoq9Xh_nvV0Q>}
That is querying for a resource that has an RDF statement with predicate
rdf:Description
that references a resource against which there is a dcterms:identifier with the specified subject. This is what is termed a nested property in OSLC terms. It's highly unlikely that predicate would be used. That is not a typical RDF representation. I think you are confusing the RDF/XML representation.
The result of an OSLC query is an LDPC (Linked Data Platform Container). See https://docs.oasis-open-projects.org/oslc-op/query/v3.0/os/oslc-query.html for details. That container will reference member URIs of the resources found by the query. The response may also contain one or more statements of properties against each member referenced in the container.
It looks like one of those resources has a
dcterms:identifier
of
_vBi8kvbqEeu2BNm-5GKwDg
. Note that this is a plain literal, not a resource, so should be specified as a quoted string in the query expression. So if you want to query for resources with that identifier, the unencoded query expression would be:
dcterms:identifier="_vBi8kvbqEeu2BNm-5GKwDg"
So the request would include the encoded parameter value as:
oslc.where=dcterms%3Aidentifier%3D%22_vBi8kvbqEeu2BNm-5GKwDg%22
.
Comments
Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 12 '23, 6:04 a.m.By "empty rows" you mean "no results"?
TOMI MOOLAN SOURU
May 12 '23, 5:31 p.m.We tried with oslc.where=dcterms%3Aidentifier%3D%22_vBi8kvbqEeu2BNm-5GKwDg%22 and it is working fine. Thanks for the quick responses. But still one more question spin around my head
David Honey
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 12 '23, 5:48 p.m.Again, you are not interpreting the RDF/XML representation correctly. In Turtle, this would be:
Turtle is a more human-friendly RDF serialization format that many find is easier to understand. So, if the query capability you are using supports querying on
process:projectArea
the unencoded query expression would beprocess:projectArea=<https://<server>:9443/qm/process/project-areas/_dN2TEMKTEem1W-cJDHSXXQ>
. However, that will only work if the query capability supports query on that property. You will probably have to just try it.