src-db/database/build.xml
author Antonio Moreno <antonio.moreno@openbravo.com>
Thu, 24 Jun 2010 11:58:06 +0200
changeset 7709 effc222a5857
parent 7580 85eb92e7e94b
child 7894 10a6e520f525
permissions -rw-r--r--
Implemented reversal of configuration script functionality.
This functionality basically allows a developer to export a module even when there is a configuration script in the system which modifies its contents.
Also, fixed some issues related to formalChanges script.
carlos@0
     1
<?xml version="1.0" encoding="UTF-8" ?>
carlos@0
     2
<!--
carlos@0
     3
 *************************************************************************
carlos@0
     4
 * The contents of this file are subject to the Openbravo  Public  License
carlos@0
     5
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
     7
 * file except in compliance with the License. You  may  obtain  a copy of
carlos@0
     8
 * the License at http://www.openbravo.com/legal/license.html 
carlos@0
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    11
 * License for the specific  language  governing  rights  and  limitations
carlos@0
    12
 * under the License. 
carlos@0
    13
 * The Original Code is Openbravo ERP. 
ggi@6701
    14
 * The Initial Developer of the Original Code is Openbravo SLU 
ggi@6701
    15
 * All portions are Copyright (C) 2001-2009 Openbravo SLU 
carlos@0
    16
 * All Rights Reserved. 
carlos@0
    17
 * Contributor(s):  ______________________________________.
carlos@0
    18
 ************************************************************************
carlos@0
    19
-->
juanpablo@213
    20
<!--
juanpablo@213
    21
List of targets:
juanpablo@213
    22
juanpablo@213
    23
update.database: updates structure and data in database.
juanpablo@213
    24
create.database.script: Creates the database script in the script directory.
juanpablo@213
    25
update.database.script: Updates the database script in the script directory.
juanpablo@213
    26
export.database.structure: Exports the database structure in the xml's files.
fernando@207
    27
-->
stefan@5443
    28
<project name="openbravo" basedir=".">
carlos@0
    29
  <property environment="env" />
carlos@0
    30
  <condition property="bbdd.owner.url" value="${bbdd.url}/${bbdd.sid}" else="${bbdd.url}">
carlos@0
    31
    <and>
martin@2869
    32
      <equals arg1="${bbdd.rdbms}" arg2="POSTGRE" />
carlos@0
    33
    </and>
carlos@0
    34
  </condition>
carlos@0
    35
carlos@0
    36
  <path id="runtime-classpath">
carlos@0
    37
    <fileset dir="./lib">
carlos@0
    38
      <include name="**/*.jar" />
martin@2869
    39
      <exclude name="**/dbsourcemanagerlight.jar" />
carlos@0
    40
    </fileset>
asier@1929
    41
    <pathelement path="${build}" />
jordi@1711
    42
    <fileset dir="${base.lib}">
martin@2869
    43
      <include name="**/*.jar" />
jordi@1711
    44
    </fileset>
antonio@6886
    45
    <dirset dir="${base.modules}">
antonio@6886
    46
      <include name="*/build/classes/" />
antonio@6886
    47
    </dirset>
antonio@6886
    48
    <pathelement path="${basedir}/../../src-util/modulescript/build/classes/" />
carlos@0
    49
  </path>
martin@2869
    50
martin@2869
    51
  <taskdef name="createscript" classname="org.openbravo.ddlutils.task.CreateXML2SQL">
carlos@0
    52
    <classpath refid="runtime-classpath" />
carlos@0
    53
  </taskdef>
martin@2869
    54
  <taskdef name="alterdatabasedataall" classname="org.openbravo.ddlutils.task.AlterDatabaseDataAll">
adrian@97
    55
    <classpath refid="runtime-classpath" />
adrian@97
    56
  </taskdef>
martin@2869
    57
  <taskdef name="alterdatabasedatamod" classname="org.openbravo.ddlutils.task.AlterDatabaseDataMod">
carlos@0
    58
    <classpath refid="runtime-classpath" />
carlos@0
    59
  </taskdef>
martin@2869
    60
  <taskdef name="alterscript" classname="org.openbravo.ddlutils.task.AlterXML2SQL">
carlos@0
    61
    <classpath refid="runtime-classpath" />
