Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r306 - trunk: . lib src/org/argouml/i18n src/org/argouml/language/sql src/org/argouml/language/sql/reveng

argouml-sql
Discussion topic

Back to topic list

svn commit: r306 - trunk: . lib src/org/argouml/i18n src/org/argouml/language/sql src/org/argouml/language/sql/reveng

Author closettop_nightlybuild
Full name ArgoUML Nightly Build (monitored by Linus Tolke)
Date 2013-05-16 22:02:22 PDT
Message Author: closettop_nightlybuild
Date: 2013-05-16 22:02:21-0700
New Revision: 306

Added:
   trunk/lib/
   trunk/lib/antlr-2.7.7.jar
   trunk/lib/antlr-runt​ime-3.1.1.jar
   trunk/lib/antlrworks-1.2.2.jar
   trunk/src/org/argoum​l/language/sql/reven​g/
   trunk/src/org/argoum​l/language/sql/reven​g/ANTLRNoCaseInputSt​reamReader.java
   trunk/src/org/argoum​l/language/sql/reven​g/Modeller.java
   trunk/src/org/argoum​l/language/sql/reven​g/MySql.g
   trunk/src/org/argoum​l/language/sql/reven​g/SqlImport.java
   trunk/src/org/argoum​l/language/sql/reven​g/SqlImportSettings.​java
   trunk/src/org/argoum​l/language/sql/reven​g/SqlServer.g
Modified:
   trunk/.classpath
   trunk/ArgoUML with Sql.launch
   trunk/build.xml
   trunk/pom.xml
   trunk/src/org/argoum​l/i18n/argouml-sql.p​roperties
   trunk/src/org/argoum​l/language/sql/Colum​nDefinition.java
   trunk/src/org/argoum​l/language/sql/Forei​gnKeyDefinition.java​
   trunk/src/org/argoum​l/language/sql/Index​Definition.java
   trunk/src/org/argoum​l/language/sql/Table​Definition.java

Log:
Import a simple Script (like mysqlDump, or from Sql server)

Only tables name,columns and FK are imported (as a class/attribute/
association or generalization). No stereotype yet.
Ignore DROP TABLE, for testing some MySQL script get with
 mysqldump -u root -p --no-data icescrum > myFile.sql
Setting for choosing dump Database (MySQL / SqlServer)
Setting for building model :
 If a column belong to a FK, enable to create it or not in the model

Initial value for Mysql and SqlServer (String / Numeric)
If a is value is null, multiplicity is 0..1, otherwise 1.
For a FK, if a column can be null then I choose that the association is
0..1

Contributed-by: Laurent BRAUD

Change-Id: I1d0d67f67559aba28a4​3535b8e913245bf70108​b

Modified: trunk/.classpath
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/.classpath?view=di​ff&pathrev=306​&r1=305&r2=306​
====================​====================​====================​==================
--- trunk/.classpath (original)
+++ trunk/.classpath 2013-05-16 22:02:21-0700
@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
- <classpathentry kind="con" path="org.eclipse.jd​t.launching.JRE_CONT​AINER/org.eclipse.jd​t.internal.debug.ui.​launcher.StandardVMT​ype/JavaSE-1.6"/>​
+ <classpathentry kind="con" path="org.eclipse.jd​t.launching.JRE_CONT​AINER/org.eclipse.jd​t.internal.debug.ui.​launcher.StandardVMT​ype/JavaSE-1.6"/>​
     <classpathentry kind="con" path="org.eclipse.pd​e.core.requiredPlugi​ns"/>
     <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src_generated"/>
     <classpathentry kind="src" path="tests"/>
     <classpathentry kind="con" path="org.eclipse.jd​t.junit.JUNIT_CONTAI​NER/3"/>
+ <classpathentry kind="lib" path="lib/antlr-runt​ime-3.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/>
     <classpathentry kind="output" path="build-eclipse"/>
 </classpath>

Modified: trunk/ArgoUML with Sql.launch
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/ArgoUML%20with%20S​ql.launch?view=diff​&pathrev=306&​r1=305&r2=306
====================​====================​====================​==================
--- trunk/ArgoUML with Sql.launch (original)
+++ trunk/ArgoUML with Sql.launch 2013-05-16 22:02:21-0700
@@ -34,5 +34,5 @@
 <booleanAttribute key="org.eclipse.jdt​.launching.DEFAULT_C​LASSPATH" value="false"/>
 <stringAttribute key="org.eclipse.jdt​.launching.MAIN_TYPE​" value="org.argouml.a​pplication.Main"/​>
 <stringAttribute key="org.eclipse.jdt​.launching.PROJECT_A​TTR" value="argouml-module-sql"/>
-<stringAttribute key="org.eclipse.jdt​.launching.VM_ARGUME​NTS" value="-Xmx400M -ea -Dlog4j.configuratio​n=org/argouml/resour​ce/info_console.lcf -Dargouml.modules=or​g.argouml.sequence2.​SequenceDiagramModul​e;org.argouml.langua​ge.sql.SqlInit;org.a​rgouml.core.property​panels.module.XmlPro​pertyPanelsModule"/​>
+<stringAttribute key="org.eclipse.jdt​.launching.VM_ARGUME​NTS" value="-Xmx400M -ea -Dlog4j.configuratio​n=org/argouml/resour​ce/info_console.lcf -Dargouml.modules=or​g.argouml.sequence2.​SequenceDiagramModul​e;org.argouml.langua​ge.sql.SqlInit;org.a​rgouml.language.sql.​reveng.SqlImport;org​.argouml.core.proper​typanels.module.XmlP​ropertyPanelsModule"​/>
 </launchConfiguration>

Modified: trunk/build.xml
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/build.xml?view=dif​f&pathrev=306​&r1=305&r2=306
====================​====================​====================​==================
--- trunk/build.xml (original)
+++ trunk/build.xml 2013-05-16 22:02:21-0700
@@ -20,6 +20,7 @@
     <target name="init">
         <property name="build.dir" value="build" />
         <property name="build.classes" value="${build.dir}/classes" />
+ <property name="module.root" location="."/>
         <property name="module.src.dir" value="src" />
         <property name="module.tests.src" value="tests" />
         <property name="module.tests.reports" value="${build.dir}/tests" />
@@ -27,6 +28,14 @@
                 value="${module.tes​ts.reports}/html" />
         <property name="module.javadocs.dir" value="${build.dir}/javadocs" />
 
+ <property name="module.src_generated.dir" value="${module.roo​t}/src_generated"/​>
+
+ <property name="module.lib.dir" value="${module.root}/lib"/>
+
+ <property name="antlr-rt.jar" value="antlr-runtime​-3.1.1.jar"/>
+ <property name="antlrall.jar.path" value="${module.lib​.dir}/antlrworks-1.2​.2.jar"/>
+ <property name="antlr-rt.jar.path" value="${module.lib​.dir}/${antlr-rt.ja​r}"/>
+
         <property name="debug" value="yes" />
         <property name="deprecation" value="yes" />
         <property name="optimize" value="yes" />
@@ -55,7 +64,8 @@
         </path>
         
         <mkdir dir="${build.dir}" />
-
+ <mkdir dir="${module.src_g​enerated.dir}"/>
+
         <copy file="${module.src.​dir}/org/argouml/lan​guage/sql/domainmapp​ing.xml"
                 todir="${build.dir}"/>
         <copy todir="${build.classes}">
@@ -77,18 +87,49 @@
             </classpath>
         </java>
     </target>
-
+ <!-- ====================​====================​====================​======= -->
+ <!-- Generates the parser and lexer classes -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="generateparser" depends="init" description="Generates the parser and lexer classes">
+ <uptodate property="parser.is.current"
+ targetfile="${modul​e.src_generated.dir}​/org/argouml/languag​e/sql/reveng/MySql.t​okens">
+
+ <srcfiles dir="${module.src.d​ir}/org/argouml/lang​uage/sql/reveng">​
+ <include name="MySql.g"/>
+ <include name="SqlServer.g"/>
+ </srcfiles>
+ </uptodate>
+ <antcall target="generatepars​er_internal"/>
+
+ </target>
+
+
+ <target name="generateparser_internal" unless="parser.is.current"
+ depends="init">
+ <echo message="Running antlr3 from ${antlrall.jar.path}"/>
+ <java classname="org.antlr.Tool" fork="yes" maxmemory="128M" classpath="${antlra​ll.jar.path}">
+ <arg value="-o"/>
+ <arg file="${module.src_​generated.dir}/org/a​rgouml/language/sql/​reveng"/>
+ <arg file="${module.src.​dir}/org/argouml/lan​guage/sql/reveng/MyS​ql.g"/>
+ </java>
+ <java classname="org.antlr.Tool" fork="yes" maxmemory="128M" classpath="${antlra​ll.jar.path}">
+ <arg value="-o"/>
+ <arg file="${module.src_​generated.dir}/org/a​rgouml/language/sql/​reveng"/>
+ <arg file="${module.src.​dir}/org/argouml/lan​guage/sql/reveng/Sql​Server.g"/>
+ </java>
+ </target>
+
     <!-- ====================​====================​====================​======= -->
     <!-- Compiles the source directory -->
     <!-- ====================​====================​====================​======= -->
- <target name="compile" depends="init" description="Compile the sources.">
+ <target name="compile" depends="generateparser" description="Compile the sources.">
         <!-- create directories -->
         <mkdir dir="${build.classes}" />
 
         <javac srcdir="src" destdir="${build.classes}"
                 includes="org/argoum​l/**/*.java" debug="${debug}"
                 deprecation="${deprecation}" optimize="${optimize}"
- source="1.5" target="1.5">
+ source="1.6" target="1.6">
             <classpath>
                 <path refid="compile.classpath" />
             </classpath>
@@ -140,7 +181,7 @@
         <javac srcdir="${module.tests.src}" destdir="${build.classes}"
                 includes="org/argoum​l/**/*.java" debug="${debug}"
                 deprecation="${deprecation}" optimize="${optimize}"
- source="1.5" target="1.5">
+ source="1.6" target="1.6">
             <classpath>
                 <path refid="compile.classpath" />
                 <pathelement location="${junit.jar.path}" />
@@ -216,7 +257,7 @@
                  destdir="${module.j​avadocs.dir}"
                  maxmemory="128M"
                  packagenames="org.argouml.*"
- source="1.5"
+ source="1.6"
                  use="true"
                  windowtitle="ArgoUML-SQL Javadoc for internal use">
             <sourcepath>

Added: trunk/lib/antlr-2.7.7.jar
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/lib/antlr-2.7.7.ja​r?view=markup&pa​threv=306
====================​====================​====================​==================
Binary files (empty file) and trunk/lib/antlr-2.7.7.jar 2013-05-16 22:02:21-0700 differ

Added: trunk/lib/antlr-runt​ime-3.1.1.jar
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/lib/antlr-runtime-​3.1.1.jar?view=marku​p&pathrev=306
====================​====================​====================​==================
Binary files (empty file) and trunk/lib/antlr-runt​ime-3.1.1.jar 2013-05-16 22:02:21-0700 differ

Added: trunk/lib/antlrworks-1.2.2.jar
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/lib/antlrworks-1.2​.2.jar?view=markup​&pathrev=306
====================​====================​====================​==================
Binary files (empty file) and trunk/lib/antlrworks-1.2.2.jar 2013-05-16 22:02:21-0700 differ

Modified: trunk/pom.xml
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/pom.xml?view=diff​&pathrev=306&​r1=305&r2=306
====================​====================​====================​==================
--- trunk/pom.xml (original)
+++ trunk/pom.xml 2013-05-16 22:02:21-0700
@@ -46,14 +46,46 @@
       <type>jar</type>
       <scope>compile​</scope>
     </dependency>
- </dependencies>
 
+ <dependency>
+ <groupId>antlr​</groupId>
+ <artifactId>an​tlr</artifactId​>
+ <version>2.7.7​-3</version>
+ <scope>compile​</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>antlr​</groupId>
+ <artifactId>an​tlr-runtime</arti​factId>
+ <version>3.1.1​-2</version>
+ <scope>compile​</scope>
+ </dependency>
 
+ </dependencies>
+
   <name>argouml-​sql</name>
   <description>
 SQL support for argouml.
   </description>
-
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.a​ntlr</groupId>​
+ <artifactId>an​tlr3-maven-plugin​</artifactId>
+ <version>3.1.3​-1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <sourceDirectory​>${project.basedi​r}/src</sourceDir​ectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
   <scm>
     <connection>scm:svn:http://argouml-sql.t​igris.org/svn/argoum​l-sql/trunk/</con​nection>
     <developerConnect​ion>scm:svn:http://argouml-sql.t​igris.org/svn/argoum​l-sql/trunk/</dev​eloperConnection>​

Modified: trunk/src/org/argoum​l/i18n/argouml-sql.p​roperties
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/i1​8n/argouml-sql.prope​rties?view=diff&​pathrev=306&r1=3​05&r2=306
====================​====================​====================​==================
--- trunk/src/org/argoum​l/i18n/argouml-sql.p​roperties (original)
+++ trunk/src/org/argoum​l/i18n/argouml-sql.p​roperties 2013-05-16 22:02:21-0700
@@ -1,3 +1,38 @@
+#******************​********************​********************​********************​
+# Copyright (c) 2010 Contributors - see below
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.o​rg/legal/epl-v10.htm​l
+#
+# Contributors:
+# Laurent BRAUD
+#******************​********************​********************​********************​
+#
+# Some portions of this file was previously release using the BSD License:
+#
+# Copyright (c) 2003-2007 The Regents of the University of California. All
+# Rights Reserved. Permission to use, copy, modify, and distribute this
+# software and its documentation without fee, and without a written
+# agreement is hereby granted, provided that the above copyright notice
+# and this paragraph appear in all copies. This software program and
+# documentation are copyrighted by The Regents of the University of
+# California. The software program and documentation are supplied "AS
+# IS", without any accompanying services from The Regents. The Regents
+# does not warrant that the operation of the program will be
+# uninterrupted or error-free. The end-user understands that the program
+# was developed for research purposes and is advised not to rely
+# exclusively on the program for any reason. IN NO EVENT SHALL THE
+# UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+# SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+# THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+# PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+# CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+# UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 argouml-sql.settings​.title=ArgoUML-SQL
 argouml-sql.settings​.domain=domain
 argouml-sql.settings​.datatype=datatype
@@ -10,3 +45,13 @@
 argouml-sql.select-d​ialog.label-select=P​lease select one of the following found code creators
 
 argouml-sql.exceptio​ns.no_sqlcodecreator​=SqlCodeCreator could not be instantiated
+
+argouml-sql.filefilter.sql = Sql source files
+
+argouml-sql.import.​listdatabase = Script from :
+argouml-sql.import.​database.MySql = MySQL / MariaDB dump
+argouml-sql.import.​database.SqlServer = SQL Server
+
+argouml-sql.import.level = Level :
+argouml-sql.import.level.MCD = Conception
+argouml-sql.import.level.MPD = Physical

Modified: trunk/src/org/argoum​l/language/sql/Colum​nDefinition.java
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/ColumnDef​inition.java?view=di​ff&pathrev=306​&r1=305&r2=306​
====================​====================​====================​==================
--- trunk/src/org/argoum​l/language/sql/Colum​nDefinition.java (original)
+++ trunk/src/org/argoum​l/language/sql/Colum​nDefinition.java 2013-05-16 22:02:21-0700
@@ -8,6 +8,7 @@
  *
  * Contributors:
  * drahmann
+ * Laurent BRAUD
  ********************​********************​********************​*****************
  *
  * Some portions of this file was previously release using the BSD License:
