Main Content

removeLink

Remove link from local OSLC requirement resource object

Since R2021a

    Description

    removeLink(reqResource,resourceURL) removes the RDF/XML element j.0:Link that has the rdf:resource attribute set to resourceURL from the requirement or requirement collection resource specified by reqResource. Use the commit function to apply the change to the service provider. For more information about RDF/XML elements, see An XML Syntax for RDF on the World Wide Web Consortium website and QM Resource Definitions on the Open Services for Lifecycle Collaboration (OSLC) website.

    example

    Examples

    collapse all

    This example shows how to add and remove links from OSLC resources to an OSLC requirement.

    After you have created and configured the OSLC client myClient as described in Create and Configure an OSLC Client for the Requirements Management Domain, create a query capability for the requirement resource type. Submit a query request to the service provider for the available requirement resources.

    myQueryCapability = getQueryService(myClient,'Requirement');
    reqs = queryRequirements(myQueryCapability)
    reqs = 
    
      1×30 Requirement array with properties:
    
        ResourceUrl
        Dirty
        IsFetched
        Title
        Identifier

    Assign one of the requirements to a variable called myReq and one to linkReq. Fetch the full resource properties for the requirements.

    myReq = reqs(1);
    linkReq = reqs(5);
    fetch(myReq,myClient);
    fetch(linkReq,myClient);

    Add a link from linkReq to myReq. Confirm the link creation by getting the links for myReq.

    addLink(myReq,linkReq)
    links = getLinks(myReq)
    links =
    
      1×1 cell array
    
        {'https://localhost:9443/rm/CA_3d5ba3752e2c489b965a3ecceffb664a'}

    In the service provider, identify a test case to link to the requirement. Identify the resource URL of the test case and assign it to a variable called URL. Add a link from URL to myReq. Confirm the link creation by getting the links for myReq.

    URL = 'https://localhost:9443/qm/_ibz6tGWYEeuAF8ZpKyQQtg';
    addLink(myReq,URL)
    links = getLinks(myReq)
    links =
    
      1×2 cell array
    
        {'https://localhost:9443/rm...'}    {'https://localhost:9443/qm...'}

    Commit the changes to the service provider.

    status = commit(myReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    Fetch the full resource properties for the updated requirement myReq.

    status = fetch(myReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    Get the resource URLs linked to myReq.

    links = getLinks(myReq)
    links =
    
      1×2 cell array
    
        {'https://localhost:9443/rm...'}    {'https://localhost:9443/qm...'}

    Get the URL for the first linked resource and assign it to URL.

    URL = links{1}
    URL =
    
        'https://localhost:9443/rm/CA_3d5ba3752e2c489b965a3ecceffb664a'

    Before removing the link from myReq, confirm that the resource URL points to the requirement that you want to remove. Create a requirement resource object and set the resource URL. Fetch the full resource properties for the requirement and inspect the requirement.

    req = oslc.rm.Requirement;
    setResourceUrl(req,URL);
    status = fetch(req,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    req
    ans = 
    
      Requirement with properties:
    
        ResourceUrl: 'https://localhost:9443/rm/CA_3d5ba3752e2c489b965a...'
              Dirty: 0
          IsFetched: 1
              Title: '[SAFe] Lifecycle Scenario Template'
         Identifier: '1165'

    Remove the link from myReq and commit the changes to the service provider.

    removeLink(myReq,URL)
    status = commit(myReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    Fetch the full resource properties for the updated requirement myReq.

    status = fetch(myReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    Verify the link removal by getting the URLs for the resources linked to myReq.

    links = getLinks(myReq)
    links =
    
      1×1 cell array
    
        {'https://localhost:9443/qm/_ibz6tGWYEeuAF8ZpKyQQtg'}

    Input Arguments

    collapse all

    OSLC requirement or requirement collection resource object, specified as an oslc.rm.Requirement or oslc.rm.RequirementCollection object.

    OSLC resource URL, specified as a character vector.

    Version History

    Introduced in R2021a