简体   繁体   English

如何在QVTo转换中的UML标准配置文件中应用构造型?

[英]How to apply a stereotype from UML Standard Profile inside QVTo transformation?

Inside a QVTo transformation I want to apply the <<Create>> stereotype from the UML Standard Profile to a newly created Operation. 在QVTo转换中,我想将UML标准配置文件中的<<Create>>构造型应用于新创建的Operation。 On page 678 of the UML spec it says, that it is applicable to BehavioralFeatures and consequently to Operations. 它在UML规范的第678页上说,它适用于BehavioralFeatures,因此适用于Operations。 I tried the following inside a helper, but to no avail: 我在帮助器中尝试了以下操作,但无济于事:

var _result := object Class {};

var const := object Operation {
    name := "Constructor";
    _class := _result;

    ownedParameter += object Parameter{
        name := "return";
        type := _result;
        direction := ParameterDirectionKind::_return;
    };
};

_result.ownedOperation += const;

log("", SP.ownedStereotype![name = "Create"]));
// ", data: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@4e796d93 (name: Create, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)"

log("", const.getApplicableStereotypes());
// , data: []

log("", const.applyStereotype(SP.ownedStereotype![name = "Create"]));
// ", data: <Invalid>"

The transformation works on an inout sourceModel : UML and I checked that the profile is applied to the sourceModel in advance: 转换适用于inout sourceModel : UML ,我事先检查了配置文件是否已应用到sourceModel

property SP = sourceModel.rootObjects()![Model].getAppliedProfile("StandardProfile");

What am I doing wrong and how is this done correctly? 我在做什么错,如何正确完成?

I found out that I can apply the stereotype from the context of a mapping after it was returned by the helper and added to an element like this: 我发现可以在帮助者返回并将其添加到这样的元素后,从映射的上下文中应用构造型:

element.allSubobjectsOfKind(Operation)
    // TODO: Refine selector if there is more than one Operation
    .applyStereotype(SP.ownedStereotype![name = "Create"]);

I suspect, that inside the helper the element does not belong to the output model, yet, and therefore can not be applied a stereotype from a profile that is applied to the model. 我怀疑,在助手内部,该元素尚不属于输出模型,因此无法从应用于该模型的概要文件中应用构造型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将构造型应用于Eclipse UML-Designer中的操作 - Apply Stereotype to operation in Eclipse UML-Designer 如何从QVTo的生命线获取OrderedSet of OccurrenceSpecifications? - How to get an OrderedSet of OccurrenceSpecifications from a Lifeline in QVTo? 如何使用已部署的QVTo Eclipse插件 - How to use deployed QVTo Eclipse Plug-In 在Eclipse UML2 3.1中,如果原型B是原型A的泛化,那么B是否继承了A的元类扩展? - In Eclipse UML2 3.1, if stereotype B is a generalization of stereotype A, does B inherit the meta-class extension of A? 关闭图后,在Eclipse UML中显示原型应用 - show stereotype application in eclipse uml, after closing diagram 如何在独立应用程序中使用EMF创建和应用UML2原型? - How to create and apply a UML2 stereo-type using EMF in a standalone app? 从Eclipse UML2的.uml文件绘制图形UML图 - Draw a graphical UML diagram from .uml files of Eclipse UML2 Rational Software Architect:UML到Java转换:Java源代码布局 - Rational Software Architect: UML to Java transformation: Java Source Code Layout Papyrus UML:使用配置文件(元模型扩展)将类型添加到属性 - Papyrus UML: add a type to a property using a Profile (Metamodel Extension) 使用具有已应用配置文件的EMF加载UML模型 - Load UML Model with EMF that has an applied profile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM