Using OSLC capabilities in the Requirements Management application

You can use Open Services for Lifecycle Collaboration 2.0 (OSLC) capabilities in the Requirements Management (RM) application for the Rational solution for Collaborative Lifecycle Management (CLM). This article includes examples of how to use those capabilities in an HTTP poster tool. These basic examples are described.

Notes:

Prerequisites:

Before you begin using the OSLC capabilities for requirements management, these prerequisites must be met:

  • All requests must specify the following headers. When you send content, the content type must be Application/rdf+xml.
    • OSLC-Core-Version=2.0
    • Accept=application/rdf+xml
  • Make sure that you know the terminology to use. The most frequently used namespaces in the queries are as follows:
    • rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    • dcterms=<http://purl.org/dc/terms/>
    • nav=<http://com.ibm.rdm/navigation#>
    • rrmCollection=<http://jazz.net/xmlns/alm/rm/Collection/v1.0/>
    • oslc=<http://open-services.net/ns/core#>
    • oslc_rm=<http://open-services.net/ns/rm#>

Managing artifacts

1. Getting startup information

To manage artifacts, you first need startup information. Begin by logging into the RM server. When developing an OSLC Consumer, users must implement and follow the OAuth protocol. Sample code of an OAuth implementation that is used to log on to the RM server is in the “Open Services for Lifecycle Collaboration Workshop” article at https://jazz.net/library/article/635. For details, see Example04.java.

For testing purposes, you can add the HTTP poster (or similar tool), to your browser and use it to test the samples. To pass the authentication, log in to the browser and then start the HTTP poster.

To get the startup information, follow these steps:

  1. Request the server’s services:
    GET https://grarrc.ibm.com:9443/rm/rootservices
  2. From the response, get this Catalog entry: <oslc_rm:rmServiceProviders rdf:resource="https://grarrc.ibm.com:9443/rm/discovery/RMCatalog" />.
    GET https://grarrc.ibm.com:9443/rm/discovery/RMCatalog

    The Catalog exposes the server project areas as an oslc:serviceProvider:

      <oslc:ServiceProvider rdf:about="https://grarrc.ibm.com:9443/rm/discovery/_zpWqELrZEeG3OKR6fZ1svQ/services.xml">  <dcterms:title rdf:parseType="Literal">CML_Project (Requirements)</dcterms:title>  <jp:consumerRegistry rdf:resource="https://grarrc.ibm.com:9443/jts/process/project-areas/_zpWqELrZEeG3OKR6fZ1svQ/links"/>  <oslc:details rdf:resource="https://grarrc.ibm.com:9443/jts/process/project-areas/_zpWqELrZEeG3OKR6fZ1svQ"/>  </oslc:ServiceProvider>  
  3. From the response, get the services that are offered for a specific project area:
    GET https://grarrc.ibm.com:9443/rm/discovery/_zpWqELrZEeG3OKR6fZ1svQ/services.xml

    The response contains information about the project, for instance, it describes the usage of the Requirements Creation Factory and Requirements Collections Creation Factory.

      <oslc:CreationFactory>  <dcterms:title rdf:parseType="Literal">Requirement Creation Factory</dcterms:title>  <oslc:creation rdf:resource="https://grarrc.ibm.com:9443/rm/requirementFactory?projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_zpWqELrZEeG3OKR6fZ1svQ" />  <oslc:resourceType rdf:resource="http://open-services.net/ns/rm#Requirement" />  <oslc:resourceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0Z8ZgrrZEeG3OKR6fZ1svQ" />  <oslc:resourceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0aWpMrrZEeG3OKR6fZ1svQ" />  <oslc:resourceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0cxEALrZEeG3OKR6fZ1svQ" />  <oslc:usage rdf:resource="http://open-services.net/ns/core#default" />  </oslc:CreationFactory>  

2. Creating artifacts