carlos@0
    62
  </taskdef>
martin@2869
    63
  <taskdef name="exportconfigscript" classname="org.openbravo.ddlutils.task.ExportConfigScript">
martin@2869
    64
    <classpath refid="runtime-classpath" />
martin@2869
    65
  </taskdef>
carlos@0
    66
asier@1929
    67
  <target name="export.config.script">
antonio@6073
    68
    <exportconfigscript driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" filter="com.openbravo.db.OpenbravoMetadataFilter" password="${bbdd.password}" excludeobjects="com.openbravo.db.OpenbravoExcludeFilter" moduledir="${base.modules}" model="model" coreData="${base.db}/sourcedata" verbosity="${bbdd.verbosity}" industryTemplate="${industryTemplate}" />
antonio@6073
    69
    <antcall target="update.dbupdate.timestamp" />
antonio@1335
    70
  </target>
antonio@1335
    71
martin@2869
    72
  <target name="update.database">
martin@5455
    73
    <alterdatabasedataall driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" password="${bbdd.password}" excludeobjects="com.openbravo.db.OpenbravoExcludeFilter" model="model" filter="com.openbravo.db.OpenbravoMetadataFilter" input="sourcedata" object="${bbdd.object}" failonerror="false" verbosity="${bbdd.verbosity}" basedir="${base.modules}/" dirFilter="*/src-db/database/model" datadir="${base.modules}/" dataFilter="*/src-db/database/sourcedata" userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" force="${force}" onlyIfModified="${onlyIfModified}"/>
martin@2869
    74
    <antcall target="database.postupdate.${bbdd.rdbms}" />
martin@2869
    75
    <antcall target="update.dbupdate.timestamp" />
martin@2869
    76
  </target>
antonio@5117
    77
  
antonio@5117
    78
  
antonio@4870
    79
  <target name="update.database.java">
antonio@6073
    80
    <java classname="org.openbravo.ddlutils.task.AlterDatabaseJava" failonerror="true" fork="true" maxmemory="${build.maxmemory}">
antonio@4870
    81
      <arg value="${bbdd.driver}"/>
antonio@4870
    82
      <arg value="${bbdd.owner.url}"/>
antonio@4870
    83
      <arg value="${bbdd.user}"/>
antonio@4870
    84
      <arg value="${bbdd.password}"/>
antonio@4870
    85
      <arg value="com.openbravo.db.OpenbravoExcludeFilter"/>
antonio@4870
    86
      <arg value="model"/>
antonio@4870
    87
      <arg value="com.openbravo.db.OpenbravoMetadataFilter"/>
antonio@4870
    88
      <arg value="sourcedata"/>
antonio@4870
    89
      <arg value="${bbdd.object}"/>
antonio@4870
    90
      <arg value="false"/>
antonio@4870
    91
      <arg value="${bbdd.verbosity}"/>
antonio@4870
    92
      <arg value="${base.modules}/"/>
antonio@4870
    93
      <arg value="*/src-db/database/model"/>
antonio@4870
    94
      <arg value="${base.modules}/"/>
antonio@4870
    95
      <arg value="*/src-db/database/sourcedata"/>
antonio@4870
    96
      <arg value="${force}"/>
antonio@7709
    97
      <arg value="${strict.template.application}"/>
antonio@4870
    98
      <classpath refid="runtime-classpath" />
antonio@7580
    99
      <syspropertyset>
antonio@7580
   100
         <propertyref name="java.security.egd" />
antonio@7580
   101
      </syspropertyset>
antonio@4870
   102
    </java>
antonio@4870
   103
    <antcall target="database.postupdate.${bbdd.rdbms}" />
antonio@4870
   104
    <antcall target="update.dbupdate.timestamp" />
antonio@4870
   105
  </target>
antonio@4870
   106
antonio@5596
   107
  <target name="update.database.mod.java">
antonio@5596
   108
    <java classname="org.openbravo.ddlutils.task.AlterDatabaseModJava" failonerror="true" fork="true" maxmemory="${build.maxmemory}">
antonio@5596
   109
      <arg value="${bbdd.driver}"/>
antonio@5596
   110
      <arg value="${bbdd.owner.url}"/>
antonio@5596
   111
      <arg value="${bbdd.user}"/>
