[英]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.