Coverage Report - net.sourceforge.addam.ddlrun.InstallTask
 
Classes in this File Line Coverage Branch Coverage Complexity
InstallTask
0%
0/26
0%
0/1
1.667
 
 1  
 /*
 2  
  * Copyright (c) 2004 International Decision Systems, Inc.  All Rights Reserved.
 3  
  *
 4  
  * By using this Software, You acknowledge that the Software is a valuable asset
 5  
  * and trade secret of either International Decision Systems, Inc. ("IDSI") or a
 6  
  * third party supplier of IDSI and constitutes confidential and proprietary
 7  
  * information.
 8  
  *
 9  
  * NEITHER IDSI NOR ANY AGENT OR PERSON ACTING FOR OR WITH IDSI HAS MADE OR DOES
 10  
  * MAKE ANY STATEMENTS, AFFIRMATIONS, REPRESENTATIONS OR WARRANTIES WHATSOEVER
 11  
  * TO YOU, WHETHER EXPRESS OR IMPLIED, AS TO THE SOFTWARE, THE QUALITY OR
 12  
  * CONDITION OF THE SOFTWARE, OR THE OPERATING CHARACTERISTICS OR RELIABILITY OF
 13  
  * THE SOFTWARE, OR ITS SUITABILITY FOR ANY GENERAL OR PARTICULAR PURPOSE, OR AS
 14  
  * TO ANY OTHER MATTER WHATSOEVER; ANY AND ALL OTHER WARRANTIES INCLUDING
 15  
  * WITHOUT LIMITATION ANY WARRANTIES IMPLIED BY LAW, SUCH AS THE IMPLIED
 16  
  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND TITLE,
 17  
  * USE AND NON-INFRINGEMENT; ARE HEREBY EXPRESSLY DISCLAIMED AND EXCLUDED.
 18  
 */
 19  
 package net.sourceforge.addam.ddlrun;
 20  
 
 21  
 import net.sourceforge.addam.ddlrun.grammars.ScriptGrammar;
 22  
 import net.sourceforge.addam.ddlrun.grammars.ScriptGrammarManager;
 23  
 import net.sourceforge.addam.ddlrun.runners.DeploymentRunner;
 24  
 import net.sourceforge.addam.ddlrun.runners.DeploymentRunnerFactory;
 25  
 import net.sourceforge.addam.ddlrun.utils.FileSystemReaderFactory;
 26  
 import net.sourceforge.addam.ddlrun.utils.ResourceReaderFactory;
 27  
 import net.sourceforge.addam.ddlrun.utils.RunLogger;
 28  
 
 29  
 import org.apache.tools.ant.BuildException;
 30  
 import org.apache.tools.ant.taskdefs.JDBCTask;
 31  
 
 32  
 import java.io.File;
 33  
 import java.sql.Connection;
 34  
 
 35  
 /**
 36  
  * Implementation of the ant deployment task
 37  
  */
 38  
 public class InstallTask extends JDBCTask implements RunLogger {
 39  
 
 40  0
     public InstallTask() {
 41  0
     }
 42  
 
 43  
     public void setScript(File script) {
 44  0
         this.script = script;
 45  0
     }
 46  
 
 47  
     public void execute() throws BuildException {
 48  0
         Connection connection = getConnection();
 49  0
         ResourceReaderFactory factory = new FileSystemReaderFactory(script.getParentFile());
 50  0
         ScriptGrammar grammar = new ScriptGrammarManager().getGrammar(connection);
 51  0
         if (grammar == null) {
 52  0
             throw new BuildException("" + connection + " does not use a supported database driver");
 53  
         }
 54  
         try {
 55  0
             DeploymentRunner runner = DeploymentRunnerFactory.getInstance().getInstallRunner(factory,
 56  0
                     connection,
 57  0
                     grammar);
 58  0
             runner.addRunLogger(this);
 59  0
             System.out.println("running script " + script.getName());
 60  0
             runner.run(script.getName());
 61  0
         } catch (Exception e) {
 62  0
             throw new BuildException(e);
 63  0
         }
 64  0
     }
 65  
 
 66  
     public void logRunScript(String script, long time) throws Exception {
 67  0
         this.log("executed " + script + " (" + time + "ms)");
 68  0
     }
 69  
 
 70  
     public void logRunComplete(String group, long time) throws Exception {
 71  0
         this.log("completed execution of available scripts in " + group + " (" + time + "ms)");
 72  0
     }
 73  
 
 74  
     public void logRunFailure(String group, String script, Exception e) throws Exception {
 75  0
         this.log(group + "/" + script + " failed!");
 76  0
     }
 77  
 
 78  0
     private File script = null;
 79  
 }