第五章 展示與驗證
5.2 建立 QVT 轉換檔
5.2.2 專案執行 QVT 轉換檔
當建立的 QVT 撰寫完成並儲存後,即可選擇模型來使用此 QVT 檔進行轉 換,以下是Borland Together 執行 QVT 轉換的步驟。
Step 1:將左側目錄中選擇 Model Navigator 顯示,點選來源模型 Book,
後 在 平 台 上 排 的 工 具 列 依 序 選 擇 Model→Apply Transformation→QVT→From Workspace。
圖64. 選擇來源模型 Book 進行轉換
Step 2 : 在 出 現 的 視 窗 中 選 取 Business Project 目 錄 下 名 為 Tramsformation 的 qvt 檔並選擇下一步。
圖65. 選擇執行轉換語言檔
Step 3:此一步驟為設定目標模型存放之路徑,本研究將目標模型存放至原 本的專案中,故在其Target type 選擇 Existing container,URI 選擇 Business Project,而 Feature 選擇 Model 目錄下的 ownedMembers,
最後不勾選Clear conents 以保留來源模型。
圖66. 選擇目標模型存放位置
Step 4:完成上述動作並點選 Finish 後,即完成轉換,左側目錄下將產生轉 換之目標模型BookPSM。
圖67. 完成轉換後左側目錄圖 5.3 結果展示
在Borland Together 軟體平台根據第四章個案所執行其轉換規則與語法之結 果如 圖 68。在介面類別轉換中,根據 P3產生 Catalog Page、Book Details Page 與Shopping Cart Page 三張類別圖,其包含之屬性型態轉換為 HTML 相對應的屬 性型態,以及根據P4轉換其所連結至控制類別之 Dependency 關聯線。在控制類 別轉換中,根據規則B1產生出 Browse Books、Display Detail 與 Display Cart 三 個控制類別;根據規則B5產生出 Cart Items 一個類別;根據規則 B6則轉換出控 制類別與後台資料庫之Dependency 關聯線。在實體類別轉換中根據規則 D1產生 出Book、Order、Invoice 三個類別;根據規則 D2產生出 Order Items、Invoice Items 兩個類別;根據規則 D3與規則 D4產生出 Association 關聯線表達實體類別之間
的關係。
圖68. 本研究實作轉換之 PSM 結果圖
第六章 結論與建議
本研究詳細彙整QVT 語言,並以 QVT 撰寫模式轉換規則,將 QVT 轉換程 式碼運用在PIM 至 PSM 的自動化轉換上,使用者或企業能參考本研究的結果,
建構出不同的轉換規則與QVT 語言的應用。此外,本研究也提出一個轉換個案 實作,包含了PIM 模型的建立與 QVT 的執行轉換,也可成為日後的參考依據。
6.1 結果分析
本研究彙整並展示以QVT 建構模式轉換規則的過程,並且藉由實際個案的 操作,探討轉換結果以及QVT 與 Borland Together 軟體的優缺點。本研究在介面 類別未完成規則P1與規則 P2之轉換,規則 P1與 P2原本應會產生出的 Frameset、
Form 以及 Target 類別圖以及與控制類別之間的關聯線並無轉出。推究其原因,
過去有學者表示大部分的QVT 範例通常應用在簡單轉換上,也就是將單一個來 源模型元素轉換至單一個目標模型元素[16],故本研究在撰寫 QVT-O 的語法上,
應屬於使用基礎的對應來源圖形後並執行轉換,對於 PIM 中未出現的圖形,無 法對應並執行轉換。也有學者表示目前Ecplise 軟體平台可能無法執行 QVT 可用 的所有功能[7](Borland Together 是建構在 Ecplise 平台上執行),而目前也沒有 辦法確認QVT-O 語法是否可以新增圖形至目標模型中。因此在介面類別的 PSM 結果無法轉換出Frameset、Form 以及 Target 之間的關聯線與其新增之 Dependency 關聯線;而保持著與 PIM 相同,只有屬性以及其型態進行轉換。在控制類別以 及實體類別部分,由於來源模型中均有出現,故使用QVT-O 即成功轉換其類別 圖型別以及屬性,關聯線部分也將多對多關聯以MySQL 的應用平台表示之。本 研究將QVT 應用在轉換模型上的優缺點歸納如下:
優點一:函數應用
QVT-O 屬於命令式語言的語言,能夠將轉換規則撰寫成函數的方
式,並重複呼叫。本研究發覺轉換規則之間有彼此呼叫的需求,由 於轉換規則已經以函數實作,轉換規則之間的呼叫可以用函數之間 彼此呼叫的方式進行。
優點二:Meta-Model 的擴充
藉由 Meta-Model 的擴充,QVT 可以匯入來源模型與目標模型的 Meta-Model,讓 QVT 在將來可以適用其他模式或平台之間的轉換。
缺點一:撰寫難度較高
雖然命令式語言能夠以獨立函數的方式重複呼叫應用,但其方式針 對大型的來源模型進行轉換時,撰寫函數使用的程序與邏輯也相對 變得複雜[10] [14]。
缺點二:只能產出程式框架
QVT 對於來源模型所包含的函數應用,僅轉換其程式框架,例如 轉換類別圖中的操作函數,只能產出操作名稱以及操作函數所應用 的參數,其函數中詳細的程式碼無法轉換出來。這也是轉換所面臨 的困難點之一[18] [33]。
本研究也將Borland Together 軟體在使用上的優缺點歸納如下:
優點一:Profile 擴充機制
Borland Together 提供 Profile 技術的應用,使用者可自行擴充 Borland Together 的 Meta-Model,並佈署至軟體之中以供塑模之用。
優點二:支援Debug 功能
Borland Together 除了提供轉換語言的編譯外,也擁有 Debug 的功 能幫助使用者了解程式之執行程序,進而提高除錯效率。
缺點一:轉換結果顯示不完全
本研究在使用Borland Together 完成轉換後,第一次開啟目標模型 專案所顯示出的圖形與關聯線並不完全,必須關閉並重新開啟後才 能正確顯示其轉換結果。此漏洞容易造成使用者對於轉換結果之誤 解。
透過上述結果整理與優缺點歸納,在實務上能讓使用者明確了解使用此方式 進行模型轉換其優劣勢,對於企業或是研究人員在未來使用 QVT 以及 Borland Together 時可著重在其優勢方面或是降低其劣勢。以 QVT 為例:其函數應用的 架構讓轉換規則可以累積成知識庫的型式,逐步充實轉換規則之後就可以進行複 雜的模式轉換;撰寫方面進行良好程式程序規劃,降低邏輯順序混亂的問題。以 Borland Together 為例:使用者可利用 Profile 機制,對於自行開發之技術平台或 是Borland Together 中未提供之技術平台進行塑模;轉換方面善加利用 Debug 功 能提高撰寫與除錯效率,也提供學術上學習QVT 語言之應用。
6.2 研究成果與貢獻
本研究建立三層式的系統進行個案實作,將轉換以實證的範例表現出來,所 歸納的研究成果貢獻如下:
1. 展示如何使用 QVT 語言表示轉換規則,並應用 PIM 至 PSM 的轉換中:
本研究的三層式軟體案例與轉換規則可做為未來企業推行MDA 系統開 發之參考,透過本研究所建立之完整個案中成功轉換以及未成功轉換之圖形 可以更深入瞭解MDA 在系統分析中實務上的參考與應用。
2. 說明如何在 Borland Together 軟體平台建立與使用 QVT 語言以及轉換步驟:
本研究所展示之QVT 語法以及平台應用,在實務上提供企業使用平台 與程式碼之參考,進而轉換較複雜之模型。
3. 實際操作 QVT 在 PIM 類別圖上的應用,展示其轉換結果並探討目前轉換的 困難點:
目前所遭遇的轉換問題可以讓研究人員了解QVT 或是三層式軟體在進 行模式轉換上尚需釐清的問題以及未來的方向。而其概念也能做為學術上學 習轉換語言之參考。
6.3 未來研究方向
本研究在Borland Together 軟體平台上,建立類別圖並執行轉換,但轉換結 果顯示出新增類別圖以及關聯線之困難,而在物件導向系統分析中,所塑模出的 PIM 不只有類別圖一種,其使用的轉換規則也有無限種需求;轉換方法以及工具 也不單只有Borland Together 與 QVT,因此本研究未來期望能加強 QVT 針對模 型轉換的完整度,不僅只使用在類別圖轉換上,且能針對較廣泛使用的需求撰寫 其對應語法,進而比較與其他方法的轉換效益、困難點以及不同CASE 工具的比 較。
參考文獻
[5] Arrassen, I., Meziane, A., Sbai, R., & Erramdani, M. “QVT transformation by modeling,” International Journal of Advanced Computer Science and
Applications, Vol. 2, No. 5, 2011, pp. 7-14.
[6] Atkinson, C. Supporting and Applying the UML Conceptual Framework. In J.
Bézivin and P.-A. Muller (Eds)., Proceeding of the First International Workshop
on the Unified Modeling Language, LNCS 1618. pp. 21-36, Mulhouse, France:
Springer, 1999.
[7] Barendrecht, P. J. Modeling Transformation Using QVT Operational Mappings.
Research project report, Eindhoven University of Technology, Department of Mechanical Engineering, Eindhoven, 2010.
[8] Boehm, B. Software Engineering Economics, New Jersey: Prentice-Hall, 1982.
[9] Booch, G., Rumbaugh, J., & Jacobson, I. The Unified Modeling Language User
Guide, 2
nd Edition, Addision-Wesley, Massachusetts, 2005.[10] Bosems ,S. A Performance Analysis of Model Transformations and Tools.
Unpublished doctoral dissertation, University of Twente, Department of Electrical Engineering Mathematics and Computer Science, Netherlands, 2011.
[11] Brucker, A. D., Doser, J., & Wolff, B. A Model Transformation Semantics and Analysis Methodology for SecureUML, In O. Nierstrasz, J. Whittle, D. Harel, and G. Reggio (Eds)., Model Driven Engineering Language and System, 9th
International Conference. pp. 306-320, Springer, 2006.
[12] Czarnecki, K., & Helsen, S. Classification of Model Transformation Approaches.
In Proceedings of the 2nd
OOPSLA Workshop on Generative Techniques in the Context of the Model Driven Architecture, Vol. 45, No. 3, 2003, pp. 1-17.
[13] Dongen, V. M. Visualization of Model Transformations in QVTo. Unpublished doctoral dissertation, Technische Universiteit Eindhoven, Netherlands, 2012.
[14] Einarsson, H. Þ., & Neukirchen, H. An Approach and Tool for Synchronous Refactoring of UML Diagrams and Models Using Model-to-Model Transformations. In Proceedings of the Fifth Workshop on Refactoring Tools.
ACM, 2012, pp. 16-23.
[15] Fowler, M., & Scott, K. UML Distilled: A Brief Guide to the Standard Object
Modeling Language, 3
rd Edition, Addison-Wesley, Massachusetts, 2003.[16] Gardner, T., Griffin, C., Koehler, J., & Hauser, R. A review of OMG MOF 2.0 Query/Views/Transformations Submissions and Recommendations towards the final Standard, In MetaModeling for MDA Workshop, 2003, pp. 178-197.
[17] Glinz, M. “Problems and Deficiencies of UML as a Requirements Specification Language,” Proceedings of The Tenth International Workshop on Software Specification and Design, San Diego, 2000, pp. 11-22.
[18] Graham, J. Applying a QVT-baed Approach to Metamodelling and the Model Driven Architecture. Project submitted in part fulfilment of BSc/BEng in Computer Science, University of York, Department of Computer Science, UK, 2004.
[19] Greenyer, J., & Kindler, E. Reconciling TGGs with QVT. In Model Driven
Engineering Languages and Systems. Springer Berlin Heidelberg, 2007, pp.
16-30.
[20] Jacobson, I., Booch, G., & Rumbaugh, J. The Unified Modeling Language for Object-Oriented Development Documentation Set Version 0.9, Addendum, 1996.
[21] Kleppe, A. Warmer, J. & Bast, W. The Model Driven Architecture: Practice and
Promise, Addison-Wesley, Boston, 2003.
[22] Kurtev, I. State of the art of QVT: A Model Transformation Language Standard.
In Applications of Graph Transformations with Industrial Relevance. Springer Berlin Heidelberg, 2008, pp. 377-393.
[23] Laarman, A. W. Achieving QVTO & ATL Interoperability: An Experience Report on the Realization of a QVTO to ATL Computer. University of Twente, Software Engineering Group, The Netherlands, 2009.
[24] Nunamaker Jr, J.F., Chen, M., & Purdin, T. D. M. “System Development in Information Systems Research,” Journal of Management Information Systems, Vol. 7, No. 3, 1991, pp. 89-106.
[25] Object Management Group, Meta Object Facility 2.0 (MOF) Query/View/Transformation Specification V1.1.
http://www.omg.org/spec/QVT/1.1/PDF/, January 1, 2011.
[26] Object Management Group, Object Constraint Language V2.3.1.
http://www.omg.org/spec/OCL/2.3.1/PDF, January 1, 2012.
[27] Object Management Group, OMG Unified Modeling Language (OMG UML), Infrastructure V2.4.1. http://www.omg.org/spec/UML/2.4.1, August 5, 2011.
[28] Pilone, D., & Pitman, N. UML 2.0 in a Nutshell. Sebastopol, CA:O’Reilly, 2005.
[29] Pilskalns, O., Williams, D., Aracic, D., & Andrews, A. “Security Consistency in
UML Designs,” 30th Annual International Computer Software and Applications Conference (COMPSAC), Chicago, IL, September 17~21, 2006.
[30] Rosenberg, D., & Scott, K. Applying Use Case Driven Object Modeling with
UML: An Annotated e-Commerce Example, Addison-Wesley, Massachusetts,
2001.[31] Rumbaugh, J., Jacobson, I., & Booch, G. The Unified Modeling Language
Reference Manual, 2
nd Edition, Addision-Wesley, Boston, 2005.[32] Shin-Shing Shin, Jen-Her Wu, & Ming-Che Hsieh “A MDA-based Development Approach for 3-tiers applications,” The 20th European Conference on Information Systems (ECIS-20), Barcelona, Spain, June 10~13, 2012.
[33] Thomas, D. “MDA: Revenge of the Modelers or UML Utopia? ” IEEE Software, Vol. 21(3), 2004, pp. 15-17.
[34] Warmer, J., & Kleppe, A. The Object Constraint Language-Getting Your Models
Ready for MDA, 2
nd Edition, Addision-Wesley, Boston, 2003.附錄
transformation Transformation;--轉換程式名稱 import library Strings;
metamodel 'http://www.borland.com/together/uml';--匯入Meta-Model metamodel 'http://www.borland.com/together/uml14';--匯入Meta-Model metamodel 'http://www.borland.com/together/uml20';--匯入Meta-Model mapping main (in package: uml::kernel::packages::Package):
kernel::packages::Package{--轉換進入點為套件,來源與目標均為套件 uml::
init{
var Classes :=
package.ownedMembers.oclAsType(uml20::classes::Class) ->asOrderedSet();
} object{
name := 'BookPSM';--定義目標套件名稱 ownedMembers +=Classes.toClass();
} }
mapping uml20::classes::Class::toClass() : uml20::classes::Class{
init
轉換類別圖函數 {
result := self.resolve(uml20::classes::Class)-> any(true);
} object{
name := self.name;
stereotypes += PHPstereotype(self.stereotypes);
attributes += self.ownedAttributes.toAttributes();
associations +=self.associations.D5();
dependencies +=self.dependencies.B7(self);
dependencies +=self.dependencies.P4De();
} }
mapping uml20::kernel::KernelAssociation::D5() : uml20::kernel::KernelAssociation
--D5關聯線轉換函數 when{
self.clientCardinality.isMany() and
self.supplierCardinality.isMany()}{
init{
var depsupplier1:=
dependencies.supplier.oclAsType(uml20::classes::Class) any(true);
->
result := D5associations(supplier,depsupplier1);
result := D5associations(client,depsupplier1);
} }
mapping D5associations(in client : uml::kernel::Element,in depsupplier:uml20::classes::Class):
depsupplier.oclAsType(uml20::classes::Class).toAssociationClass();
mapping uml20::classes::Class::toAssociationClass() : uml20::classes::Class{
init
多對多關聯線之類別圖轉換函數,與轉換類別圖函數toClass差別在於呼叫D6轉換規則。
{
result := self.resolve(uml20::classes::Class)-> any(true);
} object{
name := self.name;
stereotypes += PHPstereotype(self.stereotypes);
attributes += self.ownedAttributes.toAttributes();
associations +=self.associations.D6();
associations +=self.associations.D6();