antonio@5596
   112
      <arg value="${bbdd.password}"/>
antonio@5596
   113
      <arg value="com.openbravo.db.OpenbravoExcludeFilter"/>
antonio@5596
   114
      <arg value="model"/>
antonio@5596
   115
      <arg value="com.openbravo.db.OpenbravoMetadataFilter"/>
antonio@5596
   116
      <arg value="sourcedata"/>
antonio@5596
   117
      <arg value="${bbdd.object}"/>
antonio@5596
   118
      <arg value="false"/>
antonio@5596
   119
      <arg value="${bbdd.verbosity}"/>
antonio@5596
   120
      <arg value="${base.modules}/"/>
antonio@5596
   121
      <arg value="${base.config}/"/>
antonio@5596
   122
      <arg value="*/src-db/database/model"/>
antonio@5596
   123
      <arg value="${base.modules}/"/>
antonio@5596
   124
      <arg value="*/src-db/database/sourcedata"/>
antonio@5596
   125
      <arg value="${module}"/>
antonio@5596
   126
      <arg value="${force}"/>
antonio@7709
   127
      <arg value="${strict.template.application}"/>
antonio@5596
   128
      <classpath refid="runtime-classpath" />
antonio@7580
   129
      <syspropertyset>
antonio@7580
   130
         <propertyref name="java.security.egd" />
antonio@7580
   131
      </syspropertyset>
antonio@5596
   132
    </java>
antonio@5596
   133
    <antcall target="database.postupdate.${bbdd.rdbms}" />
antonio@5596
   134
    <antcall target="update.dbupdate.timestamp" />
antonio@5596
   135
  </target>
antonio@5596
   136
  
martin@2869
   137
  <target name="update.database.mod">
martin@5455
   138
    <alterdatabasedatamod driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" password="${bbdd.password}" excludeobjects="com.openbravo.db.OpenbravoExcludeFilter" model="model" filter="com.openbravo.db.OpenbravoMetadataFilter" input="sourcedata" object="${bbdd.object}" failonerror="false" verbosity="DEBUG" basedir="${base.modules}/" baseConfig="${base.config}" dirFilter="*/src-db/database/model" datadir="${base.modules}/" dataFilter="*/src-db/database/sourcedata" module="${module}" userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" force="${force}" />
martin@2869
   139
    <antcall target="database.postupdate.${bbdd.rdbms}" />
antonio@3566
   140
    <antcall target="update.dbupdate.timestamp" />
martin@2869
   141
  </target>
martin@2869
   142
martin@2869
   143
  <target name="create.database.script">
martin@2869
   144
    <createscript driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" password="${bbdd.password}" model="model" object="${bbdd.object}" output="${bbdd.outputscript}" dropfirst="false" verbosity="${bbdd.verbosity}" />
martin@2869
   145
  </target>
martin@2869
   146
martin@2869
   147
  <target name="update.database.script">
antonio@6668
   148
    <alterscript driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" password="${bbdd.password}" excludeobjects="com.openbravo.db.OpenbravoExcludeFilter"  model="model/" filter="com.openbravo.db.OpenbravoMetadataFilter"  input="sourcedata" object="${bbdd.object}" failonerror="false" verbosity="${bbdd.verbosity}"  basedir="${base.modules}/" dirFilter="*/src-db/database/model" datadir="${base.modules}/" dataFilter="*/src-db/database/sourcedata" force="${force}" onlyIfModified="${onlyIfModified}" output="${bbdd.outputscript}" />
martin@2869
   149
  </target>
martin@2869
   150
martin@2869
   151
  <target name="export.database.structure">
antonio@6668
   152
      <taskdef name="exportdatabase" classname="org.openbravo.ddlutils.task.ExportDatabase">
antonio@6668
   153
        <classpath refid="runtime-classpath" />
antonio@6668
   154
      </taskdef>
antonio@6784
   155
      <exportdatabase driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" password="${bbdd.password}" excludeobjects="com.openbravo.db.OpenbravoExcludeFilter" model="model" moduledir="${base.modules}" verbosity="${bbdd.verbosity}" output="sourcedata" codeRevision="${code.revision}" userId="0" adminMode="true" propertiesFile="${base.config}/Openbravo.properties" force="${force}" validateModel="${validate.model}" testAPI="${isMinorVersion}" datasetList="AD,ADRD" rd="${rd}" checkTranslationConsistency="${checkTranslationConsistency}"/>
