• No results found

Using and Extending the Data Tools Platform. Brian Fitzpatrick (Sybase) Linda Chan (Actuate) Brian Payton (IBM)

N/A
N/A
Protected

Academic year: 2021

Share "Using and Extending the Data Tools Platform. Brian Fitzpatrick (Sybase) Linda Chan (Actuate) Brian Payton (IBM)"

Copied!
73
0
0

Loading.... (view fulltext now)

Full text

(1)

Using and Extending the Data Tools Platform

Brian Fitzpatrick (Sybase) Linda Chan (Actuate)

Brian Payton (IBM)

(2)

Welcome!

ƒ Goals for this tutorial:

ƒ Get a working knowledge of DTP Tooling

ƒ Get a glimpse into how to enable or extend database support for a particular vendor

ƒ Get familiar with some DTP APIs

ƒ Use ODA to extend DTP for a non-database data source

ƒ See how to expand the SQL Query Model and Parser for a particular DB

ƒ And finally see how DTP is being leveraged in other Eclipse projects

(3)

Before we begin…

ƒ What do you hope to get out of the talk today?

ƒ What are your goals? What do you know already about DTP?

(4)

Beginning DTP

ƒWhat is the Data Tools Platform (DTP)?

(5)

Important Concepts in the Tooling

ƒConnection Profiles & Driver Definitions

(6)

Available Perspectives for DTP

ƒDatabase Development

ƒDatabase Debug

(7)

Basic Components

Data Source Explorer (DSE)

SQL Scrapbook

SQL Results View

(8)

Creating a Database Connection in DTP

ƒ In the Data Source Explorer, right-click on “Database Connections” and select “New…”

ƒ Specify your database type, click Next

ƒ If no driver available, click the New Driver Definition button

ƒ Select a driver template, set your jar paths, click OK

ƒ Customize database properties, click Finish

(9)

Expanding and Exploring the Connected Profile

ƒ Once you connect to a profile, it starts to load the model a level at a time

ƒ So you can expand and see catalogs, schemas, tables, procedures, and so on – to represent what your database (and the DTP implementation for that database) supports

(10)

Using the SQL Scrapbook to Execute Queries

ƒ Right-click on a database Connection Profile and select “Open SQL Scrapbook”

ƒ Type your query, select it, and select “Execute Selected Text”

(11)

How to Use the SQL Query Builder from the SQL Scrapbook

ƒ To create more complicated queries, you can use the SQL Query Builder (SQB), which simplifies query creation by allowing you to click, drag, and drop to customize the SQL

ƒ To open the SQB, right-click and select “Edit in SQL Query Builder”

ƒ Right-click where it says

“To add a table…” and select

“Add Table…”

ƒ Select one or more tables to use in the query and click OK

ƒ Then you can select columns, specify conditions, and so on

(12)

Executing a Query from the SQB

ƒ Once you’ve customized your query in the SQB, right-click in the SQL text area at the top and select “Run SQL” to show the

results

(13)

Interacting with Stored Procedures and UDFs

ƒ In SQL, you can define and call stored procedures in user- defined functions if your database supports them. DTP allows you to call them as well.

ƒ In a Derby database, you can call the SQLTABLES procedure:

ƒ call SYSIBM.SQLTABLES(null, 'APP', null, null, null);

(14)

Stored Procedures and UDFs continued…

ƒ You can also create and then use user-defined functions…

ƒ In a Derby database, try this:

ƒ create function getSystemProperty(name varchar(128)) returns varchar(128) language java external name

'java.lang.System.getProperty' parameter style java no sql;

(15)

Creating Tables and Modifying Content

ƒ In addition to simply running SQL, you can use DTP tools to create tables and view/modify their data

ƒ In the Data Source Explorer, connect to and drill down into a database connection profile. On the “Tables” folder in the tree, right-click and select “New Table…”

ƒ The New Table wizard creates DDL that you can then execute to create the table.

