Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Metamodel in Superstructure.uml
Metamodel in Superstructure.uml [message #699887] Fri, 22 July 2011 10:40 Go to next message
wws_ques wws_ques is currently offline wws_ques wws_ques
Messages: 64
Registered: July 2009
Member
I wrote a simple program to save a class diagram to a uml file. After
that I can read the elements such as Class in the uml
file using the following code:

if(resource.getContents().get(i) instanceof Model)
{
System.out.println("Model name is " + ((Model) resource.getContents().get(i)).getName());
}
else if (resource.getContents().get(i) instanceof Class)
System.out.println("Class name is " + ((Class) resource.getContents().get(i)).getName());
....

But when I try to load the UML Metamodel from the Superstructure.uml file, the above code failed. When I check Superstructure.uml, I find this file is different from the
uml file where I saved a class model created using UML2 api. The element in my created uml file is like UML:MetaClass such as UML:Class while Superstructure.uml has elements whose name is PackagedElement... In this case, how Superstructure.uml is created? It does not seem to be created by ECore... How can I read Superstructure.uml? Thanks.
Wuwei
Re: Metamodel in Superstructure.uml [message #699909 is a reply to message #699887] Fri, 22 July 2011 10:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25949
Registered: July 2009
Senior Member
Don't classes generally need to be contained in a Package or Model or
something like that?


On 22/07/2011 7:40 AM, Wuwei wrote:
> I wrote a simple program to save a class diagram to a uml file. After
> that I can read the elements such as Class in the uml
> file using the following code:
>
> if(resource.getContents().get(i) instanceof Model)
> {
> System.out.println("Model name is " + ((Model)
> resource.getContents().get(i)).getName());
> } else if (resource.getContents().get(i)
> instanceof Class)
> System.out.println("Class name is " + ((Class)
> resource.getContents().get(i)).getName());
> ...
>
> But when I try to load the UML Metamodel from the Superstructure.uml
> file, the above code failed. When I check Superstructure.uml, I find
> this file is different from the
> uml file where I saved a class model created using UML2 api. The
> element in my created uml file is like UML:MetaClass such as UML:Class
> while Superstructure.uml has elements whose name is PackagedElement...
> In this case, how Superstructure.uml is created? It does not seem to
> be created by ECore... How can I read Superstructure.uml? Thanks.
> Wuwei
Re: Metamodel in Superstructure.uml [message #699918 is a reply to message #699909] Fri, 22 July 2011 11:12 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_ques
Messages: 64
Registered: July 2009
Member
Yes. The following code should catch Model's name. But it seems nothing
from Superstructure.uml is an instance of Model...

Ed Merks wrote on Fri, 22 July 2011 10:54
Don't classes generally need to be contained in a Package or Model or
something like that?


On 22/07/2011 7:40 AM, Wuwei wrote:
> I wrote a simple program to save a class diagram to a uml file. After
> that I can read the elements such as Class in the uml
> file using the following code:
>
> if(resource.getContents().get(i) instanceof Model)
> {
> System.out.println("Model name is " + ((Model)
> resource.getContents().get(i)).getName());
> } else if (resource.getContents().get(i)
> instanceof Class)
> System.out.println("Class name is " + ((Class)
> resource.getContents().get(i)).getName());
> ...
>
> But when I try to load the UML Metamodel from the Superstructure.uml
> file, the above code failed. When I check Superstructure.uml, I find
> this file is different from the
> uml file where I saved a class model created using UML2 api. The
> element in my created uml file is like UML:MetaClass such as UML:Class
> while Superstructure.uml has elements whose name is PackagedElement...
> In this case, how Superstructure.uml is created? It does not seem to
> be created by ECore... How can I read Superstructure.uml? Thanks.
> Wuwei

Re: Metamodel in Superstructure.uml [message #699964 is a reply to message #699918] Fri, 22 July 2011 11:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25949
Registered: July 2009
Senior Member
You've used the debugger to see what is at the root of that resource? I
can assure you everything you see serialized was created with the UML2 APIs.


On 22/07/2011 8:12 AM, Wuwei wrote:
> Yes. The following code should catch Model's name. But it seems nothing
> from Superstructure.uml is an instance of Model...
>
> Ed Merks wrote on Fri, 22 July 2011 10:54
>> Don't classes generally need to be contained in a Package or Model or
>> something like that?
>>
>>
>> On 22/07/2011 7:40 AM, Wuwei wrote:
>> > I wrote a simple program to save a class diagram to a uml file. After
>> > that I can read the elements such as Class in the uml
>> > file using the following code:
>> >
>> > if(resource.getContents().get(i) instanceof Model)
>> > {
>> > System.out.println("Model name is " + ((Model) >
>> resource.getContents().get(i)).getName());
>> > } else if (resource.getContents().get(i) >
>> instanceof Class)
>> > System.out.println("Class name is " + ((Class)
>> > resource.getContents().get(i)).getName());
>> > ...
>> >
>> > But when I try to load the UML Metamodel from the
>> Superstructure.uml > file, the above code failed. When I check
>> Superstructure.uml, I find > this file is different from the
>> > uml file where I saved a class model created using UML2 api. The >
>> element in my created uml file is like UML:MetaClass such as
>> UML:Class > while Superstructure.uml has elements whose name is
>> PackagedElement... > In this case, how Superstructure.uml is created?
>> It does not seem to > be created by ECore... How can I read
>> Superstructure.uml? Thanks.
>> > Wuwei
>
>
Re: Metamodel in Superstructure.uml [message #700005 is a reply to message #699918] Fri, 22 July 2011 13:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

The Indigo version of Superstructure.uml starts

<?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:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/5"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/5
pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA">
<uml:Model xmi:id="_s-vBgBjPEdqPB8O80Bm3OQ" name="UML">

demonstrating that the root element is a Model and that the namespace is
http://www.eclipse.org/uml2/3.0.0/UML rather than ...omg... It differs
variously becuase OMG URI policy has been evolving and because an Ecore
prpfile is applied.

The file is readable by the UML model editor so you can debug that
editor to compare it with your code.

Regards

Ed Willink

On 22/07/2011 16:12, Wuwei wrote:
> Yes. The following code should catch Model's name. But it seems nothing
> from Superstructure.uml is an instance of Model...
Re: Metamodel in Superstructure.uml [message #700007 is a reply to message #699918] Fri, 22 July 2011 13:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

The Indigo version of Superstructure.uml starts

<?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:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/5"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/5
pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA">
<uml:Model xmi:id="_s-vBgBjPEdqPB8O80Bm3OQ" name="UML">

demonstrating that the root element is a Model and that the namespace is
http://www.eclipse.org/uml2/3.0.0/UML rather than ...omg... It differs
variously becuase OMG URI policy has been evolving and because an Ecore
prpfile is applied.

The file is readable by the UML model editor so you can debug that
editor to compare it with your code.

Regards

Ed Willink

On 22/07/2011 16:12, Wuwei wrote:
> Yes. The following code should catch Model's name. But it seems nothing
> from Superstructure.uml is an instance of Model...
Re: Metamodel in Superstructure.uml [message #701748 is a reply to message #700007] Mon, 25 July 2011 10:26 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_ques
Messages: 64
Registered: July 2009
Member
Ed,
It works when I use the model from UML2 v3.2. But I still get confused about why the previous model I used didn't work out. Here is the beginning of that file:

<?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:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/5" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/5 pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA">
<uml:Model xmi:id="_s-vBgBjPEdqPB8O80Bm3OQ" name="UML">

Now, I try to visit a navigable end of an association. According to the UML spec_2.1.2 p. 43, it says:

"navigable notation was often used in the past according to an informal convention, whereby non-navigable ends were assumed to be owned by the association whereas navigable ends were assumed to be owned by the classifier at the opposite end. This convention is now deprecated"

Then, how UML2 is implemented to support the navigability for an association? It seems UML2 still supports the informal convention, right?
Thanks.
Wuwei

Edward Willink wrote on Fri, 22 July 2011 13:03
Hi

The Indigo version of Superstructure.uml starts

<?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:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/5"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/5
pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA">
<uml:Model xmi:id="_s-vBgBjPEdqPB8O80Bm3OQ" name="UML">

demonstrating that the root element is a Model and that the namespace is
http://www.eclipse.org/uml2/3.0.0/UML rather than ...omg... It differs
variously becuase OMG URI policy has been evolving and because an Ecore
prpfile is applied.

The file is readable by the UML model editor so you can debug that
editor to compare it with your code.

Regards

Ed Willink

On 22/07/2011 16:12, Wuwei wrote:
> Yes. The following code should catch Model's name. But it seems nothing
> from Superstructure.uml is an instance of Model...

Re: Metamodel in Superstructure.uml [message #701842 is a reply to message #701748] Mon, 25 July 2011 12:54 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi
> It works when I use the model from UML2 v3.2. But I still get
> confused about why the previous model I used didn't work out.
Wierd things sometimes happen. Not all are easy to explain. Some take a
long time to make them go away.
> Then, how UML2 is implemented to support the navigability for an
> association? It seems UML2 still supports the informal convention, right?
No idea. You can study the code as well as I can.

Regards

Ed
Previous Topic:Adding a Double value to a Slot
Next Topic:How to draw diagrams in Indigo?
Goto Forum:
  


Current Time: Fri Aug 01 12:14:40 EDT 2014

Powered by FUDForum. Page generated in 0.05876 seconds