antonio@6073
   156
      <antcall target="update.dbupdate.timestamp" />
martin@2869
   157
  </target>
adrian@97
   158
antonio@1952
   159
  <target name="database.postupdate.ORACLE">
antonio@3145
   160
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
martin@2869
   161
      <classpath>
martin@2869
   162
        <fileset dir="${base.lib}">
martin@2869
   163
          <include name="**/*.jar">
martin@2869
   164
          </include>
martin@2869
   165
        </fileset>
martin@2869
   166
      </classpath>
martin@2869
   167
      <transaction>
antonio@4817
   168
          UPDATE AD_SYSTEM_INFO SET CODE_REVISION=SUBSTR('${code.revision}',1,60);
antonio@1952
   169
          CALL AD_UPDATE_ACCESS();
antonio@6043
   170
          UPDATE AD_MODULE SET SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL WHERE STATUS IS NULL OR STATUS='I';
antonio@6074
   171
          UPDATE AD_MODULE SET ISINDEVELOPMENT='N' WHERE ISINDEVELOPMENT IS NULL;
asier@3996
   172
          CALL AD_LANGUAGE_CREATE(NULL);
antonio@1952
   173
        </transaction>
antonio@1952
   174
    </sql>
antonio@1952
   175
  </target>
antonio@1952
   176
antonio@1952
   177
  <target name="database.postupdate.POSTGRE">
antonio@3145
   178
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
martin@2869
   179
      <classpath>
martin@2869
   180
        <fileset dir="${base.lib}">
martin@2869
   181
          <include name="**/*.jar">
martin@2869
   182
          </include>
martin@2869
   183
        </fileset>
martin@2869
   184
      </classpath>
martin@2869
   185
      <transaction>
antonio@3961
   186
          UPDATE AD_SYSTEM_INFO SET CODE_REVISION=SUBSTR('${code.revision}',1,60);
antonio@1952
   187
          SELECT AD_UPDATE_ACCESS();
antonio@6043
   188
          UPDATE AD_MODULE SET SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL WHERE STATUS IS NULL OR STATUS='I';
antonio@6074
   189
          UPDATE AD_MODULE SET ISINDEVELOPMENT='N' WHERE ISINDEVELOPMENT IS NULL;
asier@3996
   190
          SELECT AD_LANGUAGE_CREATE(NULL);
antonio@1952
   191
        </transaction>
antonio@1952
   192
    </sql>
antonio@1952
   193
  </target>
antonio@1952
   194
antonio@5611
   195
  <target name="setApplied">
antonio@5603
   196
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
antonio@5603
   197
      <classpath>
antonio@5603
   198
        <fileset dir="${base.lib}">
antonio@5603
   199
          <include name="**/*.jar">
antonio@5603
   200
          </include>
antonio@5603
   201
        </fileset>
antonio@5603
   202
      </classpath>
antonio@5603
   203
      <transaction>
antonio@6404
   204
          UPDATE AD_MODULE SET STATUS='A' WHERE STATUS='P';
antonio@5603
   205
          DELETE FROM AD_MODULE WHERE STATUS = 'U';
antonio@5603
   206
      </transaction>
antonio@5603
   207
    </sql>
antonio@5603
   208
  </target>
antonio@5603
   209
  
antonio@2824
   210
  <target name="update.dbupdate.timestamp">
martin@2869
   211
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="continue" autocommit="true">
martin@2869
   212
      <classpath>
martin@2869
   213
        <fileset dir="${base.lib}">
martin@2869
   214
          <include name="**/*.jar">
martin@2869
   215
          </include>
martin@2869
   216
        </fileset>
martin@2869
   217
      </classpath>
martin@2869
   218
      <transaction>
antonio@2839
   219
          UPDATE AD_SYSTEM_INFO SET LAST_DBUPDATE=NOW()
antonio@2824
   220
        </transaction>
martin@2869
   221
    </sql>
martin@2869
   222
  </target>
carlos@0
   223
</project>
antonio@3566
   224