Author Topic: generate requirements diagram automatically  (Read 12864 times)

simonspaten

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
generate requirements diagram automatically
« on: July 03, 2013, 07:13:56 pm »
Hi folks, I am new in this forum and I´m also a newbie in using the EA functions, so I wanna know if it is possible to generate a requirement diagramm automatically from imported requirements (via MDG-Link for DOORS).

Beforehand, thanks a lott for replies !

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: generate requirements diagram automatically
« Reply #1 on: July 03, 2013, 08:35:00 pm »
Hello,

if the DOORS MDG don't creates diagrams as part of the import you may write an Addin to visualize the requirements in a diagram for each package.

Kind regards,

Helmut

Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: generate requirements diagram automatically
« Reply #2 on: July 03, 2013, 10:39:12 pm »
FWIW: a pure requirements diagram does not mean much to readers. At that level they prefer a tabular output. However, once you have connected requirements to use cases (or whatever) these diagrams make a lot of sense. But those can't be created automatically.

q.

sdh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: generate requirements diagram automatically
« Reply #3 on: July 05, 2013, 01:59:21 pm »
I am also looking for a way to create the requirement diagram after import from doors. Is there a way to connect the requirement elements using the Aggregate relationships to form a hierarchy. The imported requirements are already displayed in hierarchical manner but a matching diagram is missing.
« Last Edit: July 05, 2013, 01:59:54 pm by sdh »

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: generate requirements diagram automatically
« Reply #4 on: July 05, 2013, 02:53:41 pm »
Hello,

you may write an Addin to create a requirement diagram for each package containing requirements.

Best regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile
Re: generate requirements diagram automatically
« Reply #5 on: July 05, 2013, 04:02:12 pm »
Like Q says, where the relationships are non existant at this stage best to view via as table: try selecting the package - right-click | Package Browser
Then use the Show Hierarchy icon to see the nesting. This will match more clearly the DOORS formating.

sdh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: generate requirements diagram automatically
« Reply #6 on: July 05, 2013, 05:25:54 pm »
Quote
Hello,

you may write an Addin to create a requirement diagram for each package containing requirements.

Best regards,

Helmut

I am new to EA and not expert in addins. Is there a community created addin for the same? I am sure there must be others who would have faced the same challenge.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: generate requirements diagram automatically
« Reply #7 on: July 05, 2013, 05:33:15 pm »
Hello,

I see the following possibilities to get quickly started:
  • Thomas Kilian's book ScriptingEA
  • Geert Bellekens Tutorial in the Community (Addin in 10 Minutes or so)

There is also a bunch of examples in:
- Online Help
- Scripting example Code (MDG EAScriptLib) and LocalScript in View Scripting

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

sdh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: generate requirements diagram automatically
« Reply #8 on: July 11, 2013, 03:25:29 pm »
Thanks Helmut. I have started the VB script but I am facing some issues.
To start with, I am able to recurse through the requirement package and list all the requirements.
As a second step, I wanted to add the requirements to Requirement Diagram and create the "Aggregration" relation from the current element to elements ParentID.

I used the following code to add the current element to diagram and in the process, the requirements also became flat in the package. Any idea what is going wrong. Also how do I create the connector/relation between current element and the parent.

Code: [Select]
' Add the element to the diagram
            dim diagramObjects as EA.Collection
            set diagramObjects = currentDiagram.DiagramObjects
      
            dim currentDiagramObject as EA.DiagramObject
            set currentDiagramObject = diagramObjects.AddNew("","")
            currentDiagramObject.ElementID( currentElement.ElementID )
            CurrentDiagramObject.Update()
            CurrentDiagramObject.Refresh()

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: generate requirements diagram automatically
« Reply #9 on: July 11, 2013, 03:56:33 pm »
Hi,

