\r
import org.apache.commons.lang.StringUtils;\r
import org.apache.log4j.Logger;\r
+import org.joda.time.DateTime;\r
\r
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;\r
private static final Logger logger = Logger.getLogger(SchemaUpdaterStepBase.class);\r
\r
protected String stepName;\r
+\r
+ private boolean ignoreErrors;\r
\r
\r
//************************ CONSTRUCTOR ***********************************/\r
- \r
+\r
protected SchemaUpdaterStepBase(String stepName){\r
this.setStepName(stepName);\r
}\r
\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep#invoke(eu.etaxonomy.cdm.database.ICdmDataSource, eu.etaxonomy.cdm.common.IProgressMonitor)\r
- */\r
- public abstract Integer invoke (ICdmDataSource datasource, IProgressMonitor monitor) throws SQLException;\r
\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep#setStepName(java.lang.String)\r
- */\r
+ @Override\r
+ public abstract Integer invoke (ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType) throws SQLException;\r
+\r
+\r
+ @Override\r
public void setStepName(String stepName) {\r
this.stepName = stepName;\r
}\r
\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep#getStepName()\r
- */\r
+ @Override\r
public String getStepName() {\r
return stepName;\r
}\r
\r
-\r
-\r
protected String getBoolean(boolean value, ICdmDataSource datasource) {\r
+ \r
String result;\r
DatabaseTypeEnum type = datasource.getDatabaseType();\r
+ //TODO use\r
+// type.getHibernateDialect().toBooleanValueString(bool);\r
int intValue = value == true? 1 : 0;\r
if (type.equals(DatabaseTypeEnum.MySQL)){\r
result = "b'"+intValue+"'";\r
return result;\r
}\r
\r
- protected Integer getEnglishLanguageId(ICdmDataSource datasource, IProgressMonitor monitor) throws SQLException {\r
- return getLanguageId(Language.uuidEnglish, datasource, monitor);\r
+ protected Integer getEnglishLanguageId(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType) throws SQLException {\r
+ return getLanguageId(Language.uuidEnglish, datasource, monitor, caseType);\r
}\r
\r
/**\r
* @return\r
* @throws SQLException\r
*/\r
- protected Integer getLanguageId(UUID uuidLanguage, ICdmDataSource datasource, IProgressMonitor monitor) throws SQLException {\r
+ protected Integer getLanguageId(UUID uuidLanguage, ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType) throws SQLException {\r
+ \r
ResultSet rs;\r
Integer langId = null;\r
- String sqlLangId = " SELECT id FROM DefinedTermBase WHERE uuid = '" + uuidLanguage + "'";\r
+ String sqlLangId = " SELECT id FROM %s WHERE uuid = '%s'";\r
+ sqlLangId = String.format(sqlLangId, caseType.transformTo("DefinedTermBase"), uuidLanguage.toString() );\r
rs = datasource.executeQuery(sqlLangId);\r
if (rs.next()){\r
langId = rs.getInt("id");\r
public List<ISchemaUpdaterStep> getInnerSteps(){\r
return new ArrayList<ISchemaUpdaterStep>();\r
}\r
+ \r
+ @Override\r
+ public boolean isIgnoreErrors() {\r
+ return ignoreErrors;\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public void setIgnoreErrors(boolean ignoreErrors) {\r
+ this.ignoreErrors = ignoreErrors;\r
+ }\r
+ \r
+\r
+ /**\r
+ * Returns a time string with date and time (without millis) that \r
+ * can be used as a time string for database insert and update\r
+ * @return\r
+ */\r
+ protected String getNowString() {\r
+ return DateTime.now().toString("YYYY-MM-dd HH:mm:ss");\r
+ }\r
\r
@Override\r
public String toString(){\r