From c6103c7c9a6b6971d2aa0b8e3997608cb5f2c36f Mon Sep 17 00:00:00 2001 From: lresende Date: Mon, 2 Nov 2009 22:22:29 +0000 Subject: Move the das folder as new trunk for das sub project git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@832144 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/das/rdb/util/Column.java | 57 ++++++ .../org/apache/tuscany/das/rdb/util/DBSchema.java | 45 +++++ .../tuscany/das/rdb/util/DBToSchemaFile.java | 119 ++++++++++++ .../tuscany/das/rdb/util/DBToXSDGenerator.java | 88 +++++++++ .../apache/tuscany/das/rdb/util/ForeignKey.java | 51 ++++++ .../apache/tuscany/das/rdb/util/ForeignKeyRef.java | 44 +++++ .../tuscany/das/rdb/util/ModelXSDGenOption.java | 133 ++++++++++++++ .../tuscany/das/rdb/util/SQLTypeChecker.java | 186 +++++++++++++++++++ .../tuscany/das/rdb/util/SchemaFileToXSD.java | 200 +++++++++++++++++++++ .../org/apache/tuscany/das/rdb/util/Table.java | 66 +++++++ 10 files changed, 989 insertions(+) create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Column.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/DBSchema.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/DBToSchemaFile.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/DBToXSDGenerator.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/ForeignKey.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/ForeignKeyRef.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/ModelXSDGenOption.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/SQLTypeChecker.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/SchemaFileToXSD.java create mode 100644 das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Table.java (limited to 'das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb') diff --git a/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Column.java b/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Column.java new file mode 100644 index 0000000000..cbadde0717 --- /dev/null +++ b/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Column.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.util; + +public class Column { + private String name; + private String type; + private boolean isPK; + private boolean isRequired; + + protected String getName() { + return name; + } + protected void setName(String name) { + this.name = name; + } + protected String getType() { + return type; + } + protected void setType(String type) { + this.type = type; + } + protected boolean isPK() { + return isPK; + } + protected void setPK(boolean isPK) { + this.isPK = isPK; + } + protected boolean isRequired() { + return isRequired; + } + protected void setRequired(boolean isRequired) { + this.isRequired = isRequired; + } + + public String toString() { + StringBuffer dbSchemaStr = new StringBuffer(); + dbSchemaStr.append("Name:"+this.getName()+", Type:"+this.getType()+", isPK:"+this.isPK()+", isRequired:"+this.isRequired()+"\n"); + return dbSchemaStr.toString(); + } +} diff --git a/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/DBSchema.java b/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/DBSchema.java new file mode 100644 index 0000000000..4ae038b24d --- /dev/null +++ b/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/DBSchema.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.util; + +import java.util.ArrayList; +import java.util.List; + +public class DBSchema { + private List tables = new ArrayList(); + + protected List getTables() { + return tables; + } + + protected void setTables(List tables) { + this.tables = tables; + } + + public String toString() { + StringBuffer dbSchemaStr = new StringBuffer(); + dbSchemaStr.append("_____DB SChema_______\n"); + for(int i=0; i\n"; + String endLine = ""; + + if(xsdModelFileName != null && !xsdModelFileName.trim().equals("")) { + writeFilesToDir = true; + } + + //get all FKs to form a Map - PKtable -> FKTable , e.g. if CITIES has FK such that CITIES.STATE_ID is STATES.ID, then + //the map shall have STATES -> CITIES, TABLE2,... + Hashtable pkTofkTable = new Hashtable(); + + for(int i=0; i\n"; + srcCode = srcCode + " \n"; + + for(int j=0; j\n"; + } + + if(pkTofkTable.get(curTable.getName()) != null) { + ArrayList fkTables = (ArrayList)pkTofkTable.get(curTable.getName()); + + for(int k=0; k\n"; + } + } + + srcCode = srcCode + " \n"; + srcCode = srcCode + "\n\n"; + } + + srcCode = srcCode + endLine; + + File javaFile = new File(xsdModelFileName); + javaFile.createNewFile(); + PrintStream flStrm = new PrintStream(javaFile); + + if(writeFilesToDir) { + flStrm.print(srcCode); + flStrm.flush(); + flStrm.close(); + } else { + System.out.print(srcCode); + } + } +} \ No newline at end of file diff --git a/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Table.java b/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Table.java new file mode 100644 index 0000000000..c41085cf2f --- /dev/null +++ b/das-java/trunk/tools/src/main/java/org/apache/tuscany/das/rdb/util/Table.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.util; + +import java.util.ArrayList; +import java.util.List; + +public class Table { + private String name; + private List columns = new ArrayList(); + private List fks = new ArrayList(); + + protected String getName() { + return name; + } + protected void setName(String name) { + this.name = name; + } + protected List getColumns() { + return columns; + } + protected void setColumns(List columns) { + this.columns = columns; + } + protected List getFks() { + return fks; + } + protected void setFks(List fks) { + this.fks = fks; + } + + public String toString() { + StringBuffer dbSchemaStr = new StringBuffer(); + dbSchemaStr.append("_____Table_______"+this.name+"\n"); + dbSchemaStr.append("_____Columns_______\n"); + for(int i=0; i 0) + dbSchemaStr.append("_____FKs_______\n"); + for(int i=0; i