Main Content

Load and Resolve Links

When you open or load an artifact that has incoming or outgoing links, Requirements Toolbox™ loads the link sets that contain those links. If the link sets have registered requirement sets, the software also loads those requirement sets. Loading registered requirement sets can further load links if the requirement set has incoming or outgoing links to additional artifacts.

When you load links, the software may identify unresolved links where the source or destination item are not available. You can resolve links by loading the artifact that contains the unloaded item or by repairing the link manually.

Load Artifacts and Associated Link Sets

When you load artifacts such as requirement sets, Simulink® models, or MATLAB® code that have incoming or outgoing links, Requirements Toolbox loads the link sets that contain those links.

For example:

  1. Open the ShortestPath project. At the MATLAB command line, enter this command:

    openExample("slrequirements/ShortestPathExample")

  2. Open the shortest_path_func_reqs requirement set. At the MATLAB command line, enter:

    slreq.open("shortest_path_func_reqs");
    The shortest_path_func_reqs requirement set has outgoing links to MATLAB code ranges in shortest_path.m and graph_unit_tests.m.

  3. View the loaded link sets. In the Requirements Editor, click Show Links. The software loaded the link sets associated with shortest_path.m and graph_unit_tests.m.

    The Requirements Editor links view shows that shortest_path.slmx and graph_unit_tests.slmx are loaded.

Load Registered Requirement Sets

When you create a link to a requirement, the requirement set that contains the requirement becomes registered to the link set. You can view the registered requirement sets for a link set by using the getRegisteredReqSets method.

When you load a link set that has registered requirements, Requirements Toolbox also loads those requirement sets. If those requirement sets have links to additional artifacts, the software also loads the link sets that contain those links.

For example:

  1. Clear the loaded requirement sets and link sets by entering this command at the MATLAB command line:

    slreq.clear

  2. Open the ShortestPath project by entering this command at the MATLAB command line:

    openExample("slrequirements/ShortestPathExample")

  3. Open the graph_unit_tests.m MATLAB code file. At the MATLAB command line, enter:

    edit graph_unit_tests.m
    The graph_unit_tests.m file has outgoing links to requirements.

  4. View the loaded link sets. Open the Requirements Editor.

    slreq.editor
    In the Requirements Editor, click Show Links. The software loaded graph_unit_tests.slmx, which is the link set that contains the outgoing links from graph_unit_tests.m.

    The Requirements Editor links view shows that the shortest_path.slmx and graph_unit_tests.slmx link sets are loaded.

    The graph_unit_tests.m file has outgoing links to the shortest_path_tests_reqs and shortest_path_func_reqs requirement sets, so they are registered to the graph_unit_tests link set.

  5. View the loaded requirement sets. In the Requirements Editor, click Show Requirements. Because the shortest_path_tests_reqs and shortest_path_func_reqs requirement sets are registered to the graph_unit_tests link set, they software also loaded them.

    The Requirements Editor requirements view shows that the shortest_path_tests_reqs and shortest_path_func_reqs requirement sets are loaded.

    The shortest_path_func_reqs requirement set also has incoming links from shortest_path.m stored in shortest_path.slmx.

  6. View the loaded link sets again. In the Requirements Editor, click Show Links. Because the software loaded the shortest_path_func_reqs requirement set, it also loaded the link set that contains its incoming links, shortest_path.slmx.

    The Requirements Editor links view shows that the shortest_path.slmx and graph_unit_tests.slmx link sets are loaded.

Unregister Requirement Sets

To unregister a requirement set from a link set, use the updateRegisteredReqSets method. You can only unregister a requirement set from a link set if the requirement set does not have incoming links stored in the link set.

Resolve Links

An unresolved link has a source item or destination item that is not available. Items can be unavailable because:

  • The artifact that contains the source or destination item is not loaded.

    For example, loading a requirement set that has incoming links from a Simulink model also loads the link set that belongs to the model. However, if you do not load the Simulink model, the links are unresolved.

  • The artifact is loaded, but the specified ID does not exist.

    For example, if you delete a linked requirement, the link becomes unresolved because the stored ID no longer corresponds to a valid item.

Links that are unresolved because the specified ID does not exist are called invalid links. Links that have invalid sources are called orphan links and links that have invalid destinations are called broken links.

To see the unresolved links, in the Requirements Editor, click Show Links. Unresolved links have the unresolved link icon .

To resolve a link with an unloaded source or destination item, load the artifact that contains the item. Load the artifact by selecting the link in the Requirements Editor and, in the right pane, under Properties, click the source or destination item that has a warning icon .

To resolve invalid links:

  1. In the Requirements Editor, select Show Links. Select a link set or a link and, in the Links section, select Resolve link issues > Repair invalid links. The Repair Invalid Links dialog box opens.

    The Repair Invalid Links dialog for the crs_controller link set is shown. The dialog box shows link 1 out of 21 flagged links.

  2. In the Repair Invalid Links dialog:

    • Update the source or destination ID by manually specifying the ID in the Update to field.

    • Update the source or destination to the currently selected item in the source or destination artifact by clicking Use current.

    • Update the source or destination artifact by clicking Browse and selecting an artifact.

    • Delete the link by clicking Delete link.

    If there are links in the link set that have the same missing source or destination, you can apply the same fix to those links by selecting the check box at the bottom of the dialog box.

  3. If you opened the Repair Invalid links dialog for a link set, you can repair or delete additional links in the link set by using the < and > buttons to navigate the links.

  4. Close the dialog by clicking OK.

  5. Save the link set. In the Requirements Editor, select the link set and, in the File section, click Save.

Resolve Links Programmatically

To resolve or delete invalid links in a link set:

  1. Get a handle to the link set by using the slreq.find function.

  2. Get the broken links by using the getBrokenLinks method. Get the orphan links by using the getOrphanLinks method.

  3. Repair the links by using the setSource and setDestination methods.

    Alternatively, delete the links. Delete the orphan links by using the deleteOrphanLinks method. Delete the broken links by using the remove method.

  4. Save the link set by using the save method.

Alternatively, to resolve or delete individual invalid links:

  1. Get a handle to the link by using the slreq.find function or the find method.

    Tip

    You can find links by destination attributes by using the slreq.find function or the find method. For more information, see Find Links by Destination Attributes.

  2. Repair the link by using the setSource or setDestination method or delete the link by using the remove method.

  3. Get a handle to the link set by using the linkSet method.

  4. Save the link set by using the save method.

To fix broken links that point to a requirement set that you renamed, use the updateDocUri method.

Unload Link Information

To unload link sets from memory, close both the source and destination artifacts that contain the linked items. If you close only the source artifact or only the destination artifact, the links remain loaded.

Alternatively, you can unload link sets by using the slreq.clear function to clear the loaded requirement sets and link sets and close the Requirements Editor and Traceability Matrix windows.

See Also

| |

Related Topics