Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Custom class [1..*] stereotype attribute saved as foo="/-1"
Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469824] Thu, 01 February 2007 08:52 Go to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Hi,

last year we made the transition from 1.x to 2.x. I thought I had done
everything but now I discovered that something is not saved correctly.
It worked fine with 1.x but does not work with 2.0. The details:

I have (among others) two classes defined in a profile, Dimension (with
two Integer properties width and height) and Bendpoint which has the one
Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
had something like this:

<generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ" general="_P0w90MJZEdqArMEYN_ynxQ">
<eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ" source="appliedStereotypes">
<contents xmi:type="Janus_4:Janus__Bendpoints" xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
<bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
<sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145" height="-44"/>
<targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ" width="-182" height="-80"/>
</bendpoints>
<bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
<sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268" height="-50"/>
<targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59" height="-86"/>
</bendpoints>
</contents>
</eAnnotations>
</generalization>

When I save now, with 2.0, I get

<generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw" general="_W9P5ULEgEduQQZSQkLuWiw"/>
[...]
<Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1" base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>

While I work in my editor everything is fine. I can add bendpoints to
relationships, I can change and remove them again. But they are not
saved. Is this something typical you know or should I provide code of
how I am modifying the model?

Regards, Thomas.
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469825 is a reply to message #469824] Thu, 01 February 2007 13:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30996
Registered: July 2009
Senior Member
Thomas,

I would suspect that the bendpoints are not contained by a resource at
the time of serialization, i.e., that eContainer for them is null. In
the 2.3 stream, with
https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this should
be properly detected during serialization. There might be something
else going on, but that would be my best theory...


Thomas Maier wrote:
> Hi,
>
> last year we made the transition from 1.x to 2.x. I thought I had done
> everything but now I discovered that something is not saved correctly.
> It worked fine with 1.x but does not work with 2.0. The details:
>
> I have (among others) two classes defined in a profile, Dimension (with
> two Integer properties width and height) and Bendpoint which has the one
> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
> had something like this:
>
> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ" general="_P0w90MJZEdqArMEYN_ynxQ">
> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ" source="appliedStereotypes">
> <contents xmi:type="Janus_4:Janus__Bendpoints" xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145" height="-44"/>
> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ" width="-182" height="-80"/>
> </bendpoints>
> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268" height="-50"/>
> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59" height="-86"/>
> </bendpoints>
> </contents>
> </eAnnotations>
> </generalization>
>
> When I save now, with 2.0, I get
>
> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw" general="_W9P5ULEgEduQQZSQkLuWiw"/>
> [...]
> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1" base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>
> While I work in my editor everything is fine. I can add bendpoints to
> relationships, I can change and remove them again. But they are not
> saved. Is this something typical you know or should I provide code of
> how I am modifying the model?
>
> Regards, Thomas.
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469877 is a reply to message #469825] Fri, 02 February 2007 12:11 Go to previous messageGo to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks for the prompt followup Ed,

I think it pointed me at a good direction. I have not thought it might
be a bug so I have only browsed the newsgroup (and google of course). I
am still having a hard time understanding those resource sets. I have
reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
link from Thunderbird works:
news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
my save method to add all stereotype applications to the resource before
the save actually happens. With this, my other stereotype applications
are saved, however, the bendpoints one is not. Tweaking in a few
sysouts in the save method, I see that even straight after adding a
stereotype application, its econtainer is still null. This is for all
stereotype applications even for the ones that are saved. What do I
miss here?


Ed Merks schrieb:
> Thomas,
>
> I would suspect that the bendpoints are not contained by a resource at
> the time of serialization, i.e., that eContainer for them is null. In
> the 2.3 stream, with
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this
> should be properly detected during serialization. There might be
> something else going on, but that would be my best theory...
>
>
> Thomas Maier wrote:
>> Hi,
>>
>> last year we made the transition from 1.x to 2.x. I thought I had done
>> everything but now I discovered that something is not saved
>> correctly. It worked fine with 1.x but does not work with 2.0. The
>> details:
>>
>> I have (among others) two classes defined in a profile, Dimension (with
>> two Integer properties width and height) and Bendpoint which has the one
>> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
>> had something like this:
>>
>> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ"
>> general="_P0w90MJZEdqArMEYN_ynxQ">
>> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ"
>> source="appliedStereotypes">
>> <contents xmi:type="Janus_4:Janus__Bendpoints"
>> xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
>> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
>> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145"
>> height="-44"/>
>> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ"
>> width="-182" height="-80"/>
>> </bendpoints>
>> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
>> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268"
>> height="-50"/>
>> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59"
>> height="-86"/>
>> </bendpoints>
>> </contents>
>> </eAnnotations>
>> </generalization>
>>
>> When I save now, with 2.0, I get
>>
>> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw"
>> general="_W9P5ULEgEduQQZSQkLuWiw"/>
>> [...]
>> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1"
>> base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>>
>> While I work in my editor everything is fine. I can add bendpoints to
>> relationships, I can change and remove them again. But they are not
>> saved. Is this something typical you know or should I provide code of
>> how I am modifying the model?
>>
>> Regards, Thomas.
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469878 is a reply to message #469877] Fri, 02 February 2007 12:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30996
Registered: July 2009
Senior Member
Thomas,

I really don't know any of the UML specifics, only the general EMF
issues. To be able to serialize a reference to any EObject, that
object's EObject.eResource() must not be null. For eResource to be
non-null, the object must either be directly contained by
Resource.getContents() or must be added or set to a containment
reference of some object that recursively has eResource that's not null;
adding or setting to a containment reference of some object is what
causes that object to become the EObject.eContainer(). So if the bend
point instance's eContainer is null, you've not added it to any
containment reference. Perhaps the reference you are already using to
refer to the bend point should be a containment reference?


Thomas Maier wrote:
> Thanks for the prompt followup Ed,
>
> I think it pointed me at a good direction. I have not thought it might
> be a bug so I have only browsed the newsgroup (and google of course). I
> am still having a hard time understanding those resource sets. I have
> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
> link from Thunderbird works:
> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
> my save method to add all stereotype applications to the resource before
> the save actually happens. With this, my other stereotype applications
> are saved, however, the bendpoints one is not. Tweaking in a few
> sysouts in the save method, I see that even straight after adding a
> stereotype application, its econtainer is still null. This is for all
> stereotype applications even for the ones that are saved. What do I
> miss here?
>
>
> Ed Merks schrieb:
>
>> Thomas,
>>
>> I would suspect that the bendpoints are not contained by a resource at
>> the time of serialization, i.e., that eContainer for them is null. In
>> the 2.3 stream, with
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this
>> should be properly detected during serialization. There might be
>> something else going on, but that would be my best theory...
>>
>>
>> Thomas Maier wrote:
>>
>>> Hi,
>>>
>>> last year we made the transition from 1.x to 2.x. I thought I had done
>>> everything but now I discovered that something is not saved
>>> correctly. It worked fine with 1.x but does not work with 2.0. The
>>> details:
>>>
>>> I have (among others) two classes defined in a profile, Dimension (with
>>> two Integer properties width and height) and Bendpoint which has the one
>>> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
>>> had something like this:
>>>
>>> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ"
>>> general="_P0w90MJZEdqArMEYN_ynxQ">
>>> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ"
>>> source="appliedStereotypes">
>>> <contents xmi:type="Janus_4:Janus__Bendpoints"
>>> xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
>>> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
>>> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145"
>>> height="-44"/>
>>> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ"
>>> width="-182" height="-80"/>
>>> </bendpoints>
>>> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
>>> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268"
>>> height="-50"/>
>>> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59"
>>> height="-86"/>
>>> </bendpoints>
>>> </contents>
>>> </eAnnotations>
>>> </generalization>
>>>
>>> When I save now, with 2.0, I get
>>>
>>> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw"
>>> general="_W9P5ULEgEduQQZSQkLuWiw"/>
>>> [...]
>>> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1"
>>> base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>>>
>>> While I work in my editor everything is fine. I can add bendpoints to
>>> relationships, I can change and remove them again. But they are not
>>> saved. Is this something typical you know or should I provide code of
>>> how I am modifying the model?
>>>
>>> Regards, Thomas.
>>>
>>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469882 is a reply to message #469877] Fri, 02 February 2007 15:01 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

When you apply a stereotype to an element, by default it is added to the
same resource as the element. If the element is not in a resource at the
time of application, then you'll need to add the stereotype application to
the appropriate resource once the element is added to a resource... Note
that stereotype applications (as of UML2 2.0) don't have containers (unlike
in UML2 1.x) - they are owned directly by a resource.

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C32A87.80905@uni-kassel.de...
> Thanks for the prompt followup Ed,
>
> I think it pointed me at a good direction. I have not thought it might
> be a bug so I have only browsed the newsgroup (and google of course). I
> am still having a hard time understanding those resource sets. I have
> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
> link from Thunderbird works:
> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
> my save method to add all stereotype applications to the resource before
> the save actually happens. With this, my other stereotype applications
> are saved, however, the bendpoints one is not. Tweaking in a few
> sysouts in the save method, I see that even straight after adding a
> stereotype application, its econtainer is still null. This is for all
> stereotype applications even for the ones that are saved. What do I
> miss here?
>
>
> Ed Merks schrieb:
>> Thomas,
>>
>> I would suspect that the bendpoints are not contained by a resource at
>> the time of serialization, i.e., that eContainer for them is null. In
>> the 2.3 stream, with
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this
>> should be properly detected during serialization. There might be
>> something else going on, but that would be my best theory...
>>
>>
>> Thomas Maier wrote:
>>> Hi,
>>>
>>> last year we made the transition from 1.x to 2.x. I thought I had done
>>> everything but now I discovered that something is not saved
>>> correctly. It worked fine with 1.x but does not work with 2.0. The
>>> details:
>>>
>>> I have (among others) two classes defined in a profile, Dimension (with
>>> two Integer properties width and height) and Bendpoint which has the one
>>> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
>>> had something like this:
>>>
>>> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ"
>>> general="_P0w90MJZEdqArMEYN_ynxQ">
>>> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ"
>>> source="appliedStereotypes">
>>> <contents xmi:type="Janus_4:Janus__Bendpoints"
>>> xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
>>> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
>>> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145"
>>> height="-44"/>
>>> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ"
>>> width="-182" height="-80"/>
>>> </bendpoints>
>>> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
>>> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268"
>>> height="-50"/>
>>> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59"
>>> height="-86"/>
>>> </bendpoints>
>>> </contents>
>>> </eAnnotations>
>>> </generalization>
>>>
>>> When I save now, with 2.0, I get
>>>
>>> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw"
>>> general="_W9P5ULEgEduQQZSQkLuWiw"/>
>>> [...]
>>> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1"
>>> base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>>>
>>> While I work in my editor everything is fine. I can add bendpoints to
>>> relationships, I can change and remove them again. But they are not
>>> saved. Is this something typical you know or should I provide code of
>>> how I am modifying the model?
>>>
>>> Regards, Thomas.
>>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469887 is a reply to message #469878] Fri, 02 February 2007 19:32 Go to previous messageGo to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Ed, thanks, I am still a newbie with EMF and about the only things I
know about eContainer and eResouce is what you and Kenn just told me,
but that fits into my picture of it. So, to be explicit, I have in my
save method:

public static ByteArrayOutputStream createStream(org.eclipse.uml2.uml.Package uml2Package, IFile file) throws IOException
{
// [...]

resource.getContents().add(uml2Package);

for (Iterator allContents = UML2Util.getAllContents(uml2Package, true, false); allContents.hasNext();)
{
EObject eObject = (EObject) allContents.next();
System.out.println("- check " + eObject);
if (eObject instanceof Element)
{
Element element = (Element) eObject;
EList stereotypeApplications = element.getStereotypeApplications();
for (Object object : stereotypeApplications)
{
EObject stereotypeApplication = (EObject) object;
System.out.println("--- add SA " + stereotypeApplications);
resource.getContents().add(stereotypeApplication);
System.out.println("----- SA.econtainer: " + stereotypeApplication.eContainer());
System.out.println("----- SA.eresource: " + stereotypeApplication.eResource());
}
}
}

// [...]

}


So I think I add each stereotype application to the resource. Looking at
my output seems to confirm this:

- check org.eclipse.uml2.uml.internal.impl.ModelImpl@8825a5 (name: emptyDiag, visibility: <unset>) (visibility: public) (viewpoint: <unset>)
- check org.eclipse.uml2.uml.internal.impl.ClassImpl@b28f30 (name: ClassOne, visibility: <unset>) (isLeaf: false, visibility: public, isAbstract: false) (isActive: false, isAbstract: false)
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@17ea55f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@100b8b (eClass: org.eclipse.emf.ecore.impl.EClassImpl@9aca82 (name: Size) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
- check org.eclipse.uml2.uml.internal.impl.ClassImpl@1660e34 (name: ClassTwo, visibility: <unset>) (isLeaf: false, visibility: public, isAbstract: false) (isActive: false, isAbstract: false)
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12e9d91 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
- check org.eclipse.uml2.uml.internal.impl.GeneralizationImpl@16ac126 (isSubstitutable: <unset>)
**********
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11da1f8 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@5e6a13 (name: Bendpoints) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
**********
- check org.eclipse.uml2.uml.internal.impl.ProfileApplicationImpl@134d246 (isStrict: false)
- check org.eclipse.emf.ecore.impl.EAnnotationImpl@1d479cf (source: http://www.eclipse.org/uml2/2.0.0/UML)


I have enclosed the addition of the bendpoints stereotype application
with **********. I think it looks fine, although I wonder what the last
line means (Kenn probably knows). My output file however still is this:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Janus="http:///schemas/Janus/6" xmlns:eco
re="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xsi:schemaLocation="http:///schemas/Janus/6 pathmap://JANUS_PROFILES/Janus.profile
..uml#_9jThIHL7EdumJ4oJfrbONw">
<uml:Model xmi:id="_myNnILLyEduIyePpvRkHlg" name="emptyDiag">
<packagedElement xmi:type="uml:Class" xmi:id="_myNnIbLyEduIyePpvRkHlg" name="ClassOne"/>
<packagedElement xmi:type="uml:Class" xmi:id="_myNnIrLyEduIyePpvRkHlg" name="ClassTwo">
<generalization xmi:id="_myNnI7LyEduIyePpvRkHlg" general="_myNnIbLyEduIyePpvRkHlg"/>
</packagedElement>
<profileApplication xmi:id="_myNnJLLyEduIyePpvRkHlg">
<eAnnotations xmi:id="_myNnJbLyEduIyePpvRkHlg" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_9jThIHL7EdumJ4oJ frbONw"/>
</eAnnotations>
<appliedProfile href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_0xvW8FK7EdqgQIFA B_VY8w"/>
</profileApplication>
</uml:Model>
<Janus:Location xmi:id="_myOOMLLyEduIyePpvRkHlg" x="50" y="60" base_Element="_myNnIbLyEduIyePpvRkHlg"/>
<Janus:Size xmi:id="_myO1QLLyEduIyePpvRkHlg" width="100" height="20" base_Element="_myNnIbLyEduIyePpvRkHlg"/>
<Janus:Location xmi:id="_myO1QbLyEduIyePpvRkHlg" x="100" y="120" base_Element="_myNnIrLyEduIyePpvRkHlg"/>
<Janus:Bendpoints xmi:id="_myPcULLyEduIyePpvRkHlg" bendpoints="/-1" base_Relationship="_myNnI7LyEduIyePpvRkHlg"/>
</xmi:XMI>

The other stereotype applications are saved fine, the bendpoints are
not. Could "/-1" indicate another thing I am doing wrong?


Ed Merks schrieb:
> Thomas,
>
> I really don't know any of the UML specifics, only the general EMF
> issues. To be able to serialize a reference to any EObject, that
> object's EObject.eResource() must not be null. For eResource to be
> non-null, the object must either be directly contained by
> Resource.getContents() or must be added or set to a containment
> reference of some object that recursively has eResource that's not
> null; adding or setting to a containment reference of some object is
> what causes that object to become the EObject.eContainer(). So if the
> bend point instance's eContainer is null, you've not added it to any
> containment reference. Perhaps the reference you are already using to
> refer to the bend point should be a containment reference?
>
>
> Thomas Maier wrote:
>> Thanks for the prompt followup Ed,
>>
>> I think it pointed me at a good direction. I have not thought it might
>> be a bug so I have only browsed the newsgroup (and google of course). I
>> am still having a hard time understanding those resource sets. I have
>> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
>> link from Thunderbird works:
>> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
>> my save method to add all stereotype applications to the resource before
>> the save actually happens. With this, my other stereotype applications
>> are saved, however, the bendpoints one is not. Tweaking in a few
>> sysouts in the save method, I see that even straight after adding a
>> stereotype application, its econtainer is still null. This is for all
>> stereotype applications even for the ones that are saved. What do I
>> miss here?
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469891 is a reply to message #469887] Fri, 02 February 2007 19:42 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

Your Bendpoints stereotype application appears to be referencing something
that hasn't been added to the resource. Please confirm that whatever you
have set as the value for Bendpoints::bendpoints is also added to the
resource. Note that, generally speaking, it is a good idea to attach
elements to resources as they are beng created rather than waiting to attach
them to a resource when saving them...

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C391E3.6080500@uni-kassel.de...
> Ed, thanks, I am still a newbie with EMF and about the only things I
> know about eContainer and eResouce is what you and Kenn just told me,
> but that fits into my picture of it. So, to be explicit, I have in my
> save method:
>
> public static ByteArrayOutputStream
> createStream(org.eclipse.uml2.uml.Package uml2Package, IFile file) throws
> IOException
> {
> // [...]
>
> resource.getContents().add(uml2Package);
>
> for (Iterator allContents = UML2Util.getAllContents(uml2Package, true,
> false); allContents.hasNext();)
> {
> EObject eObject = (EObject) allContents.next();
> System.out.println("- check " + eObject);
> if (eObject instanceof Element)
> {
> Element element = (Element) eObject;
> EList stereotypeApplications =
> element.getStereotypeApplications();
> for (Object object : stereotypeApplications)
> {
> EObject stereotypeApplication = (EObject) object;
> System.out.println("--- add SA " + stereotypeApplications);
> resource.getContents().add(stereotypeApplication);
> System.out.println("----- SA.econtainer: " +
> stereotypeApplication.eContainer());
> System.out.println("----- SA.eresource: " +
> stereotypeApplication.eResource());
> }
> }
> }
>
> // [...]
>
> }
>
>
> So I think I add each stereotype application to the resource. Looking at
> my output seems to confirm this:
>
> - check org.eclipse.uml2.uml.internal.impl.ModelImpl@8825a5 (name:
> emptyDiag, visibility: <unset>) (visibility: public) (viewpoint: <unset>)
> - check org.eclipse.uml2.uml.internal.impl.ClassImpl@b28f30 (name:
> ClassOne, visibility: <unset>) (isLeaf: false, visibility: public,
> isAbstract: false) (isActive: false, isAbstract: false)
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@17ea55f (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@100b8b (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@9aca82 (name: Size)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> - check org.eclipse.uml2.uml.internal.impl.ClassImpl@1660e34 (name:
> ClassTwo, visibility: <unset>) (isLeaf: false, visibility: public,
> isAbstract: false) (isActive: false, isAbstract: false)
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12e9d91 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> - check org.eclipse.uml2.uml.internal.impl.GeneralizationImpl@16ac126
> (isSubstitutable: <unset>)
> **********
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11da1f8 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@5e6a13 (name: Bendpoints)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> **********
> - check org.eclipse.uml2.uml.internal.impl.ProfileApplicationImpl@134d246
> (isStrict: false)
> - check org.eclipse.emf.ecore.impl.EAnnotationImpl@1d479cf (source:
> http://www.eclipse.org/uml2/2.0.0/UML)
>
>
> I have enclosed the addition of the bendpoints stereotype application
> with **********. I think it looks fine, although I wonder what the last
> line means (Kenn probably knows). My output file however still is this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:Janus="http:///schemas/Janus/6" xmlns:eco
> re="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xsi:schemaLocation="http:///schemas/Janus/6
> pathmap://JANUS_PROFILES/Janus.profile
> .uml#_9jThIHL7EdumJ4oJfrbONw">
> <uml:Model xmi:id="_myNnILLyEduIyePpvRkHlg" name="emptyDiag">
> <packagedElement xmi:type="uml:Class" xmi:id="_myNnIbLyEduIyePpvRkHlg"
> name="ClassOne"/>
> <packagedElement xmi:type="uml:Class" xmi:id="_myNnIrLyEduIyePpvRkHlg"
> name="ClassTwo">
> <generalization xmi:id="_myNnI7LyEduIyePpvRkHlg"
> general="_myNnIbLyEduIyePpvRkHlg"/>
> </packagedElement>
> <profileApplication xmi:id="_myNnJLLyEduIyePpvRkHlg">
> <eAnnotations xmi:id="_myNnJbLyEduIyePpvRkHlg"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <references xmi:type="ecore:EPackage"
> href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_9jThIHL7EdumJ4oJ frbONw"/>
> </eAnnotations>
> <appliedProfile
> href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_0xvW8FK7EdqgQIFA B_VY8w"/>
> </profileApplication>
> </uml:Model>
> <Janus:Location xmi:id="_myOOMLLyEduIyePpvRkHlg" x="50" y="60"
> base_Element="_myNnIbLyEduIyePpvRkHlg"/>
> <Janus:Size xmi:id="_myO1QLLyEduIyePpvRkHlg" width="100" height="20"
> base_Element="_myNnIbLyEduIyePpvRkHlg"/>
> <Janus:Location xmi:id="_myO1QbLyEduIyePpvRkHlg" x="100" y="120"
> base_Element="_myNnIrLyEduIyePpvRkHlg"/>
> <Janus:Bendpoints xmi:id="_myPcULLyEduIyePpvRkHlg" bendpoints="/-1"
> base_Relationship="_myNnI7LyEduIyePpvRkHlg"/>
> </xmi:XMI>
>
> The other stereotype applications are saved fine, the bendpoints are
> not. Could "/-1" indicate another thing I am doing wrong?
>
>
> Ed Merks schrieb:
>> Thomas,
>>
>> I really don't know any of the UML specifics, only the general EMF
>> issues. To be able to serialize a reference to any EObject, that
>> object's EObject.eResource() must not be null. For eResource to be
>> non-null, the object must either be directly contained by
>> Resource.getContents() or must be added or set to a containment
>> reference of some object that recursively has eResource that's not
>> null; adding or setting to a containment reference of some object is
>> what causes that object to become the EObject.eContainer(). So if the
>> bend point instance's eContainer is null, you've not added it to any
>> containment reference. Perhaps the reference you are already using to
>> refer to the bend point should be a containment reference?
>>
>>
>> Thomas Maier wrote:
>>> Thanks for the prompt followup Ed,
>>>
>>> I think it pointed me at a good direction. I have not thought it might
>>> be a bug so I have only browsed the newsgroup (and google of course). I
>>> am still having a hard time understanding those resource sets. I have
>>> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
>>> link from Thunderbird works:
>>> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
>>> my save method to add all stereotype applications to the resource before
>>> the save actually happens. With this, my other stereotype applications
>>> are saved, however, the bendpoints one is not. Tweaking in a few
>>> sysouts in the save method, I see that even straight after adding a
>>> stereotype application, its econtainer is still null. This is for all
>>> stereotype applications even for the ones that are saved. What do I
>>> miss here?
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469896 is a reply to message #469882] Fri, 02 February 2007 19:55 Go to previous messageGo to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Kenn, that is what (I think) I am actually doing. I load a model into
my editor, so the model is contained in a resource (strictly speaking I
load the resource and get the model out of it), apply bendpoints to a
generalization (which is a child of the class ClassTwo which is already
in the model and, thus, in the resource), save the model (resource)
again and have that "/-1". I thought maybe the bendpoints property
makes this stereotype something special but if I understand you right,
this "belongs-to-a-resource-thing" goes recursive so whenever I put
something into a resource I put the whole tree under that something into
the resource (which sounds like the only reasonable thing). Should I
have a very close look to what I am putting into the bendpoints
property? Anything else?


Kenn Hussey schrieb:
> Thomas,
>
> When you apply a stereotype to an element, by default it is added to the
> same resource as the element. If the element is not in a resource at the
> time of application, then you'll need to add the stereotype application to
> the appropriate resource once the element is added to a resource... Note
> that stereotype applications (as of UML2 2.0) don't have containers (unlike
> in UML2 1.x) - they are owned directly by a resource.
>
> Kenn
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469899 is a reply to message #469891] Fri, 02 February 2007 20:29 Go to previous messageGo to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Kenn, I will keep that in the back of my head. But to make that clear:
when I add my Model object to a resource right at the start and then add
Class objects to it, those Class objects get properly serialized.
Because they are added to a Model object that is already in a resource,
right? When I add a Property to such a class, it is the same, right?
It also works like that for the stereotypes I apply to such a class, right?

Looking through my editor code, when I create a Generalization object, I
only create the object by using UMLFactory.eINSTANCE.create() and set
its specific and general property. I do not explicitly add it to the
model object.

However, in my test code I currently say "Generalization generalization
= uml2ClassTwo.createGeneralization(uml2ClassOne);" and the javadoc of
createGeneralization() says "[...] and appends it to the
'Generalization' containment reference list." (which sounds kinda like
"it will be in the tree and get serialized" to my unknowing ears).

Both goes wrong, so it should not make a difference, should it?


Kenn Hussey wrote:
> Thomas,
>
> Your Bendpoints stereotype application appears to be referencing something
> that hasn't been added to the resource. Please confirm that whatever you
> have set as the value for Bendpoints::bendpoints is also added to the
> resource. Note that, generally speaking, it is a good idea to attach
> elements to resources as they are beng created rather than waiting to attach
> them to a resource when saving them...
>
> Kenn
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #469906 is a reply to message #469896] Mon, 05 February 2007 18:36 Go to previous messageGo to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Ok, thanks to you, Kenn and Ed, I finally got it. I have to manually add
the whole tree under a node when I add the node (if there are any
complex types involved). And remove the whole tree under the node when
I remove the node. However, I cannot believe this is expected behaviour.

I have a <<Bendpoints>> stereotype with Property bendpoints :
Bendpoint[0..*]. Bendpoint is a class in my profile that has a weight
(primitive double) and two Dimension objects. Dimension is also a class
defined in my profile (with two primitive doubles). Whenever I add a
Bendpoint object to the bendpoints property of a Bendpoints stereotype
application, I have to manually add the bendpoint EObject and the two
dimension EObjects to the resource.

Why doesn't that happen automatically? Could there be something wrong
with my profile? (And is it because the child objects are not in a
containment feature of their parent? Just to make sure I understand EMF
a little better? And why would that be so, given that they are children
(at least I think of a property of a class as a child of that class
(e.g. one of the Dimension objects as a child of the Bendpoint class) in
the model) only EMF does not see it like I do? Could I tell EMF somehow?)

Thank you for your time, Thomas.


Thomas Maier wrote:
> Kenn, that is what (I think) I am actually doing. I load a model into
> my editor, so the model is contained in a resource (strictly speaking I
> load the resource and get the model out of it), apply bendpoints to a
> generalization (which is a child of the class ClassTwo which is already
> in the model and, thus, in the resource), save the model (resource)
> again and have that "/-1". I thought maybe the bendpoints property
> makes this stereotype something special but if I understand you right,
> this "belongs-to-a-resource-thing" goes recursive so whenever I put
> something into a resource I put the whole tree under that something into
> the resource (which sounds like the only reasonable thing). Should I
> have a very close look to what I am putting into the bendpoints
> property? Anything else?
>
>
> Kenn Hussey schrieb:
>
>> Thomas,
>>
>> When you apply a stereotype to an element, by default it is added to the
>> same resource as the element. If the element is not in a resource at the
>> time of application, then you'll need to add the stereotype application to
>> the appropriate resource once the element is added to a resource... Note
>> that stereotype applications (as of UML2 2.0) don't have containers (unlike
>> in UML2 1.x) - they are owned directly by a resource.
>>
>> Kenn
>>
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #470055 is a reply to message #469899] Mon, 05 February 2007 19:09 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

Yes, when you add a child to a parent that is already attached to a
resource, the child is implicitly attached to the same resource. Of course
"adding a child to a parent" translates to adding the child element to a
containment feature of the parent element. I'd recommend using the convient
factory methods on the API to create and add elements to their containers in
one step, e.g. StructuredClassifier#createOwnedAttribute(String, Type, int,
int).

Setting the specific classifier of a generalization has the side effect of
adding the generalization as a child of the specific classifier (in its
generalization feature)... not sure what you mean by "both goes wrong"...

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C39F34.8060000@uni-kassel.de...
> Kenn, I will keep that in the back of my head. But to make that clear:
> when I add my Model object to a resource right at the start and then add
> Class objects to it, those Class objects get properly serialized.
> Because they are added to a Model object that is already in a resource,
> right? When I add a Property to such a class, it is the same, right?
> It also works like that for the stereotypes I apply to such a class,
> right?
>
> Looking through my editor code, when I create a Generalization object, I
> only create the object by using UMLFactory.eINSTANCE.create() and set
> its specific and general property. I do not explicitly add it to the
> model object.
>
> However, in my test code I currently say "Generalization generalization
> = uml2ClassTwo.createGeneralization(uml2ClassOne);" and the javadoc of
> createGeneralization() says "[...] and appends it to the
> 'Generalization' containment reference list." (which sounds kinda like
> "it will be in the tree and get serialized" to my unknowing ears).
>
> Both goes wrong, so it should not make a difference, should it?
>
>
> Kenn Hussey wrote:
>> Thomas,
>>
>> Your Bendpoints stereotype application appears to be referencing
>> something
>> that hasn't been added to the resource. Please confirm that whatever you
>> have set as the value for Bendpoints::bendpoints is also added to the
>> resource. Note that, generally speaking, it is a good idea to attach
>> elements to resources as they are beng created rather than waiting to
>> attach
>> them to a resource when saving them...
>>
>> Kenn
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #470057 is a reply to message #469906] Mon, 05 February 2007 19:13 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

Ah, please ensure that the aggregation of the 'bendpoints' property on your
stereotype (and any other properties that represent containment relations)
has been set to 'COMPOSITE' before defining the profile- this will result in
an Ecore representation that is able to contain the bendpoint objects (as
opposed to just referencing them).

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C7791E.9090703@uni-kassel.de...
> Ok, thanks to you, Kenn and Ed, I finally got it. I have to manually add
> the whole tree under a node when I add the node (if there are any
> complex types involved). And remove the whole tree under the node when
> I remove the node. However, I cannot believe this is expected behaviour.
>
> I have a <<Bendpoints>> stereotype with Property bendpoints :
> Bendpoint[0..*]. Bendpoint is a class in my profile that has a weight
> (primitive double) and two Dimension objects. Dimension is also a class
> defined in my profile (with two primitive doubles). Whenever I add a
> Bendpoint object to the bendpoints property of a Bendpoints stereotype
> application, I have to manually add the bendpoint EObject and the two
> dimension EObjects to the resource.
>
> Why doesn't that happen automatically? Could there be something wrong
> with my profile? (And is it because the child objects are not in a
> containment feature of their parent? Just to make sure I understand EMF
> a little better? And why would that be so, given that they are children
> (at least I think of a property of a class as a child of that class
> (e.g. one of the Dimension objects as a child of the Bendpoint class) in
> the model) only EMF does not see it like I do? Could I tell EMF somehow?)
>
> Thank you for your time, Thomas.
>
>
> Thomas Maier wrote:
>> Kenn, that is what (I think) I am actually doing. I load a model into
>> my editor, so the model is contained in a resource (strictly speaking I
>> load the resource and get the model out of it), apply bendpoints to a
>> generalization (which is a child of the class ClassTwo which is already
>> in the model and, thus, in the resource), save the model (resource)
>> again and have that "/-1". I thought maybe the bendpoints property
>> makes this stereotype something special but if I understand you right,
>> this "belongs-to-a-resource-thing" goes recursive so whenever I put
>> something into a resource I put the whole tree under that something into
>> the resource (which sounds like the only reasonable thing). Should I
>> have a very close look to what I am putting into the bendpoints
>> property? Anything else?
>>
>>
>> Kenn Hussey schrieb:
>>
>>> Thomas,
>>>
>>> When you apply a stereotype to an element, by default it is added to the
>>> same resource as the element. If the element is not in a resource at the
>>> time of application, then you'll need to add the stereotype application
>>> to
>>> the appropriate resource once the element is added to a resource... Note
>>> that stereotype applications (as of UML2 2.0) don't have containers
>>> (unlike
>>> in UML2 1.x) - they are owned directly by a resource.
>>>
>>> Kenn
>>>
>>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #470093 is a reply to message #470057] Tue, 06 February 2007 10:43 Go to previous messageGo to next message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
That's it Kenn, thank you. So the whole thing, which took me almost a
week, was only three mouse clicks away. Literally. At least I learned
some more about EMF while fiddling with it. As a side note, yesterday
one of our students gave a talk about EMF which already led me to what
you confirmed with your followup. So my other student simply discovered
the bug one week too early :).

Thanks, as always, Thomas.


Kenn Hussey wrote:
> Thomas,
>
> Ah, please ensure that the aggregation of the 'bendpoints' property on your
> stereotype (and any other properties that represent containment relations)
> has been set to 'COMPOSITE' before defining the profile- this will result in
> an Ecore representation that is able to contain the bendpoint objects (as
> opposed to just referencing them).
>
> Kenn
>
> "Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
> news:45C7791E.9090703@uni-kassel.de...
>
>> Ok, thanks to you, Kenn and Ed, I finally got it. I have to manually add
>> the whole tree under a node when I add the node (if there are any
>> complex types involved). And remove the whole tree under the node when
>> I remove the node. However, I cannot believe this is expected behaviour.
>>
>> I have a <<Bendpoints>> stereotype with Property bendpoints :
>> Bendpoint[0..*]. Bendpoint is a class in my profile that has a weight
>> (primitive double) and two Dimension objects. Dimension is also a class
>> defined in my profile (with two primitive doubles). Whenever I add a
>> Bendpoint object to the bendpoints property of a Bendpoints stereotype
>> application, I have to manually add the bendpoint EObject and the two
>> dimension EObjects to the resource.
>>
>> Why doesn't that happen automatically? Could there be something wrong
>> with my profile? (And is it because the child objects are not in a
>> containment feature of their parent? Just to make sure I understand EMF
>> a little better? And why would that be so, given that they are children
>> (at least I think of a property of a class as a child of that class
>> (e.g. one of the Dimension objects as a child of the Bendpoint class) in
>> the model) only EMF does not see it like I do? Could I tell EMF somehow?)
>>
>> Thank you for your time, Thomas.
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #470096 is a reply to message #470055] Tue, 06 February 2007 10:54 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Kenn, everything is fine now. For the archive: I wanted to express that
I was not sure whether the way I put the generalization into the tree
(using either Class.createGeneralization() including creating it or
setting an already existing generalization's specific and general
property) matters regarding the bendpoint issue (which went wrong either
way). It doesn't, both ways work fine, see my posting from a few
minutes ago.

Thanks, Thomas.


Kenn Hussey wrote:
> Thomas,
>
> Yes, when you add a child to a parent that is already attached to a
> resource, the child is implicitly attached to the same resource. Of course
> "adding a child to a parent" translates to adding the child element to a
> containment feature of the parent element. I'd recommend using the convient
> factory methods on the API to create and add elements to their containers in
> one step, e.g. StructuredClassifier#createOwnedAttribute(String, Type, int,
> int).
>
> Setting the specific classifier of a generalization has the side effect of
> adding the generalization as a child of the specific classifier (in its
> generalization feature)... not sure what you mean by "both goes wrong"...
>
> Kenn
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #579122 is a reply to message #469824] Thu, 01 February 2007 13:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30996
Registered: July 2009
Senior Member
Thomas,

I would suspect that the bendpoints are not contained by a resource at
the time of serialization, i.e., that eContainer for them is null. In
the 2.3 stream, with
https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this should
be properly detected during serialization. There might be something
else going on, but that would be my best theory...


