Author Topic: LoadControlledPackage exact prototype  (Read 3450 times)

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
LoadControlledPackage exact prototype
« on: June 10, 2009, 11:35:01 pm »
Hi,
Please tell me somebody what is exact prototype of this function. Because in manual is LoadControlledPackage(PackageGUID) but it doesn't want PackageGUID, possibly it could be xml path but It doesn't looks like it works anyway. Should be there some refresh or update method called later? This function should change also Package.LastLoadDate in xml. Am I right? In manual there is also LastLoadDate and LastSaveDate noted as Read and Write property but they're only readable.

Thanks

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #1 on: June 11, 2009, 09:23:36 am »
Here's something that might help.

What format are you providing for the parameter? There are two different formats that EA uses for these. Both are strings, so it can be a bit confusing.

One of them is called (something like) an XML GUID. This has a prefix, no curly brackets, and the hyphens are converted to underscores.

The EA Project object provides two methods to convert between these formats: GUIDtoXML and XMLtoGUID.

Please let us know if this works for you.
No, you can't have it!

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #2 on: June 11, 2009, 05:45:31 pm »
Hi,
I tried several conversion function as below. My opinion is that the problem is that package.PackageGUID is only used for object reference identification and finally there is used package.XMLPath but XMLPath contains only relative path (drive and root folder name is missing - because it has been set in project as path from where it everything should be read). Making relative path in XMLPath to absolute by setting XMLPath manually makes also no sense because when you try it in EA GUI after replacing of this string it can't be reloaded because of that as you can find in EA new path: "x:\fold\x:\fold" which is incorrect. So I tried LoadControledPackage("x:\fold" & package.XMLPath) also with brackets "{}" and get no error dialog about that file doesn't exist as I get when try use LoadControledPackage(package.PackageGUID) or LoadControledPackage(project.GUIDtoXML(package.PackageGUID)) but it doesn't work. Nothing has been reloaded. So possibly it should be one of these 2 last functions but reading of EA.Package property member XMLPath is the problem.

Conversion example
packS=package.PackageGUID     '{000-000-000}
project.XMLfromGUID(packS)      'EAID_000_000_000
PackXML=package.XMLPath         'package1.xml
project.GUIDfromXML(packXML)  '{package1.xml}
« Last Edit: June 11, 2009, 05:51:40 pm by 00112200 »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #3 on: June 11, 2009, 10:44:52 pm »
Perhaps I understand better now.

I think EA is expecting you to supply a package identifier, from which it will try to import a controlled package. AFAIK EA expects to find the import in the same file as it previously exported from. Note that the controlled package paradigm was originally to export (first) and re-import in the same project. When you originally exported the package EA captured and stored the target file path. It will look in the same place when you import.

So, make sure you have previously exported the package. Then make sure that the file is still in the same place. [You may have modified it in between, but for test purposes you can simply import the same file.] Now try identifying the package GUID with either of your first two formats. Also ensure that you are seeing the entire GUID (38 characters). [Just in case your example was not merely illustrative.]

Does this work?
No, you can't have it!

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #4 on: June 11, 2009, 11:33:15 pm »
I can try it but now I've tried project.ImportPackageXMI and it seems to work. Where is the difference? This is not big succeed anyway 'Cuz I have to specify path in code which is specified in eap project file. So it is not the best way. Possibly your way could be better but there is a little problem that I have to save changes to xml every time, but It is supposed to be done through EA GUI Package Control otherwise there can occur a collision. By the way is there implemented some method which can compare imported and exported package xml? Even there is no difference between those 2 files, exported xml looks different than imported one which was generated by EA GUI before by using Package Control. There is something additional like creating time and etc.

Thanks

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #5 on: June 12, 2009, 10:25:29 pm »
Don't know.

Did you include diagrams and diagram images in the export? Check the options dialog and also the XMI export dialog. You might need to query the registry if you need to check or set these via automation.
No, you can't have it!

ChrisM

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #6 on: June 16, 2009, 02:38:13 am »
If you want to use LoadControlledPackage to have to pass the xml GUID of the package, e.g:

String loadResult = project.LoadControlledPackage(project.GUIDtoXML(packageRef.PackageGUID));

The problem you have already found is that the xmlPath is not the fully qualified path, just the relative path from your project base. You would have thought EA would automatically pre-append the base path but it doesn't. The way I got around it was to set the applications current directory to the base of the project xml repository:

Directory.SetCurrentDirectory(BasePath);

Where BasePath is the root of you xml storage.

Hope this helps.
Chris

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: LoadControlledPackage exact prototype
« Reply #7 on: June 16, 2009, 08:41:28 pm »
Or this way. Thanks for your post. It could be also useful. I think that the base difference between LoadControlledPackage and ImportXMI is in changing/not changing of LastLoadDate or can I get last checked-in version by this and not actual stored xml? Is there really no way to get xml file path from 'Package Control Options' window in EA GUI of specific project file? I mean the way how to set that BasePath from project actual set value and not from code.

Thanks