Skip to content

Commit

Permalink
fixes on the reqs-json model for usability in macros. playground exam…
Browse files Browse the repository at this point in the history
…ple for trace creation.
  • Loading branch information
DrMarkusVoss committed Feb 21, 2025
1 parent 1a990dd commit 58c98eb
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 50 deletions.
11 changes: 11 additions & 0 deletions pumla_macros_reqs.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
' ############################################
' ---------------------------------------------
' create the reqs trace starting with the
' requirement with the given alias
!unquoted procedure PUMLAPutReqsTraceFor(alias)
!foreach $r in $allreqs.reqs
!if ($r.alias == alias)
tbd
!endif
!endfor
!endprocedure
11 changes: 6 additions & 5 deletions src/pumla/control/reqparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,24 @@ def updatePUMLAReqRepo(path, mrefilename):
# get put into dict.
pumlareqslist = []

# table to create the bi-directional traceability
derived_table = []

# sum up information from all files in common list
for f in pumlareqfiles:
reqs = parsePUMLAReqFile(f)
for r in reqs:
r.update({"derived to": "not yet derived"})
r.update({"in file": f})
if not r.get("derived from")==None:
derived_table.append({"from": r["derived from"], "to": r.get("alias")})
r.update({"derived_to": "not yet derived"})
r.update({"in_file": f})
if not r.get("derived_from")==None:
derived_table.append({"from": r["derived_from"], "to": r.get("alias")})
pumlareqslist.append(r)

# update the "derived to" attribute corresponding to the "derived from"
for e in derived_table:
for r in pumlareqslist:
if r.get("alias") == e.get("from"):
r.update({"derived to": e.get("to")})
r.update({"derived_to": e.get("to")})


# make it accessible from within PlantUML.
Expand Down
2 changes: 1 addition & 1 deletion test/examples/WeatherStation/cheatSheet.puml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startuml
' the following file gets generated when you call
' "pumla update" in this directory
!include modelrepo_json.puml
Expand Down
48 changes: 25 additions & 23 deletions test/examples/WeatherStation/playground.puml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
@startuml
!include <c4/C4_Container.puml>
!include pumla_macros.puml
!include reqsrepo_json.puml

AddElementTag("v1.0", $borderColor="#d73027")
AddElementTag("v1.1", $fontColor="#d73027")
AddElementTag("backup", $fontColor="orange")
!alias = "REQ_WS1"

'AddRelTag("backup", $textColor="orange", $lineColor="orange", $lineStyle = DashedLine())
!foreach $r in $allreqs.reqs
!if $r.alias == alias
object $r.alias {
|= //attribute// |= //content//|
|= Type | $r.type |
|= Content | $r.content |
|= Status | $r.status |
}
!endif
!if $r.derived_from == alias
object $r.alias {
|= //attribute// |= //content//|
|= Type | $r.type |
|= Content | $r.content |
|= Status | $r.status |
}
!endif
!endfor

PUMLAC4Person(user, "Customer", "People that need products")
PUMLAC4Person(admin, "Administrator", "People that administrates the products via the new v1.1 components", $tags="v1.1")
PUMLAC4Container(spa, "SPA", "angular", "The main interface that the customer interacts with via v1.0", $tags="v1.0")
PUMLAC4Container(spaAdmin, "Admin SPA", "angular", "The administrator interface that the customer interacts with via new v1.1", $tags="v1.1")
PUMLAC4Container(api, "API", "java", "Handles all business logic (incl. new v1.1 extensions)", $tags="v1.0+v1.1")
PUMLAC4ContainerDb(db, "Database", "Microsoft SQL", "Holds product, order and invoice information")
PUMLAC4Container(archive, "Archive", "Audit logging", "Stores 5 years", $tags="backup")
!foreach $r in $allreqs.reqs
!if $r.derived_from !=null
$r.derived_from <|-- $r.alias
!endif
!endfor


PUMLAC4Rel("id1", user, spa, "Uses", "https")
PUMLAC4Rel("id2", spa, api, "Uses", "https")
PUMLAC4Rel_R("id3", api, db, "Reads/Writes")
PUMLAC4Rel("id4",admin, spaAdmin, "Uses", "https")
PUMLAC4Rel("id5", spaAdmin, api, "Uses", "https")
PUMLAC4Rel_L("id6", api, archive, "Writes", "messages", $tags="backup")

user .. spa : huhu

