Book a Demo

Author Topic: use data from excel table  (Read 19185 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: use data from excel table
« Reply #15 on: August 28, 2015, 09:43:02 pm »
Searching for a class (by name) is only possible by traversing a package packages and therein the elements. Of course you could SQL search for the name but then you don't know if it's a (grand-) child of your package.

q.
« Last Edit: August 28, 2015, 09:43:52 pm by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: use data from excel table
« Reply #16 on: August 28, 2015, 10:00:43 pm »
If you are sure the class name will be unique within the tree you selected I guess you could change the code to search for classes in the sub-packages as well.

Probably the best approach is to first make a flat list of all packageID's of the selected package and all its subpackages, and then use that list of id's in the where clause of you sql that selects the class.

This way you only have to traverse the model once (traversing the model in code is slow, therefore you must try to avoid it if possible)

Geert

Prateek

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: use data from excel table
« Reply #17 on: September 03, 2015, 10:35:47 pm »
Thank you Geert and q.

But actually I am not using any dedicated database. I am not very much worried about the run time either. Its just that I do not know how to traverse in the package hierarchy. I have many independent EA models (.EAP files) and I want to use the same code for all these models. I have to sync. all the data in Excel and EA. I want to traverse all the classes and attributes under a root package (which might have varying hierarchy of packages depending on different EAP files)
and check if the class/attribute exists in Excel and then sync the data.
The code works if all the classes are under one package. But When we have a hierarchy of packages existing (and the hierarchy might change with different EAP files) I am finding it difficult to come up with a code.

Any suggestions would be pretty helpful.

Thank you

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: use data from excel table
« Reply #18 on: September 03, 2015, 11:10:47 pm »
EA always works with a database. If you are using .eap file then you are in fact using Jet databases (MS Access) in disguise.

I still think the approach I mentioned with the packageID's and a query is the easiest and fastest, but I can't write the code for you (unless you pay me to)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: use data from excel table
« Reply #19 on: September 03, 2015, 11:30:38 pm »
The fastest/best way I can think of:

- issue a SQLquery with SELECT * FROM t_object WHERE name = '...'
- for each entry get the according element
- traverse the parent packages up to get the path
- element and path can be put into a struct/class forming a result array

q.

Prateek

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: use data from excel table
« Reply #20 on: September 04, 2015, 12:04:04 pm »
Sure I would use a query.
But could let me know where can I find the commands for connecting with the default jet database(MS Access) so that I can run the query.

Thanks!!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: use data from excel table
« Reply #21 on: September 04, 2015, 12:44:29 pm »
Open an .EAP file and you're connected!

Go Edit > Search in Model > Edit Search > SQL Scratch Pad to write SQL queries.
The Sparx Team
[email protected]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: use data from excel table
« Reply #22 on: September 04, 2015, 01:24:06 pm »
And from a programming environment you can use Repository.SQLQuery

Geert

PS. Sometimes looking in the manual will help you faster then asking on the forum.

Prateek

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: use data from excel table
« Reply #23 on: September 04, 2015, 06:34:30 pm »
But actually I am trying to run the VBA Code (like EAImporter Excel), compare an excel file data with EA. So I guess I will have to establish some connectivity with the EA file database. I am currently using the getSelectedPackage() function as mentioned in your file . But what if I want to search the element in the entire model and then update its attributes. I can do it by searching it in 't_object' table and then firing the 'update' query. The approach Edit > Search in Model > Edit Search > SQL Scratch Pad would only let me search and not update. I want to update element from the backend database. So I thought that similar to what we have like a JDBC connectivity, do we need some conncection string for connecting an VBA (outside Excel file) to the database.?
Maybe a stupid question but I don't know the approach.
Thanks in advance for the help

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: use data from excel table
« Reply #24 on: September 04, 2015, 06:47:58 pm »
Quote
And from a programming environment you can use Repository.SQLQuery

I don't know what more to say :-?

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: use data from excel table
« Reply #25 on: September 04, 2015, 06:54:38 pm »
Sometimes I get the feeling that here are people which want others to write their code.

q.