Thomas Maier wrote:
> Hi,
>
> last year we made the transition from 1.x to 2.x. I thought I had done
> everything but now I discovered that something is not saved correctly.
> It worked fine with 1.x but does not work with 2.0. The details:
>
> I have (among others) two classes defined in a profile, Dimension (with
> two Integer properties width and height) and Bendpoint which has the one
> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
> had something like this:
>
> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ" general="_P0w90MJZEdqArMEYN_ynxQ">
> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ" source="appliedStereotypes">
> <contents xmi:type="Janus_4:Janus__Bendpoints" xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145" height="-44"/>
> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ" width="-182" height="-80"/>
> </bendpoints>
> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268" height="-50"/>
> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59" height="-86"/>
> </bendpoints>
> </contents>
> </eAnnotations>
> </generalization>
>
> When I save now, with 2.0, I get
>
> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw" general="_W9P5ULEgEduQQZSQkLuWiw"/>
> [...]
> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1" base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>
> While I work in my editor everything is fine. I can add bendpoints to
> relationships, I can change and remove them again. But they are not
> saved. Is this something typical you know or should I provide code of
> how I am modifying the model?
>
> Regards, Thomas.
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581569 is a reply to message #469825] Fri, 02 February 2007 12:11 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks for the prompt followup Ed,

I think it pointed me at a good direction. I have not thought it might
be a bug so I have only browsed the newsgroup (and google of course). I
am still having a hard time understanding those resource sets. I have
reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
link from Thunderbird works:
news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
my save method to add all stereotype applications to the resource before
the save actually happens. With this, my other stereotype applications
are saved, however, the bendpoints one is not. Tweaking in a few
sysouts in the save method, I see that even straight after adding a
stereotype application, its econtainer is still null. This is for all
stereotype applications even for the ones that are saved. What do I
miss here?


Ed Merks schrieb:
> Thomas,
>
> I would suspect that the bendpoints are not contained by a resource at
> the time of serialization, i.e., that eContainer for them is null. In
> the 2.3 stream, with
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this
> should be properly detected during serialization. There might be
> something else going on, but that would be my best theory...
>
>
> Thomas Maier wrote:
>> Hi,
>>
>> last year we made the transition from 1.x to 2.x. I thought I had done
>> everything but now I discovered that something is not saved
>> correctly. It worked fine with 1.x but does not work with 2.0. The
>> details:
>>
>> I have (among others) two classes defined in a profile, Dimension (with
>> two Integer properties width and height) and Bendpoint which has the one
>> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
>> had something like this:
>>
>> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ"
>> general="_P0w90MJZEdqArMEYN_ynxQ">
>> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ"
>> source="appliedStereotypes">
>> <contents xmi:type="Janus_4:Janus__Bendpoints"
>> xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
>> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
>> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145"
>> height="-44"/>
>> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ"
>> width="-182" height="-80"/>
>> </bendpoints>
>> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
>> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268"
>> height="-50"/>
>> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59"
>> height="-86"/>
>> </bendpoints>
>> </contents>
>> </eAnnotations>
>> </generalization>
>>
>> When I save now, with 2.0, I get
>>
>> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw"
>> general="_W9P5ULEgEduQQZSQkLuWiw"/>
>> [...]
>> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1"
>> base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>>
>> While I work in my editor everything is fine. I can add bendpoints to
>> relationships, I can change and remove them again. But they are not
>> saved. Is this something typical you know or should I provide code of
>> how I am modifying the model?
>>
>> Regards, Thomas.
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581601 is a reply to message #469877] Fri, 02 February 2007 12:38 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30996
Registered: July 2009
Senior Member
Thomas,

I really don't know any of the UML specifics, only the general EMF
issues. To be able to serialize a reference to any EObject, that
object's EObject.eResource() must not be null. For eResource to be
non-null, the object must either be directly contained by
Resource.getContents() or must be added or set to a containment
reference of some object that recursively has eResource that's not null;
adding or setting to a containment reference of some object is what
causes that object to become the EObject.eContainer(). So if the bend
point instance's eContainer is null, you've not added it to any
containment reference. Perhaps the reference you are already using to
refer to the bend point should be a containment reference?


Thomas Maier wrote:
> Thanks for the prompt followup Ed,
>
> I think it pointed me at a good direction. I have not thought it might
> be a bug so I have only browsed the newsgroup (and google of course). I
> am still having a hard time understanding those resource sets. I have
> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
> link from Thunderbird works:
> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
> my save method to add all stereotype applications to the resource before
> the save actually happens. With this, my other stereotype applications
> are saved, however, the bendpoints one is not. Tweaking in a few
> sysouts in the save method, I see that even straight after adding a
> stereotype application, its econtainer is still null. This is for all
> stereotype applications even for the ones that are saved. What do I
> miss here?
>
>
> Ed Merks schrieb:
>
>> Thomas,
>>
>> I would suspect that the bendpoints are not contained by a resource at
>> the time of serialization, i.e., that eContainer for them is null. In
>> the 2.3 stream, with
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this
>> should be properly detected during serialization. There might be
>> something else going on, but that would be my best theory...
>>
>>
>> Thomas Maier wrote:
>>
>>> Hi,
>>>
>>> last year we made the transition from 1.x to 2.x. I thought I had done
>>> everything but now I discovered that something is not saved
>>> correctly. It worked fine with 1.x but does not work with 2.0. The
>>> details:
>>>
>>> I have (among others) two classes defined in a profile, Dimension (with
>>> two Integer properties width and height) and Bendpoint which has the one
>>> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
>>> had something like this:
>>>
>>> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ"
>>> general="_P0w90MJZEdqArMEYN_ynxQ">
>>> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ"
>>> source="appliedStereotypes">
>>> <contents xmi:type="Janus_4:Janus__Bendpoints"
>>> xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
>>> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
>>> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145"
>>> height="-44"/>
>>> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ"
>>> width="-182" height="-80"/>
>>> </bendpoints>
>>> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
>>> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268"
>>> height="-50"/>
>>> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59"
>>> height="-86"/>
>>> </bendpoints>
>>> </contents>
>>> </eAnnotations>
>>> </generalization>
>>>
>>> When I save now, with 2.0, I get
>>>
>>> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw"
>>> general="_W9P5ULEgEduQQZSQkLuWiw"/>
>>> [...]
>>> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1"
>>> base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>>>
>>> While I work in my editor everything is fine. I can add bendpoints to
>>> relationships, I can change and remove them again. But they are not
>>> saved. Is this something typical you know or should I provide code of
>>> how I am modifying the model?
>>>
>>> Regards, Thomas.
>>>
>>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581773 is a reply to message #469877] Fri, 02 February 2007 15:01 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

When you apply a stereotype to an element, by default it is added to the
same resource as the element. If the element is not in a resource at the
time of application, then you'll need to add the stereotype application to
the appropriate resource once the element is added to a resource... Note
that stereotype applications (as of UML2 2.0) don't have containers (unlike
in UML2 1.x) - they are owned directly by a resource.

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C32A87.80905@uni-kassel.de...
> Thanks for the prompt followup Ed,
>
> I think it pointed me at a good direction. I have not thought it might
> be a bug so I have only browsed the newsgroup (and google of course). I
> am still having a hard time understanding those resource sets. I have
> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
> link from Thunderbird works:
> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
> my save method to add all stereotype applications to the resource before
> the save actually happens. With this, my other stereotype applications
> are saved, however, the bendpoints one is not. Tweaking in a few
> sysouts in the save method, I see that even straight after adding a
> stereotype application, its econtainer is still null. This is for all
> stereotype applications even for the ones that are saved. What do I
> miss here?
>
>
> Ed Merks schrieb:
>> Thomas,
>>
>> I would suspect that the bendpoints are not contained by a resource at
>> the time of serialization, i.e., that eContainer for them is null. In
>> the 2.3 stream, with
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=153577 fixed, this
>> should be properly detected during serialization. There might be
>> something else going on, but that would be my best theory...
>>
>>
>> Thomas Maier wrote:
>>> Hi,
>>>
>>> last year we made the transition from 1.x to 2.x. I thought I had done
>>> everything but now I discovered that something is not saved
>>> correctly. It worked fine with 1.x but does not work with 2.0. The
>>> details:
>>>
>>> I have (among others) two classes defined in a profile, Dimension (with
>>> two Integer properties width and height) and Bendpoint which has the one
>>> Property bendpoints : Bendpoint[1..*]. When I saved files with 1.x I
>>> had something like this:
>>>
>>> <generalization xmi:id="_QJ5gUMJZEdqArMEYN_ynxQ"
>>> general="_P0w90MJZEdqArMEYN_ynxQ">
>>> <eAnnotations xmi:id="_RqDrgMJZEdqArMEYN_ynxQ"
>>> source="appliedStereotypes">
>>> <contents xmi:type="Janus_4:Janus__Bendpoints"
>>> xmi:id="_RqDrgcJZEdqArMEYN_ynxQ">
>>> <bendpoints xmi:id="_kgRuIMJaEdqH7qsSo02lIQ" weight="0.5">
>>> <sourceDimension xmi:id="_kgSVMMJaEdqH7qsSo02lIQ" width="145"
>>> height="-44"/>
>>> <targetDimension xmi:id="_kgSVMcJaEdqH7qsSo02lIQ"
>>> width="-182" height="-80"/>
>>> </bendpoints>
>>> <bendpoints xmi:id="_RsAzUMJZEdqArMEYN_ynxQ" weight="0.5">
>>> <sourceDimension xmi:id="_RsAzUcJZEdqArMEYN_ynxQ" width="268"
>>> height="-50"/>
>>> <targetDimension xmi:id="_RsAzUsJZEdqArMEYN_ynxQ" width="-59"
>>> height="-86"/>
>>> </bendpoints>
>>> </contents>
>>> </eAnnotations>
>>> </generalization>
>>>
>>> When I save now, with 2.0, I get
>>>
>>> <generalization xmi:id="_Yp8rsLEgEduQQZSQkLuWiw"
>>> general="_W9P5ULEgEduQQZSQkLuWiw"/>
>>> [...]
>>> <Janus:Bendpoints xmi:id="_YqPmoLEgEduQQZSQkLuWiw" bendpoints="/-1"
>>> base_Relationship="_Yp8rsLEgEduQQZSQkLuWiw"/>
>>>
>>> While I work in my editor everything is fine. I can add bendpoints to
>>> relationships, I can change and remove them again. But they are not
>>> saved. Is this something typical you know or should I provide code of
>>> how I am modifying the model?
>>>
>>> Regards, Thomas.
>>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581859 is a reply to message #469878] Fri, 02 February 2007 19:32 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Ed, thanks, I am still a newbie with EMF and about the only things I
know about eContainer and eResouce is what you and Kenn just told me,
but that fits into my picture of it. So, to be explicit, I have in my
save method:

public static ByteArrayOutputStream createStream(org.eclipse.uml2.uml.Package uml2Package, IFile file) throws IOException
{
// [...]

resource.getContents().add(uml2Package);

for (Iterator allContents = UML2Util.getAllContents(uml2Package, true, false); allContents.hasNext();)
{
EObject eObject = (EObject) allContents.next();
System.out.println("- check " + eObject);
if (eObject instanceof Element)
{
Element element = (Element) eObject;
EList stereotypeApplications = element.getStereotypeApplications();
for (Object object : stereotypeApplications)
{
EObject stereotypeApplication = (EObject) object;
System.out.println("--- add SA " + stereotypeApplications);
resource.getContents().add(stereotypeApplication);
System.out.println("----- SA.econtainer: " + stereotypeApplication.eContainer());
System.out.println("----- SA.eresource: " + stereotypeApplication.eResource());
}
}
}

// [...]

}


So I think I add each stereotype application to the resource. Looking at
my output seems to confirm this:

- check org.eclipse.uml2.uml.internal.impl.ModelImpl@8825a5 (name: emptyDiag, visibility: <unset>) (visibility: public) (viewpoint: <unset>)
- check org.eclipse.uml2.uml.internal.impl.ClassImpl@b28f30 (name: ClassOne, visibility: <unset>) (isLeaf: false, visibility: public, isAbstract: false) (isActive: false, isAbstract: false)
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@17ea55f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@100b8b (eClass: org.eclipse.emf.ecore.impl.EClassImpl@9aca82 (name: Size) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
- check org.eclipse.uml2.uml.internal.impl.ClassImpl@1660e34 (name: ClassTwo, visibility: <unset>) (isLeaf: false, visibility: public, isAbstract: false) (isActive: false, isAbstract: false)
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12e9d91 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
- check org.eclipse.uml2.uml.internal.impl.GeneralizationImpl@16ac126 (isSubstitutable: <unset>)
**********
--- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11da1f8 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@5e6a13 (name: Bendpoints) (instanceClassName: null) (abstract: false, interface: false))
----- SA.econtainer: null
----- SA.eresource: org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
**********
- check org.eclipse.uml2.uml.internal.impl.ProfileApplicationImpl@134d246 (isStrict: false)
- check org.eclipse.emf.ecore.impl.EAnnotationImpl@1d479cf (source: http://www.eclipse.org/uml2/2.0.0/UML)


I have enclosed the addition of the bendpoints stereotype application
with **********. I think it looks fine, although I wonder what the last
line means (Kenn probably knows). My output file however still is this:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Janus="http:///schemas/Janus/6" xmlns:eco
re="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xsi:schemaLocation="http:///schemas/Janus/6 pathmap://JANUS_PROFILES/Janus.profile
..uml#_9jThIHL7EdumJ4oJfrbONw">
<uml:Model xmi:id="_myNnILLyEduIyePpvRkHlg" name="emptyDiag">
<packagedElement xmi:type="uml:Class" xmi:id="_myNnIbLyEduIyePpvRkHlg" name="ClassOne"/>
<packagedElement xmi:type="uml:Class" xmi:id="_myNnIrLyEduIyePpvRkHlg" name="ClassTwo">
<generalization xmi:id="_myNnI7LyEduIyePpvRkHlg" general="_myNnIbLyEduIyePpvRkHlg"/>
</packagedElement>
<profileApplication xmi:id="_myNnJLLyEduIyePpvRkHlg">
<eAnnotations xmi:id="_myNnJbLyEduIyePpvRkHlg" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_9jThIHL7EdumJ4oJ frbONw"/>
</eAnnotations>
<appliedProfile href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_0xvW8FK7EdqgQIFA B_VY8w"/>
</profileApplication>
</uml:Model>
<Janus:Location xmi:id="_myOOMLLyEduIyePpvRkHlg" x="50" y="60" base_Element="_myNnIbLyEduIyePpvRkHlg"/>
<Janus:Size xmi:id="_myO1QLLyEduIyePpvRkHlg" width="100" height="20" base_Element="_myNnIbLyEduIyePpvRkHlg"/>
<Janus:Location xmi:id="_myO1QbLyEduIyePpvRkHlg" x="100" y="120" base_Element="_myNnIrLyEduIyePpvRkHlg"/>
<Janus:Bendpoints xmi:id="_myPcULLyEduIyePpvRkHlg" bendpoints="/-1" base_Relationship="_myNnI7LyEduIyePpvRkHlg"/>
</xmi:XMI>

The other stereotype applications are saved fine, the bendpoints are
not. Could "/-1" indicate another thing I am doing wrong?


Ed Merks schrieb:
> Thomas,
>
> I really don't know any of the UML specifics, only the general EMF
> issues. To be able to serialize a reference to any EObject, that
> object's EObject.eResource() must not be null. For eResource to be
> non-null, the object must either be directly contained by
> Resource.getContents() or must be added or set to a containment
> reference of some object that recursively has eResource that's not
> null; adding or setting to a containment reference of some object is
> what causes that object to become the EObject.eContainer(). So if the
> bend point instance's eContainer is null, you've not added it to any
> containment reference. Perhaps the reference you are already using to
> refer to the bend point should be a containment reference?
>
>
> Thomas Maier wrote:
>> Thanks for the prompt followup Ed,
>>
>> I think it pointed me at a good direction. I have not thought it might
>> be a bug so I have only browsed the newsgroup (and google of course). I
>> am still having a hard time understanding those resource sets. I have
>> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
>> link from Thunderbird works:
>> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
>> my save method to add all stereotype applications to the resource before
>> the save actually happens. With this, my other stereotype applications
>> are saved, however, the bendpoints one is not. Tweaking in a few
>> sysouts in the save method, I see that even straight after adding a
>> stereotype application, its econtainer is still null. This is for all
>> stereotype applications even for the ones that are saved. What do I
>> miss here?
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581882 is a reply to message #469887] Fri, 02 February 2007 19:42 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

Your Bendpoints stereotype application appears to be referencing something
that hasn't been added to the resource. Please confirm that whatever you
have set as the value for Bendpoints::bendpoints is also added to the
resource. Note that, generally speaking, it is a good idea to attach
elements to resources as they are beng created rather than waiting to attach
them to a resource when saving them...

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C391E3.6080500@uni-kassel.de...
> Ed, thanks, I am still a newbie with EMF and about the only things I
> know about eContainer and eResouce is what you and Kenn just told me,
> but that fits into my picture of it. So, to be explicit, I have in my
> save method:
>
> public static ByteArrayOutputStream
> createStream(org.eclipse.uml2.uml.Package uml2Package, IFile file) throws
> IOException
> {
> // [...]
>
> resource.getContents().add(uml2Package);
>
> for (Iterator allContents = UML2Util.getAllContents(uml2Package, true,
> false); allContents.hasNext();)
> {
> EObject eObject = (EObject) allContents.next();
> System.out.println("- check " + eObject);
> if (eObject instanceof Element)
> {
> Element element = (Element) eObject;
> EList stereotypeApplications =
> element.getStereotypeApplications();
> for (Object object : stereotypeApplications)
> {
> EObject stereotypeApplication = (EObject) object;
> System.out.println("--- add SA " + stereotypeApplications);
> resource.getContents().add(stereotypeApplication);
> System.out.println("----- SA.econtainer: " +
> stereotypeApplication.eContainer());
> System.out.println("----- SA.eresource: " +
> stereotypeApplication.eResource());
> }
> }
> }
>
> // [...]
>
> }
>
>
> So I think I add each stereotype application to the resource. Looking at
> my output seems to confirm this:
>
> - check org.eclipse.uml2.uml.internal.impl.ModelImpl@8825a5 (name:
> emptyDiag, visibility: <unset>) (visibility: public) (viewpoint: <unset>)
> - check org.eclipse.uml2.uml.internal.impl.ClassImpl@b28f30 (name:
> ClassOne, visibility: <unset>) (isLeaf: false, visibility: public,
> isAbstract: false) (isActive: false, isAbstract: false)
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@17ea55f (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@100b8b (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@9aca82 (name: Size)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> - check org.eclipse.uml2.uml.internal.impl.ClassImpl@1660e34 (name:
> ClassTwo, visibility: <unset>) (isLeaf: false, visibility: public,
> isAbstract: false) (isActive: false, isAbstract: false)
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12e9d91 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@d420eb (name: Location)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> - check org.eclipse.uml2.uml.internal.impl.GeneralizationImpl@16ac126
> (isSubstitutable: <unset>)
> **********
> --- add SA org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11da1f8 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@5e6a13 (name: Bendpoints)
> (instanceClassName: null) (abstract: false, interface: false))
> ----- SA.econtainer: null
> ----- SA.eresource:
> org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@122cbaf
> uri='file:/home/thm/Apps/junit-workbench-workspace/de.unikas sel.janus.tests/UML2Test.uml'
> **********
> - check org.eclipse.uml2.uml.internal.impl.ProfileApplicationImpl@134d246
> (isStrict: false)
> - check org.eclipse.emf.ecore.impl.EAnnotationImpl@1d479cf (source:
> http://www.eclipse.org/uml2/2.0.0/UML)
>
>
> I have enclosed the addition of the bendpoints stereotype application
> with **********. I think it looks fine, although I wonder what the last
> line means (Kenn probably knows). My output file however still is this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:Janus="http:///schemas/Janus/6" xmlns:eco
> re="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xsi:schemaLocation="http:///schemas/Janus/6
> pathmap://JANUS_PROFILES/Janus.profile
> .uml#_9jThIHL7EdumJ4oJfrbONw">
> <uml:Model xmi:id="_myNnILLyEduIyePpvRkHlg" name="emptyDiag">
> <packagedElement xmi:type="uml:Class" xmi:id="_myNnIbLyEduIyePpvRkHlg"
> name="ClassOne"/>
> <packagedElement xmi:type="uml:Class" xmi:id="_myNnIrLyEduIyePpvRkHlg"
> name="ClassTwo">
> <generalization xmi:id="_myNnI7LyEduIyePpvRkHlg"
> general="_myNnIbLyEduIyePpvRkHlg"/>
> </packagedElement>
> <profileApplication xmi:id="_myNnJLLyEduIyePpvRkHlg">
> <eAnnotations xmi:id="_myNnJbLyEduIyePpvRkHlg"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <references xmi:type="ecore:EPackage"
> href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_9jThIHL7EdumJ4oJ frbONw"/>
> </eAnnotations>
> <appliedProfile
> href=" pathmap://JANUS_PROFILES/Janus.profile.uml#_0xvW8FK7EdqgQIFA B_VY8w"/>
> </profileApplication>
> </uml:Model>
> <Janus:Location xmi:id="_myOOMLLyEduIyePpvRkHlg" x="50" y="60"
> base_Element="_myNnIbLyEduIyePpvRkHlg"/>
> <Janus:Size xmi:id="_myO1QLLyEduIyePpvRkHlg" width="100" height="20"
> base_Element="_myNnIbLyEduIyePpvRkHlg"/>
> <Janus:Location xmi:id="_myO1QbLyEduIyePpvRkHlg" x="100" y="120"
> base_Element="_myNnIrLyEduIyePpvRkHlg"/>
> <Janus:Bendpoints xmi:id="_myPcULLyEduIyePpvRkHlg" bendpoints="/-1"
> base_Relationship="_myNnI7LyEduIyePpvRkHlg"/>
> </xmi:XMI>
>
> The other stereotype applications are saved fine, the bendpoints are
> not. Could "/-1" indicate another thing I am doing wrong?
>
>
> Ed Merks schrieb:
>> Thomas,
>>
>> I really don't know any of the UML specifics, only the general EMF
>> issues. To be able to serialize a reference to any EObject, that
>> object's EObject.eResource() must not be null. For eResource to be
>> non-null, the object must either be directly contained by
>> Resource.getContents() or must be added or set to a containment
>> reference of some object that recursively has eResource that's not
>> null; adding or setting to a containment reference of some object is
>> what causes that object to become the EObject.eContainer(). So if the
>> bend point instance's eContainer is null, you've not added it to any
>> containment reference. Perhaps the reference you are already using to
>> refer to the bend point should be a containment reference?
>>
>>
>> Thomas Maier wrote:
>>> Thanks for the prompt followup Ed,
>>>
>>> I think it pointed me at a good direction. I have not thought it might
>>> be a bug so I have only browsed the newsgroup (and google of course). I
>>> am still having a hard time understanding those resource sets. I have
>>> reread James Bruck's posting from 19.01.2007 02:45 (I don't know if that
>>> link from Thunderbird works:
>>> news://news.eclipse.org:119/eop7t1$fef$1@utils.eclipse.org) and modified
>>> my save method to add all stereotype applications to the resource before
>>> the save actually happens. With this, my other stereotype applications
>>> are saved, however, the bendpoints one is not. Tweaking in a few
>>> sysouts in the save method, I see that even straight after adding a
>>> stereotype application, its econtainer is still null. This is for all
>>> stereotype applications even for the ones that are saved. What do I
>>> miss here?
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581899 is a reply to message #469882] Fri, 02 February 2007 19:55 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Kenn, that is what (I think) I am actually doing. I load a model into
my editor, so the model is contained in a resource (strictly speaking I
load the resource and get the model out of it), apply bendpoints to a
generalization (which is a child of the class ClassTwo which is already
in the model and, thus, in the resource), save the model (resource)
again and have that "/-1". I thought maybe the bendpoints property
makes this stereotype something special but if I understand you right,
this "belongs-to-a-resource-thing" goes recursive so whenever I put
something into a resource I put the whole tree under that something into
the resource (which sounds like the only reasonable thing). Should I
have a very close look to what I am putting into the bendpoints
property? Anything else?


Kenn Hussey schrieb:
> Thomas,
>
> When you apply a stereotype to an element, by default it is added to the
> same resource as the element. If the element is not in a resource at the
> time of application, then you'll need to add the stereotype application to
> the appropriate resource once the element is added to a resource... Note
> that stereotype applications (as of UML2 2.0) don't have containers (unlike
> in UML2 1.x) - they are owned directly by a resource.
>
> Kenn
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581920 is a reply to message #469891] Fri, 02 February 2007 20:29 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Kenn, I will keep that in the back of my head. But to make that clear:
when I add my Model object to a resource right at the start and then add
Class objects to it, those Class objects get properly serialized.
Because they are added to a Model object that is already in a resource,
right? When I add a Property to such a class, it is the same, right?
It also works like that for the stereotypes I apply to such a class, right?

Looking through my editor code, when I create a Generalization object, I
only create the object by using UMLFactory.eINSTANCE.create() and set
its specific and general property. I do not explicitly add it to the
model object.

However, in my test code I currently say "Generalization generalization
= uml2ClassTwo.createGeneralization(uml2ClassOne);" and the javadoc of
createGeneralization() says "[...] and appends it to the
'Generalization' containment reference list." (which sounds kinda like
"it will be in the tree and get serialized" to my unknowing ears).

Both goes wrong, so it should not make a difference, should it?


Kenn Hussey wrote:
> Thomas,
>
> Your Bendpoints stereotype application appears to be referencing something
> that hasn't been added to the resource. Please confirm that whatever you
> have set as the value for Bendpoints::bendpoints is also added to the
> resource. Note that, generally speaking, it is a good idea to attach
> elements to resources as they are beng created rather than waiting to attach
> them to a resource when saving them...
>
> Kenn
>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581961 is a reply to message #469896] Mon, 05 February 2007 18:36 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Ok, thanks to you, Kenn and Ed, I finally got it. I have to manually add
the whole tree under a node when I add the node (if there are any
complex types involved). And remove the whole tree under the node when
I remove the node. However, I cannot believe this is expected behaviour.

I have a <<Bendpoints>> stereotype with Property bendpoints :
Bendpoint[0..*]. Bendpoint is a class in my profile that has a weight
(primitive double) and two Dimension objects. Dimension is also a class
defined in my profile (with two primitive doubles). Whenever I add a
Bendpoint object to the bendpoints property of a Bendpoints stereotype
application, I have to manually add the bendpoint EObject and the two
dimension EObjects to the resource.

Why doesn't that happen automatically? Could there be something wrong
with my profile? (And is it because the child objects are not in a
containment feature of their parent? Just to make sure I understand EMF
a little better? And why would that be so, given that they are children
(at least I think of a property of a class as a child of that class
(e.g. one of the Dimension objects as a child of the Bendpoint class) in
the model) only EMF does not see it like I do? Could I tell EMF somehow?)

Thank you for your time, Thomas.


Thomas Maier wrote:
> Kenn, that is what (I think) I am actually doing. I load a model into
> my editor, so the model is contained in a resource (strictly speaking I
> load the resource and get the model out of it), apply bendpoints to a
> generalization (which is a child of the class ClassTwo which is already
> in the model and, thus, in the resource), save the model (resource)
> again and have that "/-1". I thought maybe the bendpoints property
> makes this stereotype something special but if I understand you right,
> this "belongs-to-a-resource-thing" goes recursive so whenever I put
> something into a resource I put the whole tree under that something into
> the resource (which sounds like the only reasonable thing). Should I
> have a very close look to what I am putting into the bendpoints
> property? Anything else?
>
>
> Kenn Hussey schrieb:
>
>> Thomas,
>>
>> When you apply a stereotype to an element, by default it is added to the
>> same resource as the element. If the element is not in a resource at the
>> time of application, then you'll need to add the stereotype application to
>> the appropriate resource once the element is added to a resource... Note
>> that stereotype applications (as of UML2 2.0) don't have containers (unlike
>> in UML2 1.x) - they are owned directly by a resource.
>>
>> Kenn
>>
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #581983 is a reply to message #469899] Mon, 05 February 2007 19:09 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

