Book a Demo

Author Topic: XMI import MAY differ from XMI (controlled) load  (Read 9813 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
XMI import MAY differ from XMI (controlled) load
« on: December 05, 2008, 01:22:40 pm »
If you save a controlled package and then reload the file, you MAY get a DIFFERENT result from if you import the SAME XMI file.

By means of available EA functionality, I created Component "instances" - that is, Components with references to "Classifiers".  Thus the component appears n the browser as: <component glyph> Component Name: Classifier Name.  Why I resorted to this is another story (and may be the subject of another post).


If I use the controlled package mechanism, the Component instances are correctly saved and restored!  If, however, I import the same package, the classifier references are stripped!  Incidentally, the Export mechanism ALSO correctly exports the classifier information!

This is a high priority bug!  Being able to rely on correct XMI round tripping is crucial to effective use of EA!
Consistency, Consistency, Consistency! TM

Reported,
Paolo
      
Using EA in spite of EA, NOT because of it!TM!
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #1 on: December 08, 2008, 04:25:24 pm »
Thanks Paolo, please keep us updated.
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #2 on: December 08, 2008, 06:57:01 pm »
Quote
Thanks Paolo, please keep us updated.
I'm in discussion with Sparx Support.  They are, as yet, unable to reproduce the problem, but then I'm not sure I've communicated the exact use case correctly.

Just to be clear all round.  Loading a controlled package containing these "Component Instances" works fine.  It's when I try to import (stripping GUIDs) into another package that the classifier gets clobbered.  The reason for importing is that it's the easiest way to duplicate an entire instance structure.

One day I'll get around to using transformations, but that's not the point.  I see no reason why the outcomes should be different - especially since it has a very deleterious effect.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #3 on: December 08, 2008, 07:33:09 pm »
I think this is not a bug but a "feature". We discovered it long time ago, EA deletes all clasifiers GUIDs when importing and stripping GUIDs, to make their importing life esier.
Pitty Ea doesn't have a "copy branch" funtion.
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #4 on: December 08, 2008, 08:32:56 pm »
I'm not sure if they really delete classifier guids to make life easier. My guess is EA simply strips all guids, including those of the classifiers, and when the classifiers are not icluded in the package, they end up as stubs which can never be resolved.

What we need for the scenario Paolo has outlined is an option to strip all guids except those representing stubs. Or Martin's "copy branch" function doing just this in the background.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #5 on: December 09, 2008, 10:56:11 am »
Quote
I'm not sure if they really delete classifier GUIDs to make life easier. My guess is EA simply strips all GUIDs, including those of the classifiers, and when the classifiers are not included in the package, they end up as stubs which can never be resolved.

What we need for the scenario Paolo has outlined is an option to strip all GUIDs except those representing stubs. Or Martin's "copy branch" function doing just this in the background.
Thanks Frank! This is starting to make sense!  That is, the observed behaviour now has an explanation.

I agree there should be an option to leave/resolve classifier GUIDs after import if you're stripping GUIDs.  I have to admit, that up until your post I never thought about stripping classifier GUIDs if they were present in the model.  But I can see how it could be a simplistic (and I do understand what the word means) design.

The key principle here is the preservation/transformation of the "model" on read in.  There would appear to be three UseCases:
  • I am replacing an existing package - don't strip any GUIDs.   This is the existing Controlled package functionality and could also be an import mode.
  • I am making a copy of an existing branch - create new GUIDs for the new objects, if any classifiers point back to the new objects, replace  (resolve) their GUIDs, otherwise leave alone if found, remove if not found.   This would be Martin's and my "Copy Branch" functionality.
  • I am creating a new package, based on the original - if any classifiers point back into the new objects, replace (resolve) their GUIDs, otherwise strip.  This is the existing Import + strip GUIDs functionality.
Can anyone think of any others?

Paolo

[Edit]In passing, I should note that in thinking some more about this, I believe EA should issue a message at the end of import if any linkages were lost.  That is, classifier references or relationships that could not be resolved.  This is to alert the user that the model represented in the XMI was not "preserved" on read-in.  This should apply both to import and to controlled packages.[/Edit]

« Last Edit: December 09, 2008, 11:12:25 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #6 on: December 09, 2008, 09:44:41 pm »
It may be more complicated than that. The elements within an exported package may have all kinds of relationships with elements not contained therein.

In case of classifiers, realizations, dependencies and generalizations the desired behaviour seems obvious: preserve the target guids and resolve them when importing for duplication, or, if they cannot be resolved, keep them as stubs and resolve them when the package containing the targets is being imported.

But what about associations? Isn't the concept of source and target for an association UML 1 legacy stuff anyway?

In XMI 2.1. the notion of association source and target is contained only in the extensions section. In the model section there are two ends for an association and that's it. Who is source and who is target is completely arbitrary.

EA however marks the element from which the connector has been dragged as source and the one to which it has been dragged as target, and puts the association itself into the package containing the "source" element.

So what should happen with associations contained in the package reimported for duplication when their target is outside? I guess we would want them to be duplicated as well, to point from the duplicated source to the old (common) target.

The trap here is that you don't see in your diagrams who is source and who is target. You may have inadvertently reversed the direction, or dragged it the other way in the first place, without any difference showing in diagrams. And without any difference in the uml:Model section of an XMI 2.1 export, come to that. And it will simply be missing then after duplication because it will never have been within the exported package.

And there are many more things, like RefGuid tagged values, method overrides and such. It will take some time to think it through, and we might end up needing a tree view dialog showing all stubs and check boxes to control which kinds of relations or which individual relations are to be handled in which way.

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #7 on: December 09, 2008, 11:43:48 pm »
Yet some kind of "real" copy would help .I can get arround it and pu all elements in a diagram and then perform deep copy of the diagram, this is not perfect, but does a lot of the work.
So, if we have such functionality for the daigarm copy, we can assume at least the same logic would be "valid" anough for copy package.
Recursion definition:
If you don’t understand the definition read "Recursion definition".

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #8 on: December 09, 2008, 11:58:48 pm »
Quote
...
In passing, I should note that in thinking some more about this, I believe EA should issue a message at the end of import if any linkages were lost.  That is, classifier references or relationships that could not be resolved.  This is to alert the user that the model represented in the XMI was not "preserved" on read-in.  This should apply both to import and to controlled packages.
While they're at it, perhaps they could design the message to list the various things that were lost. Since EA has the source material - the import had to come from somewhere - this information is at hand.

After all, this is not a test of users' ability to review models and discover the differences by hand. EA could keep a running track of the unresolved items, group them in some meaningful way, and report in sufficient detail that identifying information could be captured - that means the the report must support select and copy - for use in diagnosing problems.

Just another 0.02 CAD, whatever residual value that might have these days.
No, you can't have it!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #9 on: December 11, 2008, 11:03:35 am »
Quote
It may be more complicated than that. The elements within an exported package may have all kinds of relationships with elements not contained therein.

In case of classifiers, realizations, dependencies and generalizations the desired behaviour seems obvious: preserve the target GUIDs and resolve them when importing for duplication, or, if they cannot be resolved, keep them as stubs and resolve them when the package containing the targets is being imported.

But what about associations? Isn't the concept of source and target for an association UML 1 legacy stuff anyway?
Well Frank, I don't believe so...  I believe the concept of Directedness is essential to good modelling.  (see: Directedness and Navigability of Edges)  I concede that on the paper you can't tell, but, in my view that's a rendering problem - which can be partly alleviated by the little direction indicator ([ch9658]) (which incidentally took me about 15 mins to find and wouldn't have if I hadn't remembered finally that it was associated with a label on the edge - so no label, no indicator... EAUI!  Roy - Help needs tidying up here.  The menus says direction indicator, but help won't find it!)   But back to the topic.  In our modelling, we use directedness extensively to encode information about the nature of the relationship between the two vertices.
Quote
In XMI 2.1. the notion of association source and target is contained only in the extensions section. In the model section there are two ends for an association and that's it. Who is source and who is target is completely arbitrary.