(16)

Creating Tables and Modifying Content, continued

ƒ Execute the table DDL by right-clicking and selecting “Execute All” – this will run the SQL and create the table.

ƒ Then right-click on the “Tables” node in the tree, right-click and select “Refresh” to repopulate the table list.

ƒ Once you have a table, you can edit its content by right-clicking and selecting “Data->Edit”, which opens a tabular window for editing table data that you can use for data entry

ƒ When you’re done, right-click in the editor and select Save from the popup menu to persist your changes

(17)

Creating Tables and Modifying Content, continued

ƒ Another way of loading data is by CSV file. To load a table from a CSV file, right-click on a table and select Data->Load…

ƒ Specify the input file, the delimiter, and the string delimiter, and click Finish.

(18)

Tooling Exercise…

ƒ Set up a new Derby connection profile and connect to a local database

ƒ Connect to the connection profile

ƒ Create a new Product table with three columns – product_id (varchar), name (varchar), inventory (number)

ƒ Create a new Orders table with three columns – order_id (varchar), date (date/time), product_id (varchar), number_ordered (number)

ƒ Import data from the Products.csv and Orders.csv files into your new tables

ƒ In the SQL Scrapbook, create a query (in the text editor or the SQB) to correlate information from the Product and Orders tables to get a

readable report of what products were ordered on a given date (product name, date, number ordered)

(19)

Extending DTP

ƒ Now that you have a bit of knowledge about what DTP can do for you… How do you leverage and extend it?

ƒ A few possible avenues…

ƒ Use DTP components in your own applications and simply leverage what’s already there

ƒ Extend DTP into new Data Sources and Databases (“enabling”

new databases, adding custom items to the tree, adding custom SQL syntax to what DTP already knows, etc.)

ƒ Take advantage of DTP APIs to utilize core DTP functionality under the covers

(20)

“Enabling” a New Database

ƒ Rather than spend a long time on this topic, I’ll direct you to a series of blog posts I wrote while I worked through “enabling” SQLite for DTP Enablement.

ƒ Not all databases will require all of this, but it’s not difficult to extend the existing frameworks

ƒ Driver Framework: http://fitzdtp.blogspot.com/2008/06/dtp-driver- framework-repost.html

ƒ Custom Driver Template: http://fitzdtp.blogspot.com/2008/06/how-do-you- add-your-own-custom-driver.html

ƒ Adding a Custom Catalog Loader: http://fitzdtp.blogspot.com/2008/08/dtp- sqlite-support-continued-on-to.html

ƒ Creating the SQLite Connection Profile (minus UI):

http://fitzdtp.blogspot.com/2008/08/creating-actual-sqlite-connection.html

ƒ Creating the SQLite Connection Profile UI Bits:

http://fitzdtp.blogspot.com/2008/08/creating-sqlite-connection-profile-ui.html

(21)

Leveraging DTP APIs

ƒ Though we have many cool tools in DTP, you may find that you don’t need or want to use them. In these cases, you may still be able to take advantage of DTP APIs.

ƒ There are too many APIs to really talk about in the time allowed, so I’m just going to hit upon a few of the high-level ones

ƒ In this section, we’re going to use DTP APIs to create a

connection profile and write a utility class that takes a file, loads it into memory, and loads a table from the file

ƒ Consider that APIs could also be used to map/replicate data from one database to another via a combination of JDBC and DTP

(22)

APIs for Creating Connection Profiles…

ƒ There are two types of connection profiles…

ƒ persisted

ƒ and transient.

(23)

Accessing Existing Connection Profiles (Persisted)

ƒ Access to existing connection profiles (persisted or transient) is done using the ProfileManager class

(org.eclipse.datatools.connectivity.ProfileManager)

ƒ If you know the name of your connection profile, you can find it pretty easily

IConnectionProfile myProfile =