Yes, when you add a child to a parent that is already attached to a
resource, the child is implicitly attached to the same resource. Of course
"adding a child to a parent" translates to adding the child element to a
containment feature of the parent element. I'd recommend using the convient
factory methods on the API to create and add elements to their containers in
one step, e.g. StructuredClassifier#createOwnedAttribute(String, Type, int,
int).

Setting the specific classifier of a generalization has the side effect of
adding the generalization as a child of the specific classifier (in its
generalization feature)... not sure what you mean by "both goes wrong"...

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C39F34.8060000@uni-kassel.de...
> Kenn, I will keep that in the back of my head. But to make that clear:
> when I add my Model object to a resource right at the start and then add
> Class objects to it, those Class objects get properly serialized.
> Because they are added to a Model object that is already in a resource,
> right? When I add a Property to such a class, it is the same, right?
> It also works like that for the stereotypes I apply to such a class,
> right?
>
> Looking through my editor code, when I create a Generalization object, I
> only create the object by using UMLFactory.eINSTANCE.create() and set
> its specific and general property. I do not explicitly add it to the
> model object.
>
> However, in my test code I currently say "Generalization generalization
> = uml2ClassTwo.createGeneralization(uml2ClassOne);" and the javadoc of
> createGeneralization() says "[...] and appends it to the
> 'Generalization' containment reference list." (which sounds kinda like
> "it will be in the tree and get serialized" to my unknowing ears).
>
> Both goes wrong, so it should not make a difference, should it?
>
>
> Kenn Hussey wrote:
>> Thomas,
>>
>> Your Bendpoints stereotype application appears to be referencing
>> something
>> that hasn't been added to the resource. Please confirm that whatever you
>> have set as the value for Bendpoints::bendpoints is also added to the
>> resource. Note that, generally speaking, it is a good idea to attach
>> elements to resources as they are beng created rather than waiting to
>> attach
>> them to a resource when saving them...
>>
>> Kenn
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #582007 is a reply to message #469906] Mon, 05 February 2007 19:13 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Thomas,

Ah, please ensure that the aggregation of the 'bendpoints' property on your
stereotype (and any other properties that represent containment relations)
has been set to 'COMPOSITE' before defining the profile- this will result in
an Ecore representation that is able to contain the bendpoint objects (as
opposed to just referencing them).

Kenn

"Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
news:45C7791E.9090703@uni-kassel.de...
> Ok, thanks to you, Kenn and Ed, I finally got it. I have to manually add
> the whole tree under a node when I add the node (if there are any
> complex types involved). And remove the whole tree under the node when
> I remove the node. However, I cannot believe this is expected behaviour.
>
> I have a <<Bendpoints>> stereotype with Property bendpoints :
> Bendpoint[0..*]. Bendpoint is a class in my profile that has a weight
> (primitive double) and two Dimension objects. Dimension is also a class
> defined in my profile (with two primitive doubles). Whenever I add a
> Bendpoint object to the bendpoints property of a Bendpoints stereotype
> application, I have to manually add the bendpoint EObject and the two
> dimension EObjects to the resource.
>
> Why doesn't that happen automatically? Could there be something wrong
> with my profile? (And is it because the child objects are not in a
> containment feature of their parent? Just to make sure I understand EMF
> a little better? And why would that be so, given that they are children
> (at least I think of a property of a class as a child of that class
> (e.g. one of the Dimension objects as a child of the Bendpoint class) in
> the model) only EMF does not see it like I do? Could I tell EMF somehow?)
>
> Thank you for your time, Thomas.
>
>
> Thomas Maier wrote:
>> Kenn, that is what (I think) I am actually doing. I load a model into
>> my editor, so the model is contained in a resource (strictly speaking I
>> load the resource and get the model out of it), apply bendpoints to a
>> generalization (which is a child of the class ClassTwo which is already
>> in the model and, thus, in the resource), save the model (resource)
>> again and have that "/-1". I thought maybe the bendpoints property
>> makes this stereotype something special but if I understand you right,
>> this "belongs-to-a-resource-thing" goes recursive so whenever I put
>> something into a resource I put the whole tree under that something into
>> the resource (which sounds like the only reasonable thing). Should I
>> have a very close look to what I am putting into the bendpoints
>> property? Anything else?
>>
>>
>> Kenn Hussey schrieb:
>>
>>> Thomas,
>>>
>>> When you apply a stereotype to an element, by default it is added to the
>>> same resource as the element. If the element is not in a resource at the
>>> time of application, then you'll need to add the stereotype application
>>> to
>>> the appropriate resource once the element is added to a resource... Note
>>> that stereotype applications (as of UML2 2.0) don't have containers
>>> (unlike
>>> in UML2 1.x) - they are owned directly by a resource.
>>>
>>> Kenn
>>>
>>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #582264 is a reply to message #470057] Tue, 06 February 2007 10:43 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
That's it Kenn, thank you. So the whole thing, which took me almost a
week, was only three mouse clicks away. Literally. At least I learned
some more about EMF while fiddling with it. As a side note, yesterday
one of our students gave a talk about EMF which already led me to what
you confirmed with your followup. So my other student simply discovered
the bug one week too early :).

Thanks, as always, Thomas.


Kenn Hussey wrote:
> Thomas,
>
> Ah, please ensure that the aggregation of the 'bendpoints' property on your
> stereotype (and any other properties that represent containment relations)
> has been set to 'COMPOSITE' before defining the profile- this will result in
> an Ecore representation that is able to contain the bendpoint objects (as
> opposed to just referencing them).
>
> Kenn
>
> "Thomas Maier" <Thomas.Maier@uni-kassel.de> wrote in message
> news:45C7791E.9090703@uni-kassel.de...
>
>> Ok, thanks to you, Kenn and Ed, I finally got it. I have to manually add
>> the whole tree under a node when I add the node (if there are any
>> complex types involved). And remove the whole tree under the node when
>> I remove the node. However, I cannot believe this is expected behaviour.
>>
>> I have a <<Bendpoints>> stereotype with Property bendpoints :
>> Bendpoint[0..*]. Bendpoint is a class in my profile that has a weight
>> (primitive double) and two Dimension objects. Dimension is also a class
>> defined in my profile (with two primitive doubles). Whenever I add a
>> Bendpoint object to the bendpoints property of a Bendpoints stereotype
>> application, I have to manually add the bendpoint EObject and the two
>> dimension EObjects to the resource.
>>
>> Why doesn't that happen automatically? Could there be something wrong
>> with my profile? (And is it because the child objects are not in a
>> containment feature of their parent? Just to make sure I understand EMF
>> a little better? And why would that be so, given that they are children
>> (at least I think of a property of a class as a child of that class
>> (e.g. one of the Dimension objects as a child of the Bendpoint class) in
>> the model) only EMF does not see it like I do? Could I tell EMF somehow?)
>>
>> Thank you for your time, Thomas.
>>
Re: Custom class [1..*] stereotype attribute saved as foo="/-1" [message #582279 is a reply to message #470055] Tue, 06 February 2007 10:54 Go to previous message
Thomas Maier is currently offline Thomas MaierFriend
Messages: 117
Registered: July 2009
Senior Member
Kenn, everything is fine now. For the archive: I wanted to express that
I was not sure whether the way I put the generalization into the tree
(using either Class.createGeneralization() including creating it or
setting an already existing generalization's specific and general
property) matters regarding the bendpoint issue (which went wrong either
way). It doesn't, both ways work fine, see my posting from a few
minutes ago.

Thanks, Thomas.


Kenn Hussey wrote:
> Thomas,
>
> Yes, when you add a child to a parent that is already attached to a
> resource, the child is implicitly attached to the same resource. Of course
> "adding a child to a parent" translates to adding the child element to a
> containment feature of the parent element. I'd recommend using the convient
> factory methods on the API to create and add elements to their containers in
> one step, e.g. StructuredClassifier#createOwnedAttribute(String, Type, int,
> int).
>
> Setting the specific classifier of a generalization has the side effect of
> adding the generalization as a child of the specific classifier (in its
> generalization feature)... not sure what you mean by "both goes wrong"...
>
> Kenn
>
Previous Topic:strange behavior when defining a profile
Next Topic:Source Control File Merging
Goto Forum:
  


Current Time: Mon Mar 30 11:34:46 GMT 2020

Powered by FUDForum. Page generated in 0.03718 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top