Creating artifacts is a key capability that can be used to collaborate with other applications or to import data from other applications.

  1. From the creation factory, obtain the following data:
    <oslc:creation rdf:resource="https://grarrc.ibm.com:9443/rm/requirementFactory?projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_zpWqELrZEeG3OKR6fZ1svQ" />
  2. Obtain the resource shape of the artifact type by getting the resources that you want information about:
    <oslc:resourceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0dbyY7rZEeG3OKR6fZ1svQ" />

    The next example shows how to create a simple artifact. The key fields in this example are as follows:

    • oslc:instanceShape: This entry specifies the type of the artifact to create.
    • nav:parent: This entry specifies the target folder where the artifact is created. If the folder is not present, the artifact is created at root folder of the project.

    Action: POST

    URL: https://grarrc.ibm.com:9443/rm/requirementFactory?projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_zpWqELrZEeG3OKR6fZ1svQ

    Content to send (Content Type must be : application/rdf+xml).

      <rdf:RDF  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:dc="http://purl.org/dc/terms/"  xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/"  xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"  xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"  xmlns:acp="http://jazz.net/ns/acp#"  xmlns:rm_property="https://grarrc.ibm.com:9443/rm/types/"  xmlns:oslc="http://open-services.net/ns/core#"  xmlns:nav="http://jazz.net/ns/rm/navigation#"  xmlns:oslc_rm="http://open-services.net/ns/rm#" >  <rdf:Description rdf:about="">  <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>  <dc:description rdf:parseType="Literal">OSLC Creation Example</dc:description>  <dc:title rdf:parseType="Literal">OSLC Created Requirement</dc:title>  <oslc:instanceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0dbyY7rZEeG3OKR6fZ1svQ"/>  <nav:parent rdf:resource="https://grarrc.ibm.com:9443/rm/folders/_zpWqELrZEeG3OKR6fZ1svQ"/>  </rdf:Description>  </rdf:RDF>  
  3. Modifying artifacts: Basic fields. The basic flow to update an artifact is as follows:
    1. Obtain, or get, the artifacts that you want.
    2. Modify the appropriate user fields. System fields cannot be modified.
    3. Update, or put, the modified artifact.

    The detailed steps are as follows:

    1. Get the artifacts that you want.

      Action: GET

      URL: https://grarrc.ibm.com:9443/rm/resources/_mLHpsbrhEeG3OKR6fZ1svQ

      You can obtain the URL by using the OSLC query capabilities or from the location header that is returned in the response of a just created artifact. The returned information will looks like:

        <rdf:RDF  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:dc="http://purl.org/dc/terms/"  xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/"  xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"  xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"  xmlns:acp="http://jazz.net/ns/acp#"  xmlns:rm_property="https://grarrc.ibm.com:9443/rm/types/"  xmlns:oslc="http://open-services.net/ns/core#"  xmlns:nav="http://jazz.net/ns/rm/navigation#"  xmlns:oslc_rm="http://open-services.net/ns/rm#" >  <rdf:Description rdf:about="https://grarrc.ibm.com:9443/rm/resources/_mLHpsbrhEeG3OKR6fZ1svQ">  <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>  <rm_property:_0YirU7rZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0TLqNLrZEeG3OKR6fZ1svQ#9fa948cf-d978-49b4    -aac8-ab7cf73c0b70"/>  <dc:contributor rdf:resource="https://grarrc.ibm.com:9443/jts/users/TestJazzAdmin1"/>  <oslc:serviceProvider rdf:resource="https://grarrc.ibm.com:9443/rm/discovery/_zpWqELrZEeG3OKR6fZ1svQ/services.xml"/>  <dc:description rdf:parseType="Literal"></dc:description>  <rm_property:_0D7GM7rZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0CSug7rZEeG3OKR6fZ1svQ#Text"/>  <dc:title rdf:parseType="Literal">Web_REQ01</dc:title>  <dc:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-06-20T14:09:49.004Z</dc:created>  <oslc:instanceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0d66l7rZEeG3OKR6fZ1svQ"/>  <acp:accessControl rdf:resource="https://grarrc.ibm.com:9443/rm/accessControl/_zpWqELrZEeG3OKR6fZ1svQ"/>  <dc:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-06-20T14:09:49.787Z</dc:modified>  <rm_property:_0XY0wrrZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0ThBZbrZEeG3OKR6fZ1svQ#fe1e0579-bae0-480d-8e59-2f557597d6d0"/>  <dc:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">3</dc:identifier>  <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>  <rm_property:_0YF_YbrZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0SoQkrrZEeG3OKR6fZ1svQ#ebc08514-e765-4508-8c4f-bd191ce985c1"/>  <dc:creator rdf:resource="https://grarrc.ibm.com:9443/jts/users/TestJazzAdmin1"/>  <rm_property:_0ZAlaLrZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0TX3cbrZEeG3OKR6fZ1svQ#99fa343e-2d22-47da-8243-1a51abb14c60"/>  <nav:parent rdf:resource="https://grarrc.ibm.com:9443/rm/folders/_zpWqELrZEeG3OKR6fZ1svQ"/>  </rdf:Description>  </rdf:RDF>  

      An important field from the GET response is the Etag header. This header is used when user modify the requirement.

      Etag= "_mSmKsbrhEeG3OKR6fZ1svQ"
    2. Copy the RDF response and modify or add entries to it. Add the If-Match header that contains the Etag value that was returned in the previous step. For example, you might modify the following entry:
        <dc:title rdf:parseType="Literal">Web_REQ01 Changed using OSLC</dc:title>  <dc:description rdf:parseType="Literal">Updated description using OSLC</dc:description>

      Exception: You cannot modify system properties.

    3. Update the resource by using the following code:

      Action: PUT

      URL: https://grarrc.ibm.com:9443/rm/resources/_mLHpsbrhEeG3OKR6fZ1svQ

      Additional Headers: If-Match=”_mSmKsbrhEeG3OKR6fZ1svQ”

      Content to send (Content Type must be : application/rdf+xml).

            <rdf:RDF          xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"          xmlns:dc="http://purl.org/dc/terms/"          xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/"          xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"          xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"          xmlns:acp="http://jazz.net/ns/acp#"          xmlns:rm_property="https://grarrc.ibm.com:9443/rm/types/"          xmlns:oslc="http://open-services.net/ns/core#"          xmlns:nav="http://jazz.net/ns/rm/navigation#"          xmlns:oslc_rm="http://open-services.net/ns/rm#" >        <rdf:Description rdf:about="https://grarrc.ibm.com:9443/rm/resources/_mLHpsbrhEeG3OKR6fZ1svQ">          <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>          <rm_property:_0YirU7rZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0TLqNLrZEeG3OKR6fZ1svQ#9fa948cf-d978-49b4-aac8-ab7cf73c0b70"/>          <dc:contributor rdf:resource="https://grarrc.ibm.com:9443/jts/users/TestJazzAdmin1"/>          <oslc:serviceProvider rdf:resource="https://grarrc.ibm.com:9443/rm/discovery/_zpWqELrZEeG3OKR6fZ1svQ/services.xml"/>          <dc:description rdf:parseType="Literal">Updated description using OSLC</dc:description>          <rm_property:_0D7GM7rZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0CSug7rZEeG3OKR6fZ1svQ#Text"/>          <dc:title rdf:parseType="Literal">Web_REQ01 Changed using OSLC</dc:title>          <dc:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-06-20T14:09:49.004Z</dc:created>          <oslc:instanceShape rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0d66l7rZEeG3OKR6fZ1svQ"/>          <acp:accessControl rdf:resource="https://grarrc.ibm.com:9443/rm/accessControl/_zpWqELrZEeG3OKR6fZ1svQ"/>          <dc:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-06-20T14:09:49.787Z</dc:modified>          <rm_property:_0XY0wrrZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0ThBZbrZEeG3OKR6fZ1svQ#fe1e0579-bae0-480d-8e59-2f557597d6d0"/>          <dc:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">3</dc:identifier>          <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>          <rm_property:_0YF_YbrZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0SoQkrrZEeG3OKR6fZ1svQ#ebc08514-e765-4508-8c4f-bd191ce985c1"/>          <dc:creator rdf:resource="https://grarrc.ibm.com:9443/jts/users/TestJazzAdmin1"/>          <rm_property:_0ZAlaLrZEeG3OKR6fZ1svQ rdf:resource="https://grarrc.ibm.com:9443/rm/types/_0TX3cbrZEeG3OKR6fZ1svQ#99fa343e-2d22-47da-8243-1a51abb14c60"/>          <nav:parent rdf:resource="https://grarrc.ibm.com:9443/rm/folders/_zpWqELrZEeG3OKR6fZ1svQ"/>        </rdf:Description>      </rdf:RDF>  

4. Moving artifacts to a different folder

To move an artifact to a different folder, use steps describes above, and modify the nav:parent field. For instance (The target folder URI must be valid):

  <nav:parent rdf:resource="https://grarrc.ibm.com:9443/rm/folders/_zpWqELrZEeG3OKR6fZ1svQ"/>  

The field can be modified in conjunction with other fields. To obtain information about the folder that the artifact is being moved to, use the folder query capability, which is described later in this article.

5. Modifying artifact properties

When you modify artifact attributes, use an OSLC GET to retrieve the instance shape of the resource so that you have information about each artifact attribute when you modify the attributes. For example, if you want to change the “Status” attribute of an artifact, the instance shape provides key information about the attribute, such as the values that can be assigned to the attribute and the default value of the attribute.

The following example shows the information that is exposed by the instance shape for the “Status” attribute:

      <oslc:Property>          <oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/>          <oslc:allowedValues>              <oslc:AllowedValues>                  <oslc:allowedValue rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg#9fa948cf-d978-49b4-aac8-ab7cf73c0b70"/>                  <oslc:allowedValue rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg#5f25f5ae-5100-47a0-9913-a950498106db"/>                  <oslc:allowedValue rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg#3e9db9f1-3d5c-4716-aae0-f48d49260a8b"/>                  <oslc:allowedValue rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg#217b0cc2-9b72-4753-954a-effc3cd335cb"/>                  <oslc:allowedValue rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg#6f8bd7c7-fc78-413f-8240-36628727d196"/>              </oslc:AllowedValues>          </oslc:allowedValues>          <oslc:propertyDefinition rdf:resource="https://gradev.ibm.com:9444/rdm/types/_9AkBgucBEeGTAYdIle28Lg"/>          <oslc:range rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg"/>          <oslc:defaultValue rdf:resource="https://gradev.ibm.com:9444/rdm/types/_84r34ucBEeGTAYdIle28Lg#9fa948cf-d978-49b4-aac8-ab7cf73c0b70"/>          <oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-one"/>          <dc:title rdf:parseType="Literal">Status</dc:title>          <oslc:name>_9AkBgucBEeGTAYdIle28Lg</oslc:name>      </oslc:Property>  

