Author: shawkins
Date: 2012-10-04 12:49:23 -0400 (Thu, 04 Oct 2012)
New Revision: 4514
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
Log:
TEIID-2202 adding a db2fori property on the db2 translator
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2012-10-04
16:08:45 UTC (rev 4513)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2012-10-04
16:49:23 UTC (rev 4514)
@@ -32,6 +32,7 @@
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TranslatorProperty;
import org.teiid.translator.jdbc.FunctionModifier;
@Translator(name="db2", description="A translator for IBM DB2
Database")
@@ -39,9 +40,13 @@
public static final String EIGHT_0 = "8.0"; //$NON-NLS-1$
public static final String NINE_1 = "9.1"; //$NON-NLS-1$
+
+ public static final String FIVE_4 = "5.4"; //$NON-NLS-1$
+ public static final String SIX_1 = "6.1"; //$NON-NLS-1$
+ private boolean dB2ForI;
+
public DB2ExecutionFactory() {
- setDatabaseVersion(EIGHT_0);
}
@Override
@@ -115,7 +120,7 @@
@Override
public boolean supportsFunctionsInGroupBy() {
- return true;
+ return !dB2ForI;
}
@Override
@@ -135,10 +140,22 @@
@Override
public boolean supportsElementaryOlapOperations() {
- return getDatabaseVersion().compareTo(NINE_1) >= 0;
+ return getDatabaseVersion().compareTo(isdB2ForI()?SIX_1:NINE_1) >= 0;
}
@Override
+ public String getDatabaseVersion() {
+ String version = super.getDatabaseVersion();
+ if (version != null) {
+ return version;
+ }
+ if (dB2ForI) {
+ return FIVE_4;
+ }
+ return EIGHT_0;
+ }
+
+ @Override
public void start() throws TranslatorException {
super.start();
registerFunctionModifier(SourceSystemFunctions.TRIM, new FunctionModifier() {
@@ -151,4 +168,13 @@
});
}
+ @TranslatorProperty(display="Is DB2 for i", description="If the server is
DB2 for i (formally known as DB2/AS).",advanced=true)
+ public boolean isdB2ForI() {
+ return dB2ForI;
+ }
+
+ public void setdB2ForI(boolean dB2ForI) {
+ this.dB2ForI = dB2ForI;
+ }
+
}
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2012-10-04
16:08:45 UTC (rev 4513)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2012-10-04
16:49:23 UTC (rev 4514)
@@ -279,5 +279,14 @@
input, output,
TRANSLATOR);
}
+
+ @Test public void testDB2ForI() throws Exception {
+ DB2ExecutionFactory db2 = new DB2ExecutionFactory();
+ db2.setdB2ForI(true);
+ assertFalse(db2.supportsFunctionsInGroupBy());
+ assertFalse(db2.supportsElementaryOlapOperations());
+ db2.setDatabaseVersion(DB2ExecutionFactory.SIX_1);
+ assertTrue(db2.supportsElementaryOlapOperations());
+ }
}
Show replies by date