You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by sa...@apache.org on 2016/01/25 07:09:31 UTC

ode git commit: ODE-1039: Fixed the Rakefile to generate appropriate engine type for MYSQL5 and MYSQL5.5

Repository: ode
Updated Branches:
  refs/heads/ode-1.3.x 501f70f20 -> f5ef532c8


ODE-1039: Fixed the Rakefile to generate appropriate engine type for MYSQL5 and MYSQL5.5


Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/f5ef532c
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/f5ef532c
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/f5ef532c

Branch: refs/heads/ode-1.3.x
Commit: f5ef532c8c12ac6d53df4b42d61c80176ae8c1ce
Parents: 501f70f
Author: sathwik <sa...@apache.org>
Authored: Mon Jan 25 11:27:10 2016 +0530
Committer: sathwik <sa...@apache.org>
Committed: Mon Jan 25 11:27:10 2016 +0530

----------------------------------------------------------------------
 Rakefile                                        | 54 ++++++++++++++++++++
 .../src/main/sql/simplesched-mysql.sql          |  3 +-
 .../src/main/descriptors/persistence.mysql.xml  |  3 +-
 .../src/main/scripts/simplesched-mysql.sql      |  3 +-
 4 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/f5ef532c/Rakefile
----------------------------------------------------------------------
diff --git a/Rakefile b/Rakefile
index bcd32b1..2e8a021 100644
--- a/Rakefile
+++ b/Rakefile
@@ -343,6 +343,27 @@ define "ode" do
       end
     end
 
+    mysql_sql = lambda do |src_file,dest_file,engineType|
+        File.open(project.path_to(dest_file).to_s,"a") do |w|
+            File.open(project.path_to(src_file).to_s,"r") do |f|
+                isCT="no"
+                f.each_line do |line|
+                    if line.index(/[ ]*create[ ]+table/i) && line.index(";") then
+                        w << line.insert(line.index(";"),engineType)
+                    elsif line.index(/[ ]*create[ ]+table/i) && !line.index(";") then
+                        isCT="yes"
+                        w << line
+                    elsif isCT=="yes" && line.index(";") then
+                        isCT="no"
+                        w << line.insert(line.index(";"),engineType)
+                    else
+                        w << line
+                    end
+                end
+            end
+        end
+    end
+
     common_sql = _("src/main/sql/common.sql")
     index_sql = _("src/main/sql/index.sql")
 
@@ -352,6 +373,11 @@ define "ode" do
       build concat(_("target/#{db}.sql")=>[ common_sql, predefined_for[db], partial_store, partial_runtime, index_sql])
     end
 
+    build do
+        mysql_sql["target/mysql.sql","target/mysql5.sql"," TYPE=INNODB"]
+        mysql_sql["target/mysql.sql","target/mysql55.sql"," ENGINE=INNODB"]
+    end
+
     derby_sql = _("target/derby.sql")
     derby_db = Derby.create(_("target/derby-hibdb")=>derby_sql)
     build derby_db
@@ -376,6 +402,28 @@ define "ode" do
 
   desc "ODE OpenJPA Derby Database"
   define "dao-jpa-ojpa-derby" do
+
+    mysql_sql = lambda do |src_file,dest_file,engineType|
+        File.open(project.path_to(dest_file).to_s,"a") do |w|
+            File.open(project.path_to(src_file).to_s,"r") do |f|
+                isCT="no"
+                f.each_line do |line|
+                    if line.index(/[ ]*create[ ]+table/i) && line.index(";") then
+                        w << line.insert(line.index(";"),engineType)
+                    elsif line.index(/[ ]*create[ ]+table/i) && !line.index(";") then
+                        isCT="yes"
+                        w << line
+                    elsif isCT=="yes" && line.index(";") then
+                        isCT="no"
+                        w << line.insert(line.index(";"),engineType)
+                    else
+                        w << line
+                    end
+                end
+            end
+        end
+    end
+
     %w{ derby mysql oracle postgres h2 sqlserver}.each do |db|
       db_xml = _("src/main/descriptors/persistence.#{db}.xml")
       scheduler_sql = _("src/main/scripts/simplesched-#{db}.sql")
@@ -388,6 +436,12 @@ define "ode" do
       sql = concat(_("target/#{db}.sql")=>[_("src/main/scripts/license-header.sql"), common_sql, partial_sql, scheduler_sql])
       build sql
     end
+
+    build do
+        mysql_sql["target/mysql.sql","target/mysql5.sql"," TYPE=INNODB"]
+        mysql_sql["target/mysql.sql","target/mysql55.sql"," ENGINE=INNODB"]
+    end
+
     derby_db = Derby.create(_("target/derby-jpadb")=>_("target/derby.sql"))
     h2_db = H2.create("ode-jpa-h2", _("target/h2-jpadb")=>_("target/h2.sql"))
 

http://git-wip-us.apache.org/repos/asf/ode/blob/f5ef532c/dao-hibernate-db/src/main/sql/simplesched-mysql.sql
----------------------------------------------------------------------
diff --git a/dao-hibernate-db/src/main/sql/simplesched-mysql.sql b/dao-hibernate-db/src/main/sql/simplesched-mysql.sql
index 60ef98b..ec48910 100644
--- a/dao-hibernate-db/src/main/sql/simplesched-mysql.sql
+++ b/dao-hibernate-db/src/main/sql/simplesched-mysql.sql
@@ -26,8 +26,7 @@ CREATE TABLE ODE_JOB (
   PRIMARY KEY(jobid),
   INDEX IDX_ODE_JOB_TS(ts),
   INDEX IDX_ODE_JOB_NODEID(nodeid)
-)
-TYPE=InnoDB;
+);
 
 COMMIT;
 

http://git-wip-us.apache.org/repos/asf/ode/blob/f5ef532c/dao-jpa-ojpa-derby/src/main/descriptors/persistence.mysql.xml
----------------------------------------------------------------------
diff --git a/dao-jpa-ojpa-derby/src/main/descriptors/persistence.mysql.xml b/dao-jpa-ojpa-derby/src/main/descriptors/persistence.mysql.xml
index 708e031..c5f32b2 100644
--- a/dao-jpa-ojpa-derby/src/main/descriptors/persistence.mysql.xml
+++ b/dao-jpa-ojpa-derby/src/main/descriptors/persistence.mysql.xml
@@ -42,7 +42,8 @@
         <properties>
             <!-- Properties for an embedded Derby connection -->
             <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
-            <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.MySQLDictionary"/>
+            <!-- We disable TableType generation as it is appeneded in the Rakefile to handle both mysql5 and mysql 5.5-->
+            <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.MySQLDictionary(TableType='')"/>
             <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
             <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
 

http://git-wip-us.apache.org/repos/asf/ode/blob/f5ef532c/dao-jpa-ojpa-derby/src/main/scripts/simplesched-mysql.sql
----------------------------------------------------------------------
diff --git a/dao-jpa-ojpa-derby/src/main/scripts/simplesched-mysql.sql b/dao-jpa-ojpa-derby/src/main/scripts/simplesched-mysql.sql
index 60ef98b..ec48910 100644
--- a/dao-jpa-ojpa-derby/src/main/scripts/simplesched-mysql.sql
+++ b/dao-jpa-ojpa-derby/src/main/scripts/simplesched-mysql.sql
@@ -26,8 +26,7 @@ CREATE TABLE ODE_JOB (
   PRIMARY KEY(jobid),
   INDEX IDX_ODE_JOB_TS(ts),
   INDEX IDX_ODE_JOB_NODEID(nodeid)
-)
-TYPE=InnoDB;
+);
 
 COMMIT;