Clover Coverage Report - Maven Impex Plugin 1.0.22-SNAPSHOT
Coverage timestamp: Mon Jul 18 2011 09:37:20 EDT
../../../../img/srcFileCovDistChart0.png 10% of files have more coverage
18   90   4   9
2   37   0.22   2
2     2  
1    
 
  SchemaSqlMojo       Line # 26 18 0% 4 22 0% 0.0
 
No Tests
 
1    package org.apache.torque.mojo;
2   
3    import org.apache.maven.plugin.MojoExecutionException;
4    import org.apache.torque.util.ChangeDetector;
5   
6    /**
7    * Generates platform specific SQL from database agnostic XML files.<br>
8    * <br>
9    * There are two types of SQL files created by this goal:<br>
10    * <br>
11    * Type 1: DDL statements for creating tables, primary keys, indexes, and unique constraints. Does not contain DDL for
12    * enforcing relationships between tables.<br>
13    * Type 2: DDL statements for creating and enforcing relationships between tables<br>
14    * <br>
15    * This allows data to be imported into multiple tables concurrently. Running the first type of SQL file will create the
16    * empty tables without any foreign key constraints. Data can then be loaded concurrently into the tables (using
17    * optimized high speed tools if desired) without needing to worry about the order in which the tables are loaded. After
18    * data has been loaded, the second type of SQL file can be run to add the relationships between the tables. As long as
19    * the data set is consistent and correct, all the relationships will get created correctly.<br>
20    * <br>
21    * The database platform to generate SQL for is determined by ${targetDatabase}. See also <code>impex:datasql</code>
22    *
23    * @goal schemasql
24    * @phase generate-sources
25    */
 
26    public class SchemaSqlMojo extends SqlMojoBase {
27   
28    /**
29    * The directory in which the SQL will be generated.
30    *
31    * @parameter property="outputDir" expression="${outputDir}" default-value="${project.build.directory}/classes/sql"
32    */
33    @SuppressWarnings("unused")
34    private String dummy1;
35   
36    /**
37    * The location where the report file will be generated.
38    *
39    * @parameter property="reportFile" expression="${reportFile}" default-value=
40    * "../../../reports/report.${project.artifactId}.sql.generation"
41    */
42    @SuppressWarnings("unused")
43    private String dummy2;
44   
45    /**
46    * The location where the context property file for velocity will be generated.
47    *
48    * @parameter property="contextPropertiesPath" expression="${contextPropertiesPath}"
49    * default-value="${project.build.directory}/reports/context.sql.properties"
50    */
51    @SuppressWarnings("unused")
52    private String dummy3;
53   
54    /**
55    * The suffix of the generated sql files.
56    *
57    * @parameter property="suffix" expression="${suffix}"
58    */
59    @SuppressWarnings("unused")
60    private String dummy4;
61   
 
62  0 toggle protected void showConfig() {
63  0 getLog().info("Schema Dir: " + getSchemaDir());
64  0 getLog().info("Includes: " + getSchemaIncludes());
65  0 getLog().info("Excludes: " + getSchemaExcludes());
66    }
67   
68    /**
69    * Generate SQL from schema XML files
70    */
 
71  0 toggle @Override
72    public void executeMojo() throws MojoExecutionException {
73  0 updateConfiguration();
74  0 validateConfiguration();
75  0 generateContextProperties();
76  0 configureTask();
77  0 addTargetDatabaseToOutputDir();
78  0 addTargetDatabaseToReportFile();
79  0 showConfig();
80  0 ChangeDetector detector = new ChangeDetector(getCanonicalReportFile(), getSchemaFiles());
81  0 if (!detector.isChanged() && isRunOnlyOnSchemaChange()) {
82  0 getLog().info("Schema has not changed. Skipping generation");
83  0 return;
84    }
85  0 getLog().info("------------------------------------------------------------------------");
86  0 getLog().info("Generating SQL for " + getTargetDatabase() + " from schema XML files");
87  0 getLog().info("------------------------------------------------------------------------");
88  0 getAntTask().execute();
89    }
90    }