Main Content

updateDocUri

Class: slreq.LinkSet
Namespace: slreq

Update link destinations for renamed or moved document

Description

example

count = updateDocUri(myLinkSet,oldID,newID) updates the link destinations in the link set specified by myLinkSet from the file with the resource identifier oldID to the file with the resource identifier newID. The new file can be a requirement set or an external requirements document. The method returns the number of links updated.

Note

You might have to save the link set, close it, and reopen it to see the changes.

Input Arguments

expand all

Link set, specified as an slreq.LinkSet object.

Resource identifier for the original requirement set or requirement document, specified as a string scalar or character vector. The resource identifier can be a file path or IBM® DOORS® module ID.

Example: "myAdd.slreqx"

Example: "000001c1"

Resource identifier for the new requirement set or requirement document to use as the link destinations, specified as a string scalar or character vector. The resource identifier can be a file path or IBM DOORS module ID.

Example: "myAdd2.slreqx"

Example: "000001c2"

Output Arguments

expand all

Number of updated slreq.Link objects in the link set, returned as a character vector.

Examples

expand all

This example shows how to update link destinations when you rename a requirement set that has incoming links.

Load the Requirement Set

Load the mySubtractReqs requirement set, which has incoming links from the mySubtract~m link set.

rs = slreq.load("mySubtractReqs");

Get a handle to the link set that contains the incoming links.

myLinkSet = slreq.getDependentLinkSets(rs);

Display the source artifact file name for the link set.

[~,fname,ext] = fileparts(myLinkSet.Artifact);
shortname = [fname ext]
shortname = 
'mySubtract.m'

Rename the Requirement Set

Clear the loaded requirement and link data and the variables assigned to them.

slreq.clear
clear rs myLinkSet

Rename the mySubtractReqs requirement set to mySubtract.

movefile mySubtractReqs.slreqx mySubtract.slreqx

Load the mySubtract requirement set.

rs = slreq.load("mySubtract");

Load the link set associated with the mySubtract MATLAB® code file.

myLinkSet = slreq.load(shortname);
Warning: Unable to locate Requirement Set mySubtractReqs.slreqx (referrer mySubtract.m).

Get the broken links in the link set.

[brokenLinks,linkDetails] = getBrokenLinks(myLinkSet);

Display the details for the first broken link.

linkDetails(1)
ans = struct with fields:
    status: 0
       doc: 'mySubtractReqs.slreqx'
        id: ''

Assign the invalid document name to a variable.

oldDoc = string(linkDetails(1).doc)
oldDoc = 
"mySubtractReqs.slreqx"

Fix the Broken Links

Fix the broken links by updating the the link destinations to point to mySubtract.slreqx instead of mySubtractReqs.slreqx.

newDoc = "mySubtract.slreqx";
count = updateDocUri(myLinkSet,oldDoc,newDoc)
count = 4

Confirm that there are no broken links in the link set.

brokenLinks = getBrokenLinks(myLinkSet)
brokenLinks =

     []

This example shows how to update the link destinations for direct links to the URI of a new document.

Open the Link Directly to Requirements in Microsoft Word Documents example, which uses a model that has direct links to external documents.

openExample('slrequirements/LinkToRequirementsInMicrosoftWordDocumentsExample');

Open the slvnvdemo_fuelsys_officereq model. Find the associated link set.

open_system("slvnvdemo_fuelsys_officereq.slx")
myLinkSet = slreq.find("Type","LinkSet","Name","slvnvdemo_fuelsys_officereq");

Update Direct Link Destinations

Some of the links in myLinkSet point to slvnvdemo_FuelSys_DesignDescription.docx. Update the link destinations to point to slvnvdemo_FuelSys_DesignDescription_new.docx.

count = updateDocUri(myLinkSet,"slvnvdemo_FuelSys_DesignDescription.docx","slvnvdemo_FuelSys_DesignDescription_new.docx")
count = 8

Save the link set. Then close the link set and re-open it for the changes to take effect.

tf = save(myLinkSet)
tf = logical
   1

slreq.clear;
myLinkSet = slreq.load("slvnvdemo_fuelsys_officereq.slmx");

Tips

  • To update the file name or path of the referenced requirements in the requirement set when you rename or move an external requirements document file, use updateSrcFileLocation.

  • To update the external requirements document resource identifier for referenced requirements imported from non-file-based domains, use the updateSrcArtifactUri method.

Version History

Introduced in R2018a