EA however marks the element from which the connector has been dragged as source and the one to which it has been dragged as target, and puts the association itself into the package containing the "source" element.
I stand to be corrected, but I believe it it doesn't attach the edge to any package, only to the two vertices at either end.  When exporting to XMI, EA (correctly) puts the association in both packages.
Quote
So what should happen with associations contained in the package reimported for duplication when their target is outside? I guess we would want them to be duplicated as well, to point from the duplicated source to the old (common) target.
Here, again, I think it gets back to the three use cases I mentioned.  In the case of the Copy use case you probably do want them duplicated, in the case of the New use case you probably don't.  But I guess this could be an additional option (perhaps defaulted as mentioned).
Quote
The trap here is that you don't see in your diagrams who is source and who is target. You may have inadvertently reversed the direction, or dragged it the other way in the first place, without any difference showing in diagrams. And without any difference in the uml:Model section of an XMI 2.1 export, come to that. And it will simply be missing then after duplication because it will never have been within the exported package.
As I mentioned, there IS a rendering issue here.  My personal view is that in addition to the formal UML direction indicator, EA should have an option on the diagram as a whole to add a (discreet) indicator on the edge itself to show the direction.
Quote
And there are many more things, like RefGuid tagged values, method overrides and such. It will take some time to think it through, and we might end up needing a tree view dialog showing all stubs and check boxes to control which kinds of relations or which individual relations are to be handled in which way.
Agreed it's more complicated; but we can move toward a final solution by stepwise improvement.  I think at least allowing for three (fairly) standard use cases is a start.  Especially if allied with more comprehensive information about what happened during the read in.

My AU$0.05
Paolo
« Last Edit: December 11, 2008, 11:05:17 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #10 on: December 11, 2008, 07:24:51 pm »
Quote
I think at least allowing for three (fairly) standard use cases is a start.  Especially if allied with more comprehensive information about what happened during the read in.

Agreed. I certainly wouldn't mind if they implemented it.

As to associations:

Quote
When exporting to XMI, EA (correctly) puts the association in both packages

