Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to retrieve TestCaseQuery URI via OSLC API

I would like to update a test case via the OSLC API I’m able to retrieve the designated Service Provider (Project Area) (I’m following example 4 in Lab 3 in the oslc document)

https://myJazzServer:9443/jazz/oslc_qm/contexts/<ID>/services.xml

But how do I get the right queryCapability, the one for test cases? When I use the HttpRequester add-on for FireFox I can se that the URI I’m trying to get should look like this:

https:// my JazzServer:9443/jazz/oslc_qm/contexts/<ID>/resourcescom.ibm.rqm.planning.VersionedTestCase

I’ve tried to write this

XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
String simpleQueryXPath = "//oslc:QueryCapability/oslc:queryBase/@rdf:resource"; xpath.setNamespaceContext( new NamespaceContextMap(new String[] {"oslc", "http://open-services.net/ns/qm#", "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}));

// Parse the response body to retrieve the Change Management Simple Query URL InputSource source = new InputSource(response.getEntity().getContent()); Node simpleQueryURLNode = (Node)(xpath.evaluate(simpleQueryXPath, source, XPathConstants.NODE));

0 votes



3 answers

Permanent link
Hi Helene,

You would be looking for:

<oslc:queryCapability>
    <oslc:QueryCapability>
      <dcterms:title>Default query capability for TestCase</dcterms:title>
    <oslc:queryBase rdf:resource="https://localhost:9443/jazz/oslc_qm/contexts/_stJVgGfqEd24KMoDcFLfcQ/resources/com.ibm.rqm.planning.VersionedTestCase"/>
    <oslc:resourceShape rdf:resource="https://localhost:9443/jazz/oslc_qm/contexts/_stJVgGfqEd24KMoDcFLfcQ/shape/query/com.ibm.rqm.planning.VersionedTestCase"/>
    <oslc:resourceType rdf:resource="http://open-services.net/ns/qm#TestCaseQuery"/>
  </oslc:QueryCapability>
</oslc:queryCapability>

For more information, see http://open-services.net/bin/view/Main/OslcCoreSpecification#Resource_Service_Provider.

0 votes

Comments

Hi Paul
Correct, that is what I'm looking for.
Isn't it http://open-services.net/bin/view/Main/QmSpecificationV2 I should use...


Permanent link
Hi Helene,

could you try this :
String simpleQueryXPath ="//oslc:QueryCapability[oslc:resourceType/@rdf:resource='http://open-services.net/ns/qm#TestCaseQuery']/oslc:queryBase";
Any better ?

Regards
Stéphane

0 votes

Comments

No unfortunately it didn't work.

Interesting...

Did you test with the correct namespace definition ?

xpath.setNamespaceContext( new NamespaceContextMap(new String[] {"oslc", "http://open-services.net/ns/core#", "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}));

If it still doesn't work, some additional details (e.g. error detail, stacktrace, etc.) would certainly help;

Regards,


Permanent link
OK after looking a bit more into Xpath and the notation I found out that this should be written String simpleQueryXPath = "//oslc:QueryCapability[dcterms:title='Default query capability for TestCase']/oslc:queryBase/@rdf:resource";   

and my oslc namespace was wrong.... it should be
        xpath.setNamespaceContext(
                new NamespaceContextMap(new String[]  
                        //{"oslc", "http://open-services.net/ns/core#",
                        {"oslc", "http://open-services.net/ns/core#",
                         "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                         "dcterms","http://purl.org/dc/terms/"}));

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,926

Question asked: May 16 '13, 3:33 a.m.

Question was seen: 5,112 times

Last updated: May 16 '13, 1:21 p.m.

Confirmation Cancel Confirm