Main Content

copy

Class: slreq.Justification
Namespace: slreq

Copy and paste justification

Since R2020b

Syntax

tf = copy(just1,location,just2)

Description

tf = copy(just1,location,just2) copies justification just1 and pastes it under, before, or after justification just2 depending on the location specified by location. The function returns 1 if the copy and paste is executed.

Note

If you copy a justification and paste it within the same requirement set, the copied justification retains the same custom attribute values as the original. If the justification is pasted into a different requirement set, the copied justification does not retain the custom attribute values.

Input Arguments

expand all

Justification to copy, specified as an slreq.Justification object.

Paste location, specified as 'under', 'before', or 'after'.

Justification to paste original justification near, specified as an slreq.Justification object.

Output Arguments

expand all

Paste success status, returned as a 0 or 1 of data type logical.

Examples

expand all

This example shows how to copy a justification and paste it under, before, or after another justification.

Load the crs_req_justs requirement file, which describes a cruise control system, and assign it to a variable. Find two justifications by index. The first justification will be copied and pasted in relation to the second justification.

rs = slreq.load('crs_req_justs');
jt1 = find(rs,'Type','Justification','Index','5.1');
jt2 = find(rs,'Type','Justification','Index','5.2');

Paste Under a Justification

Copy and paste the first justification, jt1, under the second justification, jt2. The first justification becomes the last child justification of jt2, which you can verify by finding the children of jt2 and comparing the summary of the last child and jt1.

tf = copy(jt1,'under',jt2);
childJusts = children(jt2);
lastChild = childJusts(numel(childJusts));
lastChild.Summary
ans = 
'Non-functional requirement'
jt1.Summary
ans = 
'Non-functional requirement'

Paste Before a Justification

Copy and paste the first justification, jt1, before the second justification, jt2. Confirm that the justification was pasted before jt2 by checking the index and summary. The old index of jt2 was 5.2. The index of the pasted justification should be 5.2 and the index of jt2 should be 5.3.

tf = copy(jt1,'before',jt2);
pastedJust1 = find(rs,'Type','Justification','Index','5.2');
pastedJust1.Summary
ans = 
'Non-functional requirement'
jt2.Index
ans = 
'5.3'

Paste After a Justification

Copy and paste the first justification, jt1, after the second justification, jt2. Confirm that the justification was pasted after jt2 by checking the index. The index of jt2 is 5.3 and should not change, which means the index of the pasted justification should be 5.4.

tf = copy(jt1,'after',jt2);
pastedJust2 = find(rs,'Type','Justification','Index','5.4');
pastedJust2.Summary
ans = 
'Non-functional requirement'
jt2.Index
ans = 
'5.3'

Cleanup

Clear the open requirement set and link sets, and close the open models without saving changes.

slreq.clear;
bdclose all;

Version History

Introduced in R2020b