static profiles - not working ;) [message #625917] |
Tue, 22 January 2008 14:26 |
Stefan Kuhn Messages: 355 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------080903030902080901060108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
hi all,
I've followed this tutorial:
----------- Create your Profile -------------
1. Create your uml profile as you would normally ( For example, create a
stereotype called MyExtendedClass that extends uml:Class ). (see the getting
started article for details ). (Call it My.profile.uml for example)
2. ** don't do the "define" step ***
3. On your profile, apply the <<ePackage>> stereotype from the existing
Ecore profile.
4. Set the nsURI to something ... say http://www.myOrg/MyProfile
------- Generate code ---------
1. Create an EMF project as you would from any other .uml model to generate
code from but specify your profile as the source ( My.profile.uml )
2. Select the "Process All" options when loading your My.profile.uml.
3. Generate code as you would normally from the resulting .genmodel.
------- Using your profile ------
Up to this point, things were pretty easy. Here comes the tricky part...
1. Move your previously generated code for your profile to your development
environment.
2. Create a new plugin in your development environment ( say a JUnit plugin
to get started with ).
3. In your JUnit plugin test, add the line:
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
id of the profile in your model.
4. Create a resource set and load your My.profile.uml.
5. Next, Load your profile using..
Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
.... )
from the already generated MyProfilePackage from the "Generate Code"
step.
6. Next, obtain your stereotype with..
Stereotype myStereotype =
myProfile.getOwnedStereotype("MyExtendedClass");
7. This is the interesting part ... Apply your stereotype as follows:
MyExtendedClass myExtendedClass =
(MyExtendedClass)myClass.applyStereotype(myStereotype);
Notice how you do not get a stereotype application but rather a type of
"MyExtendedClass".
8. Now you have full access to setting variagbles to MyExtendedClass etc.
--- how cool is that ;) ----
and couldn't get it running. The reason is that
package_.applyProfile(myProfile); calls ProfileOperations: EPackage
getDefinition(Profile profile). This calls getTaggedValue(package_,
"Ecore" ... which -since I skipped the the define step (2)- is always
not there (null).
I've attached my test code and the .profile.uml.
For online-viewing, see http://rafb.net/p/9BbS1L94.html
The result of the code is:
>>>>>>>>>>>>>
Content of ProfileResi
org.eclipse.uml2.uml.internal.impl.ProfileImpl@1f195fc (name: My,
visibility: <unset>) (visibility: public)
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@1afd9cc (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@3e926 (name: EPackage)
(instanceClassName: null) (abstract: false, interface: false)) (mixed:
[], anyAttribute: [base_Package=_EVrQ0MicEdyuvNC82dJYdg,
packageName=myProf, nsURI=http://www.my.org/Profile])
myProfile: org.eclipse.uml2.uml.internal.impl.ProfileImpl@1f195fc (name:
My, visibility: <unset>) (visibility: public)
Profile could not be applied
java.lang.IllegalArgumentException:
org.eclipse.uml2.uml.internal.impl.ProfileImpl@1f195fc (name: My,
visibility: <unset>) (visibility: public)
at
org.eclipse.uml2.uml.internal.operations.PackageOperations.a pplyProfile(PackageOperations.java:524)
at
org.eclipse.uml2.uml.internal.impl.PackageImpl.applyProfile( PackageImpl.java:1051)
at test.StaticProfile.testProfile(StaticProfile.java:102)
Stereotypes
at test.StaticProfile.main(StaticProfile.java:32
What am I doing wrong?
-stefan
--------------080903030902080901060108
Content-Type: text/xml;
name="GUI_OiO.profile.uml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="GUI_OiO.profile.uml"
<?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/4" 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/4 pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
<uml:Profile xmi:id="_12_5_1_15200e0_1191951371278_589868_232" name="GuiProfile" metamodelReference="_0metamodelReferenceGUI_OiO">
<packageImport xmi:id="_0metamodelReferenceGUI_OiO">
<importedPackage xmi:type="uml:Model" href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
</packageImport>
<packageImport xmi:id="_0primitiveTypesGUI_OiO">
<importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packageImport xmi:id="_0javaPrimitiveTypesGUI_OiO">
<importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191951444711_532617_254" name="UIControl" isAbstract="true">
<ownedAttribute xmi:id="_12_5_1_15200e0_1191951461747_586671_257" name="base_Class" visibility="private" association="_12_5_1_15200e0_1191951461742_136617_256">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191951497116_308118_278" name="name" visibility="public">
<type xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191951511530_812133_281" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191951511530_782080_280" name="" value="1"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191951461742_136617_256" name="" memberEnd="_12_5_1_15200e0_1191951461749_945624_258 _12_5_1_15200e0_1191951461747_586671_257">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191951461749_945624_258" name="extension_" visibility="private" type="_12_5_1_15200e0_1191951444711_532617_254" aggregation="composite" association="_12_5_1_15200e0_1191951461742_136617_256">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191951461750_90795_260" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191951461749_924987_259" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Enumeration" xmi:id="_12_5_1_15200e0_1191951577864_290094_283" name="UIContainerType">
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951609693_223765_302" name="COMPOSITE"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951633949_930543_304" name="SECTION"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951641341_712694_306" name="DIALOG"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951647549_41585_308" name="WIZARD"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951654389_673842_310" name="VIEW"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951660149_296674_312" name="TABFOLDER"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951669877_167411_314" name="GROUP"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191951677165_910462_316" name="SCREEN"/>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191951690312_464217_319" name="UIContainer">
<generalization xmi:id="_12_5_1_15200e0_1191951750360_472032_346" isSubstitutable="false" general="_12_5_1_15200e0_1191951444711_532617_254"/>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191951692820_263208_322" name="base_Class" visibility="private" association="_12_5_1_15200e0_1191951692820_933016_321">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191951718334_382224_343" name="type" visibility="public" type="_12_5_1_15200e0_1191951577864_290094_283">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191952749590_789899_785" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191952749590_588235_784" name="" value="1"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191951692820_933016_321" name="" memberEnd="_12_5_1_15200e0_1191951692820_263208_322 _12_5_1_15200e0_1191951692821_296714_323">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191951692821_296714_323" name="extension_" visibility="private" type="_12_5_1_15200e0_1191951690312_464217_319" aggregation="composite" association="_12_5_1_15200e0_1191951692820_933016_321">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191951692821_920088_325" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191951692821_171918_324" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191951761873_224879_371" name="UIDataControl" isAbstract="true">
<generalization xmi:id="_12_5_1_15200e0_1191951789855_785392_447" isSubstitutable="false" general="_12_5_1_15200e0_1191951444711_532617_254"/>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191951767428_923400_374" name="base_Class" visibility="private" association="_12_5_1_15200e0_1191951767428_598809_373">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191951767428_598809_373" name="" memberEnd="_12_5_1_15200e0_1191951767428_923400_374 _12_5_1_15200e0_1191951767428_297656_375">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191951767428_297656_375" name="extension_" visibility="private" type="_12_5_1_15200e0_1191951761873_224879_371" aggregation="composite" association="_12_5_1_15200e0_1191951767428_598809_373">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191951767429_574722_377" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191951767429_117114_376" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191952240606_445519_606" name="children UIContainer->UIControl">
<ownedAttribute xmi:id="_12_5_1_15200e0_1191952252681_709833_609" name="base_Association" visibility="private" association="_12_5_1_15200e0_1191952252680_904621_608">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Association"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191952252680_904621_608" name="" memberEnd="_12_5_1_15200e0_1191952252681_480707_610 _12_5_1_15200e0_1191952252681_709833_609">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191952252681_480707_610" name="extension_" visibility="private" type="_12_5_1_15200e0_1191952240606_445519_606" aggregation="composite" association="_12_5_1_15200e0_1191952252680_904621_608">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191952252681_30153_612" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191952252681_804516_611" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Enumeration" xmi:id="_12_5_1_15200e0_1191952434982_520771_645" name="UIComplexDataControlType">
<ownedLiteral xmi:id="_12_5_1_15200e0_1191952449406_918649_664" name="TABLE"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191952466006_58192_666" name="TREE"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191952472486_54160_668" name="LIST"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191952480478_349858_670" name="FORM"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191952487294_895150_672" name="EDITOR"/>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191952552688_338708_675" name="dataControlChildren UIComplexDataControl->UIDataControl">
<ownedAttribute xmi:id="_12_5_1_15200e0_1191952555379_166950_678" name="base_Association" visibility="private" association="_12_5_1_15200e0_1191952555379_305362_677">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Association"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191952555379_305362_677" name="" memberEnd="_12_5_1_15200e0_1191952555380_36450_679 _12_5_1_15200e0_1191952555379_166950_678">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191952555380_36450_679" name="extension_" visibility="private" type="_12_5_1_15200e0_1191952552688_338708_675" aggregation="composite" association="_12_5_1_15200e0_1191952555379_305362_677">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191952555380_894856_681" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191952555380_129948_680" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191952642401_691287_756" name="UIComplexDataControl">
<generalization xmi:id="_12_5_1_15200e0_1191952806356_666989_789" isSubstitutable="false" general="_12_5_1_15200e0_1191951761873_224879_371"/>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191952645284_114215_759" name="base_Class" visibility="private" association="_12_5_1_15200e0_1191952645284_484596_758">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191952721352_812895_780" name="type" visibility="public" type="_12_5_1_15200e0_1191952434982_520771_645">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191952793559_45663_787" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191952793558_859189_786" name="" value="1"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191952645284_484596_758" name="" memberEnd="_12_5_1_15200e0_1191952645284_114215_759 _12_5_1_15200e0_1191952645284_100915_760">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191952645284_100915_760" name="extension_" visibility="private" type="_12_5_1_15200e0_1191952642401_691287_756" aggregation="composite" association="_12_5_1_15200e0_1191952645284_484596_758">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191952645284_649162_762" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191952645284_136129_761" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191953026669_238956_938" name="complexDataControl UIDataControl->UIComplexDataControl">
<ownedAttribute xmi:id="_12_5_1_15200e0_1191953028759_239041_941" name="base_Association" visibility="private" association="_12_5_1_15200e0_1191953028759_918634_940">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Association"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191953028759_918634_940" name="" memberEnd="_12_5_1_15200e0_1191953028759_804402_942 _12_5_1_15200e0_1191953028759_239041_941">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191953028759_804402_942" name="extension_" visibility="private" type="_12_5_1_15200e0_1191953026669_238956_938" aggregation="composite" association="_12_5_1_15200e0_1191953028759_918634_940">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191953028759_852543_944" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191953028759_777965_943" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Stereotype" xmi:id="_12_5_1_15200e0_1191953113254_841091_964" name="UIPrimitiveDataControl">
<generalization xmi:id="_12_5_1_15200e0_1191953338087_458822_1019" isSubstitutable="false" general="_12_5_1_15200e0_1191951761873_224879_371"/>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191953116891_548625_967" name="base_Class" visibility="private" association="_12_5_1_15200e0_1191953116891_964982_966">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
<ownedAttribute xmi:id="_12_5_1_15200e0_1191953185029_1046_1014" name="type" visibility="public" type="_12_5_1_15200e0_1191953126646_606954_989">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191953279608_844377_1017" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191953279608_801287_1016" name="" value="1"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension" xmi:id="_12_5_1_15200e0_1191953116891_964982_966" name="" memberEnd="_12_5_1_15200e0_1191953116892_385941_968 _12_5_1_15200e0_1191953116891_548625_967">
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_12_5_1_15200e0_1191953116892_385941_968" name="extension_" visibility="private" type="_12_5_1_15200e0_1191953113254_841091_964" aggregation="composite" association="_12_5_1_15200e0_1191953116891_964982_966">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_12_5_1_15200e0_1191953116892_279445_970" name="" value="1"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_12_5_1_15200e0_1191953116892_356906_969" name=""/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Enumeration" xmi:id="_12_5_1_15200e0_1191953126646_606954_989" name="UIPrimitiveDataControlType">
<ownedLiteral xmi:id="_12_5_1_15200e0_1191953148501_880223_1008" name="BUTTON"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191953162205_626311_1010" name="TEXT"/>
<ownedLiteral xmi:id="_12_5_1_15200e0_1191953167709_704400_1012" name="LABEL"/>
</packagedElement>
<profileApplication xmi:id="_P9oBoMhrEdyBsvVY6aeXSQ">
<eAnnotations xmi:id="_P-C4YMhrEdyBsvVY6aeXSQ" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
</eAnnotations>
<appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
</profileApplication>
</uml:Profile>
<Ecore:EPackage xmi:id="_bRkbEMhrEdyBsvVY6aeXSQ" base_Package="_12_5_1_15200e0_1191951371278_589868_232" packageName="guiProfile" nsPrefix="guiProfileNS" nsURI="http://www.oio.de/mdsd/tools/guiModel/guiProfile" basePackage="de.oio.mdsd.tools.guiModel" prefix="GUI_OIO"/>
</xmi:XMI>
--------------080903030902080901060108
Content-Type: text/x-java;
name="StaticProfile.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="StaticProfile.java"
package test;
import java.io.IOException;
import java.util.Map;
import myProf.MyClass;
import myProf.MyProfPackage;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.eclipse.uml2.uml.util.UMLUtil;
public class StaticProfile {
public static void main(String[] args){
try {
testProfile();
} catch (Exception e) {
e.printStackTrace();
}
}
private final static String workspace = "/home/qn/Coden/workspace-oAW/umlStatic/model/My.profile.uml ";
// private final static String runtime = " /home/qn/Coden/runtime-New_configuration/umlStatic/model/My. profile.uml ";
private final static String testModel = " /home/qn/Coden/runtime-New_configuration/umlStatic.test/src/ test/model.uml ";
private final static String umlJarLoc = " jar:file://home/qn/Coden/eclipse-oAW/plugins/org.eclipse.uml 2.uml.resources_2.1.0.v200706251652.jar!/";
private final static String path2profile = workspace;
// private final static String profileEPackageName = "myProf";
private final static String profileNS = MyProfPackage.eNS_URI; //"http://www.my.org/Profile";
private final static String suffix = "#_EVrQ0MicEdyuvNC82dJYdg";
private static void testProfile() {
System.out.println(">>>>>>>>>>>>>");
System.out.println();
// UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile EPackageName, URI.createURI(path2profile+suffix));
// UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile EPackageName, URI.createURI(path2profile));
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile NS, URI.createURI(path2profile+suffix));
// UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile NS, URI.createURI(path2profile));
// UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile EPackageName, URI.createURI(path2profile+suffix));
// Map<String, URI> nsURI2ProfileMap = UMLPlugin.getEPackageNsURIToProfileLocationMap();
// uml init
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(umlJarLoc);
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
Map<String,Object> p2fMap = resourceSet.getResourceFactoryRegistry().getProtocolToFactor yMap();
// uml init ()
// Resource testResi = resourceSet.getResource(URI.createURI(path2profile+suffix), true);
// System.out.println("Content of TestResi");
// for(EObject obj : testResi.getContents()){
// System.out.println(obj);
// }
Resource resi = resourceSet.createResource(URI.createFileURI(testModel));
Resource profileResi = resourceSet.getResource(URI.createFileURI(path2profile), true);
System.out.println("Content of ProfileResi");
for(EObject obj : profileResi.getContents()){
System.out.println(obj);
}
// uml bsp data
Package package_ = UMLFactory.eINSTANCE.createPackage();
resi.getContents().add(package_);
package_.setName("MeinPacket");
Class clazz = UMLFactory.eINSTANCE.createClass();
clazz.setPackage(package_);
clazz.setName("MeineKlasse2");
// uml bsp data()
Profile myProfile = UMLUtil.getProfile(MyProfPackage.eINSTANCE,package_);
if(myProfile==null){
System.out.println("myProfile==null");
} else{
System.out.println("myProfile: "+myProfile);
}
try{
package_.applyProfile(myProfile);
} catch (Exception e) {
System.out.println("Profile could not be applied");
e.printStackTrace();
}
System.out.println("\nStereotypes");
for(Stereotype stereo : clazz.getApplicableStereotypes()){
System.out.println(stereo);
}
// save
try {
resi.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
}
--------------080903030902080901060108--
|
|
|
Powered by
FUDForum. Page generated in 0.01372 seconds