fixed quartz sql with a hack.  need a better fix.
@@ -27,17 +27,19 @@ import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+
public class SchemaInitializationProvider implements ISchemaInitializationProvider {
private final String mySchemaFileClassPath;
private final String mySchemaExistsIndicatorTable;
/**
- *
* @param theSchemaFileClassPath pathname to script used to initialize schema
* @param theSchemaExistsIndicatorTable a table name we can use to determine if this schema has already been initialized
*/
@@ -50,8 +52,7 @@ public class SchemaInitializationProvider implements ISchemaInitializationProvid
public List<String> getSqlStatements(DriverTypeEnum theDriverType) {
List<String> retval = new ArrayList<>();
- String initScript;
- initScript = mySchemaFileClassPath + "/" + theDriverType.getSchemaFilename();
+ String initScript = mySchemaFileClassPath + "/" + getInitScript(theDriverType);
try {
InputStream sqlFileInputStream = SchemaInitializationProvider.class.getResourceAsStream(initScript);
if (sqlFileInputStream == null) {
@@ -60,8 +61,9 @@ public class SchemaInitializationProvider implements ISchemaInitializationProvid
// Assumes no escaped semicolons...
String[] statements = IOUtils.toString(sqlFileInputStream, Charsets.UTF_8).split("\\;");
for (String statement : statements) {
- if (!statement.trim().isEmpty()) {
- retval.add(statement);
+ String cleanedStatement = clean(statement);
+ if (!isBlank(cleanedStatement)) {
+ retval.add(cleanedStatement + ";");
}
}
} catch (IOException e) {
@@ -70,6 +72,29 @@ public class SchemaInitializationProvider implements ISchemaInitializationProvid
return retval;
}
+ private String clean(String theStatement) {
+ String[] lines = theStatement.split("\\n");
+ String retval = "";
+ for (String fullLine : lines) {
+ String line = fullLine.trim();
+ if (isBlank(line) ||
+ line.startsWith("--")) {
+ continue;
+ }
+ // FIXME KHS hack to fix bug in Quartz SQL
+ if ("BOOL_PROP_2 BOOLEAN NULL,".equals(line)) {
+ line = "BOOL_PROP_2 BOOLEAN NULL";
+ }
+ retval += line + "\n";
+ }
+ return retval;
+ }
+
+ @Nonnull
+ protected String getInitScript(DriverTypeEnum theDriverType) {
+ return theDriverType.getSchemaFilename();
+ }
+
@Override
public boolean equals(Object theO) {
if (this == theO) return true;
@@ -93,3 +118,4 @@ public class SchemaInitializationProvider implements ISchemaInitializationProvid
return mySchemaExistsIndicatorTable;
}
}
+
