280 likes | 398 Views
Your Mediators need Data Conversion!* Sophie Cluet, Claude Delobel, Jerome Simeon, K Smaga. By Prapulla Bajjuri. Introduction. Converts the data from one format to another
E N D
Your Mediators need Data Conversion!*Sophie Cluet, Claude Delobel, Jerome Simeon, K Smaga By Prapulla Bajjuri
Introduction • Converts the data from one format to another • It provides tools for the specification and the implementation of data conversions among heterogeneous data sources. • YAT model uses graphs for representation • YATL is rule-based
Translation Scenario RDBMS OODBMS YATL translation rel + sgml ->odmg YAT/relational wrapper YAT/ODMG wrapper YATL translation Odmg -> html YAT/SGML wrapper YAT/HTML wrapper HTML files SGML Files
YAT Model • Consists of set of patterns and variable domains • Two kinds of variables • Data Variables (ii) Pattern Variables • The domain of data variable is the set of all data constants and variable names • The domain of pattern variable is the set of all its instance patterns. • Ground pattern.
Class Pclass: Yat: Class_name V & Yat V L * L Att * Ptype Yat Ptype: Y: int V String..V Tuple V Z: (set, list, bag, array) V &Pclass * * Att Ptype Ptype The YAT model The ODMG model … class class … Psup: C1: S1: S2: Pcar: car car &Pcar name desc suppliers name desc suppliers * S1:str S2:str set “Golf” “The 1995 volks Golf GTI….” set &Psup &s1 &s2 The car schema model The Golf GTI model
Model Instantiation • It relies on pattern instantiation which itself relies on variable domain inclusion. • Each pattern of the instance model must be an instance of some pattern of the source model • A variable can be instantiated either by a constant belonging to the variable’s domain or by a variable whose domain is a subset. Pattern for car objects Pcar: classcar(names1:string, descS2:string, suppliersset&Psup)
The YAT Language • It is declarative and rule-based • Deals with heterogeneity • Deals with collections • Detects cyclic programs • Supports graphical interface • Typing in YATL
Rule 1 Pbr : brochure( number Num, title T, model Year, desc D, suppls supplier ( name SN, address Add)), Year > 1975, C is city(Add), Z is zip(Add) Psup(SN) : Class supplier ( name SN, city C, zip Z) *
Rule 2 Pbr : brochure( number Num, title T, model Year, desc D, suppls supplier ( name SN, address Add)), Pcar(pbr) : Class car ( name T, desc D, suppliers set &Psup(SN) ) * { }
Rule 1’ Pbr : brochure( number Num, title T, model Year, desc D, suppls supplier ( name SN, address Add)), C is city(Add), Z is zip(Add) Psup(SN) : Class supplier ( name SN, city C, zip Z, sells set &Pcar(Pbr) ) * { }
Dealing with heterogeneity Suppliers Relational Database Schema suppliers[sid: integer, name: string, city: string, address: string, tel: string] Cars[cid: integer, broch_num: string] Sales[sid: integer, cid: integer, year: integer, sold: integer]
Rule 3 Pbr : brochure( number Num, title T, model Year, desc D, suppls supplier ( name SN, address Add)), Rsuppliers: Suppliers row (sid Sid, name SN, city C, addressAdd2, tel Tel). Rcars: Cars row (cid Cid, broch_num Num), sameaddress(Add, C, Add2) * Psup(SN) : Class car ( name T, desc D, suppliers set &Psup(Sid)) * * *
Dealing with collections • YATL handles sets and lists. • It provides one primitive for grouping and another for ordering. • It allows to grouping on some criteria and ordering on others. • Arrays can also be manipulated using YAT language.
Rule 4 Pbr : brochure( number Num, title T, model Year, desc D, suppls supplier ( name SN, address Add)), Pallsups( ) : list &Psup(SN) []SN *
sales sales Mat: Mat: Polo golf Paris nice caen Paris nice caen paris nice caen Polo golf polo golf polo golf 100 22 300 110 20 330 110 22 20 300 330 100 Input Matrix Output Transposed Matrix Rule 5 New (Id) : Id: Mat Y X A Mat X Y A []I []J I J
Detecting cyclic programs • Removing the & symbol in Rules 1’ and 2 introduces cycle in the program • Statically detecting cycles in a YATL program is undecidable • This can be done by constructing dependency graph of dereferenced functions • It rejects conversion programs working by recursion on the input tree. • Rejects programs that are not safe-recursive.
Typing in YATL • Input and output models can easily be inferred by considering (i) input and output patterns (ii) predicate/function signatures (iii) variable domains Rule 1 Psup(SN) : Class supplier ( name SN, city C, zip Z) Pbr : brochure(…… suppls supplier ( name SN, address Add)), Year > 1975, C is city(Add), Z is zip(Add) *
Customizing programs • Converts any ODMG data into HTML • An object is converted into HTML page • An atomic value is converted into a string • A collection is converted into a list of HTML items • An object reference is converted into an HTML anchor
An object is converted into an HTML page Web 1 HtmlPage(Pclass) : Html( head title Classname, body(h1Classname, ul li, ( Att2, HtmlElement(Ptype)))) Pclass : class Classname AttPtype, Att2 is concat(Att, “ : “) • An atomic value converted into a string Web 2 HtmlElement( Ptype) : S Ptype : Data, S is data_to_string(Data)
A tuple is converted into a list of HTML items Web 3 Ptype : tuple AttP2:Ptype, Att2 is concat(Att, “ : “) HtmlElement(Ptype) : ul li( Att2, HtmlElement(P2: Ptype)) * * • A collection is converted into a list of HTML elements. Web 4 HtmlElement( Ptype) : Ptype : ul li HtmlElement(P2:Ptype) X:{ set, bag} P2 : Ptype * *
A list or array is converted into a list of HTML elements. Web 5 HtmlElement(Ptype) : ol liHtmlElement(P2:Ptype)) Ptype : X : {list,array}P2:Ptype I o(I) • A object reference is converted into an HTML anchor. Web 6 HtmlElement( Ptype) : Ptype : &Ptype, A( href & HtmlPage(Pclass),Pclass : cont Classname) class Classname P2:Ptype
Example HtmlPage(Pcar) : html( head title car, body(h1car, ul( li ( ”name:”, T1), li( ”age:”, D1), li( ”suppliers:”, ul li a ( href HtmlPage(Psup), cont Classname))))) Pcar : Class car ( nameT, desc D, suppliers set &Psup), Psup: classClassnameP2:Ptype, T1 is data_to_string(T), D1 is data_to_string(D) * *
Combining programs • YATL interpreter organizes the set of rules of a program hierarchically. • For a given input pattern, the more specific rules matching the input are applied first then less specific rules are tried. • User may also enforce the rule hierarchy.
Composing programs • Using YATL , it is possible to compose two programs and generate a more efficient program. • Composition mechanism: It takes two programs and checks whether they are compatible and produces the new program by combining them. • Here it takes SGMLODMG and ODMGHTML and produces SGMLHTML
Example • Prg1: M1M2 • Prg2: M2’M3 • System instantiates prg2 with the patterns of M2. • Prg2’: M2M3’
YAT Architecture • It does not provide the ability to query or update external sources. • System is composed into three main parts • The specification environment • The runtime environment • A library of programs and formats
YAT Architecture Target 1 Specification Environment Export wrapper Graphical User Interface Runtime environment Static Typing YATL program Instantiation module YAT Patterns/YATL rules Management module Type checker YATL interpreter YAT pattern/ YATL rules management module External Functions & Predicates evaluation Import wrapper Import wrapper Library of programs and models Source 2 Source 1
Questions….? Thank You