Book a Demo

Author Topic: to get collections of all diagrams in the model  (Read 5247 times)

sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
to get collections of all diagrams in the model
« on: July 16, 2011, 06:31:08 am »
Hi,

I am not able to get the collections of diagram in the model. if there are many packages in the model  i can get the collection of diagram of individual package  from package.diagrams attribute but what i need to do if i want the collections of all diagrams in the model. I need to store that in my collection class so that i can use that in future.

Appreciate your help

Thanks
Saddiq Prasla

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: to get collections of all diagrams in the mode
« Reply #1 on: July 19, 2011, 04:41:48 pm »
The best way to go about is to use an sql query with Repository.SQLQuery() to get all id's of all diagrams, and then use Repository.GetDiagramByGuid() to get the actual diagram.

Geert

PS. Are you sure you need ALL diagrams? That might be quite a performance hit.

sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: to get collections of all diagrams in the mode
« Reply #2 on: July 20, 2011, 02:31:10 am »
Hi Geert,

Thanks you for the solution.

I need to have collection of diagram as i need to perform checks on every diagram. Also the getDiagramByGUID requires string GUID from where i would get this parameter. You told if i query i would get list of Ids and  IDs and Guid are differerent.

What i am thinking of your solution is: correct me if i am wrong
I would get the diagram Guid by iterating through all the diagram using diagram class object using DiagramGUID Attribute and then i would store that and get the diagram by passing the GUID

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: to get collections of all diagrams in the mode
« Reply #3 on: July 20, 2011, 04:30:32 am »
No,

You use an sql query to get a list of all guid's of all diagrams ("select diagramguid from t_diagram"). You loop over each of those guid's and use Repository.GetDiagramFromGUID to get the actual diagram objects.

Geert

sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: to get collections of all diagrams in the mode
« Reply #4 on: July 20, 2011, 05:53:00 am »
Hi Geert,

When i am querying using sql query i am getting an error two few parameters. Expected 1. This is what i wrote repository.sqlquery("Select diagramguid from t_diagram")

Thank you

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: to get collections of all diagrams in the mode
« Reply #5 on: July 20, 2011, 10:23:02 am »
Try:

Code: [Select]
SELECT ea_guid FROM t_diagram
The Sparx Team
[email protected]

sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: to get collections of all diagrams in the mode
« Reply #6 on: July 20, 2011, 11:55:59 pm »
Thanks it is working fine. However I am getting the string with XML format so do i need to parse that as an XML and get the GUID of all diagram is that correct.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: to get collections of all diagrams in the mode
« Reply #7 on: July 21, 2011, 12:08:15 am »
yes