|
1 | | -#!/usr/bin/env python |
| 1 | +#!/usr/bin/env python3 |
2 | 2 | from __future__ import absolute_import |
3 | 3 |
|
4 | 4 | import pyreqif.pyreqif |
5 | 5 | import pyreqif.reqif |
6 | | -import datetime |
7 | | -import uuid |
| 6 | +import pyreqif.create |
8 | 7 |
|
9 | | -def createDocument(id, title="title", comment="created by pyreqif"): |
10 | | - mydoc = pyreqif.pyreqif.doc() |
11 | | - mydoc.addHeader({"identifier":id,"sourceToolId":"pyreqif", "comment": comment, "title":title, "creationTime": str(datetime.date.today())}) |
12 | | - return mydoc |
13 | 8 |
|
14 | | -def addDatatype(id, mydoc, type="document", lastChange=datetime.datetime.today().isoformat(), longName="xhtml"): |
15 | | - mydoc.addDatatype({"identifier":id, "type":type, "lastChange": lastChange, "longName":longName}) |
| 9 | +xhtmlDatatypeId = "_2" |
| 10 | +reqirementTypeId = "_3" |
| 11 | +collumn1typeId = "_4" |
| 12 | +collumn2typeId = "_5" |
16 | 13 |
|
17 | | -def addReqType(specObjId, specObjLongName, specAttribId, collumName, typeRef, mydoc, type="complex", lastChange=datetime.datetime.today().isoformat()): |
18 | | - mydoc.addRequirementType({"identifier":specObjId, "longName": specObjLongName, "lastChange": lastChange, specAttribId : {"identifier":specAttribId, "typeRef":typeRef,"type":type, "lastChange": lastChange, "longName": collumName}}) |
| 14 | +document_id = "_1" |
19 | 15 |
|
20 | | -def addReq(id, specType, content, reqTypeRef, mydoc, lastChange=datetime.datetime.today().isoformat()): |
21 | | - mydoc.addRequirement({"typeRef" : specType, "identifier" : id, "lastChange": lastChange, "values" : {id : {"content" :content, "attributeRef":reqTypeRef, "type": "embeddedDoc"}}}) |
| 16 | +mydoc = pyreqif.create.createDocument(document_id) |
22 | 17 |
|
23 | | -def addRelation(sourceId, targetId, mydoc): |
24 | | - relation = {} |
25 | | - relation ["sourceRef"] = sourceId |
26 | | - relation["targetRef"] = targetId |
| 18 | +pyreqif.create.addDatatype(xhtmlDatatypeId,mydoc) |
27 | 19 |
|
28 | | - mydoc.addRelation(pyreqif.rif.reqif2py(relation)) |
29 | 20 |
|
30 | | -def creatUUID(itemId = None): |
31 | | - if itemId is not None: |
32 | | - return str(uuid.uuid1(int(itemId))) |
33 | | - else: |
34 | | - return str(uuid.uuid1()) |
| 21 | +pyreqif.create.addReqType(reqirementTypeId, "requirement Type",collumn1typeId, "Col1", xhtmlDatatypeId, mydoc) |
| 22 | +pyreqif.create.addReqType(reqirementTypeId,"", collumn2typeId, "Col2", xhtmlDatatypeId, mydoc) |
35 | 23 |
|
36 | | -def createHierarchHead(longName, id=None, lastChange=datetime.datetime.today().isoformat()): |
37 | | - if id is None: |
38 | | - id = creatUUID() |
39 | | - return pyreqif.pyreqif.hierarchy(**pyreqif.rif.reqif2py({"identifier": id, "longName": longName, "lastChange": lastChange})) |
| 24 | +pyreqif.create.addReq("_6", reqirementTypeId, "<div>Hallo</div>", collumn1typeId, mydoc) |
| 25 | +pyreqif.create.addReq("_6", reqirementTypeId, "<div>Hallo2</div>", collumn2typeId, mydoc) |
40 | 26 |
|
41 | | -def createHierarchElement(reqid, id=None, lastChange=datetime.datetime.today().isoformat()): |
42 | | - if id is None: |
43 | | - id = creatUUID() |
44 | | - return pyreqif.pyreqif.hierarchy(**pyreqif.rif.reqif2py({"identifier": id, "lastChange": lastChange, "objectRef": reqid})) |
| 27 | +pyreqif.create.addReq("_7", reqirementTypeId, "<div>Hallo 3</div>", collumn1typeId, mydoc) |
| 28 | +pyreqif.create.addReq("_7", reqirementTypeId, "<div>Hallo 4</div>", collumn2typeId, mydoc) |
45 | 29 |
|
46 | | -xhtmlDatatypeId = "2" |
47 | | -reqirementTypeId = "3" |
48 | | -collumn1typeId = "4" |
49 | | -collumn2typeId = "5" |
50 | 30 |
|
51 | | -mydoc = createDocument("1") |
| 31 | +link_type = document_id + "link_type" |
| 32 | +pyreqif.create.addRelation("_6","_7", mydoc, id="_self_link", type=link_type) |
| 33 | +pyreqif.create.addSpecRelationType(link_type, mydoc, longName="selflink") |
52 | 34 |
|
53 | | -addDatatype(xhtmlDatatypeId,mydoc) |
54 | | - |
55 | | - |
56 | | -addReqType(reqirementTypeId, "requirement Type",collumn1typeId, "Col1", xhtmlDatatypeId, mydoc) |
57 | | -addReqType(reqirementTypeId,"", collumn2typeId, "Col2", xhtmlDatatypeId, mydoc) |
58 | | - |
59 | | -addReq("6", reqirementTypeId, "Hallo", collumn1typeId, mydoc) |
60 | | -addReq("6", reqirementTypeId, "Hallo2", collumn2typeId, mydoc) |
61 | | - |
62 | | - |
63 | | -addRelation("6","12", mydoc) |
64 | | - |
65 | | -myHierarch = createHierarchHead("Reqirement Document Name") |
66 | | -myHierarch.addChild(createHierarchElement("6")) |
67 | | -myHierarch.addChild(createHierarchElement("7")) |
| 35 | +myHierarch = pyreqif.create.createHierarchHead("Reqirement Document Name") |
| 36 | +myHierarch.addChild(pyreqif.create.createHierarchElement("_6")) |
| 37 | +myHierarch.addChild(pyreqif.create.createHierarchElement("_7")) |
68 | 38 |
|
69 | 39 | mydoc.hierarchy.append(myHierarch) |
70 | 40 |
|
|
0 commit comments