Book a Demo

Author Topic: csv import dosn't create packages  (Read 3858 times)

LYSLauk

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
csv import dosn't create packages
« on: April 20, 2005, 09:25:22 am »
Hi,
I try to make a csv import with classes and packages. The classes are added successful to the project view but the packages are not added :(

Knows someone why?

Dave_Bullet

  • EA User
  • **
  • Posts: 295
  • Karma: +0/-0
    • View Profile
Re: csv import dosn't create packages
« Reply #1 on: June 13, 2006, 07:36:32 pm »
I came across this yesterday too.  The answer is CSV import only creates t_object rows - not the necessary t_package rows.....

However - there is a workaround.....

1. Import your elements with a type = 'Package' as you normally would for Components, Classes etc....
2. Run this SQL statement and it will create the missing t_package entries for you and voila! - they will appear in EA (when you do a package / model reload).  I suggest you create as a stored proc so other users can run it....

/* This script should be used after importing new packages via a CSV import.  EA will create the t_object rows for
the import but not t_package rows.  Hence you won't see the packages appear in the Project View explorer, even though a search will find them */

begin transaction;

/* First create the missing package table rows for any new packages imported into EA */

insert into t_package (name, parent_id, ea_guid)
select name, package_id, ea_guid from
t_object where lower(object_type) = 'package'
and PDATA1 is null

/* Now update the parent IDs in the t_object table with the newly inserted package IDs above */

update t_object
set PDATA1 = t_package.package_id
from t_object, t_package
where t_object.ea_guid = t_package.ea_guid
and PDATA1 is null

commit transaction;

The above script assumes you leave PDATA1 alone (which EA seems to use to store the package ID).

Disclaimer:  Always backup your store first.  I do not warrant / guarantee the above will work for you nor will be responsible or accountable for any damage or loss arising from the use of the above script or advice given - directly or indirectly.

Cheers,
Dave.
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"

mark.myers

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: csv import dosn't create packages
« Reply #2 on: July 31, 2007, 01:51:53 pm »
Thanks, Dave.
I came across this today as well (Build 814). Be nice if this was fixed!
Cheers, Mark

Dave_Bullet

  • EA User
  • **
  • Posts: 295
  • Karma: +0/-0
    • View Profile
Re: csv import dosn't create packages
« Reply #3 on: July 31, 2007, 02:44:22 pm »
Yes.  Also being able to import tagged values as well would be a bonus.

Someone kindly supplied me with an add-in to import tagged values. I haven't tried it yet.

David.
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"

speekna

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: csv import dosn't create packages
« Reply #4 on: August 01, 2007, 10:39:50 am »
Does this work only with the EA repository on a database?

How do you do this with an EA .eap file?

Where do you execute the sql?

Dave_Bullet

  • EA User
  • **
  • Posts: 295
  • Karma: +0/-0
    • View Profile
Re: csv import dosn't create packages
« Reply #5 on: August 01, 2007, 04:40:52 pm »
Yes - the above will work with reworked syntax to create missing package rows.  Here's how.

0. Import your packages via CSV as described above
1. Start MS Access (doesn't matter if a later version)
2. Ignore the warning about it being an MS Access 97 file (if you are running say MS Access 2003)
3. Go to "queries"
4. Open up any query (double click it) - doesn't matter which one
5. Select View -> SQL View from the menu
6. Replace the SQL with this statement (the reworked version from SQL Server above)

insert into t_package (name, parent_id, ea_guid)
select name, package_id, ea_guid from
t_object where lcase(object_type) = 'package'
and PDATA1 is null

7. Execute the above statement.  MS Access will warn you about the number of rows you will insert, if non-zero - it means you are about to insert some missing package rows. Click yes to execute

8. Replace the insert SQL with the following

update t_object, t_package
set PDATA1 = t_package.package_id
where t_object.ea_guid = t_package.ea_guid
and PDATA1 is null

9. Execute and MS Access should report back the same number from step 7.  Click yes to execute

10. Close MS Access (dont' save changes) and reload your project within EA.  You should see missing packages in your project view within EA.

The other way of doing this is a project transfer from EAP -> SQL Server, run my original SQL script then transfer back to EAP./

Hope the above helps. I tested it and it worked.

David.
« Last Edit: August 01, 2007, 04:42:05 pm by Dave_Bullet »
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"