some code to see how to add a connection and to estimate the position:
Code: [Select]
                       Repository.SaveDiagram(dia.DiagramID);
                        
                        EA.Element elNote = null;
                        try
                        {
                            elNote = (EA.Element)pkg.Elements.AddNew("", "Note");
                            elNote.Update();
                            pkg.Update();
                        }
                        catch { break; }

                        // add element to diagram
                        // "l=200;r=400;t=200;b=600;"

                        // get the position of the Element
                        EA.DiagramObject diaObj = null;
                        foreach (EA.DiagramObject dObj in dia.DiagramObjects) {
                            if (dObj.ElementID == el.ElementID)
                            {
                                diaObj = dObj;
                                break;
                            }
                        }
                          int left = diaObj.left + 2*(diaObj.right - diaObj.left);
                        int right = diaObj.right + 2 * (diaObj.right - diaObj.left);

                        string position = "l=" + left.ToString() +";r=" + right.ToString() + ";t=" + diaObj.top.ToString() + ";b=" + diaObj.bottom.ToString() + ";";
                        EA.DiagramObject diaObject = (EA.DiagramObject)dia.DiagramObjects.AddNew(position, "");
                        dia.Update();
                        diaObject.ElementID = elNote.ElementID;
                        diaObject.Update();
                        pkg.Elements.Refresh();
                        // make a connector
                        EA.Connector con = (EA.Connector)el.Connectors.AddNew("test", "NoteLink");
                        con.SupplierID = elNote.ElementID;
                        con.Update();
                        el.Connectors.Refresh();
                        Util.setElementHasAttchaedLink(Repository, el, elNote);
                        Repository.ReloadDiagram(dia.DiagramID);

                    }

I don't know why your requirements structure became flat. You have to ensure that the parent_id of the requirement remains unchanged. For me the code looks good. You are just creating a diagramobject and assign it to the requirement element. I would do it almost the same way.

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

sdh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: generate requirements diagram automatically
« Reply #10 on: July 11, 2013, 04:17:54 pm »
Thanks Helmut. One Question, when I use currentDiagramObject.ElementID( currentElement.ElementID ) command, does it add a simple link to the original object.
What I saw was that the objects were stacked one on the top of other. When I tried to drag and spearate them, the hierarchy became flat as I graged the items around. Even if I use layout tools, the diagram objests do not layout in box pattern that I selected.
If I drag and drop individual requirements on the diagram, I do not see flattening if I move the objects around in the diagram.
So there is a difference in the way the diagram is getting created by script.
« Last Edit: July 11, 2013, 04:22:27 pm by sdh »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: generate requirements diagram automatically
« Reply #11 on: July 11, 2013, 04:23:41 pm »
Ha, I see what is happening.

For some types of objects (I'm not sure which exactly) EA will nest/unnest the elements if you drag them onto each other, or if you drag them out of their parent.

The EA screens and gui elements work the same way.
I'm pretty sure that doesn't happen when putting elements on a diagram programatically.
You'll just have to be careful when moving elements around on the diagram manually.

There is an operation somewhere to auto-layout your diagram using the API. That might be an easy solution.

Geert

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: generate requirements diagram automatically
« Reply #12 on: July 11, 2013, 04:36:08 pm »
Hello,

I think Geert is right. I have the same experiences. You may try:

- Create the Diagrammobject in the way you want to see them
  (position them)
- After that set the parant-Id as they were before

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

sdh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: generate requirements diagram automatically
« Reply #13 on: July 12, 2013, 01:36:43 pm »
I am able to add all the requirements to the diagram now, they come stacked one on top of other. For now I am able to separate then using the auto layout. I will address taht later. I then tried to connect the objects in diagram and I am getting the error: Object doesn't support this property or method. Any idea what I am doing wrong.
Code: [Select]
sub addConnectors(theDiagram)
      ' Cast theDiagram to EA.Diagram so we get intellisense
      dim currentDiagram as EA.Diagram
      set currentDiagram = theDiagram
      
      ' Iterate through all objects in this diagram
      dim currentDiagramObject as EA.DiagramObject
      for each currentDiagramObject in currentDiagram.DiagramObjects
            ' Get the element that this Diagram Object represents
            dim currentElement as EA.Element
            set currentElement = Repository.GetElementByID( currentDiagramObject.ElementID )
                  
            if not currentElement is nothing then
                  ' Add the element details to the list
                  Session.Output("        -> Element: " & currentElement.Name & _
                        " (" & currentElement.Type & _
                        ", ID=" & currentElement.ElementID & _
                        ", Parent=" & currentElement.ParentID & _
                        ", Connector=" & currentElement.Connectors.Count & ")" )
                  dim connector as EA.Connector
                  if (currentElement.ParentID <>0) then
                        connector = currentElement.Connectors.AddNew("Relation","Aggregation")
                        'currentElement
                        connector.SupplierID = currentElement.ParentID
                        connector.Update
                        currentElement.Connectors.Refresh
                  end if
            end if
      next
end sub
     
« Last Edit: July 12, 2013, 01:37:53 pm by sdh »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: generate requirements diagram automatically
« Reply #14 on: July 12, 2013, 03:30:48 pm »
Which line is giving you the error?

Geert