首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Acceleo检查SysML原型?

如何使用Acceleo检查SysML原型?
EN

Stack Overflow用户
提问于 2017-05-28 16:35:07
回答 1查看 566关注 0票数 1

我使用Eclipse4.6.3 (Neon.3)和Acceleo3.6.6、Paprus2.0.3和Papyrus SysML 1.40.10.1。如何从Acceleo脚本中检查,我的模型的一个类是否应用了SysML块原型?getAppliedStereotypes()方法只适用于我自己定义的原型,而不适用于SysML 1.4。

在我的UML模型(Papyrus项目)中,我创建了

  • "Class1“,我已将我自己的原型"MyProfile::MyStereotype”通过" Profile“/"Update”在“模型资源管理器”中创建
  • "Class2“,我在”属性“/”配置文件“/”应用原型“下应用了”SysML::Block::Block“

在generate.mtl中的Acceleo项目中,如果我在这两个类中的每个类调用getAppliedStereotypes(),我只会得到"Class1“的原型,而对于"Class2”则没有。

model.uml:

代码语言:javascript
复制
<?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:

代码语言:javascript
复制
<?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:

代码语言:javascript
复制
[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]

产出:

代码语言:javascript
复制
Class1
  org.eclipse.uml2.uml.internal.impl.StereotypeImpl@485a3466 (name: MyStereotype, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
Class2

papyrus_project:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2017-06-08 08:25:54

我不太清楚里面发生了什么,但我会大胆猜测,说Acceleo无法在这里解析SysML配置文件。

如果您查看生成的启动程序(您的"@main“mtl模板旁边的java文件),您将看到一个"registerPackages”方法。您需要找到适当的URI来注册SysML配置文件,以便在您的应用程序中使用;您可以看到一个示例,说明如何在Acceleo常见问题上对以前版本的纸莎草记录进行注册。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44229639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档