it.openutils.migration.task.setup
Class BaseConditionalTask

java.lang.Object
  extended by it.openutils.migration.task.setup.BaseDbTask
      extended by it.openutils.migration.task.setup.BaseConditionalTask
All Implemented Interfaces:
DbTask
Direct Known Subclasses:
GenericConditionalTask, JdbcIfColumnExistsConditionalTask

public abstract class BaseConditionalTask
extends BaseDbTask

A base conditional task that executes a task only if an expected condition is met.

Version:
$Id:SqlServerObjCreationTask.java 3143 2007-09-24 19:50:49Z fgiust $
Author:
fgiust

Field Summary
protected  java.lang.String ddl
          DDL to run when the condition is met.
protected  org.slf4j.Logger log
          Logger.
protected  boolean not
          If true executes only if check returned false
protected  java.util.List<org.springframework.core.io.Resource> scripts
          Script list to execute
protected  java.util.Map<java.lang.String,java.lang.String> variables
          Map of key-value that will be replaced in ddl.
 
Fields inherited from class it.openutils.migration.task.setup.BaseDbTask
description
 
Constructor Summary
BaseConditionalTask()
           
 
Method Summary
abstract  boolean check(org.springframework.jdbc.core.simple.SimpleJdbcTemplate jdbcTemplate)
          Subclasses need to override this method and provide specific checks.
 void execute(javax.sql.DataSource dataSource)
          Execute this db task.
 java.lang.String getDescription()
          Returns a description for this task
protected  java.lang.String objectNameFromFileName(org.springframework.core.io.Resource script)
           
protected  java.lang.String performSubstitution(java.lang.String string)
          Perform sobstitution in the given string.
 void setDdl(java.lang.String ddls)
          
 void setDdlScript(org.springframework.core.io.Resource ddlScript)
          Deprecated. use the "scripts" property
 void setNot(boolean not)
          Sets the not.
 void setScripts(java.util.List<org.springframework.core.io.Resource> scripts)
          Sets the scripts.
 
Methods inherited from class it.openutils.migration.task.setup.BaseDbTask
setDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.slf4j.Logger log
Logger.


ddl

protected java.lang.String ddl
DDL to run when the condition is met.


not

protected boolean not
If true executes only if check returned false


variables

protected java.util.Map<java.lang.String,java.lang.String> variables
Map of key-value that will be replaced in ddl.


scripts

protected java.util.List<org.springframework.core.io.Resource> scripts
Script list to execute

Constructor Detail

BaseConditionalTask

public BaseConditionalTask()
Method Detail

setScripts

public void setScripts(java.util.List<org.springframework.core.io.Resource> scripts)
Sets the scripts.

Parameters:
scripts - the scripts to set

setDdl

public final void setDdl(java.lang.String ddls)


setNot

public final void setNot(boolean not)
Sets the not.

Parameters:
not - the not to set

setDdlScript

@Deprecated
public final void setDdlScript(org.springframework.core.io.Resource ddlScript)
Deprecated. use the "scripts" property

Sets the ddlScript.

Parameters:
ddlScript - the ddlScript to set

check

public abstract boolean check(org.springframework.jdbc.core.simple.SimpleJdbcTemplate jdbcTemplate)
Subclasses need to override this method and provide specific checks.

Parameters:
jdbcTemplate - SimpleJdbcTemplate
Returns:
true if the condition is met

getDescription

public java.lang.String getDescription()
Returns a description for this task

Specified by:
getDescription in interface DbTask
Overrides:
getDescription in class BaseDbTask
Returns:
task description

objectNameFromFileName

protected java.lang.String objectNameFromFileName(org.springframework.core.io.Resource script)
Parameters:
script - The script resource
Returns:
The script name

performSubstitution

protected java.lang.String performSubstitution(java.lang.String string)
Perform sobstitution in the given string.

Parameters:
string - Original String
Returns:
processed string

execute

public void execute(javax.sql.DataSource dataSource)
Execute this db task.

Parameters:
dataSource - javax.sql.datasource


Copyright © 2008 Openmind. All Rights Reserved.