Applying stereotype on Class [message #472226] |
Wed, 04 April 2007 15:09 |
Eclipse User |
|
|
|
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 #472503 is a reply to message #472496] |
Tue, 10 April 2007 08:36 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #472532 is a reply to message #472509] |
Thu, 12 April 2007 08:00 |
Eclipse User |
|
|
|
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 #472538 is a reply to message #472536] |
Fri, 13 April 2007 07:47 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #607432 is a reply to message #472496] |
Tue, 10 April 2007 08:36 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #607451 is a reply to message #472509] |
Thu, 12 April 2007 08:00 |
Eclipse User |
|
|
|
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 #607669 is a reply to message #472536] |
Fri, 13 April 2007 07:47 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.06903 seconds