Book a Demo

Author Topic: How to import a XML-Native file as a new root package  (Read 3471 times)

gregor139

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
How to import a XML-Native file as a new root package
« on: May 03, 2022, 01:00:11 am »
Hi

In EA 16 Client I import a package as XML- Native File by "Import Package from Native/XMI File". Just before the import process the GUI asks: "XMI contains a model which may be placed at the root level in the Project Browser. Press Yes to import as Root Model, No to place under selected package, Cancel to abort". I choose Yes and get a new Root Model, so far so good.

Now I want to have this automated by using the Automation Interface. The Project class has the method ImportPackageXMI(PackageGUID, Filename, ImportDiagrams, StripGUID) where the parameter PackageGUID represents the GUID of the target Package to import the file into. But how can I define that I want to import as a new root model instead of a subpackage of an already existing package?

Thx
Gregor

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to import a XML-Native file as a new root package
« Reply #1 on: May 03, 2022, 01:26:27 am »
have you tried to pass an empty string as packageGUID?

If that doesn't work you'll have to first import it under another package, and then move the contents to a new root package.

Geert

gregor139

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to import a XML-Native file as a new root package
« Reply #2 on: May 03, 2022, 08:04:04 pm »
Hi Geert

When passing an empty string as packageGUID the import process ends immediately with "Unknown package" error.

Your workaround works if I do the following:
create a new root node, use its guid to import as a subpackage, delete the root node in t_package after import finishes and update t_package.parent_id=0 of the imported package to make it a root package.

Would be a nice improvement for method ImportPackageXMI in the next EA Release:
empty String as packageGUID = new root package

Gregor

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to import a XML-Native file as a new root package
« Reply #3 on: May 03, 2022, 08:49:56 pm »
Would be a nice improvement for method ImportPackageXMI in the next EA Release:
empty String as packageGUID = new root package

You can send a feature request using the link on the bottom of the page.

Geert

gregor139

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to import a XML-Native file as a new root package
« Reply #4 on: May 03, 2022, 09:58:43 pm »
feature request submitted