Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wich

Starting with DAS

This page provides a simple "how to" and give a step-by-step to build a is a quick guide for building a simple aplication using DAS/SDO
features from Tuscany project. Here you'll build our "CompanyWeb Sample Web Application". This sample uses
Mysql . You will learn the simple steps required to
build "CompanyWeb" sample web application. This sample users MySQL and Tomcat.

A. Initial Setup

  1. Install Tomcat(latest version) and MysqlMySQL(latest version). which version of the Tomcat and MySQL is this tested with?
  2. Download dependencies and libraries Please add a link to this information. Which dependencies and libraries?
  3. Create companyweb directory in (Tomcat root)/webapps/. EX: (Tomcat root)/webapps/companyweb
  4. Create the directory (Tomcat root)/webapps/companyweb/WEB-INF/lib and put copy the libraries in into it. Otherwise As an alternative, you can put them in copy the libraries into (Tomcat root)/common/lib directory.
  5. The required libraries are:
    i) common-(latest version).jar
    ii) ecore-(latest version).jar
    iii) ecore-change-(latest version).jar
    iv) ecore-xmi-(lateste version).jar
    v) log4j-(latest version).jar
    vi) sdo-api-xxx.jar
    vii) tuscany-das-rdb-xxx.jar
    viii) tuscany-sdo-xxx.jar
    ix) xsd-(latest version).jar
    x) mysql-connector-java-(latest version).jar -> This is the JDBC connector, It'll be used to connect to Mysql database

B. Creating CompanyWeb Database

After the setting up your enviroment, the next step will be to create the databse where the DAS will connect and manage the transaction with the SDO featuresinteract with.

  1. Run the following commands in the Mysql MySQL Command Shell
    create database companyweb; -> This command will create the CompanyWeb database
    use companyweb; -> Set the shell to work with companyweb database
  2. Create a text file and name it as "comapnyweb.sql", you should insert the following lines in this file
    No Format
    CREATE TABLE EMPLOYEE ( 
    ID INTEGER NOT NULL AUTO_INCREMENT, NAME VARCHAR(30), SN VARCHAR(10), MANAGER SMALLINT, DEPARTMENTID INTEGER, PRIMARY KEY (ID) 
    ); 
    
    CREATE TABLE DEPARTMENT ( 
    ID INTEGER NOT NULL AUTO_INCREMENT, NAME VARCHAR(30), LOCATION VARCHAR(30), NUMBER VARCHAR(10), COMPANYID INTEGER, EOTM INTEGER, PRIMARY KEY (ID) 
    ); 
    
    CREATE TABLE COMPANY ( 
    ID INTEGER NOT NULL AUTO_INCREMENT, NAME VARCHAR(30), PRIMARY KEY (ID) 
    ); 
    
    CREATE UNIQUE INDEX SQL060217085530980 ON COMPANY (ID ASC); 
    
    CREATE UNIQUE INDEX SQL060217085531710 ON DEPARTMENT (ID ASC); 
    
    INSERT INTO COMPANY VALUES (51, "ACME Publishing"); 
    
    INSERT INTO COMPANY VALUES (52, "Do-rite plumbing"); 
    
    INSERT INTO COMPANY VALUES (53, "MegaCorp"); 
    
  3. Run the following command in the Mysql Shell to execute the script that creates tables, constraints, etc.
    Code Block
    
    source (path)/companyweb.sql
    -> Executes the script to create tables, constraints, etc
      
    

C. Creating XML configuration file

Would be nice to explain what this file is used for

  1. Create the file CompanyConfig.xml in the directory (Tomcat root)/webapps/companyweb/WEB-INF/classes
  2. Edit it and write the following code
    No Format
    <?xml version="1.0" encoding="ASCII"?> 
    <Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
    
    <Command name="all companies" SQL="select * from COMPANY" kind="Select"/> 
    <Command name="all companies and departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID" kind="Select"/> 
    <Command name="all departments for company" SQL="select * from COMPANY inner join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/> 
    <Command name="company by id with departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/> 
    <Table tableName="COMPANY"> 
    <Column columnName="ID" primaryKey="true" generated="true"/> 
    </Table> 
    <Table tableName="DEPARTMENT"> 
    ?	<Column columnName="ID" primaryKey="true" generated="true"/> 
    </Table> 
    <Relationship name="departments" primaryKeyTable="COMPANY" foreignKeyTable="DEPARTMENT" many="true"> 
    <KeyPair primaryKeyColumn="ID" foreignKeyColumn="COMPANYID"/> 
    </Relationship> 
    </Config> 
    
  3. Save the file.

...