It's all about the answers!

Ask a question

How to retrieve TestCaseQuery URI via OSLC API


helene højrup (231912) | asked May 16 '13, 3:33 a.m.
edited May 16 '13, 3:38 a.m.
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));

3 answers



permanent link
Paul Slauenwhite (8.4k12) | answered May 16 '13, 7:25 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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.

Comments
helene højrup commented May 16 '13, 10:12 a.m.

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
Stephane Leroy (1.4k149) | answered May 16 '13, 8:15 a.m.
JAZZ DEVELOPER
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


Comments
helene højrup commented May 16 '13, 10:12 a.m.

No unfortunately it didn't work.


Stephane Leroy commented May 16 '13, 10:28 a.m.
JAZZ DEVELOPER

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
helene højrup (231912) | answered May 16 '13, 1:21 p.m.
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/"}));

Your answer


Register or 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.