2017-05-28 65 views
1

我使用Eclipse 4.6.3(Neon.3)與Acceleo 3.6.6,Paprus 2.0.3和Papyrus SysML 1.4 0.10.1。 如何從Acceleo MTL腳本檢查我的模型的類是否應用了SysML塊原型?方法getAppliedStereotypes()僅適用於我自己定義的構造型,但不適用於SysML 1.4構造型。如何使用Acceleo檢查SysML定型?

在我的UML模型(紙莎草紙項目)我已經創建

  • 「1類」,而我已經通過「個人資料」應用於自己的刻板印象中的「模型瀏覽器」創建「我的資料:: MyStereotype」/「更新個人資料」 和

  • 「類2」,而我已在 「屬性」/ 「配置文件」/ 「應用定型」

在應用 「SysML的:: Blocks的::塊」 Acceleo公關如果我在這兩個類的每一個上調用getAppliedStereotypes(),我只會得到「Class1」的原型,但對於「Class2」卻沒有。

model.uml:

<?xml version="1.0" encoding="UTF-8"?> 
<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Blocks="http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks" xmlns:MyProfile="http:///schemas/MyProfile/__okhIEO5EeezquIZgVUJBA/0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks http://www.eclipse.org/papyrus/sysml/1.4/SysML#//blocks http:///schemas/MyProfile/__okhIEO5EeezquIZgVUJBA/0 MyProfile.profile.uml#__olvQUO5EeezquIZgVUJBA"> 
    <uml:Model xmi:id="_Jl27kEO4EeezquIZgVUJBA" name="RootElement"> 
    <packagedElement xmi:type="uml:Class" xmi:id="_LpXEYEO4EeezquIZgVUJBA" name="Class1"/> 
    <packagedElement xmi:type="uml:Class" xmi:id="_ZFGQwEO4EeezquIZgVUJBA" name="Class2"/> 
    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SLhJ0EO4EeezquIZgVUJBA"> 
     <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SLi_AEO4EeezquIZgVUJBA" source="http://www.eclipse.org/uml2/2.0.0/UML"> 
     <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/sysml/1.4/SysML#//blocks"/> 
     </eAnnotations> 
     <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML14_PROFILES/SysML.profile.uml#SysML.package_packagedElement_Blocks"/> 
    </profileApplication> 
    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="__om9ZkO5EeezquIZgVUJBA"> 
     <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__om9Z0O5EeezquIZgVUJBA" source="http://www.eclipse.org/uml2/2.0.0/UML"> 
     <references xmi:type="ecore:EPackage" href="MyProfile.profile.uml#__olvQUO5EeezquIZgVUJBA"/> 
     </eAnnotations> 
     <appliedProfile xmi:type="uml:Profile" href="MyProfile.profile.uml#__og2wEO5EeezquIZgVUJBA"/> 
    </profileApplication> 
    </uml:Model> 
    <Blocks:Block xmi:id="_bBkkgEO4EeezquIZgVUJBA" base_Class="_ZFGQwEO4EeezquIZgVUJBA"/> 
    <MyProfile:MyStereotype xmi:id="__ooykEO5EeezquIZgVUJBA" base_Class="_LpXEYEO4EeezquIZgVUJBA"/> 
</xmi:XMI> 

MyProfile.profile.uml:

<?xml version="1.0" encoding="UTF-8"?> 
<uml:Profile xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="__og2wEO5EeezquIZgVUJBA" name="MyProfile" metaclassReference="__oiE4EO5EeezquIZgVUJBA"> 
    <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__olvQEO5EeezquIZgVUJBA" source="http://www.eclipse.org/uml2/2.0.0/UML"> 
    <contents xmi:type="ecore:EPackage" xmi:id="__olvQUO5EeezquIZgVUJBA" name="MyProfile" nsURI="http:///schemas/MyProfile/__okhIEO5EeezquIZgVUJBA/0" nsPrefix="MyProfile"> 
     <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__om9YEO5EeezquIZgVUJBA" source="PapyrusVersion"> 
     <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__om9YUO5EeezquIZgVUJBA" key="Version" value="0.0.1"/> 
     <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__om9YkO5EeezquIZgVUJBA" key="Comment" value=""/> 
     <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__om9Y0O5EeezquIZgVUJBA" key="Copyright" value=""/> 
     <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__om9ZEO5EeezquIZgVUJBA" key="Date" value="28.05.17 17:26"/> 
     <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__om9ZUO5EeezquIZgVUJBA" key="Author" value=""/> 
     </eAnnotations> 
     <eClassifiers xmi:type="ecore:EClass" xmi:id="__olvQkO5EeezquIZgVUJBA" name="MyStereotype"> 
     <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__olvQ0O5EeezquIZgVUJBA" source="http://www.eclipse.org/uml2/2.0.0/UML" references="__og2wUO5EeezquIZgVUJBA"/> 
     <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="__olvREO5EeezquIZgVUJBA" name="base_Class" ordered="false" lowerBound="1"> 
      <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> 
     </eStructuralFeatures> 
     </eClassifiers> 
    </contents> 
    </eAnnotations> 
    <elementImport xmi:type="uml:ElementImport" xmi:id="__oiE4EO5EeezquIZgVUJBA"> 
    <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> 
    </elementImport> 
    <packagedElement xmi:type="uml:Stereotype" xmi:id="__og2wUO5EeezquIZgVUJBA" name="MyStereotype"> 
    <ownedAttribute xmi:type="uml:Property" xmi:id="__oir8kO5EeezquIZgVUJBA" name="base_Class" association="__oir8EO5EeezquIZgVUJBA"> 
     <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> 
    </ownedAttribute> 
    </packagedElement> 
    <packagedElement xmi:type="uml:Extension" xmi:id="__oir8EO5EeezquIZgVUJBA" name="Class_MyStereotype" memberEnd="__oir8UO5EeezquIZgVUJBA __oir8kO5EeezquIZgVUJBA"> 
    <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="__oir8UO5EeezquIZgVUJBA" name="extension_MyStereotype" type="__og2wUO5EeezquIZgVUJBA" aggregation="composite" association="__oir8EO5EeezquIZgVUJBA"/> 
    </packagedElement> 
</uml:Profile> 

generate.mtl:

[comment encoding = UTF-8 /] 
[module generate('http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks', 'http://www.eclipse.org/uml2/5.0.0/UML')] 


[template public generateModel(model : Model)] 
[comment @main/] 
[file (model.name, false, 'UTF-8')] 
    [for (c : Class | model.eContents(Class))] 
[c.name/] 
     [for (s : Stereotype | c.getAppliedStereotypes())] 
    [s/] 
     [/for] 
    [/for] 
[/file] 
[/template] 

輸出:

Class1 
    [email protected] (name: MyStereotype, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false) 
Class2 

papyrus_project:

papyrus_project 
papyrus_project/model.uml 
papyrus_project/MyProfile.profile.di 
papyrus_project/MyProfile.profile.notation 
papyrus_project/model.di 
papyrus_project/.project 
papyrus_project/MyProfile.profile.uml 
papyrus_project/model.notation 

acceleo_project:

acceleo_project 
acceleo_project/src 
acceleo_project/src/acceleo_project 
acceleo_project/src/acceleo_project/main 
acceleo_project/src/acceleo_project/main/generate.mtl 
acceleo_project/src/acceleo_project/main/Generate.java 
acceleo_project/src/acceleo_project/Activator.java 
acceleo_project/dst 
acceleo_project/dst/RootElement 
acceleo_project/build.properties 
acceleo_project/tasks 
acceleo_project/tasks/generate.xml 
acceleo_project/tasks/generateTarget.xml 
acceleo_project/.project 
acceleo_project/bin 
acceleo_project/bin/acceleo_project 
acceleo_project/bin/acceleo_project/Activator.class 
acceleo_project/bin/acceleo_project/main 
acceleo_project/bin/acceleo_project/main/Generate.class 
acceleo_project/bin/acceleo_project/main/generate.mtl 
acceleo_project/bin/acceleo_project/main/generate.emtl 
acceleo_project/.classpath 
acceleo_project/META-INF 
acceleo_project/META-INF/MANIFEST.MF 

回答

0

我真的不知道發生了什麼事在那裏,但我要胡亂猜測,說Acceleo不能在這裏解決SysML的輪廓。

如果你看看你生成的啓動器(你的「主」mtl模板旁邊的java文件),你會看到一個「registerPackages」方法。您將需要找到適當的URI來註冊SysML配置文件以供您的應用程序使用;你可以在the Acceleo FAQ上看到一個例子,說明它是如何爲以前版本的紙莎草紙完成的。