Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Applying stereotype on Class
Applying stereotype on Class [message #472226] Wed, 04 April 2007 15:09 Go to next message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Hi,
I have a model on which I apply a profile.

model.applyProfile(profileDocumentation);

The profileDocumentation isn't null ;-) It cames from an other model.
I get stereotype as I want.

Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");

Then I create a Class on which I want to apply the stereotype.

org.eclipse.uml2.uml.Class class_ = package_.createOwnedClass(name,
isAbstract);

class_.applyStereotype(stereotype);

But when I look in the UML editor the stereotype isn't applied to my class.
If I select the class and use the menu Element to add a stereotype it
works fine.

Any idea ??

Thx

Guillaume
Re: Applying stereotype on Class [message #472496 is a reply to message #472226] Mon, 09 April 2007 00:46 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Guillaume,

From what is described, I cannot tell why applying a stereotype would work
from the editor but not programatically in your application.
You could set a breakpoint in ApplyStereotypeAction where the call to
element.applyStereotype() is being called and see if you are making the same
calls in your application and to make sure the stereotype is applied
properly.

Are there any errors in the log?

Is your stereotype applicable to the given element ?

The article:
http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Intro duction_to_UML2_Profiles/article.html
describes this in detail.

Regards,

- James.



"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:5722f98c5d32a7a53eb09a4ed38bd2b1$1@www.eclipse.org...
> Hi,
> I have a model on which I apply a profile.
>
> model.applyProfile(profileDocumentation);
>
> The profileDocumentation isn't null ;-) It cames from an other model.
> I get stereotype as I want.
>
> Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");
>
> Then I create a Class on which I want to apply the stereotype.
>
> org.eclipse.uml2.uml.Class class_ = package_.createOwnedClass(name,
> isAbstract);
>
> class_.applyStereotype(stereotype);
>
> But when I look in the UML editor the stereotype isn't applied to my
> class.
> If I select the class and use the menu Element to add a stereotype it
> works fine.
>
> Any idea ??
>
> Thx
>
> Guillaume
>
>
>
>
>
Re: Applying stereotype on Class [message #472503 is a reply to message #472496] Tue, 10 April 2007 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

I use a break point to track the stereotype and its value. Everything
seems to be good.
The stereotype has the right value.
The very ammzing thing is that the stereotype is available in the uml
editor and I can directly aplly it on a class.

Any idea

Thx

Guillaume
Re: Applying stereotype on Class [message #472508 is a reply to message #472503] Wed, 11 April 2007 15:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Still fighting against stereotype...
A few more information...

Here is the code I use to apply stereotype on a class.
The profile comes from an other model 'm' as parameter.

Profile profileDocumentation = m.getAppliedProfile("Documentation");

I apply this profile to a package

specificationTopLevelPackage.applyProfile(profileDocumentati on);

A stereotype is already defined in the profile, its metaclass (already
defined) is UML::Class.

class1 is an instance of Class.

class1.applyStereotype(profileDocumentation.getOwnedStereoty pe( "CU"));


When I look into the uml editor the profile is well applied to the package
but the stereotype isn't applied.
I can obviously apply it with the editor but not with my code.

Any idea ?

Thx

Guillaume
Re: Applying stereotype on Class [message #472509 is a reply to message #472508] Wed, 11 April 2007 15:42 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Guillaume,

Post your profile, and your application and I'll have a look.
It is difficult to say what is going on from the description.

- James.


"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:d142486b2f3af7a39bbfc3827990ce35$1@www.eclipse.org...
> Still fighting against stereotype...
> A few more information...
>
> Here is the code I use to apply stereotype on a class.
> The profile comes from an other model 'm' as parameter.
>
> Profile profileDocumentation = m.getAppliedProfile("Documentation");
>
> I apply this profile to a package
>
> specificationTopLevelPackage.applyProfile(profileDocumentati on);
>
> A stereotype is already defined in the profile, its metaclass (already
> defined) is UML::Class.
>
> class1 is an instance of Class.
>
> class1.applyStereotype(profileDocumentation.getOwnedStereoty pe( "CU"));
>
>
> When I look into the uml editor the profile is well applied to the package
> but the stereotype isn't applied.
> I can obviously apply it with the editor but not with my code.
>
> Any idea ?
>
> Thx
>
> Guillaume
>
>
Re: Applying stereotype on Class [message #472532 is a reply to message #472509] Thu, 12 April 2007 08:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Here is my profile (Documentation.profile.uml2):


<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML"
xmi:id="_NQileegqEdulJtUB9wa0tQ" name="Documentation"
metamodelReference="_NQilgugqEdulJtUB9wa0tQ">
<eAnnotations xmi:id="_NQileugqEdulJtUB9wa0tQ" source="attributes">
<details xmi:id="_NQile-gqEdulJtUB9wa0tQ" key="version" value="0"/>
</eAnnotations>
<eAnnotations xmi:id="_NQilfOgqEdulJtUB9wa0tQ" source="ePackages">
<contents xmi:type="ecore:EPackage" xmi:id="_NQilfegqEdulJtUB9wa0tQ"
name="Documentation_0"
nsURI="http:///Documentation_0_NBMdYugqEdulJtUB9wa0tQ.profile.uml2"
nsPrefix="Documentation_0">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_NQilfugqEdulJtUB9wa0tQ" name="Documentation__CU">
<eAnnotations xmi:id="_NQilf-gqEdulJtUB9wa0tQ" source="stereotype"
references="_NQilhegqEdulJtUB9wa0tQ"/>
</eClassifiers>
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_NQilgOgqEdulJtUB9wa0tQ" name="Documentation__RG">
<eAnnotations xmi:id="_NQilgegqEdulJtUB9wa0tQ" source="stereotype"
references="_NQilh-gqEdulJtUB9wa0tQ"/>
</eClassifiers>
</contents>
</eAnnotations>
<packageImport xmi:id="_NQilgugqEdulJtUB9wa0tQ" visibility="private">
<importedPackage xmi:type="uml:Model"
href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m8qbA686EdiEh 75YJ_3n8g"/>
</packageImport>
<packageImport xmi:id="_NQilg-gqEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href=" pathmap://UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2#_Ef RZoK86EdieaYgxtVWN8Q"/>
</packageImport>
<packageImport xmi:id="_NQilhOgqEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href=" pathmap://UML2_LIBRARIES/JavaPrimitiveTypes.library.uml2#_Rj myoK86EdieaYgxtVWN8Q"/>
</packageImport>
<ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilhegqEdulJtUB9wa0tQ"
name="CU">
<ownedAttribute xmi:id="_NQilhugqEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_NQiliegqEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
</ownedAttribute>
</ownedMember>
<ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilh-gqEdulJtUB9wa0tQ"
name="RG">
<ownedAttribute xmi:id="_NQiliOgqEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_NQiljegqEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
</ownedAttribute>
</ownedMember>
<ownedMember xmi:type="uml:Extension" xmi:id="_NQiliegqEdulJtUB9wa0tQ"
memberEnd="_NQiliugqEdulJtUB9wa0tQ _NQilhugqEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiliugqEdulJtUB9wa0tQ"
name="extension_CU" visibility="private" type="_NQilhegqEdulJtUB9wa0tQ"
association="_NQiliegqEdulJtUB9wa0tQ" aggregation="composite">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_NQili-gqEdulJtUB9wa0tQ" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger"
xmi:id="_NQiljOgqEdulJtUB9wa0tQ"/>
</ownedEnd>
</ownedMember>
<ownedMember xmi:type="uml:Extension" xmi:id="_NQiljegqEdulJtUB9wa0tQ"
memberEnd="_NQiliOgqEdulJtUB9wa0tQ _NQiljugqEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiljugqEdulJtUB9wa0tQ"
name="extension_RG" visibility="private" type="_NQilh-gqEdulJtUB9wa0tQ"
association="_NQiljegqEdulJtUB9wa0tQ" aggregation="composite">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_NQilj-gqEdulJtUB9wa0tQ" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger"
xmi:id="_NQilkOgqEdulJtUB9wa0tQ"/>
</ownedEnd>
</ownedMember>
</uml:Profile>


And my application:

private static Profile profileDocumentation;


public static Model createModelFromModel(Model m) {

Model model = UMLFactory.eINSTANCE.createModel();

Package specificationTopLevelPackage =
UseCaseModelToDocumentModel .createPackage(model.getNearestPackage(),"org.application.specification ");

profileDocumentation = m.getAppliedProfile("Documentation");

specificationTopLevelPackage.applyProfile(profileDocumentati on);

//try to create a class with the CU stereotype
Class myClass = specificationTopLevelPackage.createOwnedClass("my
class",false);

Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");

myClass.applyStereotype(stereotype);

return model;

}
}



Thx,

Guillaume
Re: Applying stereotype on Class [message #472536 is a reply to message #472532] Fri, 13 April 2007 02:21 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Guillaume,

This profile is based on an older version of UML2 (1.x) and it looks like
you are trying to apply it to a model based on a newer version (2.x). To
apply this profile, you'll need to migrate it to the new format first - see
the migration guide on the UML2 documentation page
( http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html)
for details.

Kenn

"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:ef39695386120905aafb7d432a1f2e64$1@www.eclipse.org...
> Here is my profile (Documentation.profile.uml2):
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML"
> xmi:id="_NQileegqEdulJtUB9wa0tQ" name="Documentation"
> metamodelReference="_NQilgugqEdulJtUB9wa0tQ">
> <eAnnotations xmi:id="_NQileugqEdulJtUB9wa0tQ" source="attributes">
> <details xmi:id="_NQile-gqEdulJtUB9wa0tQ" key="version" value="0"/>
> </eAnnotations>
> <eAnnotations xmi:id="_NQilfOgqEdulJtUB9wa0tQ" source="ePackages">
> <contents xmi:type="ecore:EPackage" xmi:id="_NQilfegqEdulJtUB9wa0tQ"
> name="Documentation_0"
> nsURI="http:///Documentation_0_NBMdYugqEdulJtUB9wa0tQ.profile.uml2"
> nsPrefix="Documentation_0">
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_NQilfugqEdulJtUB9wa0tQ" name="Documentation__CU">
> <eAnnotations xmi:id="_NQilf-gqEdulJtUB9wa0tQ" source="stereotype"
> references="_NQilhegqEdulJtUB9wa0tQ"/>
> </eClassifiers>
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_NQilgOgqEdulJtUB9wa0tQ" name="Documentation__RG">
> <eAnnotations xmi:id="_NQilgegqEdulJtUB9wa0tQ" source="stereotype"
> references="_NQilh-gqEdulJtUB9wa0tQ"/>
> </eClassifiers>
> </contents>
> </eAnnotations>
> <packageImport xmi:id="_NQilgugqEdulJtUB9wa0tQ" visibility="private">
> <importedPackage xmi:type="uml:Model"
> href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m8qbA686EdiEh 75YJ_3n8g"/>
> </packageImport>
> <packageImport xmi:id="_NQilg-gqEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href=" pathmap://UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2#_Ef RZoK86EdieaYgxtVWN8Q"/>
> </packageImport>
> <packageImport xmi:id="_NQilhOgqEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href=" pathmap://UML2_LIBRARIES/JavaPrimitiveTypes.library.uml2#_Rj myoK86EdieaYgxtVWN8Q"/>
> </packageImport>
> <ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilhegqEdulJtUB9wa0tQ"
> name="CU">
> <ownedAttribute xmi:id="_NQilhugqEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_NQiliegqEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilh-gqEdulJtUB9wa0tQ"
> name="RG">
> <ownedAttribute xmi:id="_NQiliOgqEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_NQiljegqEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Extension" xmi:id="_NQiliegqEdulJtUB9wa0tQ"
> memberEnd="_NQiliugqEdulJtUB9wa0tQ _NQilhugqEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiliugqEdulJtUB9wa0tQ"
> name="extension_CU" visibility="private" type="_NQilhegqEdulJtUB9wa0tQ"
> association="_NQiliegqEdulJtUB9wa0tQ" aggregation="composite">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_NQili-gqEdulJtUB9wa0tQ" value="1"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_NQiljOgqEdulJtUB9wa0tQ"/>
> </ownedEnd>
> </ownedMember>
> <ownedMember xmi:type="uml:Extension" xmi:id="_NQiljegqEdulJtUB9wa0tQ"
> memberEnd="_NQiliOgqEdulJtUB9wa0tQ _NQiljugqEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiljugqEdulJtUB9wa0tQ"
> name="extension_RG" visibility="private" type="_NQilh-gqEdulJtUB9wa0tQ"
> association="_NQiljegqEdulJtUB9wa0tQ" aggregation="composite">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_NQilj-gqEdulJtUB9wa0tQ" value="1"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_NQilkOgqEdulJtUB9wa0tQ"/>
> </ownedEnd>
> </ownedMember>
> </uml:Profile>
>
>
> And my application:
>
> private static Profile profileDocumentation;
>
>
> public static Model createModelFromModel(Model m) {
>
> Model model = UMLFactory.eINSTANCE.createModel();
>
> Package specificationTopLevelPackage = UseCaseModelToDocumentModel
> .createPackage(model.getNearestPackage(),"org.application.specification ");
>
> profileDocumentation = m.getAppliedProfile("Documentation");
>
> specificationTopLevelPackage.applyProfile(profileDocumentati on);
>
> //try to create a class with the CU stereotype
> Class myClass = specificationTopLevelPackage.createOwnedClass("my
> class",false);
>
> Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");
>
> myClass.applyStereotype(stereotype);
>
> return model;
>
> }
> }
>
>
>
> Thx,
>
> Guillaume
>
Re: Applying stereotype on Class [message #472538 is a reply to message #472536] Fri, 13 April 2007 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Hi Kenn.
Thanks a lot for your post.

I was very surprising beacause I use MagicDraw to design this profile and
export it. But you're right the export are for version 1.x

I will migrate my profile.


Regards,
Guillaume
Re: Applying stereotype on Class [message #472539 is a reply to message #472538] Fri, 13 April 2007 15:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

I just migrate the profile to a new file with the link you gave me Kenn.

Here it is (version 2.1):

<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
xmi:id="_6FnduejzEdulJtUB9wa0tQ" name="Documentation"
metamodelReference="_6FndwujzEdulJtUB9wa0tQ">
<eAnnotations xmi:id="_6FndvOjzEdulJtUB9wa0tQ"
source="http://www.eclipse.org/uml2/2.0.0/UML">
<contents xmi:type="ecore:EPackage" xmi:id="_GSAO8OmSEduTONvRJBt5Ow"
name="Documentation"
nsURI="http:///schemas/Documentation/_GR2d8OmSEduTONvRJBt5Ow/1"
nsPrefix="Documentation">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_GSAO8emSEduTONvRJBt5Ow" name="CU">
<eAnnotations xmi:id="_GSAO8umSEduTONvRJBt5Ow"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6FndxejzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_GSAO8-mSEduTONvRJBt5Ow" name="base_Class" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_GSAO9OmSEduTONvRJBt5Ow" name="RG">
<eAnnotations xmi:id="_GSAO9emSEduTONvRJBt5Ow"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6Fndx-jzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_GSAO9umSEduTONvRJBt5Ow" name="base_Class" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
</contents>
<contents xmi:type="ecore:EPackage" xmi:id="_6FndvejzEdulJtUB9wa0tQ"
name="Documentation_0"
nsURI="http:///Documentation_0_57fJA-jzEdulJtUB9wa0tQ.profile.uml2"
nsPrefix="Documentation_0">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_6FndvujzEdulJtUB9wa0tQ" name="Documentation__CU">
<eAnnotations xmi:id="_6Fndv-jzEdulJtUB9wa0tQ"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6FndxejzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_Dc9UcOmSEduTONvRJBt5Ow" name="base_Class">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_6FndwOjzEdulJtUB9wa0tQ" name="Documentation__RG">
<eAnnotations xmi:id="_6FndwejzEdulJtUB9wa0tQ"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6Fndx-jzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_DdGeYOmSEduTONvRJBt5Ow" name="base_Class">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
</contents>
</eAnnotations>
<packageImport xmi:id="_6FndwujzEdulJtUB9wa0tQ" visibility="private">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
</packageImport>
<packageImport xmi:id="_6Fndw-jzEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packageImport xmi:id="_6FndxOjzEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_6FndxejzEdulJtUB9wa0tQ" name="CU">
<ownedAttribute xmi:id="_6FndxujzEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_6FndyejzEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_6Fndx-jzEdulJtUB9wa0tQ" name="RG">
<ownedAttribute xmi:id="_6FndyOjzEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_6FndzejzEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension"
xmi:id="_6FndyejzEdulJtUB9wa0tQ" memberEnd="_6FndyujzEdulJtUB9wa0tQ
_6FndxujzEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndyujzEdulJtUB9wa0tQ"
name="extension_CU" visibility="private" type="_6FndxejzEdulJtUB9wa0tQ"
aggregation="composite" association="_6FndyejzEdulJtUB9wa0tQ">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_6Fndy-jzEdulJtUB9wa0tQ" value="1"/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Extension"
xmi:id="_6FndzejzEdulJtUB9wa0tQ" memberEnd="_6FndyOjzEdulJtUB9wa0tQ
_6FndzujzEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndzujzEdulJtUB9wa0tQ"
name="extension_RG" visibility="private" type="_6Fndx-jzEdulJtUB9wa0tQ"
aggregation="composite" association="_6FndzejzEdulJtUB9wa0tQ">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_6Fndz-jzEdulJtUB9wa0tQ" value="1"/>
</ownedEnd>
</packagedElement>
</uml:Profile>

I'm able to load this resource from disk :
ResourceSet resourceSet = new ResourceSetImpl();
profileDocumentation_2_x = UMLElementLoader.loadProfile(
"Documentation.profile.uml", resourceSet);


public static Profile loadProfile(String modelFile, ResourceSet
resourceSet) {
Profile profile = null;

Resource inputResource = resourceSet.createResource(URI
.createFileURI(modelFile));
try {
inputResource.load(null);
} catch (IOException exception) {
exception.printStackTrace();
}

Iterator iterator = inputResource.getAllContents();
while (iterator.hasNext()) {
Object currentObject = iterator.next();
if (currentObject instanceof Profile) {
profile = (Profile) currentObject;
break;
}
}
return profile;
}


And I can get owned stereotype.
and try to apply them:

class_.applyStereotype(stereotype)

But The sterotype is never apply and I can do it with the editor.
Re: Applying stereotype on Class [message #472543 is a reply to message #472539] Mon, 16 April 2007 18:54 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Guillaume,

What do you mean by "stereotype is never apply"? Are you seeing any
exceptions (e.g. IllegalArgumentException)? Or is the stereotype application
just not being serialized?

Kenn

"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:2ae8e100ac7cf4d54f4f21c30322a62a$1@www.eclipse.org...
>I just migrate the profile to a new file with the link you gave me Kenn.
>
> Here it is (version 2.1):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_6FnduejzEdulJtUB9wa0tQ" name="Documentation"
> metamodelReference="_6FndwujzEdulJtUB9wa0tQ">
> <eAnnotations xmi:id="_6FndvOjzEdulJtUB9wa0tQ"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <contents xmi:type="ecore:EPackage" xmi:id="_GSAO8OmSEduTONvRJBt5Ow"
> name="Documentation"
> nsURI="http:///schemas/Documentation/_GR2d8OmSEduTONvRJBt5Ow/1"
> nsPrefix="Documentation">
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_GSAO8emSEduTONvRJBt5Ow" name="CU">
> <eAnnotations xmi:id="_GSAO8umSEduTONvRJBt5Ow"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6FndxejzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_GSAO8-mSEduTONvRJBt5Ow" name="base_Class" ordered="false"
> lowerBound="1">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_GSAO9OmSEduTONvRJBt5Ow" name="RG">
> <eAnnotations xmi:id="_GSAO9emSEduTONvRJBt5Ow"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6Fndx-jzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_GSAO9umSEduTONvRJBt5Ow" name="base_Class" ordered="false"
> lowerBound="1">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> </contents>
> <contents xmi:type="ecore:EPackage" xmi:id="_6FndvejzEdulJtUB9wa0tQ"
> name="Documentation_0"
> nsURI="http:///Documentation_0_57fJA-jzEdulJtUB9wa0tQ.profile.uml2"
> nsPrefix="Documentation_0">
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_6FndvujzEdulJtUB9wa0tQ" name="Documentation__CU">
> <eAnnotations xmi:id="_6Fndv-jzEdulJtUB9wa0tQ"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6FndxejzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_Dc9UcOmSEduTONvRJBt5Ow" name="base_Class">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_6FndwOjzEdulJtUB9wa0tQ" name="Documentation__RG">
> <eAnnotations xmi:id="_6FndwejzEdulJtUB9wa0tQ"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6Fndx-jzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_DdGeYOmSEduTONvRJBt5Ow" name="base_Class">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> </contents>
> </eAnnotations>
> <packageImport xmi:id="_6FndwujzEdulJtUB9wa0tQ" visibility="private">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
> </packageImport>
> <packageImport xmi:id="_6Fndw-jzEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
> </packageImport>
> <packageImport xmi:id="_6FndxOjzEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
> </packageImport>
> <packagedElement xmi:type="uml:Stereotype"
> xmi:id="_6FndxejzEdulJtUB9wa0tQ" name="CU">
> <ownedAttribute xmi:id="_6FndxujzEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_6FndyejzEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
> </ownedAttribute>
> </packagedElement>
> <packagedElement xmi:type="uml:Stereotype"
> xmi:id="_6Fndx-jzEdulJtUB9wa0tQ" name="RG">
> <ownedAttribute xmi:id="_6FndyOjzEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_6FndzejzEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
> </ownedAttribute>
> </packagedElement>
> <packagedElement xmi:type="uml:Extension"
> xmi:id="_6FndyejzEdulJtUB9wa0tQ" memberEnd="_6FndyujzEdulJtUB9wa0tQ
> _6FndxujzEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndyujzEdulJtUB9wa0tQ"
> name="extension_CU" visibility="private" type="_6FndxejzEdulJtUB9wa0tQ"
> aggregation="composite" association="_6FndyejzEdulJtUB9wa0tQ">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_6Fndy-jzEdulJtUB9wa0tQ" value="1"/>
> </ownedEnd>
> </packagedElement>
> <packagedElement xmi:type="uml:Extension"
> xmi:id="_6FndzejzEdulJtUB9wa0tQ" memberEnd="_6FndyOjzEdulJtUB9wa0tQ
> _6FndzujzEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndzujzEdulJtUB9wa0tQ"
> name="extension_RG" visibility="private" type="_6Fndx-jzEdulJtUB9wa0tQ"
> aggregation="composite" association="_6FndzejzEdulJtUB9wa0tQ">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_6Fndz-jzEdulJtUB9wa0tQ" value="1"/>
> </ownedEnd>
> </packagedElement>
> </uml:Profile>
>
> I'm able to load this resource from disk :
> ResourceSet resourceSet = new ResourceSetImpl();
> profileDocumentation_2_x = UMLElementLoader.loadProfile(
> "Documentation.profile.uml", resourceSet);
>
>
> public static Profile loadProfile(String modelFile, ResourceSet
> resourceSet) {
> Profile profile = null;
>
> Resource inputResource = resourceSet.createResource(URI
> .createFileURI(modelFile));
> try {
> inputResource.load(null);
> } catch (IOException exception) {
> exception.printStackTrace();
> }
>
> Iterator iterator = inputResource.getAllContents();
> while (iterator.hasNext()) {
> Object currentObject = iterator.next();
> if (currentObject instanceof Profile) {
> profile = (Profile) currentObject;
> break;
> }
> }
> return profile;
> }
>
>
> And I can get owned stereotype.
> and try to apply them:
>
> class_.applyStereotype(stereotype)
>
> But The sterotype is never apply and I can do it with the editor.
>
>
Re: Applying stereotype on Class [message #605447 is a reply to message #472226] Mon, 09 April 2007 00:46 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Guillaume,

From what is described, I cannot tell why applying a stereotype would work
from the editor but not programatically in your application.
You could set a breakpoint in ApplyStereotypeAction where the call to
element.applyStereotype() is being called and see if you are making the same
calls in your application and to make sure the stereotype is applied
properly.

Are there any errors in the log?

Is your stereotype applicable to the given element ?

The article:
http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Intro duction_to_UML2_Profiles/article.html
describes this in detail.

Regards,

- James.



"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:5722f98c5d32a7a53eb09a4ed38bd2b1$1@www.eclipse.org...
> Hi,
> I have a model on which I apply a profile.
>
> model.applyProfile(profileDocumentation);
>
> The profileDocumentation isn't null ;-) It cames from an other model.
> I get stereotype as I want.
>
> Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");
>
> Then I create a Class on which I want to apply the stereotype.
>
> org.eclipse.uml2.uml.Class class_ = package_.createOwnedClass(name,
> isAbstract);
>
> class_.applyStereotype(stereotype);
>
> But when I look in the UML editor the stereotype isn't applied to my
> class.
> If I select the class and use the menu Element to add a stereotype it
> works fine.
>
> Any idea ??
>
> Thx
>
> Guillaume
>
>
>
>
>
Re: Applying stereotype on Class [message #607432 is a reply to message #472496] Tue, 10 April 2007 08:36 Go to previous message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

I use a break point to track the stereotype and its value. Everything
seems to be good.
The stereotype has the right value.
The very ammzing thing is that the stereotype is available in the uml
editor and I can directly aplly it on a class.

Any idea

Thx

Guillaume
Re: Applying stereotype on Class [message #607444 is a reply to message #472503] Wed, 11 April 2007 15:08 Go to previous message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Still fighting against stereotype...
A few more information...

Here is the code I use to apply stereotype on a class.
The profile comes from an other model 'm' as parameter.

Profile profileDocumentation = m.getAppliedProfile("Documentation");

I apply this profile to a package

specificationTopLevelPackage.applyProfile(profileDocumentati on);

A stereotype is already defined in the profile, its metaclass (already
defined) is UML::Class.

class1 is an instance of Class.

class1.applyStereotype(profileDocumentation.getOwnedStereoty pe( "CU"));


When I look into the uml editor the profile is well applied to the package
but the stereotype isn't applied.
I can obviously apply it with the editor but not with my code.

Any idea ?

Thx

Guillaume
Re: Applying stereotype on Class [message #607446 is a reply to message #472508] Wed, 11 April 2007 15:42 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Guillaume,

Post your profile, and your application and I'll have a look.
It is difficult to say what is going on from the description.

- James.


"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:d142486b2f3af7a39bbfc3827990ce35$1@www.eclipse.org...
> Still fighting against stereotype...
> A few more information...
>
> Here is the code I use to apply stereotype on a class.
> The profile comes from an other model 'm' as parameter.
>
> Profile profileDocumentation = m.getAppliedProfile("Documentation");
>
> I apply this profile to a package
>
> specificationTopLevelPackage.applyProfile(profileDocumentati on);
>
> A stereotype is already defined in the profile, its metaclass (already
> defined) is UML::Class.
>
> class1 is an instance of Class.
>
> class1.applyStereotype(profileDocumentation.getOwnedStereoty pe( "CU"));
>
>
> When I look into the uml editor the profile is well applied to the package
> but the stereotype isn't applied.
> I can obviously apply it with the editor but not with my code.
>
> Any idea ?
>
> Thx
>
> Guillaume
>
>
Re: Applying stereotype on Class [message #607451 is a reply to message #472509] Thu, 12 April 2007 08:00 Go to previous message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Here is my profile (Documentation.profile.uml2):


<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML"
xmi:id="_NQileegqEdulJtUB9wa0tQ" name="Documentation"
metamodelReference="_NQilgugqEdulJtUB9wa0tQ">
<eAnnotations xmi:id="_NQileugqEdulJtUB9wa0tQ" source="attributes">
<details xmi:id="_NQile-gqEdulJtUB9wa0tQ" key="version" value="0"/>
</eAnnotations>
<eAnnotations xmi:id="_NQilfOgqEdulJtUB9wa0tQ" source="ePackages">
<contents xmi:type="ecore:EPackage" xmi:id="_NQilfegqEdulJtUB9wa0tQ"
name="Documentation_0"
nsURI="http:///Documentation_0_NBMdYugqEdulJtUB9wa0tQ.profile.uml2"
nsPrefix="Documentation_0">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_NQilfugqEdulJtUB9wa0tQ" name="Documentation__CU">
<eAnnotations xmi:id="_NQilf-gqEdulJtUB9wa0tQ" source="stereotype"
references="_NQilhegqEdulJtUB9wa0tQ"/>
</eClassifiers>
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_NQilgOgqEdulJtUB9wa0tQ" name="Documentation__RG">
<eAnnotations xmi:id="_NQilgegqEdulJtUB9wa0tQ" source="stereotype"
references="_NQilh-gqEdulJtUB9wa0tQ"/>
</eClassifiers>
</contents>
</eAnnotations>
<packageImport xmi:id="_NQilgugqEdulJtUB9wa0tQ" visibility="private">
<importedPackage xmi:type="uml:Model"
href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m8qbA686EdiEh 75YJ_3n8g"/>
</packageImport>
<packageImport xmi:id="_NQilg-gqEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href=" pathmap://UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2#_Ef RZoK86EdieaYgxtVWN8Q"/>
</packageImport>
<packageImport xmi:id="_NQilhOgqEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href=" pathmap://UML2_LIBRARIES/JavaPrimitiveTypes.library.uml2#_Rj myoK86EdieaYgxtVWN8Q"/>
</packageImport>
<ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilhegqEdulJtUB9wa0tQ"
name="CU">
<ownedAttribute xmi:id="_NQilhugqEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_NQiliegqEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
</ownedAttribute>
</ownedMember>
<ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilh-gqEdulJtUB9wa0tQ"
name="RG">
<ownedAttribute xmi:id="_NQiliOgqEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_NQiljegqEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
</ownedAttribute>
</ownedMember>
<ownedMember xmi:type="uml:Extension" xmi:id="_NQiliegqEdulJtUB9wa0tQ"
memberEnd="_NQiliugqEdulJtUB9wa0tQ _NQilhugqEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiliugqEdulJtUB9wa0tQ"
name="extension_CU" visibility="private" type="_NQilhegqEdulJtUB9wa0tQ"
association="_NQiliegqEdulJtUB9wa0tQ" aggregation="composite">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_NQili-gqEdulJtUB9wa0tQ" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger"
xmi:id="_NQiljOgqEdulJtUB9wa0tQ"/>
</ownedEnd>
</ownedMember>
<ownedMember xmi:type="uml:Extension" xmi:id="_NQiljegqEdulJtUB9wa0tQ"
memberEnd="_NQiliOgqEdulJtUB9wa0tQ _NQiljugqEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiljugqEdulJtUB9wa0tQ"
name="extension_RG" visibility="private" type="_NQilh-gqEdulJtUB9wa0tQ"
association="_NQiljegqEdulJtUB9wa0tQ" aggregation="composite">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_NQilj-gqEdulJtUB9wa0tQ" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger"
xmi:id="_NQilkOgqEdulJtUB9wa0tQ"/>
</ownedEnd>
</ownedMember>
</uml:Profile>


And my application:

private static Profile profileDocumentation;


public static Model createModelFromModel(Model m) {

Model model = UMLFactory.eINSTANCE.createModel();

Package specificationTopLevelPackage =
UseCaseModelToDocumentModel .createPackage(model.getNearestPackage(),"org.application.specification ");

profileDocumentation = m.getAppliedProfile("Documentation");

specificationTopLevelPackage.applyProfile(profileDocumentati on);

//try to create a class with the CU stereotype
Class myClass = specificationTopLevelPackage.createOwnedClass("my
class",false);

Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");

myClass.applyStereotype(stereotype);

return model;

}
}



Thx,

Guillaume
Re: Applying stereotype on Class [message #607461 is a reply to message #472532] Fri, 13 April 2007 02:21 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Guillaume,

This profile is based on an older version of UML2 (1.x) and it looks like
you are trying to apply it to a model based on a newer version (2.x). To
apply this profile, you'll need to migrate it to the new format first - see
the migration guide on the UML2 documentation page
( http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html)
for details.

Kenn

"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:ef39695386120905aafb7d432a1f2e64$1@www.eclipse.org...
> Here is my profile (Documentation.profile.uml2):
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML"
> xmi:id="_NQileegqEdulJtUB9wa0tQ" name="Documentation"
> metamodelReference="_NQilgugqEdulJtUB9wa0tQ">
> <eAnnotations xmi:id="_NQileugqEdulJtUB9wa0tQ" source="attributes">
> <details xmi:id="_NQile-gqEdulJtUB9wa0tQ" key="version" value="0"/>
> </eAnnotations>
> <eAnnotations xmi:id="_NQilfOgqEdulJtUB9wa0tQ" source="ePackages">
> <contents xmi:type="ecore:EPackage" xmi:id="_NQilfegqEdulJtUB9wa0tQ"
> name="Documentation_0"
> nsURI="http:///Documentation_0_NBMdYugqEdulJtUB9wa0tQ.profile.uml2"
> nsPrefix="Documentation_0">
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_NQilfugqEdulJtUB9wa0tQ" name="Documentation__CU">
> <eAnnotations xmi:id="_NQilf-gqEdulJtUB9wa0tQ" source="stereotype"
> references="_NQilhegqEdulJtUB9wa0tQ"/>
> </eClassifiers>
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_NQilgOgqEdulJtUB9wa0tQ" name="Documentation__RG">
> <eAnnotations xmi:id="_NQilgegqEdulJtUB9wa0tQ" source="stereotype"
> references="_NQilh-gqEdulJtUB9wa0tQ"/>
> </eClassifiers>
> </contents>
> </eAnnotations>
> <packageImport xmi:id="_NQilgugqEdulJtUB9wa0tQ" visibility="private">
> <importedPackage xmi:type="uml:Model"
> href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m8qbA686EdiEh 75YJ_3n8g"/>
> </packageImport>
> <packageImport xmi:id="_NQilg-gqEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href=" pathmap://UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2#_Ef RZoK86EdieaYgxtVWN8Q"/>
> </packageImport>
> <packageImport xmi:id="_NQilhOgqEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href=" pathmap://UML2_LIBRARIES/JavaPrimitiveTypes.library.uml2#_Rj myoK86EdieaYgxtVWN8Q"/>
> </packageImport>
> <ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilhegqEdulJtUB9wa0tQ"
> name="CU">
> <ownedAttribute xmi:id="_NQilhugqEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_NQiliegqEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Stereotype" xmi:id="_NQilh-gqEdulJtUB9wa0tQ"
> name="RG">
> <ownedAttribute xmi:id="_NQiliOgqEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_NQiljegqEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href=" pathmap://UML2_METAMODELS/UML2.metamodel.uml2#_m88uxq86EdiEh 75YJ_3n8g"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Extension" xmi:id="_NQiliegqEdulJtUB9wa0tQ"
> memberEnd="_NQiliugqEdulJtUB9wa0tQ _NQilhugqEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiliugqEdulJtUB9wa0tQ"
> name="extension_CU" visibility="private" type="_NQilhegqEdulJtUB9wa0tQ"
> association="_NQiliegqEdulJtUB9wa0tQ" aggregation="composite">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_NQili-gqEdulJtUB9wa0tQ" value="1"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_NQiljOgqEdulJtUB9wa0tQ"/>
> </ownedEnd>
> </ownedMember>
> <ownedMember xmi:type="uml:Extension" xmi:id="_NQiljegqEdulJtUB9wa0tQ"
> memberEnd="_NQiliOgqEdulJtUB9wa0tQ _NQiljugqEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_NQiljugqEdulJtUB9wa0tQ"
> name="extension_RG" visibility="private" type="_NQilh-gqEdulJtUB9wa0tQ"
> association="_NQiljegqEdulJtUB9wa0tQ" aggregation="composite">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_NQilj-gqEdulJtUB9wa0tQ" value="1"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_NQilkOgqEdulJtUB9wa0tQ"/>
> </ownedEnd>
> </ownedMember>
> </uml:Profile>
>
>
> And my application:
>
> private static Profile profileDocumentation;
>
>
> public static Model createModelFromModel(Model m) {
>
> Model model = UMLFactory.eINSTANCE.createModel();
>
> Package specificationTopLevelPackage = UseCaseModelToDocumentModel
> .createPackage(model.getNearestPackage(),"org.application.specification ");
>
> profileDocumentation = m.getAppliedProfile("Documentation");
>
> specificationTopLevelPackage.applyProfile(profileDocumentati on);
>
> //try to create a class with the CU stereotype
> Class myClass = specificationTopLevelPackage.createOwnedClass("my
> class",false);
>
> Stereotype stereotype = profileDocumentation.getOwnedStereotype("CU");
>
> myClass.applyStereotype(stereotype);
>
> return model;
>
> }
> }
>
>
>
> Thx,
>
> Guillaume
>
Re: Applying stereotype on Class [message #607669 is a reply to message #472536] Fri, 13 April 2007 07:47 Go to previous message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

Hi Kenn.
Thanks a lot for your post.

I was very surprising beacause I use MagicDraw to design this profile and
export it. But you're right the export are for version 1.x

I will migrate my profile.


Regards,
Guillaume
Re: Applying stereotype on Class [message #607675 is a reply to message #472538] Fri, 13 April 2007 15:08 Go to previous message
Eclipse UserFriend
Originally posted by: guillaume.clement.gmail.com

I just migrate the profile to a new file with the link you gave me Kenn.

Here it is (version 2.1):

<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
xmi:id="_6FnduejzEdulJtUB9wa0tQ" name="Documentation"
metamodelReference="_6FndwujzEdulJtUB9wa0tQ">
<eAnnotations xmi:id="_6FndvOjzEdulJtUB9wa0tQ"
source="http://www.eclipse.org/uml2/2.0.0/UML">
<contents xmi:type="ecore:EPackage" xmi:id="_GSAO8OmSEduTONvRJBt5Ow"
name="Documentation"
nsURI="http:///schemas/Documentation/_GR2d8OmSEduTONvRJBt5Ow/1"
nsPrefix="Documentation">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_GSAO8emSEduTONvRJBt5Ow" name="CU">
<eAnnotations xmi:id="_GSAO8umSEduTONvRJBt5Ow"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6FndxejzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_GSAO8-mSEduTONvRJBt5Ow" name="base_Class" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_GSAO9OmSEduTONvRJBt5Ow" name="RG">
<eAnnotations xmi:id="_GSAO9emSEduTONvRJBt5Ow"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6Fndx-jzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_GSAO9umSEduTONvRJBt5Ow" name="base_Class" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
</contents>
<contents xmi:type="ecore:EPackage" xmi:id="_6FndvejzEdulJtUB9wa0tQ"
name="Documentation_0"
nsURI="http:///Documentation_0_57fJA-jzEdulJtUB9wa0tQ.profile.uml2"
nsPrefix="Documentation_0">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_6FndvujzEdulJtUB9wa0tQ" name="Documentation__CU">
<eAnnotations xmi:id="_6Fndv-jzEdulJtUB9wa0tQ"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6FndxejzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_Dc9UcOmSEduTONvRJBt5Ow" name="base_Class">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_6FndwOjzEdulJtUB9wa0tQ" name="Documentation__RG">
<eAnnotations xmi:id="_6FndwejzEdulJtUB9wa0tQ"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_6Fndx-jzEdulJtUB9wa0tQ"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_DdGeYOmSEduTONvRJBt5Ow" name="base_Class">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
</contents>
</eAnnotations>
<packageImport xmi:id="_6FndwujzEdulJtUB9wa0tQ" visibility="private">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
</packageImport>
<packageImport xmi:id="_6Fndw-jzEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packageImport xmi:id="_6FndxOjzEdulJtUB9wa0tQ">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_6FndxejzEdulJtUB9wa0tQ" name="CU">
<ownedAttribute xmi:id="_6FndxujzEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_6FndyejzEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_6Fndx-jzEdulJtUB9wa0tQ" name="RG">
<ownedAttribute xmi:id="_6FndyOjzEdulJtUB9wa0tQ" name="base_Class"
visibility="private" association="_6FndzejzEdulJtUB9wa0tQ">
<type xmi:type="uml:Class"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension"
xmi:id="_6FndyejzEdulJtUB9wa0tQ" memberEnd="_6FndyujzEdulJtUB9wa0tQ
_6FndxujzEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndyujzEdulJtUB9wa0tQ"
name="extension_CU" visibility="private" type="_6FndxejzEdulJtUB9wa0tQ"
aggregation="composite" association="_6FndyejzEdulJtUB9wa0tQ">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_6Fndy-jzEdulJtUB9wa0tQ" value="1"/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Extension"
xmi:id="_6FndzejzEdulJtUB9wa0tQ" memberEnd="_6FndyOjzEdulJtUB9wa0tQ
_6FndzujzEdulJtUB9wa0tQ">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndzujzEdulJtUB9wa0tQ"
name="extension_RG" visibility="private" type="_6Fndx-jzEdulJtUB9wa0tQ"
aggregation="composite" association="_6FndzejzEdulJtUB9wa0tQ">
<upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="_6Fndz-jzEdulJtUB9wa0tQ" value="1"/>
</ownedEnd>
</packagedElement>
</uml:Profile>

I'm able to load this resource from disk :
ResourceSet resourceSet = new ResourceSetImpl();
profileDocumentation_2_x = UMLElementLoader.loadProfile(
"Documentation.profile.uml", resourceSet);


public static Profile loadProfile(String modelFile, ResourceSet
resourceSet) {
Profile profile = null;

Resource inputResource = resourceSet.createResource(URI
.createFileURI(modelFile));
try {
inputResource.load(null);
} catch (IOException exception) {
exception.printStackTrace();
}

Iterator iterator = inputResource.getAllContents();
while (iterator.hasNext()) {
Object currentObject = iterator.next();
if (currentObject instanceof Profile) {
profile = (Profile) currentObject;
break;
}
}
return profile;
}


And I can get owned stereotype.
and try to apply them:

class_.applyStereotype(stereotype)

But The sterotype is never apply and I can do it with the editor.
Re: Applying stereotype on Class [message #607697 is a reply to message #472539] Mon, 16 April 2007 18:54 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Guillaume,

What do you mean by "stereotype is never apply"? Are you seeing any
exceptions (e.g. IllegalArgumentException)? Or is the stereotype application
just not being serialized?

Kenn

"Guillaume Clement" <guillaume.clement@gmail.com> wrote in message
news:2ae8e100ac7cf4d54f4f21c30322a62a$1@www.eclipse.org...
>I just migrate the profile to a new file with the link you gave me Kenn.
>
> Here it is (version 2.1):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_6FnduejzEdulJtUB9wa0tQ" name="Documentation"
> metamodelReference="_6FndwujzEdulJtUB9wa0tQ">
> <eAnnotations xmi:id="_6FndvOjzEdulJtUB9wa0tQ"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <contents xmi:type="ecore:EPackage" xmi:id="_GSAO8OmSEduTONvRJBt5Ow"
> name="Documentation"
> nsURI="http:///schemas/Documentation/_GR2d8OmSEduTONvRJBt5Ow/1"
> nsPrefix="Documentation">
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_GSAO8emSEduTONvRJBt5Ow" name="CU">
> <eAnnotations xmi:id="_GSAO8umSEduTONvRJBt5Ow"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6FndxejzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_GSAO8-mSEduTONvRJBt5Ow" name="base_Class" ordered="false"
> lowerBound="1">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_GSAO9OmSEduTONvRJBt5Ow" name="RG">
> <eAnnotations xmi:id="_GSAO9emSEduTONvRJBt5Ow"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6Fndx-jzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_GSAO9umSEduTONvRJBt5Ow" name="base_Class" ordered="false"
> lowerBound="1">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> </contents>
> <contents xmi:type="ecore:EPackage" xmi:id="_6FndvejzEdulJtUB9wa0tQ"
> name="Documentation_0"
> nsURI="http:///Documentation_0_57fJA-jzEdulJtUB9wa0tQ.profile.uml2"
> nsPrefix="Documentation_0">
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_6FndvujzEdulJtUB9wa0tQ" name="Documentation__CU">
> <eAnnotations xmi:id="_6Fndv-jzEdulJtUB9wa0tQ"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6FndxejzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_Dc9UcOmSEduTONvRJBt5Ow" name="base_Class">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xmi:type="ecore:EClass"
> xmi:id="_6FndwOjzEdulJtUB9wa0tQ" name="Documentation__RG">
> <eAnnotations xmi:id="_6FndwejzEdulJtUB9wa0tQ"
> source="http://www.eclipse.org/uml2/2.0.0/UML"
> references="_6Fndx-jzEdulJtUB9wa0tQ"/>
> <eStructuralFeatures xmi:type="ecore:EReference"
> xmi:id="_DdGeYOmSEduTONvRJBt5Ow" name="base_Class">
> <eType xmi:type="ecore:EClass"
> href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
> </eStructuralFeatures>
> </eClassifiers>
> </contents>
> </eAnnotations>
> <packageImport xmi:id="_6FndwujzEdulJtUB9wa0tQ" visibility="private">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
> </packageImport>
> <packageImport xmi:id="_6Fndw-jzEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
> </packageImport>
> <packageImport xmi:id="_6FndxOjzEdulJtUB9wa0tQ">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
> </packageImport>
> <packagedElement xmi:type="uml:Stereotype"
> xmi:id="_6FndxejzEdulJtUB9wa0tQ" name="CU">
> <ownedAttribute xmi:id="_6FndxujzEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_6FndyejzEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
> </ownedAttribute>
> </packagedElement>
> <packagedElement xmi:type="uml:Stereotype"
> xmi:id="_6Fndx-jzEdulJtUB9wa0tQ" name="RG">
> <ownedAttribute xmi:id="_6FndyOjzEdulJtUB9wa0tQ" name="base_Class"
> visibility="private" association="_6FndzejzEdulJtUB9wa0tQ">
> <type xmi:type="uml:Class"
> href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
> </ownedAttribute>
> </packagedElement>
> <packagedElement xmi:type="uml:Extension"
> xmi:id="_6FndyejzEdulJtUB9wa0tQ" memberEnd="_6FndyujzEdulJtUB9wa0tQ
> _6FndxujzEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndyujzEdulJtUB9wa0tQ"
> name="extension_CU" visibility="private" type="_6FndxejzEdulJtUB9wa0tQ"
> aggregation="composite" association="_6FndyejzEdulJtUB9wa0tQ">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_6Fndy-jzEdulJtUB9wa0tQ" value="1"/>
> </ownedEnd>
> </packagedElement>
> <packagedElement xmi:type="uml:Extension"
> xmi:id="_6FndzejzEdulJtUB9wa0tQ" memberEnd="_6FndyOjzEdulJtUB9wa0tQ
> _6FndzujzEdulJtUB9wa0tQ">
> <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_6FndzujzEdulJtUB9wa0tQ"
> name="extension_RG" visibility="private" type="_6Fndx-jzEdulJtUB9wa0tQ"
> aggregation="composite" association="_6FndzejzEdulJtUB9wa0tQ">
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="_6Fndz-jzEdulJtUB9wa0tQ" value="1"/>
> </ownedEnd>
> </packagedElement>
> </uml:Profile>
>
> I'm able to load this resource from disk :
> ResourceSet resourceSet = new ResourceSetImpl();
> profileDocumentation_2_x = UMLElementLoader.loadProfile(
> "Documentation.profile.uml", resourceSet);
>
>
> public static Profile loadProfile(String modelFile, ResourceSet
> resourceSet) {
> Profile profile = null;
>
> Resource inputResource = resourceSet.createResource(URI
> .createFileURI(modelFile));
> try {
> inputResource.load(null);
> } catch (IOException exception) {
> exception.printStackTrace();
> }
>
> Iterator iterator = inputResource.getAllContents();
> while (iterator.hasNext()) {
> Object currentObject = iterator.next();
> if (currentObject instanceof Profile) {
> profile = (Profile) currentObject;
> break;
> }
> }
> return profile;
> }
>
>
> And I can get owned stereotype.
> and try to apply them:
>
> class_.applyStereotype(stereotype)
>
> But The sterotype is never apply and I can do it with the editor.
>
>
Previous Topic:mapping of an association (with an interface as member end) to a link in the instance diagram !?
Next Topic:minor extensions to the UML metamodel
Goto Forum:
  


Current Time: Thu Mar 28 13:55:51 GMT 2024

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

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

Back to the top