Main Content

getAttribute

Class: slreq.Requirement
Namespace: slreq

Get requirement property values

Syntax

val = getAttribute(req,propertyName)

Description

val = getAttribute(req,propertyName) returns the value of the requirement property, propertyName, for the requirement, req. The property can be a built-in property, a custom attribute, or a stereotype property.

Note

To return the value of a stereotype property, you must pass the fully qualified name of the property. For example, the fully qualified name for a property called Status in a stereotype called myStereotype in a profile called myProfile is myProfile.myStereotype.Status.

Input Arguments

expand all

Requirement, specified as an slreq.Requirement object.

Requirement property name, specified as a string scalar or character vector.

Example: "Description"

Output Arguments

expand all

Requirement property value, returned as a:

  • String scalar

  • Character array

  • boolean

  • datetime

  • single

  • double

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • enumeration

The data type depends on the type of the built-in property, custom attribute, or stereotype property.

Examples

expand all

This example shows how to assign a profile to a requirement set and get and set stereotype property values for requirements.

Open the ShortestPath project.

openProject("ShortestPath");

Load the shortest_path_tests_reqs requirement set.

rs = slreq.load("shortest_path_tests_reqs");

Assign the TestReqProfile profile to the shortest_path_tests_reqs requirement set.

importProfile(rs,"TestReqProfile");

Find the requirement with index 2.1.1. Apply the TestRequirement stereotype to the requirement.

testReq = find(rs,Index="2.1.1");
testReq.Type = "TestReqProfile.TestRequirement";

Get the value of the Reviewed stereotype property.

val = getAttribute(testReq,"TestReqProfile.TestRequirement.Reviewed")
val = 0

Set the value of the Reviewed stereotype property to 1.

setAttribute(testReq,"TestReqProfile.TestRequirement.Reviewed",1)

Tips

  • To get property values for links, use the getAttribute method of slreq.Link.

Version History

Introduced in R2018a