file based script enhancement support

git-svn-id: https://svn.code.sf.net/p/jailer/code/trunk@58 3dd849cd-670e-4645-a7cd-dd197c8d0e81
This commit is contained in:
rwisser
2007-06-12 09:44:27 +00:00
parent 061894ee8d
commit 07af07d15b
9 changed files with 44 additions and 9 deletions
+8
View File
@@ -13,6 +13,14 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema
<!-- Script-enhancer
adds application specific extensions to generated SQL-scripts -->
<util:list id="script-enhancer">
<!--
Inserts the content of the files
- prolog/[INSERT|DELETE]/<TABLE>.sql
- epilog/[INSERT|DELETE]/<TABLE>.sql
at top/bottom of the generated script for each table <TABLE>
for which at least one row is inserted/deleted.
-->
<bean class="org.jailer.enhancer.FileBasedScriptEnhancer"/>
</util:list>
+11 -6
View File
@@ -169,8 +169,10 @@ org.jailer.Jailer $@</span><br>
</table>
<br>
<h3>Step 2. Setup the Database</h3>
Create a new schema and execute <big><a href="scott-tiger.sql.html"><span
style="font-family: monospace;">script/scott-tiger.sql</span></a></big>.
Create a new schema and execute <a href="scott-tiger.sql.html"><img
alt="" src="arrow.gif"
style="border: 0px solid ; width: 13px; height: 13px;" hspace="4"><big><span
style="font-family: monospace;">script/scott-tiger.sql</span></big></a>.
Make sure that the script runs successfully.<br>
<br>
<table style="width: 100%; text-align: left;" border="0"
@@ -415,7 +417,8 @@ re-create the tables after any model-changes)<br>
<td
style="background-color: rgb(230, 255, 230); vertical-align: top;"><span
style="font-family: monospace;">$ sh bin/jailer.sh create-ddl &gt; <a
href="jailer-ddl.sql.html">jailer-ddl.sql</a><br>
href="jailer-ddl.sql.html"><img alt="" src="arrow.gif"
style="border: 0px solid ; width: 13px; height: 13px;" hspace="4">jailer-ddl.sql</a><br>
$ db2 -tvf jailer-ddl.sql<br>
</span></td>
</tr>
@@ -499,7 +502,8 @@ SALARYGRADE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
</table>
<br>
<br>
A file <a href="scott.sql.html"><big><span
A file <a href="scott.sql.html"><img alt="" src="arrow.gif"
style="border: 0px solid ; width: 13px; height: 13px;" hspace="4"><big><span
style="font-family: monospace;">scott.sql</span></big></a> is created
containing <big><span style="font-family: monospace;">Insert</span></big>-statements
for Scott, for his evil boss, for the president and for scott's
@@ -924,8 +928,9 @@ and repeat the exportation:<br>
<td
style="background-color: rgb(230, 255, 230); vertical-align: top;"><span
style="font-family: monospace;">$ sh bin/jailer.sh export -e <a
href="scott.sql.2.html">scott.sql</a> <span
style="color: rgb(0, 0, 0);">-d delete-scott.sql</span>
href="scott.sql.2.html"><img alt="" src="arrow.gif"
style="border: 0px solid ; width: 13px; height: 13px;" hspace="4">scott.sql</a>
<span style="color: rgb(0, 0, 0);">-d delete-scott.sql</span>
extractionmodel/scott-without-subordinates.csv
com.ibm.db2.jcc.DB2Driver jdbc:db2://localhost:50001/wisser scott tiger
&gt; /dev/null<br>
Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

+2
View File
@@ -0,0 +1,2 @@
The content of each file <TABLE>.sql in this folder will be inserted
at bottom of the deletion-script if at least one row of <TABLE> is deleted.
+2
View File
@@ -0,0 +1,2 @@
The content of each file <TABLE>.sql in this folder will be inserted
at bottom of the export-script if at least one row of <TABLE> is exported.
+2
View File
@@ -0,0 +1,2 @@
The content of each file <TABLE>.sql in this folder will be inserted
at top of the deletion-script if at least one row of <TABLE> is deleted.
+2
View File
@@ -0,0 +1,2 @@
The content of each file <TABLE>.sql in this folder will be inserted
at top of the export-script if at least one row of <TABLE> is exported.
+8
View File
@@ -0,0 +1,8 @@
-- keeps DB-statistic up-to-date for the following tables:
-- ENTITY
-- ENTITY_GRAPH
-- DEPENDENCY
-- ENTITY_SET_ELEMENT
-- todo: insert statements necessary to do the job
@@ -31,7 +31,13 @@ import org.jailer.entitygraph.EntityGraph;
/**
* Enhances a script with the content of a <code>prolog/*.sql</code> or <code>epilog/*.sql</code> file.
* Inserts the content of the files
* <ul>
* <li><code>prolog/[INSERT|DELETE]/&lt;TABLE&gt;.sql</code></li>
* <li><code>epilog/[INSERT|DELETE]/&lt;TABLE&gt;.sql</code></li>
* </ul>
* at top/bottom of the generated script for each table &lt;TABLE&gt;
* for which at least one row is inserted/deleted.
*
* @author Wisser
*/
@@ -49,7 +55,7 @@ public class FileBasedScriptEnhancer implements ScriptEnhancer {
*/
public void addEpilog(Writer script, ScriptType scriptType, StatementExecutor statementExecutor, EntityGraph entityGraph,
Set<Table> progress) throws IOException, SQLException {
addEnhancement(script, progress, new File("epilog"));
addEnhancement(script, progress, new File("epilog" + File.separatorChar + scriptType));
}
/**
@@ -57,7 +63,7 @@ public class FileBasedScriptEnhancer implements ScriptEnhancer {
*/
public void addProlog(Writer script, ScriptType scriptType, StatementExecutor statementExecutor, EntityGraph entityGraph,
Set<Table> progress) throws IOException, SQLException {
addEnhancement(script, progress, new File("prolog"));
addEnhancement(script, progress, new File("prolog" + File.separatorChar + scriptType));
}
/**