Author: shawkins
Date: 2010-07-13 17:10:14 -0400 (Tue, 13 Jul 2010)
New Revision: 2339
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected
Log:
TEIID-1149 fix to ensure system datatypes are used and to not omit columns without a
datatype.
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
---
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-07-13
21:10:14 UTC (rev 2339)
@@ -11,6 +11,7 @@
<bean name="JBossLifeCycleListener"
class="org.teiid.jboss.JBossLifeCycleListener"/>
<bean name="VDBParserDeployer"
class="org.teiid.deployers.VDBParserDeployer">
+ <property name="vdbRepository"><inject
bean="VDBRepository"/></property>
<property name="objectSerializer"><inject
bean="ObjectSerializer"/></property>
<property name="managedObjectFactory"><inject
bean="ManagedObjectFactory"/></property>
</bean>
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -186,12 +186,14 @@
for (Schema schema : getVisibleSchemas(vdb, metadata)) {
for (Procedure proc : schema.getProcedures().values()) {
for (ProcedureParameter param : proc.getParameters()) {
- rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(),
param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(),
param.getType().toString(), param.isOptional(),
+ Datatype dt = param.getDatatype();
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(),
param.getName(), dt!=null?dt.getRuntimeTypeName():null, param.getPosition(),
param.getType().toString(), param.isOptional(),
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(),
param.getNullType().toString(), param.getUUID(), param.getAnnotation()));
}
if (proc.getResultSet() != null) {
for (Column param : proc.getResultSet().getColumns()) {
- rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(),
param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(),
"ResultSet", false, //$NON-NLS-1$
+ Datatype dt = param.getDatatype();
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(),
param.getName(), dt!=null?dt.getRuntimeTypeName():null, param.getPosition(),
"ResultSet", false, //$NON-NLS-1$
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(),
param.getNullType().toString(), param.getUUID(), param.getAnnotation()));
}
}
@@ -233,13 +235,11 @@
break;
case COLUMNS:
for (Column column : table.getColumns()) {
- if (column.getDatatype() == null) {
- continue; //some mapping classes don't set the datatype
- }
+ Datatype dt = column.getDatatype();
rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(),
column.getName(), column.getPosition(), column.getNameInSource(),
- column.getDatatype().getRuntimeTypeName(), column.getScale(),
column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
+ dt!=null?dt.getRuntimeTypeName():null, column.getScale(), column.getLength(),
column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
column.isCaseSensitive(), column.isSigned(), column.isCurrency(),
column.isAutoIncremented(), column.getNullType().toString(), column.getMinimumValue(),
- column.getMaximumValue(), column.getSearchType().toString(),
column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(),
column.getPrecision(),
+ column.getMaximumValue(), column.getSearchType().toString(),
column.getFormat(), column.getDefaultValue(), dt!=null?dt.getJavaClassName():null,
column.getPrecision(),
column.getCharOctetLength(), column.getRadix(), column.getUUID(),
column.getAnnotation()));
}
break;
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
---
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -112,7 +112,7 @@
addEntriesPlusVisibilities(vdb, new VDBMetaData());
}
- public MetadataStore getMetadataStore() throws IOException {
+ public MetadataStore getMetadataStore(Collection<Datatype> systemDatatypes) throws
IOException {
if (this.store == null) {
this.store = new MetadataStore();
ArrayList<Index> tmp = new ArrayList<Index>();
@@ -124,7 +124,12 @@
this.indexes = tmp.toArray(new Index[tmp.size()]);
getAnnotationCache();
getExtensionCache();
- getDatatypeCache();
+ Map<String, Datatype> datatypes = getDatatypeCache();
+ if (systemDatatypes != null) {
+ for (Datatype datatype : systemDatatypes) {
+ datatypes.put(datatype.getUUID(), datatype);
+ }
+ }
List<KeyRecord> keys =
findMetadataRecords(MetadataConstants.RECORD_TYPE.PRIMARY_KEY, null, false);
for (KeyRecord keyRecord : keys) {
this.primaryKeyCache.put(keyRecord.getUUID(), keyRecord);
Modified:
trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
===================================================================
---
trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -28,6 +28,7 @@
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
@SuppressWarnings("nls")
@@ -39,6 +40,10 @@
assertEquals(1, names.size());
names = tm.getGroupsForPartialName("PARTS");
assertEquals(1, names.size());
+
+ //ensure that datatypes are set
+ Table t = (Table)tm.getGroupID(names.iterator().next());
+ assertNotNull(t.getColumns().get(0).getDatatype());
}
}
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
---
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -49,6 +49,7 @@
public class VDBMetadataFactory {
public static LRUCache<URL, TransformationMetadata> VDB_CACHE = new
LRUCache<URL, TransformationMetadata>(10);
+ private static MetadataStore system;
public static TransformationMetadata getVDBMetadata(String vdbFile) {
try {
@@ -58,10 +59,12 @@
}
}
- public static MetadataStore getSystemVDBMetadataStore() {
+ public static MetadataStore getSystem() {
try {
- IndexMetadataFactory imf =
loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB));
- return imf.getMetadataStore();
+ if (system == null) {
+ system =
loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB)).getMetadataStore(null);
+ }
+ return system;
} catch (Exception e) {
throw new TeiidRuntimeException("System VDB not found");
}
@@ -80,8 +83,8 @@
if (udfFile != null) {
methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
}
- MetadataStore system =
loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB)).getMetadataStore();
- vdbmetadata = new TransformationMetadata(null, new
CompositeMetadataStore(Arrays.asList(system, imf.getMetadataStore())),
imf.getEntriesPlusVisibilities(), methods);
+
+ vdbmetadata = new TransformationMetadata(null, new
CompositeMetadataStore(Arrays.asList(getSystem(),
imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(),
methods);
VDB_CACHE.put(vdbURL, vdbmetadata);
return vdbmetadata;
} catch (URISyntaxException e) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2010-07-13
18:07:49 UTC (rev 2338)
+++ trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -42,11 +42,11 @@
if (url == null) {
throw new
TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found"));
//$NON-NLS-1$
}
- this.vdbRepository.setSystemStore(new IndexMetadataFactory(url).getMetadataStore());
+ this.vdbRepository.setSystemStore(new
IndexMetadataFactory(url).getMetadataStore(null));
} catch (URISyntaxException e) {
- throw new TeiidRuntimeException(e,
RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB));
//$NON-NLS-1$
+ throw new TeiidRuntimeException(e,
RuntimePlugin.Util.getString("system_vdb_load_error")); //$NON-NLS-1$
} catch (IOException e) {
- throw new TeiidRuntimeException(e,
RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB));
//$NON-NLS-1$
+ throw new TeiidRuntimeException(e,
RuntimePlugin.Util.getString("system_vdb_load_error")); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-07-13
18:07:49 UTC (rev 2338)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -61,6 +61,7 @@
*/
public class VDBParserDeployer extends BaseMultipleVFSParsingDeployer<VDBMetaData>
implements ManagedObjectCreator {
private ObjectSerializer serializer;
+ private VDBRepository vdbRepository;
public VDBParserDeployer() {
super(VDBMetaData.class, getCustomMappings(),
IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT, IndexMetadataFactory.class,
VdbConstants.MODEL_EXT, UDFMetaData.class);
@@ -146,7 +147,7 @@
MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile,
MetadataStoreGroup.class);
if (stores == null) {
stores = new MetadataStoreGroup();
- stores.addStore(imf.getMetadataStore());
+ stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
}
unit.addAttachment(MetadataStoreGroup.class, stores);
}
@@ -179,8 +180,12 @@
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB
"+unit.getRoot().getName()+" has been parsed."); //$NON-NLS-1$
//$NON-NLS-2$
return vdb;
- }
+ }
+ public void setVdbRepository(VDBRepository vdbRepository) {
+ this.vdbRepository = vdbRepository;
+ }
+
public void setObjectSerializer(ObjectSerializer serializer) {
this.serializer = serializer;
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-07-13 18:07:49
UTC (rev 2338)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-07-13 21:10:14
UTC (rev 2339)
@@ -109,6 +109,10 @@
throw new
VirtualDatabaseException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, latestVersion)); //$NON-NLS-1$
}
+ public MetadataStore getSystemStore() {
+ return systemStore;
+ }
+
public void setSystemStore(MetadataStore store) {
this.systemStore = store;
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -161,8 +161,8 @@
0,
CONNECTOR_METADATA_UTILITY,
"http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#timestamp",
//$NON-NLS-1$
- "http://www.w3.org/2001/XMLSchema#dateTime",
//$NON-NLS-1$
- "http://www.w3.org/2001/XMLSchema#dateTime");
//$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#string",
//$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#string");
//$NON-NLS-1$
checkParameter((Argument)params.get(3),
"inOptional", //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-07-13
18:07:49 UTC (rev 2338)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -52,21 +52,17 @@
import org.teiid.transport.LocalServerConnection;
import org.teiid.transport.LogonImpl;
-
+@SuppressWarnings("nls")
public class FakeServer extends ClientServiceRegistryImpl {
SessionServiceImpl sessionService = new SessionServiceImpl();
LogonImpl logon;
DQPCore dqp = new DQPCore();
VDBRepository repo = new VDBRepository();
- MetadataStore systemStore;
public FakeServer() {
this.logon = new LogonImpl(sessionService, null);
-
- systemStore = VDBMetadataFactory.getSystemVDBMetadataStore();
- this.repo.setSystemStore(systemStore);
-
+ this.repo.setSystemStore(VDBMetadataFactory.getSystem());
this.sessionService.setVDBRepository(repo);
this.dqp.setBufferService(new FakeBufferService());
this.dqp.setTransactionService(new FakeTransactionService());
@@ -90,13 +86,13 @@
public void deployVDB(String vdbName, String vdbPath) throws Exception {
IndexMetadataFactory imf = VDBMetadataFactory.loadMetadata(new
File(vdbPath).toURI().toURL());
- MetadataStore metadata = imf.getMetadataStore();
+ MetadataStore metadata = imf.getMetadataStore(repo.getSystemStore().getDatatypes());
VDBMetaData vdbMetaData = new VDBMetaData();
vdbMetaData.setName(vdbName);
vdbMetaData.setStatus(VDB.Status.ACTIVE);
- for (Schema schema : systemStore.getSchemas().values()) {
+ for (Schema schema : repo.getSystemStore().getSchemas().values()) {
ModelMetaData model = new ModelMetaData();
model.setName(schema.getName());
vdbMetaData.addModel(model);
Modified:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2010-07-13
21:10:14 UTC (rev 2339)
@@ -26,8 +26,8 @@
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.FakeServer;
@@ -45,14 +45,14 @@
static final String VDB = "PartsSupplier";
- @Before public void setUp() throws Exception {
+ @BeforeClass public static void setUp() throws Exception {
FakeServer server = new FakeServer();
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$
//$NON-NLS-2$
dbMetadata = connection.getMetaData();
}
- @After public void tearDown() throws SQLException {
+ @AfterClass public static void tearDown() throws SQLException {
connection.close();
}
Modified:
trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected
===================================================================
---
trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected 2010-07-13
18:07:49 UTC (rev 2338)
+++
trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected 2010-07-13
21:10:14 UTC (rev 2339)
@@ -35,6 +35,7 @@
QT_Ora9DS XQTDoc
BQTDocTestDocument.MappingClasses.SingleRow
ShortValue 5
short 5
<null> 0 0
1 <null>
<null>
<null> <null>
0 14
NO <null>
<null>
<null> !
<null>
NO
QT_Ora9DS XQTDoc
BQTDocTestDocument.MappingClasses.SingleRow
BigIntegerValue 2
biginteger 19
<null> 0 0
1 <null>
<null>
<null> <null>
0 15
NO <null>
<null>
<null> !
<null>
NO
QT_Ora9DS XQTDoc
BQTDocTestDocument.MappingClasses.SingleRow
BigDecimalValue 2
bigdecimal 20
<null> 0 0
1 <null>
<null>
<null> <null>
0 16
NO <null>
<null>
<null> !
<null>
NO
+QT_Ora9DS XQTDoc
BQTDocTestDocument.MappingClasses.SingleRow
ObjectValue
<null> <null>
<null> <null>
0 0 1 <null>
<null>
<null>
<null> 0
17 NO
<null> <null>
<null> !
<null>
NO
QT_Ora9DS VQT
Base.Agg1
StringNum 12
string 10
<null> 0
10 1 <null>
<null>
<null> <null>
10 1
NO <null>
<null>
<null> !
<null>
NO
QT_Ora9DS VQT
Base.Agg2
StringNum 12
string 10
<null> 0
10 1 <null>
<null>
<null> <null>
10 1
NO <null>
<null>
<null> !
<null>
NO
QT_Ora9DS VQT
Base.Agg3
count 4
integer 10
<null> 0
10 0 <null>
<null>
<null> <null>
1 1
YES <null>
<null>
<null> !
<null>
NO
@@ -972,7 +973,7 @@
QT_Ora9DS XQT
xqtFullData
BigIntegerValue 2
biginteger 19
<null> 0
10 1 <null>
<null>
<null> <null>
28 15
NO <null>
<null>
<null> !
<null>
NO
QT_Ora9DS XQT
xqtFullData
BigDecimalValue 2
bigdecimal 20
<null> 0
10 1 <null>
<null>
<null> <null>
126 16
NO <null>
<null>
<null> !
<null>
NO
QT_Ora9DS XQT
xqtFullData
ObjectValue
2000 object 2048
<null> 0
10 1 <null>
<null>
<null> <null>
2048 17
NO <null>
<null>
<null> !
<null>
NO
-Row Count : 972
+Row Count : 973
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel
getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision
getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable
isReadOnly isSearchable isSigned isWritable
TABLE_CAT 12 QT_Ora9DS java.lang.String TABLE_CAT
string SYS Columns 255 255 0
false false false false 0 true
true false false
TABLE_SCHEM 12 QT_Ora9DS java.lang.String TABLE_SCHEM
string SYS Columns 255 255 0
false true false true 1 false
true true true