From 8793fa8f6bd4b4fc10bdb98bfb04818198cc4754 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 2 Nov 2007 09:51:12 +0000 Subject: [PATCH] Preparing for nightly build --- utils/RUN_ImportReference.sh | 11 ++- utils/RUN_PostMigration.sh | 73 +++++++++++++++++++ utils/oracle/01_add_missing_Translations.sql | 67 +++++++++++++++++ utils/oracle/PostMigration.sh | 23 ++++++ .../01_add_missing_translations.sql | 69 ++++++++++++++++++ utils/postgresql/DBExport.sh | 2 +- utils/postgresql/DBRestore.sh | 2 +- utils/postgresql/ExportReference.sh | 20 +++++ utils/postgresql/ImportAdempiere.sh | 6 +- utils/postgresql/PostMigration.sh | 25 +++++++ 10 files changed, 292 insertions(+), 6 deletions(-) create mode 100644 utils/RUN_PostMigration.sh create mode 100644 utils/oracle/01_add_missing_Translations.sql create mode 100644 utils/oracle/PostMigration.sh create mode 100644 utils/postgresql/01_add_missing_translations.sql create mode 100644 utils/postgresql/ExportReference.sh create mode 100644 utils/postgresql/PostMigration.sh diff --git a/utils/RUN_ImportReference.sh b/utils/RUN_ImportReference.sh index 7e9bb13273..1ffc67a719 100644 --- a/utils/RUN_ImportReference.sh +++ b/utils/RUN_ImportReference.sh @@ -8,12 +8,19 @@ fi . ./myEnvironment.sh Server echo Import Reference - $ADEMPIERE_HOME \($ADEMPIERE_DB_NAME\) +SUFFIX="" +SYSUSER=system +if [ $ADEMPIERE_DB_PATH = "postgresql" ] +then + SUFFIX="_pg" + SYSUSER=postgres +fi echo Re-Create Reference User and import $ADEMPIERE_HOME/data/Adempiere.dmp - \($ADEMPIERE_DB_NAME\) echo == The import will show warnings. This is OK == -ls -lsa $ADEMPIERE_HOME/data/Adempiere.dmp +ls -lsa $ADEMPIERE_HOME/data/Adempiere${SUFFIX}.dmp echo Press enter to continue ... read in # Parameter: -sh $ADEMPIERE_DB_PATH/ImportAdempiere.sh system/$ADEMPIERE_DB_SYSTEM reference reference +sh $ADEMPIERE_DB_PATH/ImportAdempiere.sh $SYSUSER/$ADEMPIERE_DB_SYSTEM reference reference $ADEMPIERE_DB_SYSTEM diff --git a/utils/RUN_PostMigration.sh b/utils/RUN_PostMigration.sh new file mode 100644 index 0000000000..1d484677b8 --- /dev/null +++ b/utils/RUN_PostMigration.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# +# $Id: RUN_ImportAdempiere.sh,v 1.9 2005/01/22 21:59:15 jjanke Exp $ + +if [ $ADEMPIERE_HOME ]; then + cd $ADEMPIERE_HOME/utils +fi +. ./myEnvironment.sh Server + +#check java home +if [ $JAVA_HOME ]; then + export PATH=$JAVA_HOME/bin:$PATH +else + echo JAVA_HOME is not set. + echo You may not be able to build Adempiere + echo Set JAVA_HOME to the directory of your local JDK. + exit +fi + +# check jdk +if [ ! -f $JAVA_HOME/lib/tools.jar ] ; then + echo "** Need full Java SDK **" + exit +fi + +SUFFIX="" +SYSUSER=system +if [ $ADEMPIERE_DB_PATH = "postgresql" ] +then + SUFFIX="_pg" + SYSUSER=postgres +fi + +#classpath +MYCLASSPATH=../lib/Adempiere.jar:../lib/CCTools.jar:../lib/postgresql.jar:../lib/oracle.jar:../lib/jboss.jar + +JAVA_OPTS="-Xms128m -Xmx512m -Djava.awt.headless=true" + +ADEMPIERE_OPTS="-DADEMPIERE_HOME=$ADEMPIERE_HOME -DPropertyFile=../Adempiere.properties" + +#Run generate model +echo +echo Generate Model +echo + +$JAVA_HOME/bin/java $JAVA_OPTS $ADEMPIERE_OPTS -classpath $MYCLASSPATH org.adempiere.util.GenerateModel src/org/compiere/model org.compiere.model 'D' '%' + +#Add missing translations +echo +echo Add missing translations +echo + +# Parameter: +sh $ADEMPIERE_DB_PATH/PostMigration.sh $SYSUSER/$ADEMPIERE_DB_SYSTEM $ADEMPIERE_DB_USER $ADEMPIERE_DB_PASSWORD $ADEMPIERE_DB_SYSTEM + +#Run Synchronized Terminology +echo +echo Synchronized Terminology +echo + +$JAVA_HOME/bin/java $JAVA_OPTS $ADEMPIERE_OPTS -classpath $MYCLASSPATH org.compiere.process.SynchronizeTerminology + +#Run Sequence Check +echo +echo Sequence Check +echo + +$JAVA_HOME/bin/java $JAVA_OPTS $ADEMPIERE_OPTS -classpath $MYCLASSPATH org.compiere.process.SequenceCheck + +echo Done ... + +exit 0 + diff --git a/utils/oracle/01_add_missing_Translations.sql b/utils/oracle/01_add_missing_Translations.sql new file mode 100644 index 0000000000..2a2f789e92 --- /dev/null +++ b/utils/oracle/01_add_missing_Translations.sql @@ -0,0 +1,67 @@ +DECLARE + ins VARCHAR2 (2000); + sel VARCHAR2 (2000); + inssel VARCHAR2 (4001); + table_id NUMBER; +BEGIN + ins := RPAD (' ', 2000, ' '); + sel := RPAD (' ', 2000, ' '); + inssel := RPAD (' ', 4001, ' '); + DBMS_OUTPUT.PUT_LINE ('Start'); + + FOR t IN (SELECT ad_table_id, + SUBSTR (tablename, 1, LENGTH (tablename) - 4) tablename + FROM AD_TABLE + WHERE tablename LIKE '%_Trl' AND isactive = 'Y' + AND isview = 'N') + LOOP + ins := + 'INSERT INTO ' + || t.tablename + || '_TRL (' + || 'ad_language,ad_client_id,ad_org_id,created,createdby,updated,updatedby,isactive,istranslated,' + || t.tablename + || '_id'; + sel := + 'SELECT l.ad_language,t.ad_client_id,t.ad_org_id,t.created,t.createdby,t.updated,t.updatedby,t.isactive,''N'' as istranslated,' + || t.tablename + || '_id'; + + SELECT ad_table_id + INTO table_id + FROM AD_TABLE + WHERE tablename = t.tablename; + + FOR c IN (SELECT col.columnname + FROM AD_COLUMN col INNER JOIN AD_TABLE tab + ON (col.ad_table_id = tab.ad_table_id) + WHERE col.ad_table_id = table_id + AND col.istranslated = 'Y' + AND col.isactive = 'Y' + ORDER BY 1) + LOOP + ins := TRIM (ins) || ',' || TRIM (c.columnname); + sel := TRIM (sel) || ',t.' || TRIM (c.columnname); + END LOOP; + + ins := TRIM (ins) || ')'; + sel := + TRIM (sel) + || ' from ' + || t.tablename + || ' t, ad_language l WHERE l.issystemlanguage=''Y'' AND NOT EXISTS (SELECT 1 FROM ' + || t.tablename + || '_TRL b WHERE b.' + || t.tablename + || '_id=t.' + || t.tablename + || '_id AND b.AD_LANGUAGE=l.AD_LANGUAGE)'; + inssel := TRIM (ins) || ' ' || TRIM (sel); + + DBMS_OUTPUT.PUT_LINE (inssel); + EXECUTE IMMEDIATE inssel; + END LOOP; + + DBMS_OUTPUT.PUT_LINE ('End'); + COMMIT; +END; diff --git a/utils/oracle/PostMigration.sh b/utils/oracle/PostMigration.sh new file mode 100644 index 0000000000..257d590b21 --- /dev/null +++ b/utils/oracle/PostMigration.sh @@ -0,0 +1,23 @@ +# $Id: ImportAdempiere.sh,v 1.10 2005/12/20 07:12:17 jjanke Exp $ +echo Adempiere Database Import $Revision: 1.10 $ + +echo Importing Adempiere DB from $ADEMPIERE_HOME/data/Adempiere.dmp + +if [ $# -le 2 ] + then + echo "Usage: $0 " + echo "Example: $0 system/manager adempiere adempiere" + exit 1 +fi +if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ] + then + echo "Please make sure that the environment variables are set correctly:" + echo " ADEMPIERE_HOME e.g. /Adempiere" + echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org" + exit 1 +fi + +echo ------------------------------------- +echo Add missing translations +echo ------------------------------------- +echo sqlplus $2/$3@$ADEMPIERE_DB_SERVER/$ADEMPIERE_DB_NAME @$ADEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/01_add_missing_Translations.sql diff --git a/utils/postgresql/01_add_missing_translations.sql b/utils/postgresql/01_add_missing_translations.sql new file mode 100644 index 0000000000..4c40cbdeec --- /dev/null +++ b/utils/postgresql/01_add_missing_translations.sql @@ -0,0 +1,69 @@ +CREATE OR REPLACE FUNCTION add_missing_translations() RETURNS void as $func$ +DECLARE + ins VARCHAR (2000); + sel VARCHAR (2000); + inssel VARCHAR (4001); + table_id NUMERIC; + t RECORD; + c RECORD; +BEGIN + + FOR t IN (SELECT ad_table_id, + SUBSTR (tablename, 1, LENGTH (tablename) - 4) as tablename + FROM AD_TABLE + WHERE tablename LIKE '%_Trl' AND isactive = 'Y' + AND isview = 'N') + LOOP + ins := + 'INSERT INTO ' + || t.tablename + || '_TRL (' + || 'ad_language,ad_client_id,ad_org_id,created,createdby,updated,updatedby,isactive,istranslated,' + || t.tablename + || '_id'; + sel := + 'SELECT l.ad_language,t.ad_client_id,t.ad_org_id,t.created,t.createdby,t.updated,t.updatedby,t.isactive,''N'' as istranslated,' + || t.tablename + || '_id'; + + SELECT ad_table_id + INTO table_id + FROM AD_TABLE + WHERE tablename = t.tablename; + + FOR c IN (SELECT col.columnname + FROM AD_COLUMN col INNER JOIN AD_TABLE tab + ON (col.ad_table_id = tab.ad_table_id) + WHERE col.ad_table_id = table_id + AND col.istranslated = 'Y' + AND col.isactive = 'Y' + ORDER BY 1) + LOOP + ins := TRIM (ins) || ',' || TRIM (c.columnname); + sel := TRIM (sel) || ',t.' || TRIM (c.columnname); + END LOOP; + + ins := TRIM (ins) || ')'; + sel := + TRIM (sel) + || ' from ' + || t.tablename + || ' t, ad_language l WHERE l.issystemlanguage=''Y'' AND NOT EXISTS (SELECT 1 FROM ' + || t.tablename + || '_TRL b WHERE b.' + || t.tablename + || '_id=t.' + || t.tablename + || '_id AND b.AD_LANGUAGE=l.AD_LANGUAGE)'; + inssel := TRIM (ins) || ' ' || TRIM (sel); + + EXECUTE inssel; + END LOOP; + +END; +$func$ LANGUAGE plpgsql; + +select add_missing_translations(); + +commit; + diff --git a/utils/postgresql/DBExport.sh b/utils/postgresql/DBExport.sh index 75c1bc2f42..a2d2ecf729 100644 --- a/utils/postgresql/DBExport.sh +++ b/utils/postgresql/DBExport.sh @@ -19,7 +19,7 @@ if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ] fi export PGPASSWORD=$2 -pg_dump -U $1 $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/ExpDat.dmp +pg_dump --no-owner -U $1 $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/ExpDat.dmp export PGPASSWORD= cd $ADEMPIERE_HOME/data diff --git a/utils/postgresql/DBRestore.sh b/utils/postgresql/DBRestore.sh index 67cfb19b1c..3a31303843 100644 --- a/utils/postgresql/DBRestore.sh +++ b/utils/postgresql/DBRestore.sh @@ -39,4 +39,4 @@ echo ------------------------------------- psql -d $ADEMPIERE_DB_NAME -U $2 -c "drop schema sqlj cascade" psql -d $ADEMPIERE_DB_NAME -U $2 -f $ADEMPIERE_HOME/data/ExpDat.dmp -export PGPASSWORD= \ No newline at end of file +export PGPASSWORD= diff --git a/utils/postgresql/ExportReference.sh b/utils/postgresql/ExportReference.sh new file mode 100644 index 0000000000..a8b2fe1dc0 --- /dev/null +++ b/utils/postgresql/ExportReference.sh @@ -0,0 +1,20 @@ +echo Adempiere PostgreSQL Database Export $Revision: 1.3 $ + +# $Id: DBExport.sh,v 1.3 2005/01/22 21:59:15 jjanke Exp $ + +echo Saving database reference@$ADEMPIERE_DB_NAME to $ADEMPIERE_HOME/data/Adempiere_pg.dmp + +if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ] + then + echo "Please make sure that the environment variables are set correctly:" + echo " ADEMPIERE_HOME e.g. /Adempiere" + echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org" + exit 1 +fi + +export PGPASSWORD=reference +pg_dump --no-owner -U reference $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/Adempiere_pg.dmp +export PGPASSWORD= + +cd $ADEMPIERE_HOME/data +jar cvfM Adempiere_pg.jar Adempiere_pg.dmp diff --git a/utils/postgresql/ImportAdempiere.sh b/utils/postgresql/ImportAdempiere.sh index 5209752f84..e37d22f7bb 100644 --- a/utils/postgresql/ImportAdempiere.sh +++ b/utils/postgresql/ImportAdempiere.sh @@ -36,7 +36,9 @@ createdb $ADEMPIERE_DB_NAME -E UNICODE -O $2 -U $2 echo ------------------------------------- echo Import Adempiere_pg.dmp echo ------------------------------------- +ADEMPIERE_ALTER_ROLE_SQL = "ALTER ROLE $2 SET search_path TO adempiere, sqjj, pg_catalog" +psql -d $ADEMPIERE_DB_NAME -U $2 -c "$ADEMPIERE_ALTER_ROLE_SQL" psql -d $ADEMPIERE_DB_NAME -U $2 -c "drop schema sqlj cascade" psql -d $ADEMPIERE_DB_NAME -U $2 -f $ADEMPIERE_HOME/data/Adempiere_pg.dmp - -export PGPASSWORD= \ No newline at end of file +ADEMPIERE_ALTER_ROLE_SQL= +export PGPASSWORD= diff --git a/utils/postgresql/PostMigration.sh b/utils/postgresql/PostMigration.sh new file mode 100644 index 0000000000..0063175a68 --- /dev/null +++ b/utils/postgresql/PostMigration.sh @@ -0,0 +1,25 @@ +# $Id: ImportAdempiere.sh,v 1.10 2005/12/20 07:12:17 jjanke Exp $ +echo Adempiere Database Import $Revision: 1.10 $ + +echo Importing Adempiere DB from $ADEMPIERE_HOME/data/Adempiere_pg.dmp + +if [ $# -le 2 ] + then + echo "Usage: $0 " + echo "Example: $0 postgres adempiere adempiere postgresPwd" + exit 1 +fi +if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ] + then + echo "Please make sure that the environment variables are set correctly:" + echo " ADEMPIERE_HOME e.g. /Adempiere" + echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org" + exit 1 +fi + +export PGPASSWORD=$3 +echo ------------------------------------- +echo Import Adempiere_pg.dmp +echo ------------------------------------- +psql -d $ADEMPIERE_DB_NAME -U $2 -f 01_add_missing_translations.sql +export PGPASSWORD=