Well, in XMI 2.1 it doesn't. Just tried it out and found that it's even weirder than I had thought. I made a Package1 with Class1 and a Package2 with Class2 and dragged an association from Class2 to Class1, within a class diagram in Package2. Exporting the whole thing to XMI 2.1 does this:

Code: [Select]
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_223A09D0_D893_4a1f_84A8_74E5335A66AC" name="Package1" visibility="public">
                        <packagedElement xmi:type="uml:Class" xmi:id="EAID_6F52A8EE_CAEE_4e46_9433_8D7A48C72D8E" name="Class1" visibility="public"/>
                        <packagedElement xmi:type="uml:Association" xmi:id="EAID_46BDE15A_B11D_4199_B706_E74F3A5E6147" visibility="public">
                              <memberEnd xmi:idref="EAID_dstBDE15A_B11D_4199_B706_E74F3A5E6147"/>
                              <memberEnd xmi:idref="EAID_srcBDE15A_B11D_4199_B706_E74F3A5E6147"/>
                              <ownedEnd xmi:type="uml:Property" xmi:id="EAID_srcBDE15A_B11D_4199_B706_E74F3A5E6147" visibility="public" association="EAID_46BDE15A_B11D_4199_B706_E74F3A5E6147" isOrdered="false" isDerived="false" isDerivedUnion="false" isUnique="true" aggregation="none">
                                    <type xmi:idref="EAID_D278F603_E64B_4e17_A035_F61959225004"/>
                              </ownedEnd>
                              <ownedEnd xmi:type="uml:Property" xmi:id="EAID_dstBDE15A_B11D_4199_B706_E74F3A5E6147" visibility="public" association="EAID_46BDE15A_B11D_4199_B706_E74F3A5E6147" isOrdered="false" isDerived="false" isDerivedUnion="false" isUnique="true" aggregation="none">
                                    <type xmi:idref="EAID_6F52A8EE_CAEE_4e46_9433_8D7A48C72D8E"/>
                              </ownedEnd>
                        </packagedElement>
                  </packagedElement>
                  <packagedElement xmi:type="uml:Package" xmi:id="EAPK_629003D2_1307_4d1d_B939_87BF697B80F5" name="Package2" visibility="public">
                        <packagedElement xmi:type="uml:Class" xmi:id="EAID_D278F603_E64B_4e17_A035_F61959225004" name="Class2" visibility="public"/>
                  </packagedElement>

So the association is exported to the package containg the target class!

When I export Package1 alone, it contains the association as well, but with an orphaned source ID. No stubs saved in XMI 2.1.
And when I export Package2 alone it also contains the association, with an orphaned target ID.

At least reimporting works well. When I import both packages to a new project the association is restored after imorting the second one, no matter if I imported Package1 or Package2 first.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #11 on: December 11, 2008, 11:06:03 pm »
Quote
...
So the association is exported to the package containg the target class!

When I export Package1 alone, it contains the association as well, but with an orphaned source ID. No stubs saved in XMI 2.1.
And when I export Package2 alone it also contains the association, with an orphaned target ID.

At least reimporting works well. When I import both packages to a new project the association is restored after imorting the second one, no matter if I imported Package1 or Package2 first.
Just musing here, but it seems that we've got several strange nuances in the most recent build. I cannot help wondering if there's been a first stab at improving the long-standing situation where EA needs more than one pass to import 'partial' associations. It might be that we are seeing some side effects of trying to work around this issue. If so, perhaps we'll see an improvement before the run-up to EA 7.5. I'd hate to have to wait until after the new version to get these resolved.
No, you can't have it!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #12 on: December 12, 2008, 08:24:04 pm »
Quote
Just musing here, but it seems that we've got several strange nuances in the most recent build. I cannot help wondering if there's been a first stab at improving the long-standing situation where EA needs more than one pass to import 'partial' associations. It might be that we are seeing some side effects of trying to work around this issue. If so, perhaps we'll see an improvement before the run-up to EA 7.5. I'd hate to have to wait until after the new version to get these resolved.

Maybe that's what it is, but then the problem of losing information or having to import twice has hardly ever been discussed with respect to XMI 2.1, but chiefly in the context of controlled packages.

And EA still uses XMI 1.1 for controlled packages, and it has to, of course, until XMI 2.1 export/import is complete and free of bugs. And in the xmi files for controlled packages, the association definitely resides in the package where the source is. Otherwise you could not define an association with the source in a checked out package and the target in a locked one.

But you can, and version control would be worthless if you couldn't. It's quite a common scenario to have basic things in packages which are hardly ever checked out but used by current models, with current classes having associations to basic ones.

Which shows that the way EA handles XMI 2.1 is not yet fit for version control. Doesn't really matter though, the main point being that whatever they use to save controlled packages must be complete and reliable.

But XMI 2.1 is my pet cause I'm using it as a source for various transformations, so I'm kepping a close watch on what's happening there.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: XMI import MAY differ from XMI (controlled) lo
« Reply #13 on: December 13, 2008, 04:15:01 am »
And XMI 1.1 is getting (much too) long in the tooth.
No, you can't have it!