ProfileManager.getInstance().getProfileByName(“MyProfile”);

(24)

Creating a Transient Connection Profile

ƒ In the second case, where you may not want to use the whole connection profile UI framework but want to leverage other components, you use the Transient API

ƒ These are the typical JDBC properties you think of…

String profileUserName = "";

String profilePassword = "";

String profileURL = "jdbc:derby:C:\\DerbyDatabases\\MyDB;create=true";

String profileDriverClass = "org.apache.derby.jdbc.EmbeddedDriver";

String profileJarList = "C:\\Derby10.2.2\\db-derby-10.2.2.0-bin\\lib\\derby.jar";

ƒ Then there’s the DTP-specific properties you need…

String providerID =

"org.eclipse.datatools.connectivity.db.derby.embedded.connectionProfile";

String vendor = "Derby";

String version = "10.1";

(25)

Transient Profile, continued

ƒ So once you have your properties, you can do this:

Properties baseProperties = new Properties();

baseProperties.setProperty( IDriverMgmtConstants.PROP_DEFN_JARLIST, jarList );

baseProperties.setProperty(IJDBCConnectionProfileConstants.DRIVER_CLASS_PROP_ID, driverClass);

baseProperties.setProperty(IJDBCConnectionProfileConstants.URL_PROP_ID, driverURL);

baseProperties.setProperty(IJDBCConnectionProfileConstants.USERNAME_PROP_ID, userName);

baseProperties.setProperty(IJDBCConnectionProfileConstants.PASSWORD_PROP_ID, password);

baseProperties.setProperty(IJDBCConnectionProfileConstants.DATABASE_VENDOR_PROP_ID, vendor);

baseProperties.setProperty(IJDBCConnectionProfileConstants.DATABASE_VERSION_PROP_ID, version);

baseProperties.setProperty( IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String.valueOf( true ) );

ProfileManager pm = ProfileManager.getInstance();

IConnectionProfile icp = pm.createTransientProfile(providerID, baseProperties);

(26)

Transient Profile, continued…

ƒ So the upside to the Transient profile is that you don’t have to pre-define it in the UI

ƒ The downside is that you have some additional properties to figure out.

ƒ This is *new* API for Galileo. There are other changes to help with getting the correct vendor and version in Galileo so you can hand it a JDBC connection you managed yourself, it gets the properties it needs, and then returns the correct vendor, and version.

ƒ For now, you can use the provider ID of the Generic JDBC profile (org.eclipse.datatools.connectivity.db.generic.connectionProfile)

(27)

Using your Connection Profile reference

ƒ Now that you have an IConnectionProfile instance, what can you do with it?

ƒ If it’s not connected, you can connect to it:

IConnectionProfile profile =

ProfileManager.getInstance().getProfileByName("myprofile");

IStatus status = profile.connect();

if (status.equals(IStatus.OK)) { // success

} else {

// failure :(

if (status.getException() != null) {

status.getException().printStackTrace();

} }

(28)

Using your Connection Profile reference…

ƒ So now that you have a connected profile, you can get the JDBC connection from the ProfileConnectionManager:

public java.sql.Connection getJavaConnectionForProfile (IConnectionProfile profile) {

IConnection connection = ProfileConnectionManager.

getProfileConnectionManagerInstance().getConnection(profile,

"java.sql.Connection");

if (connection != null) {

return (java.sql.Connection) connection.getRawConnection();

}

return null;

}

(29)

Using the Connection…

ƒ From there, you can do anything you might have done with any other JDBC connection:

try{

Statement st = connection.createStatement();

String statement = “select * from mytable”;

int val = st.executeUpdate(statement);

}

