【发布时间】:2012-06-07 09:12:01
【问题描述】:
我正在使用 OCLinEcore 编辑器开发一个在 OCL 中定义了一些不变量的 Ecore 模型。在我的模型中,一些元素引用了 EClassifier;在某些 OCL 约束中,我需要检查所引用的 EClassifier 是 EDataType 还是 EClass。在 OCLinEcore 中,这是一个类似于我的模型:
import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/';
package Foo : foo = 'some_namespace'
{
class EndPoint
{
attribute name : String[1];
property type : ecore::EClassifier[1];
}
class Coupling
{
invariant Compatibility:
(destination.type.oclIsKindOf(ecore::EDataType) and source.type = destination.type) or
let destinationClass : ecore::EClass = destination.type.oclAsType(ecore::EClass) in
destinationClass.isSuperTypeOf(source.type.oclAsType(ecore::EClass));
property source : EndPoint[1];
property destination : EndPoint[1];
}
}
但是,当我尝试验证模型的动态实例时,会出现异常并显示以下消息:
委托评估时发生异常 “耦合”上的“兼容性”约束:未知类型([ecore, EDataType])
当我在 OCL 交互式控制台中尝试表达式时,我得到了正确的结果。定义我的不变量时我做错了什么吗?如何编写使用 Ecore 类型的不变量?
【问题讨论】:
标签: eclipse-emf eclipse-emf-ecore invariants ocl