270 likes | 349 Views
Jokin García 1 , Oscar Díaz 1 and Jordi Cabot 2 Onekin 1 University of the Basque Country, Spain AtlanMod 2 Ecole des Mines, Nantes (France) Thessaloniki - 19 th of june, 2014 CAiSE. An Adapter-Based Approach to Co-evolve Generated SQL in M2T Transformations. Index. Problem statement
E N D
Jokin García1, Oscar Díaz1 and Jordi Cabot2 Onekin1 University of the Basque Country, Spain AtlanMod2 Ecole des Mines, Nantes (France) Thessaloniki - 19th of june, 2014 CAiSE An Adapter-Based Approach to Co-evolve Generated SQL in M2T Transformations
Index Problem statement Case study Solution Evaluation Conclusions, future work
Problem statement: context Software components on top of platforms Dependencies Platform evolution is a common situation. DB API Blog CMS Wiki Application API
Problem statement: context Perpetual beta state of platforms. External dependency
Problem statement: context Domain model M2T Transformation Code Model refs. (Dynamic) Embedded platform code (Static) Transformation code
Problem statement: problem Different versions of the platform leave the code and M2T transformation outdated. M2T ? Code DB Δ DB’
Problem statement: solution Adapter to adapt generated code to new platform M2T Adapter Code Code MediaWiki Δ MediaWiki’
Case study: MediaWiki Used by Wikipedia and more than 40.000 wikis In 4,5 years: 171 schema upgrades
Case study: MediaWiki DB in Wikiwhirl Platform-dependent concepts Refs to domain model
Solution Synchronize the generated code with platform Using adapters at runtime M2T print("INSERT into categorylinks (cl_from, cl_to, cl_sortkey, cl_timestamp) VALUES (@pageId, '" + categoryTitle + "','" + pageTitle) Adapter New columns “cl_type”, “cl_sortkey_prefix” and “cl_collation” Code INSERT INTO categorylinks (cl_from, cl_to, cl_sortkey, cl_timestamp, cl_type, cl_sortkey_prefix, cl_collation) VALUES (@pageId, ‘Softwareproject’, ‘House_Testing’, (DATE_FORMAT(CURRENT_TIMESTAMP(), ‘%Y%m%d%k%i%s’), ‘page’, ‘’, ‘0’); MediaWiki’
Process outline Comparison (EMFCompare) 2 Domain model Difference model New schema model Old schema model Transformation (M2T+adapter) Injection (Schemol) Injection (Schemol) 3 1 Code (MediaWiki DB) New MediaWiki schema Old MediaWiki schema
Process outline Don't worry: all in one click Comparison (EMFCompare) 2 Domain model Difference model New schema model Old schema model Transformation (M2T+adapter) Injection (Schemol) Injection (Schemol) 3 1 Code (MediaWiki DB) New MediaWiki schema Old MediaWiki schema
Process: Differences between platforms: DB schema Comparison (EMFCompare) Injection (Schemol)
Process: Adaptation Plaform-specific, schema-independent Replace all “println” instructions with “printSQL” Import “printSQL” library ZQL extension For each printSQL invocation: Iterate over the changes reported in the Difference model Checks if any of the changes impacts the current statement. Needed information to adapt the statement is retrieved and added to a list of parameters: the statement, affected table, column, … A function that adapts the statement is called and new statement is printed.
Process: Adaptation output Added columns Delete tables Delete columns
Roles Producer Injector for target platform Implement adapter as a library for transformation Consumer Import adapter library in the transformation Execute the batch
Evaluation Manual Cost = D + P * #Impacts D: Detection time P: Propagation time Assisted Cost = C + V * #Impacts C: Configuration time V: Verification time
Dump changes from code to transformation Assist manual propagation Record generation with change to be done and where (line and column in the transformation) M2T transformation M2T transformation’ HOT printSQL(“select * from …”, line, column) print(“select * from …”) RECORD: #Added columns cl_type, cl_sortkey_prefix and cl_collation #transformation line: 12, column: 11 INSERT INTO categorylinks (cl_from, cl_to, cl_sortkey, cl_timestamp, cl_type, cl_sortkey_prefix, cl_collation) VALUES (@pageId, ‘Softwareproject’, ‘House_Testing’, (DATE_FORMAT(CURRENT_TIMESTAMP(), ‘%Y%m%d%k%i%s’), ‘page’, ‘’, ‘0’);
Conclusions Mechanism to adapt code generated by M2T transformations to platform evolution Apply in a specific case study Premises: platform instability and transformation coupling
Issues and future work Generalization: other platforms Methodology for adapter development
Questions Implementation: www.onekin.org/downloads/public/Batch_MofscriptAdaptation.rar Screencasts: www.onekin.org/downloads/public/screencasts/MOFScript/ jokin.garcia@ehu.es http://www.onekin.org
Process: Adaptation • 1- Iterate over the changes reported in the Difference model 2- check that the deleted column's table corresponds with the table name of the statement • 3- the statement, the table name and the removed column are added to a list of parameters • 4- outputs an SQL statement without the removed column, using a function with the list of parameters that modifies the expression
Generate traceability model MOFScript + Adapter Domain model Traceability model Difference model 3 <Transformation: line, column >-> <Code: line, column> printSQL(statement l,ine, column, print_type)
Visualize traceability model HandyMOF Traceability model ICMT July 21-23 York