For attributes whose data type is simple, which means exposed as rdf:datatype, change the value and update the resource. For example:

      <rm_property:_F5cs0dUyEeGIcftX51cahQ rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</rm_property:_F5cs0dUyEeGIcftX51cahQ>      <rm_property:_21MqgNUxEeGIcftX51cahQ rdf:datatype="http://www.w3.org/2001/XMLSchema#int">222</rm_property:_21MqgNUxEeGIcftX51cahQ>      <rm_property:_yXiMYtUxEeGIcftX51cahQ rdf:datatype="http://www.w3.org/2001/XMLSchema#string">My CHANGED str attr</rm_property:_yXiMYtUxEeGIcftX51cahQ>  

For attributes whose data type is an enumerated value that is exposed as rdf:resource, get the data type by using an OSLC Get. The data type can be cached to improve performance. The response to the Get also includes the format of the value that will be changed. For example, following property is exposed in a resource:

  <rm_property:_Fdr2gdU1EeGIcftX51cahQ rdf:resource="https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ#a321819f-caf0-426b-8b58-ab4100b136b5"/>  

The resource is composed of two parts, which are separated by the number sign (#). The first part is the data type. The second part is the data type current value.

If you use an OSLC GET to retrieve the resource data type (for instance GET https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ), following information is exposed:

  <rdf:RDF      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"      xmlns:acp="http://jazz.net/ns/acp#"      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">    <rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ#a321819f-caf0-426b-8b58-ab4100b136b5">      <rdfs:comment></rdfs:comment>      <rdfs:label>Value0</rdfs:label>    </rdf:Property>    <rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ#60e9ca3a-5bdf-4ffa-8f15-b3bb2d07f581">      <rdfs:comment></rdfs:comment>      <rdfs:label>Value2</rdfs:label>    </rdf:Property>    <rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ#39dfe83b-a589-4c8e-8006-6f423266a035">      <rdfs:comment></rdfs:comment>      <rdfs:label>Value1</rdfs:label>    </rdf:Property>    <rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ">      <acp:accessControl rdf:resource="https://gradev.ibm.com:9444/rdm/accessControl/_yUiqwtTZEeGgPK45CpBK8A"/>      <rdfs:comment></rdfs:comment>      <rdfs:label>E_Type</rdfs:label>    </rdf:Property>  </rdf:RDF>  

From this information and the information that is exposed in the artifact (a321819f-caf0-426b-8b58-ab4100b136b5), you can determine that the current value is Value0.

To modify the attribute with the Value2 value, use the following entry for the property:

<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_v7fgYNU0EeGIcftX51cahQ#60e9ca3a-5bdf-4ffa-8f15-b3bb2d07f581">

6. Adding and removing links

To add or remove a link, follow these steps:

  1. Obtain, or get, the artifacts that you want.
  2. Add or remove the links from the artifact body.
  3. Update, or put, the modified artifact.

The next examples show how to add or remove a link. Blank, or empty, RDF/xml nodes represent the title of the link.

To add an implementedBy link and a validated by link, use the following code:

      <rdf:RDF          .          .          .      <rdf:Description rdf:about="">                  .                  .                  .          <oslc_rm:implementedBy rdf:ID="n0" rdf:resource="http://www.google.com"/>          <oslc_rm:validatedBy rdf:ID="n1" rdf:resource="http://www.something.com"/>                  .                  .                  .       </rdf:Description>        <rdf:Description rdf:about="#n0">            <dc:title rdf:parseType="Literal">Link1</dc:title>       </rdf:Description>       <rdf:Description rdf:about="#n1">            <dc:title rdf:parseType="Literal">Link2</dc:title>       </rdf:Description>      </rdf:RDF>  

To remove a link, remove the entry from the artifact description and leave the other link representation. You do not need to remove the related blank node.

      <rdf:RDF          .          .          .      <rdf:Description rdf:about="">                  .                  .                  .          <oslc_rm:validatedBy rdf:ID="n1" rdf:resource="http://www.something.com"/>                  .                  .                  .       </rdf:Description>       <rdf:Description rdf:nodeID="A0">          <rdf:subject rdf:resource="https://gradev.ibm.com:9444/rdm/resources/_Rm314dU1EeGIcftX51cahQ"/>          <rdf:predicate rdf:resource="http://open-services.net/ns/rm#validatedBy"/>          <rdf:object rdf:resource="http://www.something.com"/>          <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>          <dc:title>Link2</dc:title>        </rdf:Description>      </rdf:RDF>  

7. Adding artifacts to and removing them from a collection

Requirements that belong to a collections are exposed as entries of the “oslc_rm:uses” type. A complete sample entry is as follows:

  <oslc_rm:uses rdf:resource="https://grarrc.ibm.com:9443/rm/resources/_mLHpsbrhEeG3OKR6fZ1svQ"/>  

To add artifacts to or remove artifacts from a collection, follow these steps:

  1. Obtain, or get, the collection.
  2. Either add or remove the “oslc_rm:uses” entries in the RDF.
  3. Update (Put ) the resource back in with the modified RDF.

Using the query capabilities

With the OSLC query capability, you can access artifact data and filter the results. To use the query capability, obtain it from the service document for a specific project and then use the following filters to scope the information that is returned:

  • oslc.prefix: Defines the namespace prefixes that are used in the query request
  • oslc.select: Defines the information that should be returned
  • oslc.where: Defines the query filters.
  1. Obtaining the basic query capability: To obtain the OSLC query capability, follow the steps in the “Getting startup information” section. The OSLC query capability looks like this example:
          <oslc:QueryCapability>          <dcterms:title rdf:parseType="Literal">Query Capability</dcterms:title>          <oslc:queryBase rdf:resource="https://grarrc.ibm.com:9443/rm/views?oslc.query=true&projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_C7NVcttZEeG_kKBmAlkUvA" />          <oslc:resourceType rdf:resource="http://open-services.net/ns/rm#Requirement" />          <oslc:resourceType rdf:resource="http://open-services.net/ns/rm#RequirementCollection" />      </oslc:QueryCapability>  

    To query the RM system for specific data, use the query base URL and the OSLC filters.

  2. Samples of the basic query capability: These examples show various actions that you can do with the query capability. The number sign (#) must be URL encoded as %23. For queries that are based on the artifact identifier, select all fields of the matching artifacts:
      &oslc.prefix=dcterms=<http://purl.org/dc/terms/>&oslc.select=*&oslc.where=dcterms:identifier=4  

    For queries that are based on the artifact title, select all fields of the matching artifacts:

      &oslc.prefix=dcterms=<http://purl.org/dc/terms/>&oslc.select=*&oslc.where=dcterms:title="rrc_r_01"  

    For queries that are based on a link type that is linked to a specific URL, select the title and description of the matching artifacts. This example uses the implementedBy link type:

      &oslc.prefix=dcterms=<http://purl.org/dc/terms/>,oslc_rm=<http://open-services.net/ns/rm%23>&oslc.select=dcterms:title,dcterms:description&oslc.where=oslc_rm:implementedBy=<https://rtc.dev.calm:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/8>  

    For queries that are based on a link type that uses the “in” modifier, select everything by using the wildcard character (*). This example uses the implementedBy link type:

      &oslc.prefix=dcterms=<http://purl.org/dc/terms/>,oslc_rm=<http://open-services.net/ns/rm%23> &oslc.select=*&oslc.where=oslc_rm:implementedBy in [<https://rtc.dev.calm:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/20>,<https://rtc.dev.calm:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/30>]  

    To query requirements in a specific folder use a query similar to:

      &oslc.prefix=oslc=<http://open-services.net/ns/core%23>,dcterms=<http://purl.org/dc/terms/>,nav=<http://com.ibm.rdm/navigation%23>&oslc.select=dcterms:title,dcterms:description,oslc:instanceShape&oslc.where=nav:parent=<https://grarrc.ibm.com:9443/rm/folders/_RHCJYN5jEeGb6IIbvOh9Dw>  

    To query for all collections in an specific project use a query similar to:

      &oslc.prefix=rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=*&oslc.where=rdf:type=<http://open-services.net/ns/rm%23RequirementCollection>  

    To query for all artifacts in a collection based on collection’s identifier, use a query similar to:

      &oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=oslc_rm:uses&oslc.where=dcterms:identifier=1  

    To query for artifact’s specific information of all artifacts that belongs to a collection, use a query similar to. Note:This code uses the %7B%7D instead of braces { }.

      &oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=oslc_rm:uses%7Bdcterms:title%7D&oslc.where=dcterms:identifier=1  

    Nested inline selections are not supported. However, you can use the following query to get similar results to request two or more inline fields:

      &oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=oslc_rm:uses%7Bdcterms:title%7D,oslc_rm:uses%7Bdcterms:identifier%7D&oslc.where=dcterms:identifier=1  

    To query for all collections that contain one or several requirements, use a query similar to:

      &oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=dcterms:title&oslc.where=oslc_rm:uses in [<https://grarrc.ibm.com:9443/rm/resources/__JnIVvbREeGLlsbcKLgIyg>,<https://grarrc.ibm.com:9443/rm/resources/_AQkwZvbSEeGLlsbcKLgIyg>]  

    To query for all requirements in a specific project, use a query similar to:

      &oslc.prefix=rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=*&oslc.where=rdf:type=<http://open-services.net/ns/rm%23Requirement>  

    To query for all artifacts of an specific type, use a query similar to. Note: This code can be used as a workaround when you want to query against “oslc:instanceShape”. The value that is used in the query can be obtained from either of these locations:

    • The services document of the project in the Requirement Creation factory section
    • The “oslc:instanceShape” entry of a returned RDF requirement representation
      &oslc.prefix=rm=<http://www.ibm.com/xmlns/rdm/rdf/>&oslc.select=*&oslc.where=rm:ofType=<https://grarrc.ibm.com:9443/rm/types/_SAwm2t5jEeGb6IIbvOh9Dw>  

    To query for all folders that contain artifacts in a project, use a query similar to:

      &oslc.prefix=rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns%23>,dcterms=<http://purl.org/dc/terms/>,nav=<http://com.ibm.rdm/navigation%23>&oslc.select=nav:parent,nav:parent%7Bdcterms:title%7D&oslc.where=rdf:type=<http://open-services.net/ns/rm%23Requirement>  

    To query for all artifacts that were modified on August 1, 2012 at 21:50:40.979 or later, use a query similar to. Note:This query must specify the date in the following format: ^^xsd:dateTime. (Must be encoded)

      &oslc.prefix=dcterms=<http://purl.org/dc/terms/>,oslc_rm=<http://open-services.net/ns/rm%23>&oslc.select=dcterms:title,dcterms:modified&oslc.where=dcterms:modified>="2012-08-01T21:51:40.979Z"%5E%5Exsd%3AdateTime  

    To query for all artifacts that have the Status property set to Approved, use a query similar to. Note: To run this type of query, you must obtain the value of the Approved state from the instance shape. After you have the value, create a query that is like this one:

      &oslc.prefix=rm_property=<https://grarrc.ibm.com:9443/rm/types/>&oslc.select=*&oslc.where=rm_property:_PfIW0OrtEeGaNr-hWVrMiw=<https://grarrc.ibm.com:9443/rm/types/_PamcJOrtEeGaNr-hWVrMiw%233e9db9f1-3d5c-4716-aae0-f48d49260a8b>  

    Important: The number sign (#) must be encoded as %23.

    To query for two or more properties, specify the “and” operator to separate the query conditionals:

      &oslc.prefix=rm_property=<https://grarrc.ibm.com:9443/rm/types/>&oslc.select=*&oslc.where=rm_property:_PfIW0OrtEeGaNr-hWVrMiw=<https://grarrc.ibm.com:9443/rm/types/_PamcJOrtEeGaNr-hWVrMiw%233e9db9f1-3d5c-4716-aae0-f48d49260a8b> and rm_property:_PeT3certEeGaNr-hWVrMiw=<https://grarrc.ibm.com:9443/rm/types/_PbDvIurtEeGaNr-hWVrMiw>  

Exploring the project folder structure by using the folder query capability

The folder query capability is available in version 4.0 and later of the Requirements Management (RM) application.

1. Obtaining the basic query capability

To obtain the OSLC folder query capability, follow the steps in the “Getting startup information” section. The OSLC query capability is similar to the following example:

      <oslc:QueryCapability>          <dcterms:title rdf:parseType="Literal">Folder Query Capability</dcterms:title>          <oslc:queryBase rdf:resource="https://grarrc.ibm.com:9443/rm/folders?oslc.where=public_rm:parent=https://grarrc.ibm.com:9443/rm/folders/_Or3t4OrtEeGaNr-hWVrMiw" />      </oslc:QueryCapability>  

The exposed query Folder capability can be used to get the folders at root folder of the project:

Action: Get
URL: https://grarrc.ibm.com:9443/rm/folders?oslc.where=public_rm:parent=https://grarrc.ibm.com:9443/rm/folders/_Or3t4OrtEeGaNr-hWVrMiw
The response will be an RDF which may (if folder does contains other folders) contains entries like:

      <rdfs:member>          <nav:folder rdf:about="https://grarrc.ibm.com:9443/rm/folders/_PymscOrtEeGaNr-hWVrMiw">              <dcterms:title>Glossary Terms</dcterms:title>              <nav:subfolders rdf:resource="https://grarrc.ibm.com:9443/rm/folders?oslc.where=public_rm:parent=https://grarrc.ibm.com:9443/rm/folders/_PymscOrtEeGaNr-hWVrMiw"/>          </nav:folder>      </rdfs:member>  

2. Traversing the project structure

If you use a GET to retrieve the subfolder’s resource, the folders in that folder will be exposed. Another way to navigate the folder structure is by using an OSLC GET to retrieve the folder’s URI, as in this example:

      <nav:folder rdf:about="https://grarrc.ibm.com:9443/rm/folders/_PymscOrtEeGaNr-hWVrMiw">          <dcterms:title>Glossary Terms</dcterms:title>          <dcterms:description>Glossary</dcterms:description>          <nav:parent rdf:resource="https://grarrc.ibm.com:9443/rm/folders/_Or3t4OrtEeGaNr-hWVrMiw"/>          <nav:subfolders rdf:resource="https://grarrc.ibm.com:9443/rm/folders?oslc.where=public_rm:parent=https://grarrc.ibm.com:9443/rm/folders/_PymscOrtEeGaNr-hWVrMiw"/>          <oslc:serviceProvider rdf:resource="https://grarrc.ibm.com:9443/rm/discovery/_Or3t4OrtEeGaNr-hWVrMiw/services.xml" />      </nav:folder>  

From the parent resource, you can navigate backward in the folder structure. From the subfolders resource, you can navigate forward in the folder structure.

The information discussed here shows the basics of the OSLC capabilities for the requirements management application with the goal of provide samples that will make easier to start developing application that could collaborate with the requirements management application via OSLC. The requirements management application support a wider range of OSLC capabilities which are fully described in the OSLC specification.

Feedback
Was this information helpful? Yes No 11 people rated this as helpful.