/[volute]/trunk/projects/theory/snapdm/build_db.xml
ViewVC logotype

Contents of /trunk/projects/theory/snapdm/build_db.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 626 - (show annotations)
Thu Jun 26 10:46:17 2008 UTC (12 years, 5 months ago) by bourges.laurent
File MIME type: text/xml
File size: 3654 byte(s)
up to date JDBC generated scripts 
1 <!--
2 build_db.xml file : specific targets for database management
3 -->
4 <property name="ddl.test" location="${test}/ddl" />
5
6
7 <!-- presets -->
8
9 <!-- Performs an SQL query with the database defined in jpa-config properties. -->
10 <presetdef name="doSql">
11
12 <sql classpathref="jdbc-drivers.class.path"
13 driver="${eclipselink.jdbc.driver}"
14 url="${eclipselink.jdbc.url}"
15 userid="${eclipselink.jdbc.user}"
16 password="${eclipselink.jdbc.password}" />
17
18 </presetdef>
19
20
21
22
23 <!-- targets -->
24
25 <!-- sets DB properties -->
26 <target name="initForDB">
27 <!-- Get jpa-config properties -->
28 <property file="${properties}/jpa-config.properties" />
29
30 <fail unless="eclipselink.target-database" message="missing eclipselink.target-database in jpa-config.properties !" />
31
32 <fail unless="eclipselink.jdbc.driver" message="missing eclipselink.jdbc.driver in jpa-config.properties !" />
33 <fail unless="eclipselink.jdbc.url" message="missing eclipselink.target-database in jpa-config.properties !" />
34
35 <fail unless="eclipselink.jdbc.user" message="missing eclipselink.jdbc.user in jpa-config.properties !" />
36 <fail unless="eclipselink.jdbc.password" message="missing eclipselink.jdbc.password in jpa-config.properties !" />
37
38 <!-- sets SQL script directory -->
39 <condition property="ddl.directory" value="${output}/ddl/postgres/">
40 <equals arg1="${eclipselink.target-database}" arg2="PostgreSQL" trim="true"/>
41 </condition>
42
43 <condition property="ddl.directory" value="${output}/ddl/mssqlserver/">
44 <equals arg1="${eclipselink.target-database}" arg2="SQLServer" trim="true"/>
45 </condition>
46
47 <condition property="ddl.directory.set">
48 <isset property="ddl.directory"/>
49 </condition>
50
51 <fail unless="ddl.directory.set" message="unable to define ddl.directory property for the given vendor : ${eclipselink.target-database} !" />
52
53 <echo>JDBC URL : ${eclipselink.jdbc.url}</echo>
54 <echo>JDBC USER : ${eclipselink.jdbc.user}</echo>
55 <echo>DDL HOME : ${ddl.directory}</echo>
56
57 <delete includeemptydirs="false" verbose="true">
58 <fileset dir="${ddl.test}">
59 <include name="*.sql" />
60 </fileset>
61 </delete>
62
63 <copy verbose="true" overwrite="true" todir="${ddl.test}" preservelastmodified="true">
64 <fileset dir="${ddl.directory}">
65 <include name="*.sql" />
66 </fileset>
67 </copy>
68
69 <!-- removes multi line comments that cause problems with <sql> task -->
70 <replaceregexp match="/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/" replace=" " byline="false" flags="g">
71 <fileset dir="${ddl.test}">
72 <include name="*.sql" />
73 </fileset>
74 </replaceregexp>
75
76 </target>
77
78
79
80
81 <!-- target checkDB : is database server alive ? -->
82 <target name="checkDB" depends="initForDB">
83 <echo>checkDB : ${eclipselink.jdbc.url} ...</echo>
84
85 <doSql onerror="abort" print="true">select 1;</doSql>
86
87 <echo>checkDB : done.</echo>
88 </target>
89
90
91
92 <!--
93 src="data.sql"
94 -->
95
96
97
98 <!-- target cleanDB : drops views then tables -->
99 <target name="cleanDB" depends="initForDB">
100 <echo>cleanDB : drop views then tables ...</echo>
101
102 <doSql autocommit="true" onerror="continue" src="${ddl.test}/SimDB_dropViews.sql" />
103 <doSql autocommit="true" onerror="continue" src="${ddl.test}/SimDB_dropTables.sql" />
104
105 <echo>cleanDB : done.</echo>
106 </target>
107
108
109
110
111 <!-- target createDB : creates tables then views -->
112 <target name="createDB" depends="cleanDB">
113 <echo>createDB : create tables then views ...</echo>
114
115 <doSql onerror="abort" src="${ddl.test}/SimDB_createTables.sql" />
116 <doSql onerror="abort" src="${ddl.test}/SimDB_createViews.sql" />
117
118 <echo>createDB : done.</echo>
119 </target>
120
121
122 <!-- end of build_db.xml -->

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26