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
;
13 import java
.util
.HashMap
;
16 import org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
19 import eu
.etaxonomy
.cdm
.database
.DatabaseTypeEnum
;
20 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
23 * This class represents one step in a schema update.
28 public class SimpleSchemaUpdaterStep
extends SchemaUpdaterStepBase
<SimpleSchemaUpdaterStep
> implements ISchemaUpdaterStep
, ITermUpdaterStep
{
29 @SuppressWarnings("unused")
30 private static final Logger logger
= Logger
.getLogger(SimpleSchemaUpdaterStep
.class);
32 private Map
<DatabaseTypeEnum
, String
> queryMap
= new HashMap
<DatabaseTypeEnum
, String
>();
35 // *************************** FACTORY ********************************/
37 public static SimpleSchemaUpdaterStep
NewInstance(String stepName
, String defaultQuery
){
38 return new SimpleSchemaUpdaterStep(stepName
, defaultQuery
);
41 //************************ CONSTRUCTOR ***********************************/
42 private SimpleSchemaUpdaterStep(String stepName
, String defaultQuery
){
44 queryMap
.put(null, defaultQuery
);
47 // *************************** INVOKE *****************************
50 * @see eu.etaxonomy.cdm.database.update.SchemaUpdaterStepBase#invoke(eu.etaxonomy.cdm.database.ICdmDataSource, eu.etaxonomy.cdm.common.IProgressMonitor)
52 public Integer
invoke (ICdmDataSource datasource
, IProgressMonitor monitor
){
53 boolean result
= true;
54 String query
= queryMap
.get(datasource
.getDatabaseType());
56 query
= queryMap
.get(null);
59 datasource
.executeUpdate(query
);
60 } catch (SQLException e
) {
64 return (result
== true )?
0 : null;
67 //********************************* DELEGATES *********************************/
69 public String
put(DatabaseTypeEnum dbType
, String query
) {
70 return queryMap
.put(dbType
, query
);