Manu V
Manu V

Reputation: 139

Moving Elements from one packe to another package

We have Package-A in which we have 10 class elements.We have another Package-B .Now we want to move the elements present in Package-A to Package-B through Addin.How can this be achieved in EA through Addin

Even for moving sub-packages from package-A to package-B is the same thing works

Upvotes: 0

Views: 347

Answers (2)

philippeback
philippeback

Reputation: 801

Here is a way to do it at once without any script, through SQL. Do this in the SQL Scratchpad in EA.

enter image description here

Copy the GUID of the target package in the clipboard, say {61068DDF-335B-4b29-89F8-C54A7000EF6F})

Copy GUID

Its package id is the following:

select Package_ID from t_package where ea_guid='{61068DDF-335B-4b29-89F8-C54A7000EF6F}'

Copy the GUID of the source package in the clipboard, say {F3B52DA0-D9E9-4606-BCA0-5D211B73FBE6}.

Its package id is the following:

select Package_ID from t_package where ea_guid='{F3B52DA0-D9E9-4606-BCA0-5D211B73FBE6}'

So, elements in source package are:

select * from t_object where Package_ID=(select Package_ID from t_package where ea_guid='{F3B52DA0-D9E9-4606-BCA0-5D211B73FBE6}')

So, let's make that go to the target.

update t_object 
set Package_ID=(select Package_ID from t_package where ea_guid='{61068DDF-335B-4b29-89F8-C54A7000EF6F}'
where Package_ID=(
select Package_ID from t_package where ea_guid='{F3B52DA0-D9E9-4606-BCA0-5D211B73FBE6}'
)

Should do the trick.

Backup your model first.

For an Add-In, it is just a matter of getting the two GUIDs, and Repository.Execute(theSQLString).

Repository.Execute is not in the doc, but works.

Upvotes: 0

Dah Sra
Dah Sra

Reputation: 4435

Set the PackageID property for all the class elements with PackageB ID .

sample code somethinglike

foreach(EA.Element classElement in PackageA.elements)
{
    classElement.PackageID = packageb.PackageID : 
    classElement.Update();
}  

Upvotes: 1

Related Questions