Book a Demo

Author Topic: Hierarchy in Project Browser  (Read 6733 times)

JacekSalamandra

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Hierarchy in Project Browser
« on: September 01, 2015, 09:56:47 pm »
Hi,
I try to create an empty diagram under  package using script
Code: [Select]
function createDiagram(pakiet,diagramName){
            var diag as EA.Element;
            diag = pakiet.Diagrams.AddNew(diagramName, "Activity");
            diag.Update();
       }
The diagram is created but when i loot at Project Browser i see the new diagram is under root node, not under my package.
Please help.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Hierarchy in Project Browser
« Reply #1 on: September 02, 2015, 12:22:20 am »
Check what pakiet actually is. I guess you passed the root model instead of your target packet.

q.

VKN

  • EA User
  • **
  • Posts: 187
  • Karma: +9/-1
    • View Profile
Re: Hierarchy in Project Browser
« Reply #2 on: September 02, 2015, 09:47:41 am »
Manually EA wouldn't allow to create a diagram under the root node.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Hierarchy in Project Browser
« Reply #3 on: September 02, 2015, 10:05:03 am »
Quote
Manually EA wouldn't allow to create a diagram under the root node.
Ah but this is EAUI!

Manually, you can't have more then one instance of an object on a diagram.  But, thanks to some rogue automation, last week I ended up with 4975 copies of the same object on the one diagram, before I killed the EA instance!   :-[

Fortunately now sorted!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

JacekSalamandra

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Hierarchy in Project Browser
« Reply #4 on: September 02, 2015, 05:12:38 pm »
The diagram is creates always on the same level at the same level as package "pakiet". I wolud like create diagram under "pakiet" package, not at the same level.
I ve changed "pakiet"package location but the effect is still the same.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hierarchy in Project Browser
« Reply #5 on: September 02, 2015, 05:17:50 pm »
The question was: are you sure that pakiet is what you think pakiet is?
The variable will most likely contain the parent package of pakiet in stead of pakiet

Geert

JacekSalamandra

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Hierarchy in Project Browser
« Reply #6 on: September 02, 2015, 05:34:36 pm »
Code: [Select]
function getPackageByName(nazwa){
            var  obj as EA.Element;
            var sql;
            var tablica as EA.Collection;
            sql="select * from t_object where Name=\""+nazwa+"\"and Object_Type=\"Package\" ";
            tablica=Repository.GetElementSet(sql,2);
            jedenElement("object",tablica); // throws error when tablica!=1
            Session.Output("table length"+ tablica.Count);
            Session.Output("pack name"+ tablica.GetAt(0).Name);
            return tablica.GetAt(0);
            }
Code: [Select]
function createDiagram(pakiet,diagramName){
            var diag as EA.Element;
            diag = pakiet.Diagrams.AddNew(diagramName, "Activity");
            diag.Update();
       }
Code: [Select]
createDiagram(getPackageByName("pakiet"),"examp");
I am sure there is one pakiet package.




Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hierarchy in Project Browser
« Reply #7 on: September 02, 2015, 05:43:43 pm »
Ah, I see the problem.
Your operation getPackageByName() returns an EA.Element, not an EA.Package
So when adding a diagram to an element the packageID is set to the parent package of the EA.Element, which in this case is the parent package of pakiet

If you add a GetPackageByGUID() and pass the GUID of the EA.Element for the package then this operation will return the correct EA.Package object.

Geert

JacekSalamandra

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Hierarchy in Project Browser
« Reply #8 on: September 02, 2015, 06:13:22 pm »
Yess ! That's work.
Code: [Select]
function getPackageByName(nazwa){
            var sql;
            var tablica as EA.Collection;
            sql="select * from t_object where Name=\""+nazwa+"\"and Object_Type=\"Package\" ";
            tablica=Repository.GetElementSet(sql,2);
            jedenElement("object",tablica);
            return GetPackageByGUID(tablica.GetAt(0).ElementGUID);
            }
Thank you very much.