2012-06-07 45 views
0

我正在開發一個使用OCLinEcore編輯器在OCL中定義的一些不變量的Ecore模型。在我的模型中,一些元素引用了EClassifier;在一些OCL約束中,我需要檢查引用的EClassifier是EDataType還是EClass。這裏,在OCLinEcore,模型類似於一個我:使用Ecore分類器的OCL約束 - 未知類型異常

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]; 
    } 
} 

然而,當我嘗試驗證我的模型的動態實例,異常出現以下消息:

而指派以「耦合」的 「兼容性」約束的評估異常發生:UNKNOW類型([E字形芯, EDataType])

當試圖在OCL交互式控制檯的表達,我獲得正確的結果。定義我的不變量時,我做錯了什麼?我如何編寫一個使用Ecore類型的不變量?

回答

1

愛德華Willink給了我the OCL forum的解釋和解決方法:

裸OCL不支持的Ecore的結合到一些有用的東西, 所以oclAsType(Ecore元::的EClass)從此一個懸而未決的參考每個 ecxpression是ECore文件中的獨立片段。

朱諾釋放因此增加了一個分機由此包 限定符可以是URI,因此,如果您看見上述序列化它 可能是 oclAsType(_'http://www.eclipse.org/emf/ 2002/Ecore的'::的Ecore ::的EClass)。

Juno版本還增加了靈活性,以確定是否使用新的 透視綁定與此擴展功能。在 窗口 - >首選項 - > OCL頁面中,確保 的默認代理的選定執行者爲 http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot