Author: rareddy
Date: 2011-04-15 14:12:29 -0400 (Fri, 15 Apr 2011)
New Revision: 3094
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
Log:
TEIID-1011: adding the conversion between the Object[] and Object acceptable. Also
returning the results as Object[] from the OLAP Execution factory.
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-04-15
13:59:42 UTC (rev 3093)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-04-15
18:12:29 UTC (rev 3094)
@@ -772,7 +772,7 @@
@SuppressWarnings("unchecked")
public static <T> T transformValue(Object value, Class sourceType,
Class<T> targetClass) throws TransformationException {
- if (value == null || sourceType == targetClass) {
+ if (value == null || sourceType == targetClass || DefaultDataClasses.OBJECT ==
targetClass) {
return (T) value;
}
Transform transform = DataTypeManager.getTransform(sourceType,
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-04-15
13:59:42 UTC (rev 3093)
+++
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-04-15
18:12:29 UTC (rev 3094)
@@ -222,4 +222,9 @@
assertEquals("hello", DataTypeManager.transformValue(new Foo(),
DataTypeManager.DefaultDataClasses.STRING)); //$NON-NLS-1$
}
+ @SuppressWarnings("unchecked")
+ @Test public void testObjectArrayToObject() throws Exception {
+ Object[] value = {1,2};
+ assertArrayEquals(value, (Object[])DataTypeManager.transformValue(value,
value.getClass(), DataTypeManager.DefaultDataClasses.OBJECT));
+ }
}
Modified:
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
===================================================================
---
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-04-15
13:59:42 UTC (rev 3093)
+++
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-04-15
18:12:29 UTC (rev 3094)
@@ -22,7 +22,7 @@
package org.teiid.translator.olap;
import java.sql.SQLException;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
@@ -126,8 +126,10 @@
for (Position colPos : cols) {
Cell cell = cellSet.getCell(colPos, nextRow);
result[i++] = cell.getValue();
- }
- return Arrays.asList(result);
+ }
+ ArrayList<Object[]> results = new ArrayList<Object[]>();
+ results.add(result);
+ return results;
}
@Override
Show replies by date