@@ -46,12 +47,26 @@
 public class ColumnDefinition {
     private String datatype;
 
- private Object defaultValue;
+ private String defaultValue;
 
     private String name;
 
     private Boolean nullable;
 
+ private Integer length;
+
+ private Integer nbDecimal;
+
+ /**
+ * Comment, label,...
+ */
+ private String comment;
+
+ /**
+ * Table where is the column.
+ */
+ private TableDefinition table;
+
     /**
      * Creates a new column definition.
      *
@@ -60,6 +75,13 @@
         super();
     }
 
+ public ColumnDefinition(Tab​leDefinition table, String name) {
+ this();
+ this.name = name;
+ this.table = table;
+ table.addColumnDefin​ition(this);
+ }
+
     /**
      * Creates a new column definition with the given attributes.
      *
@@ -75,6 +97,27 @@
     }
 
     /**
+ * return the column in the table.
+ * If doesn't exist, create it.
+ *
+ * Use this because if 2 (or a third) classes references each other, we need to be able to import a FK
+ * with a REFERENCES table which doesn't exist.(mysql: FOREIGN_KEY_CHECKS=0 )
+ *
+ * @param table
+ * @param columnName
+ * @return
+ */
+ public static ColumnDefinition findOrCreateColumnDe​finition(TableDefini​tion table,
+ String columnName) {
+ ColumnDefinition ret = table.getColumnDefin​ition(columnName);
+ if(ret == null) {
+ ret = new ColumnDefinition(table, columnName);
+ }
+
+ return ret;
+ }
+
+ /**
      *
      * @return The datatype of the column definition.
      */
@@ -86,7 +129,7 @@
      *
      * @return The default Value of the column definition.
      */
- public Object getDefaultValue() {
+ public String getDefaultValue() {
         return defaultValue;
     }
 
@@ -120,7 +163,7 @@
      *
      * @param defaultValue
      */
- public void setDefaultValue(Object defaultValue) {
+ public void setDefaultValue(String defaultValue) {
         this.defaultValue = defaultValue;
     }
 
@@ -141,4 +184,36 @@
     public void setNullable(Boolean nullable) {
         this.nullable = nullable;
     }
+
+ public Integer getLength() {
+ return length;
+ }
+
+ public void setLength(Integer length) {
+ this.length = length;
+ }
+
+ public Integer getNbDecimal() {
+ return nbDecimal;
+ }
+
+ public void setNbDecimal(Integer nbDecimal) {
+ this.nbDecimal = nbDecimal;
+ }
+
+ public TableDefinition getTable() {
+ return table;
+ }
+
+ public void setTable(TableDefinition table) {
+ this.table = table;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
 }

Modified: trunk/src/org/argoum​l/language/sql/Forei​gnKeyDefinition.java​
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/ForeignKe​yDefinition.java?vie​w=diff&pathrev=3​06&r1=305&r2​=306
====================​====================​====================​==================
--- trunk/src/org/argoum​l/language/sql/Forei​gnKeyDefinition.java​ (original)
+++ trunk/src/org/argoum​l/language/sql/Forei​gnKeyDefinition.java​ 2013-05-16 22:02:21-0700
@@ -73,6 +73,12 @@
         columns = new ArrayList<ColumnD​efinition>();
         referencesColumns = new ArrayList<ColumnD​efinition>();
     }
+
+ public ForeignKeyDefinition​(TableDefinition table) {
+ this();
+ this.table = table;
+ this.table.addFkDefi​nition(this);
+ }
 
     /**
      * @return A List of all column names.
@@ -97,6 +103,19 @@
     }
 
     /**
+ * Add a column definition (from its name )
+ * @param nameColDef
+ */
+ public void addColumnDefinition(String nameColDef) {
+ ColumnDefinition colDef = table.getColumnDefin​ition(nameColDef);
+
+ if (colDef == null) {
+ colDef = new ColumnDefinition(table, nameColDef);
+ }
+ columns.add(colDef);
+ }
+
+ /**
      * @return A List with all referenced column definitions.
      */
     public List<String> getReferencesColumnNames() {
@@ -118,6 +137,21 @@
     }
 
     /**
+ * Add a referenced column definition (from its name )
+ * @param nameColDef
+ *
+ * pre : referencesTable contains nameColDef
+ */
+ public void addReferencesColumn(String nameColDef) {
+ ColumnDefinition colDef = referencesTable.getC​olumnDefinition(name​ColDef);
+
+ if (colDef == null) {
+ colDef = new ColumnDefinition(ref​erencesTable, nameColDef);
+ }
+ referencesColumns.add(colDef);
+ }
+
+ /**
      * @return Returns the columns.
      */
     public List<ColumnDefinition> getColumns() {
@@ -146,6 +180,24 @@
     }
 
     /**
+ * Return true if the columnName is in the table.
+ * @param columnName
+ * @return
+ */
+ public boolean hasColumnInTable(String columnName) {
+ boolean ret = false;
+
+ for(ColumnDefinition col : columns) {
+ if (columnName.equals(c​ol.getName())) {
+ ret = true;
+ break;
+ }
+ }
+
+ return ret;
+ }
+
+ /**
      * @return Returns the referencesLower.
      */
     public int getReferencesLower() {

Modified: trunk/src/org/argoum​l/language/sql/Index​Definition.java
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/IndexDefi​nition.java?view=dif​f&pathrev=306​&r1=305&r2=306
====================​====================​====================​==================
--- trunk/src/org/argoum​l/language/sql/Index​Definition.java (original)
+++ trunk/src/org/argoum​l/language/sql/Index​Definition.java 2013-05-16 22:02:21-0700
@@ -1,6 +1,6 @@
 /* $Id$
  ********************​********************​********************​*****************
- * Copyright (c) 2009 Contributors - see below
+ * Copyright (c) 2009-2013 Contributors - see below
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  *
  * Contributors:
  * drahmann
+ * Laurent BRAUD
  ********************​********************​********************​*****************
  *
  * Some portions of this file was previously release using the BSD License:

Modified: trunk/src/org/argoum​l/language/sql/Table​Definition.java
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/TableDefi​nition.java?view=dif​f&pathrev=306​&r1=305&r2=306
====================​====================​====================​==================
--- trunk/src/org/argoum​l/language/sql/Table​Definition.java (original)
+++ trunk/src/org/argoum​l/language/sql/Table​Definition.java 2013-05-16 22:02:21-0700
@@ -1,6 +1,6 @@
 /* $Id$
  ********************​********************​********************​*****************
- * Copyright (c) 2009 Contributors - see below
+ * Copyright (c) 2009-2013 Contributors - see below
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  *
  * Contributors:
  * drahmann
+ * Laurent BRAUD
  ********************​********************​********************​*****************
  *
  * Some portions of this file was previously release using the BSD License:
@@ -51,25 +52,32 @@
 public class TableDefinition {
     private String name;
 
- private List columnDefinitions;
+ private List<ColumnDefinition> columnDefinitions;
 
- private List primaryKeyFields;
+ private List<String> primaryKeyFields;
 
- private Map columnDefNames;
+ private Map<String, ColumnDefinition> columnDefNames;
 
+ private List<ForeignKeyDe​finition> fkDefinitions;
+
+ /**
+ * Comment (mysql), label (iSeries/DB2)
+ */
+ private String comment;
     /**
      * Creates a new TableDefinition.
      */
     public TableDefinition() {
- columnDefinitions = new ArrayList();
- primaryKeyFields = new ArrayList();
- columnDefNames = new HashMap();
+ columnDefinitions = new ArrayList<ColumnD​efinition>();
+ primaryKeyFields = new ArrayList<String>();
+ columnDefNames = new HashMap<String, ColumnDefinition>();
+ fkDefinitions = new ArrayList<Foreign​KeyDefinition>();​
     }
 
     /**
      * @return Returns the columnDefinitions.
      */
- public List getColumnDefinitions() {
+ public List<ColumnDefinition> getColumnDefinitions() {
         return columnDefinitions;
     }
 
@@ -109,10 +117,18 @@
         this.name = name;
     }
 
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
     /**
      * @return Returns the primaryKeyFields.
      */
- public List getPrimaryKeyFields() {
+ public List<String> getPrimaryKeyFields() {
         return primaryKeyFields;
     }
 
@@ -128,4 +144,14 @@
     public ColumnDefinition getColumnDefinition(String name) {
         return (ColumnDefinition) columnDefNames.get(name);
     }
+
+
+ public List<ForeignKeyDe​finition> getFkDefinitions() {
+ return fkDefinitions;
+ }
+
+ public void addFkDefinition(Fore​ignKeyDefinition fkDefinition) {
+ this.fkDefinitions.a​dd(fkDefinition);
+ }
+
 }

Added: trunk/src/org/argoum​l/language/sql/reven​g/ANTLRNoCaseInputSt​reamReader.java
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/reveng/AN​TLRNoCaseInputStream​Reader.java?view=mar​kup&pathrev=306
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/org/argoum​l/language/sql/reven​g/ANTLRNoCaseInputSt​reamReader.java 2013-05-16 22:02:21-0700
@@ -0,0 +1,49 @@
+/* $Id$
+ ********************​********************​********************​*******************
+ * Copyright (c) 2013 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.o​rg/legal/epl-v10.htm​l
+ *
+ * Contributors:
+ * Laurent BRAUD
+ ********************​********************​********************​*******************
+ */
+
+package org.argouml.language​.sql.reveng;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.antlr.runtime.AN​TLRReaderStream;
+import org.antlr.runtime.CharStream;
+
+/**
+ * Usefull because syntaxe SQL is not case sentisive.
+ *
+ * http://www.antlr.org​/wiki/pages/viewpage​.action?pageId=1782
+ */
+public class ANTLRNoCaseInputStreamReader extends ANTLRReaderStream {
+
+ public ANTLRNoCaseInputStre​amReader(InputStream​Reader is) throws IOException {
+ super(is);
+ }
+
+ @Override
+ public int LA(int i) {
+ if (i == 0) {
+ return 0; // undefined
+ }
+ if (i < 0) {
+ i++; // e.g., translate LA(-1) to use offset 0
+ }
+
+ if ((p + i - 1) >= n) {
+
+ return CharStream.EOF;
+ }
+ return Character.toUpperCase(data[p + i - 1]);
+ }
+
+}

Added: trunk/src/org/argoum​l/language/sql/reven​g/Modeller.java
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/reveng/Mo​deller.java?view=mar​kup&pathrev=306
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/org/argoum​l/language/sql/reven​g/Modeller.java 2013-05-16 22:02:21-0700
@@ -0,0 +1,523 @@
+/* $Id$
+ ********************​********************​********************​*******************
+ * Copyright (c) 2013 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.o​rg/legal/epl-v10.htm​l
+ *
+ * Contributors:
+ * Laurent BRAUD (From Java module)
+ ********************​********************​********************​*******************
+ */
+
+package org.argouml.language​.sql.reveng;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.argouml.applicat​ion.api.Argo;
+
+import org.argouml.kernel.P​rojectManager;
+import org.argouml.language​.sql.ColumnDefinitio​n;
+import org.argouml.language​.sql.ForeignKeyDefin​ition;
+import org.argouml.language​.sql.TableDefinition​;
+import org.argouml.model.Model;
+
+
+import org.argouml.profile.Profile;
+
+public class Modeller {
+ private static final int ASSOCIATION = 1;
+ private static final int GENERALIZATION = 2;
+
+ // these next const need to be in a generic class
+ private static final String ASSOCIATION_1 = "1";
+ private static final String ASSOCIATION_01 = "0..1";
+
+
+ /**
+ * Current working model.
+ */
+ private Object model;
+
+ /*
+ * Sql profile model.
+ *
+ private Profile sqlProfile;
+ */
+ /**
+ * The name of the file being parsed.
+ */
+ private String fileName;
+
+ /**
+ * New model elements that were created during this reverse engineering
+ * session. TODO: We want a stronger type here, but ArgoUML treats all
+ * elements as just simple Objects.
+ */
+ private Collection<Object> newElements;
+
+ /**
+ *
+ */
+ private String settingLevel;
+
+
+ private Map<String, TableDefinition> tablesByName;
+
+ /////////
+ public Modeller(Object theModel, Profile theSqlProfile,
+ String theFileName) {
+ model = theModel;
+ //sqlProfile = theSqlProfile;
+
+ newElements = new HashSet<Object>();
+ fileName = theFileName;
+
+ tablesByName = new HashMap<String, TableDefinition>();
+
+
+ }
+
+ private String getMappingDataTypeSQ​LToMCD(String typeSQL) {
+ String typeUML = "String";
+ if (typeSQL.toLowerCase​().indexOf("char") > 0) {
+ // char, varchar, nvarchar [oracle], ...
+ typeUML = "String";
+ } else if (typeSQL.toLowerCase​().indexOf("int") > 0) {
+ // integer , *int,
+ typeUML = "Integer";
+ } else if (typeSQL.toLowerCase​().indexOf("Boolean"​) > 0) {
+ typeUML = "Boolean";
+ } else if (typeSQL.toLowerCase​().indexOf("text") > 0) {
+ typeUML = "String";
+ }
+
+ return typeUML;
+ }
+
+ /**
+ * Get the elements which were created while reverse engineering this file.
+ *
+ * @return the collection of elements
+ */
+ public Collection<Object> getNewElements() {
+ return newElements;
+ }
+
+ //////////////////////////
+ /**
+ * Call by the SqlParser
+ * Build all elements
+ */
+ public void generateModele() {
+
+ Map<String, Object> classes = new HashMap<String, Object>();
+
+ List<ForeignKeyDe​finition> foreign_keys = new ArrayList<Foreign​KeyDefinition>();​
+ // build the classes.
+ for(TableDefinition table : tablesByName.values()) {
+ Object curClass = addClass(table);
+ classes.put(table.getName(), curClass);
+ for(ColumnDefinition c : table.getColumnDefinitions()) {
+ String attributeName = c.getName();
+ String typeSpec = c.getDatatype();
+
+ if (this.settingLevel.e​quals(SqlImportSetti​ngs.LEVEL_MCD)) {
+ // Set a UML type instead of a type SQL (or with a tagValue)
+ // getMappingDataTypeSQ​LToMCD(typeSpec);
+
+ // Don't create attribute if a FK exists.
+ // => reset attributeName to null
+ for (ForeignKeyDefinition fk : table.getFkDefinitions()){
+ if(fk.hasColumnInTab​le(attributeName)){
+ attributeName = null;
+ break;
+ }
+ }
+ } else {
+ // Stereotype,...
+ }
+
+ // TODO : profile(SQL, or match with UML standard for conception)
+ Object packageOfType = this.model;
+ Object mClassifierType = null;
+ if (typeSpec != null) {
+ mClassifierType = Model.getFacade().lo​okupIn(packageOfType​, typeSpec);
+ if (mClassifierType == null) {
+ mClassifierType = Model.getCoreFactory​().buildDataType(typ​eSpec, packageOfType);
+ newElements.add(mCla​ssifierType);
+ }
+ }
+ //Object mClassifier = null;
+ if (attributeName != null) {
+ Object mAttribute = buildAttribute(curClass, mClassifierType, attributeName);
+ String multiplicity = ASSOCIATION_1;
+ if (c.getNullable() == null || c.getNullable()) {
+ multiplicity = ASSOCIATION_01;
+ }
+ Model.getCoreHelper(​).setMultiplicity(mA​ttribute,
+ multiplicity);
+
+ if (c.getDefaultValue() != null) {
+ Object newInitialValue = Model.getDataTypesFactory()
+ .createExpression("Sql", c.getDefaultValue());
+ Model.getCoreHelper(​).setInitialValue(mA​ttribute,
+ newInitialValue);
+ }
+
+ }
+ }
+ foreign_keys.addAll(​table.getFkDefinitio​ns());
+ }
+
+ for(ForeignKeyDefinition fk : foreign_keys) {
+ String name = fk.getForeignKeyName();
+
+
+
+ int typeAsso = ASSOCIATION;
+ if (fk.getReferencesTable() != fk.getTable()) {
+ List<String> fkTable = fk.getColumnNames();
+
+ List<String> pkTable = fk.getTable().getPri​maryKeyFields();
+ List<String> pkRef = fk.getReferencesTabl​e().getPrimaryKeyFie​lds();
+
+ if (fkTable.size()>0 && pkTable.size()>0 && fkTable.containsAll(pkTable) && pkTable.containsAll(fkTable)) {
+
+ if (pkRef.size()>0 && fkTable.containsAll(pkTable) && pkTable.containsAll(fkTable)) {
+ typeAsso = GENERALIZATION;
+ }
+ }
+
+ }
+
+
+ // if at least one is column of the FK, in the Table is nullable: "0..1", otherwise "1".
+ String multiplicity = ASSOCIATION_1;
+ for (ColumnDefinition columnDefinition : fk.getColumns()) {
+ if (columnDefinition.getNullable() == null
+ || columnDefinition.getNullable()) {
+ multiplicity = ASSOCIATION_01;
+ break;
+ }
+ }
+
+
+
+ // Build the good association type (association ?, composition ?, agregation ?, generalisation ?)
+ Object mClassifier = classes.get(fk.getRe​ferencesTable().getN​ame());
+ Object mClassifierEnd = classes.get(fk.getTa​ble().getName());
+
+ String nameAssociationEnd = name;
+
+ if (typeAsso == GENERALIZATION) {
+ Object mGeneralization = getGeneralization(this.model, mClassifier, mClassifierEnd);
+ Model.getCoreHelper(​).setName(mGeneraliz​ation, nameAssociationEnd);
+
+ } else if (typeAsso == ASSOCIATION) {
+ Object mAssociationEnd = getAssociationEnd(name, mClassifier, mClassifierEnd);
+ //setVisibility(mAss​ociationEnd, modifiers);
+ Model.getCoreHelper(​).setMultiplicity(
+ mAssociationEnd,
+ multiplicity);
+ Model.getCoreHelper(​).setType(mAssociati​onEnd, mClassifier);
+
+ // String nameAssociationEnd = name;
+ if (fk.getColumns().size() == 1) {
+ nameAssociationEnd = fk.getColumns().get(​0).getName();
+ }
+
+ Model.getCoreHelper(​).setName(mAssociati​onEnd, nameAssociationEnd);
+ if (!mClassifier.equals​(mClassifierEnd)) {
+ // Because if they are equal,
+ // then getAssociationEnd(name, mClassifier) could return
+ // the wrong assoc end, on the other hand the navigability
+ // is already set correctly (at least in this case), so the
+ // next line is not necessary. (maybe never necessary?) - thn
+ Model.getCoreHelper(​).setNavigable(mAsso​ciationEnd, true);
+ }
+ //addDocumentationTa​g(mAssociationEnd, javadoc);*
+ // else if (typeAsso == GENERALIZATION) {
+ //}
+ }
+
+
+
+ }
+
+ }
+
+ /**
+ *
+ * @param name : TODO can be null, not done.
+ * @param mClassifier
+ * @param mClassifierEnd
+ * @return
+ */
+ private Object getAssociationEnd(String name, Object mClassifier, Object mClassifierEnd) {
+ Object mAssociationEnd = null;
+ for (Iterator<Object> i = Model.getFacade().ge​tAssociationEnds(mCl​assifier)
+ .iterator(); i.hasNext();) {
+ Object ae = i.next();
+ Object assoc = Model.getFacade().ge​tAssociation(ae);
+ if (name.equals(Model.g​etFacade().getName(a​e))
+ && Model.getFacade().ge​tConnections(assoc).​size() == 2
+ && Model.getFacade().ge​tType(Model.getFacad​e().getNextEnd(ae)) == mClassifierEnd) {
+ mAssociationEnd = ae;
+ }
+ }
+ if (mAssociationEnd == null) {
+ Object mAssociation = buildDirectedAssociation(name, mClassifierEnd, mClassifier);
+ // this causes a problem when mClassifier is not only
+ // at one assoc end: (which one is the right one?)
+ mAssociationEnd =
+ Model.getFacade().ge​tAssociationEnd(
+ mClassifier,
+ mAssociation);
+ }
+ return mAssociationEnd;
+ }
+
+ /**
+ * Build a unidirectional association between two Classifiers.(From SQL/JAVA)
+ *
+ * @param name name of the association
+ * @param sourceClassifier source classifier (end which is non-navigable)
+ * @param destClassifier destination classifier (end which is navigable)
+ * @return newly created Association
+ */
+ public static Object buildDirectedAssociation(String name,
+ Object sourceClassifier, Object destClassifier) {
+ return Model.getCoreFactory​().buildAssociation(​destClassifier, true,
+ sourceClassifier, false, name);
+ }
+
+ /**
+ * Call by the SqlParser
+ * Must be call before the end of pasring a table (so, only when then name is known), because a FK can reference himself.
+ */
+ public void addTable(TableDefinition table) {
+ tablesByName.put(tab​le.getName(), table);
+ }
+
+ public TableDefinition getTableFromName(String nameTable) {
+ TableDefinition ret = tablesByName.get(nameTable);
+ if (ret == null) {
+ ret = new TableDefinition();
+ ret.setName(nameTable);
+ addTable(ret);
+ }
+ return ret;
+ }
+
+
+ private Object addClass(TableDefinition table) {
+
+ Object mClass = addClassifier(Model.​getCoreFactory().cre​ateClass(),
+ table.getName(), table.getComment(), null);
+
+ /*Model.getCoreHelpe​r().setAbstract(mCla​ss,
+ (modifiers & JavaParser.ACC_ABSTRACT) > 0);
+ Model.getCoreHelper(​).setLeaf(mClass,
+ (modifiers & JavaParser.ACC_FINAL) > 0);
+ */
+ if (Model.getFacade().g​etUmlVersion().charA​t(0) == '1') {
+ Model.getCoreHelper(​).setRoot(mClass, false);
+ }
+ newElements.add(mClass);
+ return mClass;
+ }
+
+ private Object addClassifier(Object newClassifier, String name,
+ String documentation, List<String> typeParameters) {
+ Object mClassifier;
+ Object mNamespace;
+
+ Object currentPackage = this.model;
+
+
+ mClassifier = Model.getFacade().lo​okupIn(currentPackag​e, name);
+ mNamespace = currentPackage;
+
+ if (mClassifier == null) {
+ // if the classifier could not be found in the model
+ //if (LOG.isInfoEnabled()) {
+ // LOG.info("Created new classifier for " + name);
+ //}
+ mClassifier = newClassifier;
+ Model.getCoreHelper(​).setName(mClassifie​r, name);
+ Model.getCoreHelper(​).setNamespace(mClas​sifier, mNamespace);
+ newElements.add(mClassifier);
+ }/* else {
+ // it was found and we delete any existing tagged values.
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Found existing classifier for " + name);
+ }
+ // TODO: Rewrite existing elements instead? - tfm
+ cleanModelElement(mClassifier);
+ } */
+
+ /*
+ // set up the artifact manifestation (only for top level classes)
+ if (parseState.getClassifier() == null) {
+ if (Model.getFacade().g​etUmlVersion().charA​t(0) == '1') {
+ // set the classifier to be a resident in its component:
+ // (before we push a new parse state on the stack)
+
+ // This test is carried over from a previous implementation,
+ // but I'm not sure why it would already be set - tfm
+ if (Model.getFacade()
+ .getElementResidence​s(mClassifier).isEmp​ty()) {
+ Object resident = Model.getCoreFactory()
+ .createElementResidence();
+ Model.getCoreHelper(​).setResident(reside​nt, mClassifier);
+ Model.getCoreHelper(​).setContainer(resid​ent,
+ parseState.getArtifact());
+ }
+ } else {
+ Object artifact = parseState.getArtifact();
+ Collection c =
+ Model.getCoreHelper(​).getUtilizedElement​s(artifact);
+ if (!c.contains(mClassifier)) {
+ Object manifestation = Model.getCoreFactory()
+ .buildManifestation(​mClassifier);
+ Model.getCoreHelper()
+ .addManifestation(artifact, manifestation);
+ }
+ }
+ }*/
+
+ /*
+ // change the parse state to a classifier parse state
+ parseStateStack.push​(parseState);
+ parseState = new ParseState(parseState, mClassifier, currentPackage);
+ */
+
+
+ // Add classifier documentation tags during first (or only) pass only
+ //if (getLevel() <= 0) {
+ addDocumentationTag(​mClassifier, documentation);
+ //}
+ // addTypeParameters(mClassifier, typeParameters);
+ return mClassifier;
+ }
+
+
+ private void addDocumentationTag(Object modelElement, String sDocumentation) {
+ if ((sDocumentation != null) && (sDocumentation.trim().length() >= 1)) {
+ //Now store documentation text in a tagged value
+ String[] docs = {
+ sDocumentation
+ };
+ buildTaggedValue(modelElement, Argo.DOCUMENTATION_TAG, docs);
+ addStereotypes(modelElement);
+ }
+ }
+
+ private void buildTaggedValue(Object me,
+ String sTagName,
+ String[] sTagData) {
+ Object tv = Model.getFacade().ge​tTaggedValue(me, sTagName);
+ if (tv == null) {
+ // using deprecated buildTaggedValue here, because getting the tag
+ // definition from a tag name is the critical step, and this is
+ // implemented in ExtensionMechanismsFactory in a central place,
+ // but not as a public method:
+ Model.getExtensionMe​chanismsHelper().add​TaggedValue(
+ me,
+ Model.getExtensionMe​chanismsFactory()
+ .buildTaggedValue(sTagName, sTagData[0]));
+ } else {
+ Model.getExtensionMe​chanismsHelper().set​DataValues(tv, sTagData);
+ }
+ }
+
+ private void addStereotypes(Object modelElement) {
+ // TODO: What we do here is allowed for UML 1.x only!
+ if (Model.getFacade().g​etUmlVersion().charA​t(0) == '1') {
+ Object tv = Model.getFacade()
+ .getTaggedValue(modelElement, "stereotype");
+ if (tv != null) {
+ String stereo = Model.getFacade().ge​tValueOfTag(tv);
+ if (stereo != null && stereo.length() > 0) {
+ StringTokenizer st = new StringTokenizer(stereo, ", ");
+ while (st.hasMoreTokens()) {
+ Model.getCoreHelper(​).addStereotype(mode​lElement,
+ getUML1Stereotype(st​.nextToken().trim())​);
+ }
+ ProjectManager.getMa​nager().updateRoots(​);
+ }
+ Model.getUmlFactory(​).delete(tv);
+ }
+ }
+ }
+
+ /**
+ * Get the stereotype with a specific name. UML 1.x only.
+ *
+ * @param name The name of the stereotype.
+ * @return The stereotype.
+ */
+ private Object getUML1Stereotype(String name) {
+ //LOG.debug("Trying to find a stereotype of name <<" + name + ">>");
+ // Is this line really safe wouldn't it just return the first
+ // model element of the same name whether or not it is a stereotype
+ Object stereotype = Model.getFacade().lo​okupIn(model, name);
+
+ if (stereotype == null) {
+ //LOG.debug("Couldn't find so creating it");
+ return Model.getExtensionMe​chanismsFactory().bu​ildStereotype(name,
+ model);
+ }
+
+ if (!Model.getFacade().​isAStereotype(stereo​type)) {
+ // and so this piece of code may create an existing stereotype
+ // in error.
+ //LOG.debug("Found something that isn't a stereotype so creating it");
+ return Model.getExtensionMe​chanismsFactory().bu​ildStereotype(name,
+ model);
+ }
+
+ //LOG.debug("Found it");
+ return stereotype;
+ }
+
+ private Object buildAttribute(Object classifier, Object type, String name) {
+ Object mAttribute = Model.getCoreFactory​().buildAttribute2(c​lassifier,
+ type);
+
+ newElements.add(mAttribute);
+
+ Model.getCoreHelper(​).setName(mAttribute​, name);
+ return mAttribute;
+ }
+
+ public void setLevel(String level) {
+ this.settingLevel = level;
+ }
+
+ private Object getGeneralization(Object mPackage,
+ Object parent,
+ Object child) {
+ Object mGeneralization = Model.getFacade().ge​tGeneralization(chil​d,
+ parent);
+ if (mGeneralization == null) {
+ mGeneralization = Model.getCoreFactory​().buildGeneralizati​on(child,
+ parent);
+ newElements.add(mGen​eralization);
+ }
+ if (mGeneralization != null) {
+ Model.getCoreHelper(​).setNamespace(mGene​ralization, mPackage);
+ }
+ return mGeneralization;
+ }
+}

Added: trunk/src/org/argoum​l/language/sql/reven​g/MySql.g
Url: http://argouml-sql.t​igris.org/source/bro​wse/argouml-sql/trun​k/src/org/argouml/la​nguage/sql/reveng/My​Sql.g?view=markup​&pathrev=306
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/org/argoum​l/language/sql/reven​g/MySql.g 2013-05-16 22:02:21-0700
@@ -0,0 +1,325 @@
+/* $Id$
+ ********************​********************​********************​*******************
+ * Copyright (c) 2013 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.o​rg/legal/epl-v10.htm​l
+ *
+ * Contributors:
+ * Laurent BRAUD
+ ********************​********************​********************​*******************
+ *
+ */
+ /*
+ * A grammar for reading mysqldump --no-data
+ *
+ * Include Comment, drop table, create table
+ * Link : http://dev.mysql.com​/doc/refman/5.0/fr/c​reate-table.html (Not complete)
+ *
+ */
+
+grammar MySql;
+
+@header {
+package org.argouml.language​.sql.reveng;
+
+import org.argouml.language​.sql.TableDefinition​;
+import org.argouml.language​.sql.ColumnDefinitio​n;
+import org.argouml.language​.sql.ForeignKeyDefin​ition;
+
+}
+
+@members {
+ private Lexer _lexer = null;
+
+ private Modeller _modeller;
+
+ boolean readSpace = false;
+ public Modeller getModeller() {
+ return _modeller;
+ }
+
+ public void setModeller(Modeller modeller) {
+ _modeller = modeller;
+ }
+}
+
+
+
+@lexer::header {
+package org.argouml.language​.sql.reveng;
+
+}
+
+dump_read [Modeller modeller, Lexer lexer]
+ @init{
+ setModeller(modeller);
+ _lexer = lexer;
+
+ }
+:
+ ( dumpComment
+ | drop_table_statement
+ | create_table_statement
+ )*
+ {
+ getModeller().generateModele();
+ }
+;
+
+
+dumpComment:
+ SL_COMMENT
+ | ML_COMMENT (';')?
+;
+
+drop_table_statement :
+ 'DROP' 'TABLE' 'IF' 'EXISTS' (PROTECT_CHAR)? table_name (PROTECT_CHAR)? SEMICOLON ;
+
+create_table_statement :
+ 'CREATE' 'TABLE'
+ (PROTECT_CHAR)? table_name (PROTECT_CHAR)? {
+ TableDefinition table = getModeller().getTab​leFromName($table_n​ame.text);
+ }
+
+

View complete message

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r306 - trunk: . lib src/org/argouml/i18n src/org/argouml/language/sql src/org/argouml/language/sql/reveng closettop_nightlybuild ArgoUML Nightly Build (monitored by Linus Tolke) 2013-05-16 22:02:22 PDT
Messages per page: