You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Amita Vadhavkar <am...@gmail.com> on 2007/02/09 15:01:27 UTC

DAS - JIRA-952 - multiple database schema support

Hi All,

Please see the below details for DAS JIRA-952 - mutliple schema support.
I have made an attempt to analyze a scenario and change code and test
with basic set of test cases. Details as below. Please give me your
feedback.

If below is what is expected out of this JIRA, please let me know if I can
provide a patch to it and continue working for completion.

Also, a question, what I have done manually in TableImpl.java and
ResultDescriptorImpl.java,
i.e. have a logic in auto-generated code in get..(), is there any feature in
tuscany-SDO
or eclipse SDO which support such simple manipulations? i.e. in other words,
how to
map 1 property from SDO - say SDOTableName to 2 properties from config
(TableName
and SchemaName, based on null/"" detection).

There is one old thread listing here for ref.
http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg11282.html

________________________________________________________________________________________
Note:

Scenario is created in db2, where 1 database dastest has 3 schemas which are
dastest1
dastest2
db2admin

db2admin also is the login id used to get connection to db.

dastest1 and db2admin both have table customer, in which 1 col name is same
- ID and other col names
differ.

dastest2 has table customer_account which has customer_id present.
________________________________________________________________________________________

Code changes:

1) config.xsd - schemaName attribute added to <Table> and to
<ResultDescriptor>
<xsd:attribute name="schemaNameSupport" type="xsd:boolean"
default="false"/> added to <Config>

schemaNameSupport will aid to switch on/off the new feature, with off as
default. With this
the old test cases, xmls will work as is. When off, the config xml should
not provide
attribute schemaName in any <Table> or <ResultDescriptor>.

2) sdo-source/
org.apache.tuscany.das.rdb.config.impl.TableImpl
 public String getTableName()
  {
   if(schemaName != null && !schemaName.equals("")){
    return schemaName+"."+tableName;
   }
    return tableName;
  }

3)sdo-source/
org.apache.tuscany.das.rdb.config.impl.ResultDescriptorImpl
 public String getTableName()
  {
   if(schemaName != null && !schemaName.equals("")){
    return schemaName+"."+tableName;
   }
    return tableName;
  }

4)
org.apache.tuscany.das.rdb.impl.ResultSetShape constructor

if(model.getSchemaNameSupport()){
 if(metadata.getSchemaName(i) != null &&
!metadata.getSchemaName(i).equals("")){
  tables[i - 1] = metadata.getSchemaName(i)+"."+metadata.getTableName(i);
 }
 else{
  tables[i - 1] = metadata.getTableName(i);
 }
}
else{
 tables[i - 1] = metadata.getTableName(i);
}


5) org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper
changes in methods like getTableTypeName() to check if schemaNameSupport is
on/off
and based on that if a tableName contains schemaName+".", keep it or remove
it.

If user follows a convention that, when schemaNameSupport is true, provide
schemaName in
<Table> and don't provide same when schemaNameSupport is false, no changes
will be required
in MappingWrapper. The changes are only to keep DAS working in case users do
not follow this
convention.

____________________________________________________________________________________________

Test cases:

Currently test cases are added in sample-customer-j2se-das, the sample
I have introduced in JIRA-948, for ease of testing, Can add test cases to
run through mvn too.

1) when schemaName, typeName, tableName there and typeName ensured non
unique,
select - works correct
update - works correct
insert - execute(), works correct
insert - applyChanges(), works correct
delete - execute(), works correct
delete - applyChanges(), works correct

2) when schemaName, tableName there and typeName not there,
select - works correct
update - works correct
insert - execute(), works correct
insert - applyChanges(), works correct
delete - execute(), works correct
delete - applyChanges(), works correct

3) when table itself is not there in config -
works correct for insert(execute()), delete(execute()),select
and
fails with expected exception as below for insert(applyChanges()),
delete(applyChanges()) and update
Table DASTEST1.CUSTOMER was changed in the DataGraph but is not present in
the Config

4) when no schemaName in config and table exists in the schema of login id
works correct - root.getList(SchemaName.TableName) is required to verify
results.

5) when no schemaName in config <Table> and table does not exist in the
schema of login id
works correct

6) all existing mvn test cases are working

7) when both schema's customer tables have same column names - viz. ID
works correct
8) Use of ResultDescriptor
works correct

Regards,
Amita