SHOW_LEGEND()
@enduml
10 changes: 5 additions & 5 deletions test/examples/WeatherStation/req.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- type: Requirement
alias: REQ_WS1
status: decided
derived from:
derived_from:
taggedvalues:
- tag: "Vendor"
values:
Expand All @@ -17,30 +17,30 @@
- type: Requirement
alias: REQ_WS2
status: new
derived from:
derived_from:
content:
This is another requirement. The Weather Station housing shall be blue.

- type: Requirement
alias: REQ_WS3
status: aligned
derived from:
derived_from:
content:
The Weather Station shall display the measured temperature so that it
is conveniently readable by a human looking at it in a distance of up to 3m.

- type: Requirement
alias: REQ_WS4
status: aligned
derived from:
derived_from:
content:
It shall be possible to switch the unit of the displayed temperature
between degree Celsius and Fahrenheit.

- type: Requirement
alias: REQ_WS5
status: aligned
derived from:
derived_from:
content:
The unit in which the temperature is displayed shall stay as it is even
after the batteries and/or the power supply has been removed.
14 changes: 7 additions & 7 deletions test/examples/WeatherStation/reqs_json_diagram.puml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@startjson
{"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived to": "REQ_SensorA1", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS2", "status": "new", "derived from": null, "content": "This is another requirement. The Weather Station housing shall be blue.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS3", "status": "aligned", "derived from": null, "content": "The Weather Station shall display the measured temperature so that it is conveniently readable by a human looking at it in a distance of up to 3m.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS5", "status": "aligned", "derived from": null, "content": "The unit in which the temperature is displayed shall stay as it is even after the batteries and/or the power supply has been removed.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived from": "REQ_WS1", "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived to": "not yet derived", "in file": "./tempSensorA/req.yaml"}]}
{"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived_from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived_to": "REQ_SensorA1", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS2", "status": "new", "derived_from": null, "content": "This is another requirement. The Weather Station housing shall be blue.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS3", "status": "aligned", "derived_from": null, "content": "The Weather Station shall display the measured temperature so that it is conveniently readable by a human looking at it in a distance of up to 3m.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived_from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS5", "status": "aligned", "derived_from": null, "content": "The unit in which the temperature is displayed shall stay as it is even after the batteries and/or the power supply has been removed.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived_from": "REQ_WS1", "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived_to": "not yet derived", "in_file": "./tempSensorA/req.yaml"}]}
@endjson


14 changes: 7 additions & 7 deletions test/examples/WeatherStation/reqsrepo_json.puml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
!$allreqs = {"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived to": "REQ_SensorA1", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS2", "status": "new", "derived from": null, "content": "This is another requirement. The Weather Station housing shall be blue.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS3", "status": "aligned", "derived from": null, "content": "The Weather Station shall display the measured temperature so that it is conveniently readable by a human looking at it in a distance of up to 3m.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS5", "status": "aligned", "derived from": null, "content": "The unit in which the temperature is displayed shall stay as it is even after the batteries and/or the power supply has been removed.", "derived to": "not yet derived", "in file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived from": "REQ_WS1", "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived to": "not yet derived", "in file": "./tempSensorA/req.yaml"}]}
!$allreqs = {"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived_from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived_to": "REQ_SensorA1", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS2", "status": "new", "derived_from": null, "content": "This is another requirement. The Weather Station housing shall be blue.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS3", "status": "aligned", "derived_from": null, "content": "The Weather Station shall display the measured temperature so that it is conveniently readable by a human looking at it in a distance of up to 3m.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived_from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_WS5", "status": "aligned", "derived_from": null, "content": "The unit in which the temperature is displayed shall stay as it is even after the batteries and/or the power supply has been removed.", "derived_to": "not yet derived", "in_file": "./req.yaml"},
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived_from": "REQ_WS1", "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived_to": "not yet derived", "in_file": "./tempSensorA/req.yaml"}]}

4 changes: 2 additions & 2 deletions test/examples/WeatherStation/tempSensorA/req.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
- type: Requirement
alias: REQ_SensorA1
status: aligned
derived from: REQ_WS1
derived_from: REQ_WS1
content:
The sensor shall be able to measure the temperature of the surrounding air in the room.
The sensor shall be able to measure the temperature of the surrounding air in the room.

0 comments on commit 58c98eb

Please sign in to comment.