3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.database
.update
;
12 import java
.sql
.SQLException
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.common
.IProgressMonitor
;
17 import eu
.etaxonomy
.cdm
.database
.DatabaseTypeEnum
;
18 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
25 public abstract class SchemaUpdaterStepBase
implements ISchemaUpdaterStep
{
26 @SuppressWarnings("unused")
27 private static final Logger logger
= Logger
.getLogger(SchemaUpdaterStepBase
.class);
29 private String stepName
;
32 //************************ CONSTRUCTOR ***********************************/
34 protected SchemaUpdaterStepBase(String stepName
){
35 this.setStepName(stepName
);
39 * @see eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep#invoke(eu.etaxonomy.cdm.database.ICdmDataSource, eu.etaxonomy.cdm.common.IProgressMonitor)
41 public abstract Integer
invoke (ICdmDataSource datasource
, IProgressMonitor monitor
) throws SQLException
;
44 * @see eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep#setStepName(java.lang.String)
46 public void setStepName(String stepName
) {
47 this.stepName
= stepName
;
51 * @see eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep#getStepName()
53 public String
getStepName() {
59 protected String
getBoolean(boolean value
, ICdmDataSource datasource
) {
61 DatabaseTypeEnum type
= datasource
.getDatabaseType();
62 int intValue
= value
== true?
1 : 0;
63 if (type
.equals(DatabaseTypeEnum
.MySQL
)){
64 result
= "b'"+intValue
+"'";
65 }else if (type
.equals(DatabaseTypeEnum
.PostgreSQL
)){
66 result
= "'"+intValue
+"'";
67 }else if (type
.equals(DatabaseTypeEnum
.H2
)){
68 logger
.warn("H2 boolean not tested yet");
69 result
= "b'"+intValue
+"'";
70 }else if (type
.equals(DatabaseTypeEnum
.SqlServer2005
)){
71 logger
.warn("SQLServer boolean not tested yet");
72 result
= "b'"+intValue
+"'";
74 throw new RuntimeException("Database type not supported for boolean" + type
.getName());