Re: [mdr-users] createExtent(String, RefObject, RefPackage[])
Pieter Van Gorp <[email protected]> Mon, 5 Sep 2005 13:50:58 +0200
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.user |
|---|---|
| Message-ID | <[email protected]> |
From the description of the method one would expect that as soon as the array includes existing extents they will be shared. http://www.netbeans.org/download/dev/javadoc/MdrAPIs/org/netbeans/api/mdr/MDRepository.html#createExtent(java.lang.String,%20javax.jmi.reflect.RefObject,%20javax.jmi.reflect.RefPackage[]) This is not the case. Originally, I expected that I could even load a standalone extent and then pass it to the clustering extent. As you stated, MDR could support this but does not do this: http://mdr.netbeans.org/servlets/ReadMsg?list=users&msgNo=3259 What I did afterwards was using extents loaded with the clustering metamodel only (instead of using instances of the standalone version of the clustered metamodels). However, I passed such an extent twice as member of two different arrays. MDR did not check whether the array members were already clustered. I would expect this to happen, according to the Javadoc description. Regards, Pieter On 9/5/05, Martin Matula <[email protected]> wrote: > Sorry, I do not understand the problem. What is the significance of the > array identity? > Martin > > Pieter Van Gorp wrote: > > >Hi all, > >I looked at the problem again with a fresh mind and found its cause. > > > >Apparantly, MDR does not check the actual contents of the array passed > >to createExtent(String, RefObject, RefPackage[])... therefore, when > >you want to cluster only one metapackage (say "C") into two different > >extents (say "A" and "B") and pass this C two times with an inline > >array initialization like: > >A= createExtent("A", A_M2, RefPackage[]{C})); > >B= createExtent("B", B_M2, RefPackage[]{C})); > > > >then MDR represents the content of C into B two times. This leads to > >reference problems when storing/loading B to/from XMI. > > > >I solved the problem by using the same array variable for creating the > >extent for A and B but I'd suggest to let MDR check the content of the > >array passed to createExtent instead of comparing its address... > > > >Regards, > >Pieter. > > > >On 8/10/05, Martin Matula <[email protected]> wrote: > > > > > >>Have you tried debugging it? > >> > >>Pieter Van Gorp wrote: > >> > >> > >> > >>>Hi again, > >>> > >>>On 8/9/05, Pieter Van Gorp <[email protected]> wrote: > >>> > >>> > >>> > >>> > >>>>On 8/8/05, Martin Matula <[email protected]> wrote: > >>>> > >>>> > >>>> > >>>> > >>>>>To fix this, you need to load the tracing metamodel. Now find UML > >>>>>package in this tracing metamodel and instantiate it. If you now find > >>>>>tracing package, instantiate it and pass in the instance of UML package, > >>>>>the instance of UML package will be reused. > >>>>> > >>>>> > >>>>> > >>>>> > >>>>Good to know, > >>>>thanks for the insight, I'll try it right away! > >>>> > >>>> > >>>> > >>>> > >>>After changing merely one line of code, the clustered extent was > >>>indeed filled up with the content of the UML-XMI: I replaced > >>><original>appMextent= (RefPackage) > >>>repo.createExtent(appMurl.toExternalForm(), getMainMP(appMMurl, "UML", > >>>xmiReader));</original> > >>> > >>>by: > >>> > >>><new>appMextent= (RefPackage) > >>>repo.createExtent(appMurl.toExternalForm(), getMainMP(traceMMurl, > >>>"UML", xmiReader));</new> > >>> > >>>Strange enough, I'm now confronted with the opposite problem: all UML > >>>elements seem to be available twice! Moreover, this leads to > >>>"duplicate IDREF" exceptions when using XMI modules for importing UML > >>>profiles. I started debugging with a UML file without XMI modules (by > >>>storing the UML profiles within my UML test project) and can now open > >>>the XMI that MDR writes from the clustered UML extent to a file called > >>>"standalone.xmi". Luckily, MagicDraw ignores the duplicate model > >>>elements... however, I believe I should remove the error in my code > >>>that causes the duplication of model elements... Martin, am I still > >>>using the API wrong? > >>> > >>>Please refer to yesterday's mail for reproducing my problem: > >>>http://mdr.netbeans.org/servlets/ReadMsg?list=users&msgNo=3255 > >>> > >>>Regards, > >>>-- Pieter. > >>> > >>> > >>> > >>> > >> > >> > >