catch (SQLException s){

// exception }

(30)

Other good API bits…

ƒ You can also get the SQL model from a database connection.

ƒ First, you have to get the ConnectionInfo class, which acts as a bridge between the JDBC connection and the SQL models

IManagedConnection managedConnection = ((IConnectionProfile)profile).getManagedConnection(

"org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo");

if (managedConnection != null) { try {

ConnectionInfo connectionInfo = (ConnectionInfo) managedConnection.getConnection().getRawConnection();

if (connectionInfo != null) {

Database database = connectionInfo.getSharedDatabase();

// do something with the database reference…

}

} catch (Exception e) {

e.printStackTrace();

} }

ƒ This is how to get the SQL Model’s root Database node for your connection profile

(31)

Using the Database reference…

ƒ Once you have the Database reference, you can drill into your database and get the abstracted SQL structure, which you can then use to develop more flexible SQL calls for a variety of

reasons…

ƒ Imagine being able to connect to two databases and providing a tool that allows you to map data between disparate tables…

ƒ Imagine writing tooling or a set of APIs that could be used to inject data via DTP’s abstracted models

ƒ Imagine abstracting a data source class for a given table or set of tables that would hide SQL complexity and allow a developer to more easily add/remove/edit data via simple calls

ƒ The sky’s the limit!

(32)

API Exercise…

ƒ Using the base plug-in provided, in the action’s run method, dive into the connection profile and print a few things to the console for the Product table in the App schema of our Derby database…

ƒ MyDatabase.getCatalogs() returns an EList of catalogs. Derby has a dummy Catalog object, so you’ll have to get it and then go

deeper ( (Catalog)MyDatabase.getCatalogs().get(0) )

ƒ MyCatalog.getSchemas() returns an EList of schemas you can iterate through until you find APP

ƒ Once you find the Schema, MySchema.getTables() returns an EList of tables you can iterate through until you find Product

ƒ MyTable.getColumns() returns an EList of columns…

ƒ And so on… simply work down the hierarchy and show a list of the columns in the Product table

(33)

In Summary… Tools + API = Flexibility

ƒ DTP’s tooling provides useful database and data source

functionality that’s also extendable and reusable in your own code

ƒ And DTP’s APIs allow you to go deeper than the tooling to do many cool things with JDBC, the SQL model, and your own tools/APIs

(34)

More DTP Information

ƒ Main DataTools site at http://www.eclipse.org/datatools

ƒ Newsgroup - news://news.eclipse.org/eclipse.dtp

ƒ Mailing list – http://dev.eclipse.org/mailman/listinfo/dtp-dev

ƒ Wiki - http://wiki.eclipse.org/index.php/Data_Tools_Platform_Project

ƒ Bugzilla for bug or enhancement requests

ƒ Feel free to ask questions!

(35)

DTP Open Data Access (ODA) Framework

Extend DTP for Non Relational Database Data Sources

Linda Chan – Actuate® Corporation

(36)

Topics

ƒ What is Open Data Access1 (ODA)?

ƒ Overview – ODA Framework

ƒ Enabling non-RDBMS data source with an ODA Data Provider

ƒ Demo/Exercise: creating ODA provider plug-ins

(37)

Open Data Access Framework

Enables data access to any data source

• Provides an abstraction for accessing heterogeneous data sources

• Highly scalable data retrieval and easy end-user experience

• Built using familiar Eclipse extension points Extends & customizes Applications Systems

• Applications can provide custom data driver and query builder for accessing their data

Provides proven framework

• BIRT’s built-in ODA data connectors

• Commercial products’ ODA data connectors

(38)

Overview – Open Data Access Architecture

ODA Data Driver

ODA Query Builder

Application Client Tools BIRT Report Designer

Data Sources

Application Server

ODA Runtime Interfaces ODA Design

Interfaces

Data Access & Query Definition

Run-Time Data Access Design-Time Query Builder

(39)

Overview – Open Data Access Framework

ƒ Run-time

ƒ Public API defines a set of Java™ interfaces that allow heterogeneous data to be accessed in a generic way

ƒ Design-time

ƒ Allows data source-specific user interface to be embedded in any ODA-compliant consumer application

ƒ ODA Consumer Helper

ƒ Built-in support for any ODA-compliant consumer application to consume data from any ODA data provider

(40)

ODA Run-time Framework

ƒ Stable run-time API since DTP 0.9

ƒ Integrates with DTP Connection Profile and JDBC™ Databases framework

ƒ Implementation wraps data source-specific APIs

ƒ Run-time plug-in implements

ƒ extension points

ƒ org.eclipse.datatools.connectivity.oda.dataSource

ƒ org.eclipse.datatools.connectivity.connectionProfile

ƒ ODA run-time API interfaces

ƒ org.eclipse.datatools.connectivity.oda package

(41)

ODA Run-time API Interfaces

ƒ Defines the primary run-time operations of an ODA data provider to access and retrieve data from a data source

ƒ Java interfaces

ƒ JDBC-like, extended to support additional capabilities of non- RDBMS data sources

ƒ Emphasis on scalable data retrieval

ƒ Main run-time operations

ƒ Data Source Connection – IConnection

ƒ Establishes a live connection to any type of data source

ƒ Obtains provider capabilities for each type of data set queries

ƒ Creates one or multiple concurrent data set-specific queries

(42)

ODA Run-time API Interfaces

ƒ Main run-time operations (cont’d)

ƒ Data Set Query – IQuery, IAdvancedQuery

ƒ Prepares and executes a data set-specific query text

command, e.g. XPath, MDX, SQL, Stored Procedure calls

ƒ Handles one or more sets of data rows, i.e. result sets, retrieved by a single data set query

ƒ Query Parameters – IParameterMetaData, IParameterRowSet

ƒ Provides run-time metadata of parameters specified in a prepared query

ƒ Handles scalar and complex input/output parameters

ƒ Result Sets – IResultSet, IResultSetMetaData

ƒ Fetches tabular data rows

ƒ Allows sequential or concurrent access to multiple result sets

(43)

ODA Design-time Framework

ƒ Eclipse Modeling Framework (EMF) model-based design-time interfaces

ƒ communicate connection properties, query and parameter definitions to an ODA consumer application

ƒ Integrates with DTP Data Source Explorer view

(44)

ODA Design-time Framework

ODA Design Session model

(45)

ODA Designer UI Plug-in

ƒ Implements

ƒ extension points

ƒ org.eclipse.datatools.connectivity.connectionProfile

ƒ org.eclipse.ui.propertyPages

ƒ org.eclipse.datatools.connectivity.oda.design.ui.dataSource

ƒ org.eclipse.datatools.connectivity.ui.connectionProfileImage (optional)

ƒ customizes ODA Designer UI pages

ƒ org.eclipse.datatools.connectivity.oda.design.ui.wizards package

ƒ Communicates its Data Source and Data Set design definitions in an ODA Design Session model

(46)

ODA Design Session model

ƒ Model based on Eclipse Modeling Framework (EMF)

ƒ org.eclipse.datatools.connectivity.oda.design package

ƒ Allows customized data source and query builders to design the slice of data to access at run-time

ƒ Communicates connection information, query and parameter definitions to an ODA consumer application

ƒ Transient Objects

ƒ root element: org.eclipse datatools.connectivity.oda.design.OdaDesignSession

ƒ ODA design-time consumer application, e.g. BIRT Report Designer, initiates an ODA design session

ƒ Consumes a data provider’s UI page contributions

ƒ Adapts an edited data access design to host-specific design components

ƒ Provides persistent services for editing designs

(47)

Build a Custom ODA Data Provider

ƒ From scratch

ƒ PDE New Plug-in Project Wizard

ƒ Demo / Exercise

ƒ Extends an existing ODA provider

ƒ driverBridge extension point

ƒ org.eclipse.datatools.connectivity.oda.consumer.driverBridge

(48)

Build a Custom ODA Data Provider – from Scratch

ƒ PDE New Plug-in Project Wizard

ƒ Demo / Exercise

(49)

Extends an Existing ODA Data Provider

ƒ Modify/enhance behavior of an existing ODA data provider

ƒ org.eclipse.datatools.connectivity.oda.consumer.driverBridge extension point

ƒ Ideal for minor enhancements

ƒ preserves existing ODA extension ID

ƒ Supports “chained” bridges

(50)

DriverBridge Extension Point

ODA Consumer Application (e.g. BIRT)

ODA Runtime Interfaces

oda.consumer.helper

Driver Bridge

driverTypeÆ driver class name

Driver Bridge

bridgeIdÆ oda.dataSource extension id

(51)

Enhance an Existing ODA Data Provider

ƒ DriverBridge extension implements

ƒ Extension Point

ƒ org.eclipse.datatools.connectivity.oda.consumer.driverBridge

ƒ Sample driverBridge extension element

<bridge

driverType="org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDri ver"

bridgeId="org.eclipse.birt.report.data.testjdbc">

</bridge>

ƒ Bridge driver is handed its underlying driver instance

ƒ IDriver.setAppContext( Map )

ƒ Key: OdaDriver.ODA_BRIDGED_DRIVER

ƒ Value: underlying driver instance

ƒ May use own API between Bridge and underlying Driver instances

(52)

ODA Data Providers

ƒ Out-of-the-Box ODA Data Providers

ƒ CSV data file

ƒ org.eclipse.datatools.connectivity.oda.flatfile* plug-ins

ƒ XML data

ƒ org.eclipse.datatools.enablement.oda.xml* plug-ins

ƒ Web Services

ƒ org.eclipse.datatools.enablement.oda.ws* plug-ins

ƒ JDBC Drivers – SQL Query Builder & SQL Textual Editor

ƒ org.eclipse.birt.report.data.oda.jdbc* plug-ins

ƒ DTP Incubation Project

ƒ ECore ODA Data Provider (Bugzilla 132958)

ƒ org.eclipse.datatools.enablement.oda.ecore* plug-ins

ƒ Separate incubator download package

ƒ Welcomes contribution

(53)

What is New in ODA – DTP 1.7 Release

ƒ ODA API Enhancements

ƒ Java Object data type

ƒ Availability of Data Set Property and Input Parameter Values prior to Query Preparation

ƒ Cancel a Query Execution

ƒ Connection-level Locale Setting

ƒ Consumer Resource Identifiers

http://wiki.eclipse.org/Galileo_DTP_ODA_API_Changes_Spec

ƒ Dynamic Query Result Specification API – Experimental API

ƒ Filtering

ƒ Result Projection

ƒ Row Ordering

(54)

Resources

ƒ ODA Overview document

ƒ link on DTP Connectivity home page

http://wiki.eclipse.org/Connectivity

ƒ Developers' Guide for Connectivity Frameworks

ƒ DTP Help Contents – Javadoc™ and Extension Points’ Schema

ƒ Presentation slides

ƒ https://www.eclipsecon.org/submissions/2009/view_talk.php?id=686

(55)

Open Data Access Framework

ƒ Discussions, Feedbacks, Q&As

(56)

Using and Extending the Data Tools Platform SQL Query Model and Parser

Brian Payton (IBM)

(57)

Agenda

ƒ Introduction and background

ƒ Characteristics

ƒ What is it good for?

ƒ Tour of the Query Model and Parser components

ƒ Query Model

ƒ Query Parser

ƒ Parser Factory

ƒ Post-parse Processors

ƒ SQL Source Writer

ƒ Query Model Helpers

ƒ Extending the Query Model and Parser

(58)

Introduction and background

ƒ The Data Studio Query Model and Parser is a system for

representing, analyzing, manipulating, and generating SQL query statements in client-side database applications.

ƒ Originally created for the SQL Assist component of IBM® DB2 Control Center, later used in IBM® WebSphere® Studio

Application Developer, IBM Rational® Application Developer, and IBM Data Studio Developer.

ƒ Donated by IBM to the Eclipse Data Tool Platform project 2006 and used in the DTP SQL Query Builder component.

(59)

Characteristics

ƒ Deep coverage of SQL DML statements (Query, Insert, Update, Delete)

ƒ But DML only!

ƒ Extensible, componentized system

ƒ Extension points to register extensions for different databases

ƒ Parser grammar inheritance

ƒ Model is based on EMF technology

ƒ Parser is based on LPG (LALR Parser Generator) technology

ƒ SourceForge project, but available in Eclipse through Orbit

ƒ Think of the model as an SQL AST (Abstract Syntax Tree) on steriods!

(60)

What is it good for?

ƒ Provides underlying support for the SQL Query Builder

ƒ Makes “round-trip” editing possible

ƒ Can do SQL Syntax validation outside of the database

ƒ Enables query analysis

(61)

Tour of the Query Model and Parser components

ƒ Query Model

ƒ Represent the essential structure of a query statement

ƒ Query Parser

ƒ Validate SQL source syntax and generate the query model

ƒ Parser Factory

ƒ Set of methods used by the parser to generate the model

ƒ Post-parse Processors

ƒ Validate semantics and modify the model after parsing

ƒ SQL Source Writer

ƒ Generate SQL source from the model

ƒ Model Helpers

(62)

Query Model

ƒ Represents the essential syntactic structure of a query statement as an object model

ƒ Covers DML statements

ƒ SELECT, INSERT, UPDATE, DELETE

ƒ Implemented using EMF (Eclipse Modeling Facility)

ƒ Derived from object model diagrams created using Rational Rose

ƒ Extends and complements the SQL Model

ƒ SQL Model is the foundation for the Data Studio tool set

ƒ SQL Model models the database catalog while the Query Model

(63)

Query Model - plugins

ƒ org.eclipse.datatools.modelbase.sql.query

ƒ Base query model

ƒ org.eclipse.datatools.modelbase.sql.xml.query

ƒ SQL/XML extension

ƒ Depends on:

ƒ org.eclipse.datatools.modelbase.sql

(64)

Query Model – EMF Model

ƒ Java code is generated directly from the Rose model using EMF (Eclipse Modeling Facility)

ƒ Each Rose diagram class becomes a Java class

ƒ Model classes extend EMF EObject class

ƒ EMF handles details of getters, setters, collections, notifications

ƒ Each Rose diagram class becomes two EMF classes: an interface class and an implementation (Impl) class

ƒ Generated code can be customized, and changes won't be lost when regenerated

(65)

Query Parser

ƒ Parses a SQL DML statement and generates an instance of the Query Model

ƒ Implemented using LPG (LALR Parser Generator) from IBM Research

ƒ Parser is generated from BNF-like grammar files

ƒ Like the Query Model, is actually an extendable set of parsers:

base SQL, SQL/XML

ƒ Base SQL query grammar derived from ISO SQL 2003

(66)

Parser Factory

ƒ Set of methods used by the parser to create a Query Model instance

ƒ Each parser plug-in has a parser factory class

ƒ Used in the “action” clauses of the LPG grammar file rules

ƒ In turn the parser factory methods call model factory methods to create individual model elements

ƒ Model factory code is generated by EMF, parser factory methods are hand-coded

(67)

Post-parse Processors

ƒ Query Parser provides a mechanism to allow clients to modify a generated Query Model after the Parser Factory creates it but before it is returned as a parse result

ƒ “Post-parse processors” are attached to the parser, register what model elements they are interested in, and after the parse get a chance to modify the model

ƒ Two default post-parse processors are provided:

ƒ DataTypeResolver

ƒ Tries to determine datatypes of value expressions in the model using available information

ƒ TableReferenceResolver

ƒ Replaces place-holder table references in generated model with

(68)

SQL Source Writer

ƒ Generates SQL source from a Query Model instance

ƒ Together with the Query Parser, provides “round-trip” capability from SQL to model and back

ƒ Like the model and parser, is configurable and extendable

ƒ Walks the model tree and uses reflection to find the right source writer method for each model element

(69)

Query Model Helpers

ƒ Query Model Helpers are a set of classes and methods that provide useful utility functions for the Query Model

ƒ DataTypeHelper

ƒ JoinHelper

ƒ StatementHelper

ƒ TableHelper

ƒ ValueExpressionHelper

ƒ Used both for analyzing and manipulating the model. Examples:

ƒ Find information, such as all table references or all effective result columns

ƒ Modify the model, such as remove a table and all column references for that table from a query

(70)

Extending the Query Model and Parser

ƒ Process:

ƒ Analyze the grammar feature you want to add. Is it specific to one database type, or common to several?

ƒ Modify the appropriate to add the new feature

ƒ Getting this right is not easy! Modeling is hard work.

ƒ Regenerate the EMF model

ƒ Add Parser Factory methods for the new model elements

ƒ Modify the appropriate parser grammar to cover the new syntax

ƒ Update the SQL Source Writer to generate SQL for the new syntax

ƒ Update the Query Model Helper classes as needed

ƒ Update the JUnit tests for the parser

ƒ Make sure it all works!

(71)

Fun with the interactive tester

ƒ Along with JUnit tests, the test plugins for the Query Parsers include an interactive testing tool

ƒ In org.eclipse.datatools.sqltools.parsers.sql, it's SQLQueryParserInteractiveTest

ƒ A command-line tool, works with the Eclipse console view

ƒ Type in a SQL statement, and it displays the generated model elements, then the SQL generated back out from the model

(72)

DTP Adopters

ƒ Eclipse Projects

ƒ Business Intelligence and Reporting Tools (BIRT)

ƒ SQL Query Builder

ƒ Database Enablement

ƒ Connection Profile Management

ƒ Open Data Access

http://www.eclipse.org/birt

ƒ Web Tools Project (WTP) – EJB or Dali JPA Tools development

http://www.eclipse.org/webtools

ƒ Other Adopters

http://www.eclipse.org/datatools/community.php

(73)

Legal Notices

ƒ Actuate is a registered trademark of Actuate Corporation and/or its affiliates in the U.S. and certain other countries.

ƒ IBM, Rational, Rational Rose, and WebSphere are registered trademarks of International Business Machines Corporation in the United States, other countries, or both.

ƒ Sybase and Adaptive Server are registered trademarks of Sybase, Inc. or its subsidiaries.

ƒ Java and all Java-based trademarks are trademarks of Sun

Microsystems, Inc. in the United States, other countries, or both.

ƒ Other company, product, or service names may be trademarks or service marks of others.

References

Related documents

Solid dispersion technology extremely helps in improving the dissolution property of poorly water soluble drugs. Various techniques described in this review

To check which roles are assigned to a user, review the following:. • roles_gr.sql (

Like the human eye, the relative sensitivity of a photoconductive cell is dependent on the wavelength (color) of the incident light. Each photoconductor material

Win-Situ Baro Merge™ software automatically subtracts BaroTROLL readings from data collected by an absolute Level TROLL instrument. Titanium

А для того, щоб така системна організація інформаційного забезпечення управління існувала необхідно додержуватися наступних принципів:

Finally, protease sensitivity studies in Pax3 mutants bearing engineered Factor Xa sites either in the linker separating the PAl and RED motif (position 100), or upstream the

Saturday (hard day, 6-8 hours): dojo class conditioning hard stretching sparring weight training  bag work. running

However, there were no significant differ- ences between intervention and control groups in the changes in scores on body image, self-esteem, or gender equitable norms, and there