[teiid-commits] teiid SVN: r1537 - in trunk/metadata/src/main/java/org/teiid/metadata: index and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Sat Oct 24 22:00:37 EDT 2009


Author: shawkins
Date: 2009-10-24 22:00:37 -0400 (Sat, 24 Oct 2009)
New Revision: 1537

Added:
   trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java
Removed:
   trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
   trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java
   trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java
   trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java
   trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
Modified:
   trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java
Log:
TEIID-871 TEIID-792 TEIID-102 TEIID-254 TEIID-869 TEIID-875 further clean up of metadata related logic.  The index connector has been removed and the system virtual views promoted to physical tables.  some of the tables/procedures have been removed. and minor changes have been made to MMDatabaseMetadata queries.


Deleted: trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.metadata;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.query.metadata.MetadataStore;
-
-public class CompositeMetadataStore implements MetadataStore {
-
-	private List<? extends MetadataStore> metadataStores;
-	private MetadataSource metadataSource;
-	private Map<String, MetadataStore> storeMap;
-	
-	public CompositeMetadataStore(List<? extends MetadataStore> metadataStores, MetadataSource metadataSource) {
-		this.metadataStores = metadataStores;
-		this.metadataSource = metadataSource;
-		this.storeMap = new HashMap<String, MetadataStore>();
-		for (MetadataStore metadataStore : metadataStores) {
-			for (String model : metadataStore.getModelNames()) {
-				storeMap.put(model.toUpperCase(), metadataStore);
-			}
-		}
-	}
-	
-	@Override
-	public Collection<String> getModelNames() {
-		return storeMap.keySet();
-	}
-	
-	@Override
-	public ModelRecordImpl getModel(String fullName)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		return getMetadataStore(fullName).getModel(fullName);
-	}
-	
-	@Override
-	public ColumnRecordImpl findElement(String fullName)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		List<String> tokens = StringUtil.getTokens(fullName, TransformationMetadata.DELIMITER_STRING);
-		if (tokens.size() < 3) {
-		    throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-		}			
-		return getMetadataStore(tokens.get(0)).findElement(fullName);
-	}
-	
-	@Override
-	public TableRecordImpl findGroup(String fullName)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		List<String> tokens = StringUtil.getTokens(fullName, TransformationMetadata.DELIMITER_STRING);
-		if (tokens.size() < 2) {
-		    throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-		}			
-		return getMetadataStore(tokens.get(0)).findGroup(fullName);
-	}
-	
-	@Override
-	public Collection<String> getGroupsForPartialName(String partialGroupName)
-			throws MetaMatrixComponentException, QueryMetadataException {
-		List<String> result = new LinkedList<String>();
-		for (MetadataStore store : metadataStores) {
-			result.addAll(store.getGroupsForPartialName(partialGroupName));
-		}
-		return result;
-	}
-	
-	@Override
-	public Collection getXMLTempGroups(TableRecordImpl table)
-			throws MetaMatrixComponentException {
-		return getMetadataStore(table.getModelName()).getXMLTempGroups(table);
-	}
-	
-	@Override
-	public ProcedureRecordImpl getStoredProcedure(
-			String fullyQualifiedProcedureName)
-			throws MetaMatrixComponentException, QueryMetadataException {
-		List<String> tokens = StringUtil.getTokens(fullyQualifiedProcedureName, TransformationMetadata.DELIMITER_STRING);
-		if (tokens.size() < 2) {
-		    throw new QueryMetadataException(fullyQualifiedProcedureName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-		}
-		return getMetadataStore(tokens.get(0)).getStoredProcedure(fullyQualifiedProcedureName);
-	}
-
-	@Override
-	public Collection<? extends AbstractMetadataRecord> findMetadataRecords(char recordType,
-			String entityName, boolean isPartialName)
-			throws MetaMatrixComponentException {
-		LinkedList<AbstractMetadataRecord> result = new LinkedList<AbstractMetadataRecord>();
-		for (MetadataStore store : metadataStores) {
-			Collection<? extends AbstractMetadataRecord> results = store.findMetadataRecords(recordType, entityName, isPartialName);
-			if (!results.isEmpty() && !isPartialName) {
-				return results;
-			}
-			result.addAll(results);
-		}
-		return result;
-	}
-	
-	public boolean postProcessFindMetadataRecords() {
-		for (MetadataStore store : metadataStores) {
-			if (store.postProcessFindMetadataRecords()) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	@Override
-	public Collection<AbstractMetadataRecord> findMetadataRecords(String indexName,
-			String pattern, boolean isPrefix,
-			boolean isCaseSensitive) throws MetaMatrixCoreException {
-		LinkedList<AbstractMetadataRecord> result = new LinkedList<AbstractMetadataRecord>();
-		for (MetadataStore store : metadataStores) {
-			Collection<? extends AbstractMetadataRecord> results = store.findMetadataRecords(indexName, pattern, isPrefix, isCaseSensitive);
-			result.addAll(results);
-		}
-		return result;
-	}
-
-	@Override
-	public Collection<PropertyRecordImpl> getExtensionProperties(AbstractMetadataRecord record)
-			throws MetaMatrixComponentException {
-		return getMetadataStore(record.getModelName()).getExtensionProperties(record);
-	}
-
-	public MetadataStore getMetadataStore(String modelName) throws QueryMetadataException {
-		MetadataStore store = this.storeMap.get(modelName.toUpperCase());
-		if (store == null) {
-			throw new QueryMetadataException(modelName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-		}
-		return store;
-	}
-
-	public MetadataSource getMetadataSource() {
-		return metadataSource;
-	}
-	
-}

Deleted: trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,248 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.metadata;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
-import org.teiid.connector.metadata.runtime.ConnectorMetadata;
-import org.teiid.connector.metadata.runtime.MetadataConstants;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
-import org.teiid.metadata.index.IndexConstants;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.query.metadata.MetadataStore;
-
-public class ConnectorMetadataStore implements MetadataStore {
-	
-	private ConnectorMetadata metadata;
-	private String modelName;
-	
-	public ConnectorMetadataStore(String modelName, ConnectorMetadata metadata) {
-		this.modelName = modelName;
-		this.metadata = metadata;
-	}
-	
-	@Override
-	public ModelRecordImpl getModel(String fullName)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		//there's no need to check the name, the CompositeMetadataStore will have already done that
-		return metadata.getModel();
-	}
-	
-	@Override
-	public ColumnRecordImpl findElement(String fullName)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		throw new UnsupportedOperationException();
-	}
-	
-	@Override
-	public TableRecordImpl findGroup(String fullName)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		for (TableRecordImpl tableRecordImpl : metadata.getTables()) {
-			if (tableRecordImpl.getFullName().equalsIgnoreCase(fullName)) {
-				return tableRecordImpl;
-			}
-		}
-        throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-	}
-	
-	@Override
-	public Collection<String> getGroupsForPartialName(String partialGroupName)
-			throws MetaMatrixComponentException, QueryMetadataException {
-		Collection<String> results = new LinkedList<String>();
-		for (TableRecordImpl tableRecordImpl : metadata.getTables()) {
-			if (tableRecordImpl.getFullName().toLowerCase().endsWith(partialGroupName)) {
-				results.add(tableRecordImpl.getFullName());
-			}
-		}
-		return results;
-	}
-	
-	@Override
-	public Collection<String> getModelNames() {
-		return Arrays.asList(modelName);
-	}
-	
-	@Override
-	public ProcedureRecordImpl getStoredProcedure(
-			String fullyQualifiedProcedureName)
-			throws MetaMatrixComponentException, QueryMetadataException {
-		for (ProcedureRecordImpl procedureRecordImpl : metadata.getProcedures()) {
-			if (procedureRecordImpl.getFullName().equalsIgnoreCase(fullyQualifiedProcedureName)) {
-				return procedureRecordImpl;
-			}
-		}
-        throw new QueryMetadataException(fullyQualifiedProcedureName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-	}
-	
-	@Override
-	public Collection getXMLTempGroups(TableRecordImpl table)
-			throws MetaMatrixComponentException {
-		throw new UnsupportedOperationException();
-	}
-
-	@Override
-	public Collection<? extends AbstractMetadataRecord> findMetadataRecords(char recordType,
-			String entityName, boolean isPartialName)
-			throws MetaMatrixComponentException {
-		throw new UnsupportedOperationException();
-	}
-
-	private Collection<? extends AbstractMetadataRecord> getRecordsByType(
-			char recordType) {
-		switch (recordType) {
-		case MetadataConstants.RECORD_TYPE.CALLABLE:
-			return metadata.getProcedures();
-		case MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER: {
-			Collection<ProcedureParameterRecordImpl> results = new ArrayList<ProcedureParameterRecordImpl>();
-			for (ProcedureRecordImpl procedure : metadata.getProcedures()) {
-				results.addAll(procedure.getParameters());
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.RESULT_SET: {
-			Collection<ColumnSetRecordImpl> results = new ArrayList<ColumnSetRecordImpl>();
-			for (ProcedureRecordImpl procedure : metadata.getProcedures()) {
-				if (procedure.getResultSet() != null) {
-					results.add(procedure.getResultSet());
-				}
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.ACCESS_PATTERN: {
-			Collection<ColumnSetRecordImpl> results = new ArrayList<ColumnSetRecordImpl>();
-			for (TableRecordImpl table : metadata.getTables()) {
-				results.addAll(table.getAccessPatterns());
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.UNIQUE_KEY: {
-			Collection<ColumnSetRecordImpl> results = new ArrayList<ColumnSetRecordImpl>();
-			for (TableRecordImpl table : metadata.getTables()) {
-				results.addAll(table.getUniqueKeys());
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.PRIMARY_KEY: {
-			Collection<ColumnSetRecordImpl> results = new ArrayList<ColumnSetRecordImpl>();
-			for (TableRecordImpl table : metadata.getTables()) {
-				if (table.getPrimaryKey() != null) {
-					results.add(table.getPrimaryKey());
-				}
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.FOREIGN_KEY: {
-			Collection<ColumnSetRecordImpl> results = new ArrayList<ColumnSetRecordImpl>();
-			for (TableRecordImpl table : metadata.getTables()) {
-				results.addAll(table.getForeignKeys());
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.INDEX: {
-			Collection<ColumnSetRecordImpl> results = new ArrayList<ColumnSetRecordImpl>();
-			for (TableRecordImpl table : metadata.getTables()) {
-				results.addAll(table.getIndexes());
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.MODEL:
-			return Arrays.asList(metadata.getModel());
-		case MetadataConstants.RECORD_TYPE.TABLE:
-			return metadata.getTables();
-		case MetadataConstants.RECORD_TYPE.COLUMN: {
-			Collection<ColumnRecordImpl> results = new ArrayList<ColumnRecordImpl>();
-			for (TableRecordImpl table : metadata.getTables()) {
-				results.addAll(table.getColumns());
-			}
-			return results;
-		}
-		case MetadataConstants.RECORD_TYPE.ANNOTATION: {
-			return metadata.getAnnotations();
-		}
-		case MetadataConstants.RECORD_TYPE.PROPERTY: {
-			return metadata.getProperties();
-		}
-		}
-		return Collections.emptyList();
-	}
-
-	@Override
-	public Collection<? extends AbstractMetadataRecord> findMetadataRecords(String indexName,
-			String pattern, boolean isPrefix,
-			boolean isCaseSensitive) throws MetaMatrixCoreException {
-		if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.COLUMNS_INDEX)) {
-			return getRecordsByType(MetadataConstants.RECORD_TYPE.COLUMN);
-		} else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.KEYS_INDEX)) {
-			List<AbstractMetadataRecord> result = new ArrayList<AbstractMetadataRecord>();
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.ACCESS_PATTERN));
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.UNIQUE_KEY));
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.PRIMARY_KEY));
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.FOREIGN_KEY));
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.INDEX));
-			return result;
-		} else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MODELS_INDEX)) {
-			return getRecordsByType(MetadataConstants.RECORD_TYPE.MODEL);
-		} else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROCEDURES_INDEX)) {
-			List<AbstractMetadataRecord> result = new ArrayList<AbstractMetadataRecord>();
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.CALLABLE));
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER));
-			result.addAll(getRecordsByType(MetadataConstants.RECORD_TYPE.RESULT_SET));
-			return result;
-		} else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.TABLES_INDEX)) {
-			return getRecordsByType(MetadataConstants.RECORD_TYPE.TABLE);
-		} else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.ANNOTATION_INDEX)) {
-			return getRecordsByType(MetadataConstants.RECORD_TYPE.ANNOTATION);
-		}
-		return Collections.emptyList();
-	}
-	
-	@Override
-	public boolean postProcessFindMetadataRecords() {
-		return true;
-	}
-
-	@Override
-	public Collection<PropertyRecordImpl> getExtensionProperties(AbstractMetadataRecord record)
-			throws MetaMatrixComponentException {
-		if (record.getExtensionProperties() == null) {
-			return Collections.emptyList();
-		}
-		return record.getExtensionProperties();
-	}
-		
-}

Deleted: trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,277 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.metadata;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.teiid.connector.metadata.IndexFile;
-import org.teiid.connector.metadata.MetadataConnectorConstants;
-import org.teiid.connector.metadata.MultiObjectSource;
-import org.teiid.connector.metadata.PropertyFileObjectSource;
-import org.teiid.connector.metadata.runtime.ConnectorMetadata;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.metadata.index.IndexMetadataStore;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.DataTypeManager.DefaultDataTypes;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.connector.metadata.internal.IObjectSource;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.query.metadata.MetadataStore;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.vdb.runtime.VDBKey;
-
-
-/** 
- * This caches QueryMetadataInterface implementations for all vdbs, each implementation has access to
- * metadata for a given vdb and the system vdb.
- * @since 4.2
- */
-public class QueryMetadataCache {
-	
-	private static class QueryMetadataHolder {
-		QueryMetadataInterface qmi;
-	}
-    
-    // vdbID to QueryMetadataInterfaceHolder map
-    private Map<VDBKey, QueryMetadataHolder> vdbToQueryMetadata = Collections.synchronizedMap(new HashMap<VDBKey, QueryMetadataHolder>());
-    // map between vdbID and CompositeIndexSelector for the vdb (RuntimeSelector for the vdb and system vdb)
-    private Map<VDBKey, CompositeMetadataStore> vdbToCompositeSelector = Collections.synchronizedMap(new HashMap<VDBKey, CompositeMetadataStore>());
-    // RuntimeIndexSelector for the system vdb    
-    private final VDBArchive systemVDBSelector;
-
-    // boolean for the cache being valid
-    private boolean isCacheValid = true;
-	private IndexMetadataStore indexMetadataStore;
-    
-    /** 
-     * Constructor given a URL to a system vdb. 
-     * @since 4.2
-     */
-    public QueryMetadataCache(final URL systemVdbUrl) throws MetaMatrixComponentException {
-        try {
-            this.systemVDBSelector = new VDBArchive(systemVdbUrl.openStream());
-            this.indexMetadataStore = new IndexMetadataStore(this.systemVDBSelector);
-        } catch(IOException e) {
-            throw new MetaMatrixComponentException(e, DQPPlugin.Util.getString("QueryMetadataCache.Failed_creating_Runtime_Index_Selector._4", CoreConstants.SYSTEM_VDB));  //$NON-NLS-1$
-        }        
-    }
-    
-    /** 
-     * Constructor given the contents of a system vdb. 
-     * @since 4.2
-     */
-    public QueryMetadataCache(final byte[] systemVdbContent) throws MetaMatrixComponentException {
-        try {
-	        this.systemVDBSelector = new VDBArchive(new ByteArrayInputStream(systemVdbContent));
-            this.indexMetadataStore = new IndexMetadataStore(this.systemVDBSelector);
-	    } catch(IOException e) {
-	        throw new MetaMatrixComponentException(e, DQPPlugin.Util.getString("QueryMetadataCache.Failed_creating_Runtime_Index_Selector._4", CoreConstants.SYSTEM_VDB));  //$NON-NLS-1$
-	    }        
-    }
-
-    /**
-     * Get the composite selector fot the given vdbName, version. 
-     */
-    private CompositeMetadataStore getCompositeSelector(final String vdbName, final String vdbVersion) {
-        // check cache status
-        assertIsValidCache();
-        VDBKey vdbID = toVdbID(vdbName, vdbVersion);
-        return this.vdbToCompositeSelector.get(vdbID);
-    }
-    
-    public IObjectSource getCompositeMetadataObjectSource(String vdbName, String vdbVersion, VDBService vdbService){
-    	CompositeMetadataStore indexSelector = getCompositeSelector(vdbName, vdbVersion);
-
-		// build up sources to be used by the index connector
-		IObjectSource indexFile = new IndexFile(indexSelector, vdbName, vdbVersion, vdbService);
-
-		PropertyFileObjectSource propertyFileSource = new PropertyFileObjectSource();
-		IObjectSource multiObjectSource = new MultiObjectSource(indexFile, MetadataConnectorConstants.PROPERTIES_FILE_EXTENSION,propertyFileSource);
-    	return multiObjectSource;
-    }
-    
-    /**
-     * Look up metadata for the given vdbName, version at the given filecontent.
-     * @throws MetaMatrixComponentException 
-     */
-    public QueryMetadataInterface lookupMetadata(final String vdbName, final String vdbVersion, MetadataSource iss, DataService dataService) throws MetaMatrixComponentException {
-    	assertIsValidCache();        
-        VDBKey vdbID = toVdbID(vdbName, vdbVersion);
-        QueryMetadataHolder qmiHolder = null;
-        // Enter a synchronized block to find the holder of a QueryMetadataInterface for a VDB
-        synchronized(vdbToQueryMetadata) {
-            qmiHolder = vdbToQueryMetadata.get(vdbID);
-            if ( qmiHolder == null ) {
-            	qmiHolder = new QueryMetadataHolder();
-                vdbToQueryMetadata.put(vdbID, qmiHolder);
-            }
-        }
-        synchronized (qmiHolder) {
-        	if (qmiHolder.qmi == null) {
-        		qmiHolder.qmi = loadMetadata(vdbID, iss, dataService);
-        	}
-		}
-        return qmiHolder.qmi;
-    }
-    
-    private void assertIsValidCache() {
-        if(!this.isCacheValid) {
-            throw new MetaMatrixRuntimeException(DQPPlugin.Util.getString("QueryMetadataCache.cache_not_valid"));             //$NON-NLS-1$
-        }
-    }
-
-    private QueryMetadataInterface loadMetadata(final VDBKey vdbID, final MetadataSource runtimeSelector, DataService dataService) throws MetaMatrixComponentException {
-        // check cache status
-        assertIsValidCache();
-
-        List<MetadataStore> metadataStores = new ArrayList<MetadataStore>();
-        try {
-			metadataStores.add(new IndexMetadataStore(runtimeSelector));
-	        Set<String> modelNames = runtimeSelector.getConnectorMetadataModelNames();
-	        if (!modelNames.isEmpty()) {
-		        for (String modelName : modelNames) {
-		        	ConnectorMetadata connectorMetadata = null;
-		        	String savedMetadata = "/META-INF/" + modelName.toLowerCase() + ".ser"; //$NON-NLS-1$ //$NON-NLS-2$
-	        		if (runtimeSelector.cacheConnectorMetadata()) {
-		        		File f = runtimeSelector.getFile(savedMetadata);
-		        		if (f != null) {
-		        			ObjectInputStream ois = null;
-		        			try {
-			        			ois = new ObjectInputStream(new FileInputStream(f));
-			        			connectorMetadata = (ConnectorMetadata)ois.readObject();
-		        			} catch (Exception e) {
-		        				
-		        			} finally {
-		        				if (ois != null) {
-				        			ois.close();
-		        				}
-		        			}
-		        		}
-		        	}
-		        	if (connectorMetadata == null) {
-		        		connectorMetadata = dataService.getConnectorMetadata(vdbID.getName(), vdbID.getVersion(), modelName, runtimeSelector.getModelInfo(modelName).getProperties());
-		        	}
-		        	if (runtimeSelector.cacheConnectorMetadata()) {
-		        		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		        		ObjectOutputStream oos = new ObjectOutputStream(baos);
-		        		oos.writeObject(connectorMetadata);
-		        		oos.close();
-		        		runtimeSelector.saveFile(new ByteArrayInputStream(baos.toByteArray()), savedMetadata);
-		        	}
-		        	metadataStores.add(new ConnectorMetadataStore(modelName, connectorMetadata));
-				}
-	        }
-			metadataStores.add(indexMetadataStore);
-		} catch (IOException e) {
-			throw new MetaMatrixComponentException(e);
-		}
-        // build a composite selector for the runtimeselectors of this vdb and system vdb
-        CompositeMetadataStore composite = new CompositeMetadataStore(metadataStores, runtimeSelector);
-        vdbToCompositeSelector.put(vdbID, composite);
-        QueryMetadataInterface result = new TransformationMetadata(composite);
-        return result;        
-    }
-
-	public Map<String, DatatypeRecordImpl> getBuiltinDatatypes() throws MetaMatrixComponentException {
-		Collection<DatatypeRecordImpl> datatypes = this.indexMetadataStore.getDatatypes();
-		Map<String, DatatypeRecordImpl> datatypeMap = new HashMap<String, DatatypeRecordImpl>();
-		for (String typeName : DataTypeManager.getAllDataTypeNames()) {
-			for (DatatypeRecordImpl datatypeRecordImpl : datatypes) {
-				if (datatypeRecordImpl.getName().equals("int")) { //$NON-NLS-1$
-					datatypeMap.put(DefaultDataTypes.INTEGER, datatypeRecordImpl);
-				} else if (datatypeRecordImpl.getName().equals("XMLLiteral")) { //$NON-NLS-1$
-					datatypeMap.put(DataTypeManager.DefaultDataTypes.XML, datatypeRecordImpl);
-				} else if (datatypeRecordImpl.getName().equals(typeName)) {
-					datatypeMap.put(typeName, datatypeRecordImpl);
-				}
-			}
-		}
-		return datatypeMap;
-	}
-
-    /**
-     * Clears all state on this cache and also deletes any indexfiles
-     * associated with the cache.  
-     * @since 4.2
-     */
-    public void clearCache() {
-        LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache Clearing VDB cache"});  //$NON-NLS-1$
-        // mark cache invalid
-        isCacheValid = false;
-        // Clear the holders ...
-        vdbToQueryMetadata.clear();
-
-        // Clean up the directory for the System VDB ...
-        if (this.systemVDBSelector != null) {
-            // selector should no longer be used
-            this.systemVDBSelector.close();
-        }
-
-        // Clear the cache of selectors ...
-        vdbToCompositeSelector.clear();
-    }
-
-    /**
-     * Remove cache for a given vdb, called when a vdb is actually deleted.
-     * Also deletes any temp files associated with the vdb.
-     */
-    public void removeFromCache(final String vdbName, final String vdbVersion) {
-        LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache Removing vdb from cache", vdbName, vdbVersion});  //$NON-NLS-1$ 
-        if(vdbName != null && vdbVersion != null) {
-	        final VDBKey vdbID = toVdbID(vdbName, vdbVersion);
-            vdbToQueryMetadata.remove(vdbID);
-            vdbToCompositeSelector.remove(vdbID);
-        }
-    }
-
-    /**
-     * Return unique id for a vdb
-     */
-    private VDBKey toVdbID(final String vdbName, final String vdbVersion) {
-        return new VDBKey(vdbName, vdbVersion);
-    }
-
-}

Deleted: trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.metadata;
-
-import java.util.ResourceBundle;
-
-import com.metamatrix.core.BundleUtil;
-
-/**
- * CommonPlugin
- * <p>Used here in <code>metadata.runtime</code> to have access to the new
- * logging framework for <code>LogManager</code>.</p>
- */
-public class RuntimeMetadataPlugin {
-
-	/**
-     * The plug-in identifier of this plugin
-     * (value <code>"com.metamatrix.metadata.runtime"</code>).
-	 */
-	public static final String PLUGIN_ID = "org.teiid.metadata"; //$NON-NLS-1$
-
-	public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
-	                                                         PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
-}

Deleted: trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,1069 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.metadata;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
-import org.teiid.connector.metadata.runtime.MetadataConstants;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
-import org.teiid.connector.metadata.runtime.TransformationRecordImpl;
-import org.teiid.metadata.index.IndexConstants;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.core.vdb.ModelType;
-import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingLoader;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.metadata.BasicQueryMetadata;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.sql.lang.SPParameter;
-
-/**
- * Modelers implementation of QueryMetadataInterface that reads columns, groups, models etc.
- * index files for various metadata properties.
- */
-public class TransformationMetadata extends BasicQueryMetadata {
-
-	//Fix Me: The following constants come from com.metamatrix.metamodels.relational.NullableType
-	private static int NULLABLE = 1;
-	private static int NULLABLE_UNKNOWN = 2;
-	//Fix Me: The following constants come from com.metamatrix.metamodels.relational.SearchabilityType
-	private static int SEARCHABLE = 0;
-	private static int ALL_EXCEPT_LIKE = 1;
-	private static int LIKE_ONLY = 2;
-	
-    /** Delimiter character used when specifying fully qualified entity names */
-    public static final char DELIMITER_CHAR = IndexConstants.NAME_DELIM_CHAR;
-    public static final String DELIMITER_STRING = StringUtil.Constants.EMPTY_STRING + IndexConstants.NAME_DELIM_CHAR;
-    
-    // error message cached to avoid i18n lookup each time
-    public static String NOT_EXISTS_MESSAGE = StringUtil.Constants.SPACE+RuntimeMetadataPlugin.Util.getString("TransformationMetadata.does_not_exist._1"); //$NON-NLS-1$
-
-    private final CompositeMetadataStore store;
-
-    /*
-     * TODO: move caching to jboss cache structure
-     */
-    private final Map<String, Object> metadataCache = Collections.synchronizedMap(new LRUCache<String, Object>(500));
-    private final Map<String, TableRecordImpl> groupCache = Collections.synchronizedMap(new LRUCache<String, TableRecordImpl>(2000));
-    private final Map<String, StoredProcedureInfo> procedureCache = Collections.synchronizedMap(new LRUCache<String, StoredProcedureInfo>(200));
-    private final Map<String, String> partialNameToFullNameCache = Collections.synchronizedMap(new LRUCache<String, String>(1000));
-    private final Map<String, ModelRecordImpl> modelCache = Collections.synchronizedMap(new LRUCache<String, ModelRecordImpl>(100));
-    
-    /**
-     * TransformationMetadata constructor
-     * @param context Object containing the info needed to lookup metadta.
-     */
-    public TransformationMetadata(final CompositeMetadataStore store) {
-    	ArgCheck.isNotNull(store);
-        this.store = store;
-    }
-
-    //==================================================================================
-    //                     I N T E R F A C E   M E T H O D S
-    //==================================================================================
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementID(java.lang.String)
-     */
-    public Object getElementID(final String elementName) throws MetaMatrixComponentException, QueryMetadataException {
-		ArgCheck.isNotEmpty(elementName);
-
-        return getMetadataStore().findElement(elementName);
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupID(java.lang.String)
-     */
-    public Object getGroupID(final String groupName) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isNotEmpty(groupName);
-        String upperGroupName = groupName.toUpperCase();
-        TableRecordImpl result = this.groupCache.get(upperGroupName);
-        
-        if (result == null) {
-        	result = getMetadataStore().findGroup(groupName);
-        	this.groupCache.put(upperGroupName, result);
-        }
-        return result;
-    }
-    
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupsForPartialName(java.lang.String)
-     */
-    public Collection getGroupsForPartialName(final String partialGroupName)
-        throws MetaMatrixComponentException, QueryMetadataException {
-		ArgCheck.isNotEmpty(partialGroupName);
-
-		String groupName = this.partialNameToFullNameCache.get(partialGroupName);
-		
-		if (groupName != null) {
-			return Arrays.asList(groupName);
-		}
-		
-		String partialName = DELIMITER_CHAR + partialGroupName.toLowerCase(); 
-
-        Collection result = getMetadataStore().getGroupsForPartialName(partialName);
-        
-        if (result.size() == 1) {
-        	this.partialNameToFullNameCache.put(partialGroupName, (String)result.iterator().next());
-        }
-        return result;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModelID(java.lang.Object)
-     */
-    public Object getModelID(final Object groupOrElementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if (!(groupOrElementID instanceof TableRecordImpl) && !(groupOrElementID instanceof ColumnRecordImpl)) {
-        	throw createInvalidRecordTypeException(groupOrElementID);
-        }
-        
-        String modelName = ((AbstractMetadataRecord)groupOrElementID).getModelName();
-        return getModel(modelName);
-    }
-
-	private Object getModel(String modelName) throws QueryMetadataException,
-			MetaMatrixComponentException {
-		modelName = modelName.toUpperCase();
-		ModelRecordImpl model = modelCache.get(modelName);
-        if (model == null) {
-        	model = getMetadataStore().getModel(modelName);
-        	modelCache.put(modelName, model);
-        }
-        return model;
-	}
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getFullName(java.lang.Object)
-     */
-    public String getFullName(final Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
-        AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) metadataID;
-        return metadataRecord.getFullName();
-    }
-
-  /* (non-Javadoc)
-   * @see com.metamatrix.query.metadata.QueryMetadataInterface#getFullElementName(java.lang.String, java.lang.String)
-   */
-    public String getFullElementName(final String fullGroupName, final String shortElementName)     
-        throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isNotEmpty(fullGroupName);
-        ArgCheck.isNotEmpty(shortElementName);
-
-        return fullGroupName + DELIMITER_CHAR + shortElementName;
-    }
-
-  /* (non-Javadoc)
-   * @see com.metamatrix.query.metadata.QueryMetadataInterface#getShortElementName(java.lang.String)
-   */
-    public String getShortElementName(final String fullElementName) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isNotEmpty(fullElementName);
-        int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
-        if(index >= 0) { 
-            return fullElementName.substring(index+1);
-        }
-        return fullElementName;
-    }
-
-    /**
-     * Return the text portion of the fullElementName representing a group.
-     * That means that this should only return text that is part of the 
-     * fullElementName and not look up new IDs or do much of anything fancy.
-     * This method is used by the resolver to decide which portion of a fully-
-     * qualified element name is the group name.  It will compare whatever comes
-     * back with the actual group names and aliases in the query, which is 
-     * why it is important not to introduce new metadata here.  Also, returning
-     * null indicates that no portion of the fullElementName is a
-     * group name - that is ok as it will be resolved as an ambiguous element.
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupName(java.lang.String)
-     */
-    public String getGroupName(final String fullElementName) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isNotEmpty(fullElementName);  
-
-        int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
-        if(index >= 0) { 
-            return fullElementName.substring(0, index);
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInGroupID(java.lang.Object)
-     */
-    public List getElementIDsInGroupID(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-    	ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-    	return ((TableRecordImpl)groupID).getColumns();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupIDForElementID(java.lang.Object)
-     */
-    public Object getGroupIDForElementID(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            ColumnRecordImpl columnRecord = (ColumnRecordImpl) elementID;
-            return this.getGroupID(columnRecord.getParentFullName());
-        } else if(elementID instanceof ProcedureParameterRecordImpl){
-            ProcedureParameterRecordImpl columnRecord = (ProcedureParameterRecordImpl) elementID;
-            return this.getGroupID(columnRecord.getParentFullName());
-        } else {
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getStoredProcedureInfoForProcedure(java.lang.String)
-     */
-    public StoredProcedureInfo getStoredProcedureInfoForProcedure(final String fullyQualifiedProcedureName)
-        throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isNotEmpty(fullyQualifiedProcedureName);
-        String upperGroupName = fullyQualifiedProcedureName.toUpperCase();
-        StoredProcedureInfo procInfo = this.procedureCache.get(upperGroupName);
-        
-        if (procInfo != null) {
-        	return procInfo;
-        }
-        
-    	ProcedureRecordImpl procRecord = getMetadataStore().getStoredProcedure(fullyQualifiedProcedureName); 
-
-        String procedureFullName = procRecord.getFullName();
-
-        // create the storedProcedure info object that would hold procedure's metadata
-        procInfo = new StoredProcedureInfo();
-        procInfo.setProcedureCallableName(procRecord.getName());
-        procInfo.setProcedureID(procRecord);
-
-        // modelID for the procedure
-        procInfo.setModelID(getModel(procRecord.getModelName()));
-
-        // get the parameter metadata info
-        for (ProcedureParameterRecordImpl paramRecord : procRecord.getParameters()) {
-            String runtimeType = paramRecord.getRuntimeType();
-            int direction = this.convertParamRecordTypeToStoredProcedureType(paramRecord.getType());
-            // create a parameter and add it to the procedure object
-            SPParameter spParam = new SPParameter(paramRecord.getPosition(), direction, paramRecord.getFullName());
-            spParam.setMetadataID(paramRecord);
-            spParam.setClassType(DataTypeManager.getDataTypeClass(runtimeType));
-            procInfo.addParameter(spParam);
-        }
-
-        // if the procedure returns a resultSet, obtain resultSet metadata
-        if(procRecord.getResultSet() != null) {
-            ColumnSetRecordImpl resultRecord = procRecord.getResultSet();
-            // resultSet is the last parameter in the procedure
-            int lastParamIndex = procInfo.getParameters().size() + 1;
-            SPParameter param = new SPParameter(lastParamIndex, SPParameter.RESULT_SET, resultRecord.getFullName());
-            param.setClassType(java.sql.ResultSet.class);           
-            param.setMetadataID(resultRecord);
-
-            for (ColumnRecordImpl columnRecord : resultRecord.getColumns()) {
-                String colType = columnRecord.getRuntimeType();
-                param.addResultSetColumn(columnRecord.getFullName(), DataTypeManager.getDataTypeClass(colType), columnRecord);
-            }
-
-            procInfo.addParameter(param);            
-        }
-
-        // if this is a virtual procedure get the procedure plan
-        if(procRecord.isVirtual()) {
-            QueryNode queryNode = new QueryNode(procedureFullName, procRecord.getQueryPlan()); 
-            procInfo.setQueryPlan(queryNode);
-        }
-        
-        //subtract 1, to match up with the server
-        procInfo.setUpdateCount(procRecord.getUpdateCount() -1);
-
-    	this.procedureCache.put(upperGroupName, procInfo);
-    	
-        return procInfo;
-    }
-    
-    /**
-     * Method to convert the parameter type returned from a ProcedureParameterRecord
-     * to the parameter type expected by StoredProcedureInfo
-     * @param parameterType
-     * @return
-     */
-    private int convertParamRecordTypeToStoredProcedureType(final int parameterType) {
-        switch (parameterType) {
-            case MetadataConstants.PARAMETER_TYPES.IN_PARM : return SPParameter.IN;
-            case MetadataConstants.PARAMETER_TYPES.OUT_PARM : return SPParameter.OUT;
-            case MetadataConstants.PARAMETER_TYPES.INOUT_PARM : return SPParameter.INOUT;
-            case MetadataConstants.PARAMETER_TYPES.RETURN_VALUE : return SPParameter.RETURN_VALUE;
-            case MetadataConstants.PARAMETER_TYPES.RESULT_SET : return SPParameter.RESULT_SET;
-            default : 
-                return -1;
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementType(java.lang.Object)
-     */
-    public String getElementType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getRuntimeType();            
-        } else if(elementID instanceof ProcedureParameterRecordImpl){
-            return ((ProcedureParameterRecordImpl) elementID).getRuntimeType();
-        } else {
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getDefaultValue(java.lang.String)
-     */
-    public Object getDefaultValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getDefaultValue();            
-        } else if(elementID instanceof ProcedureParameterRecordImpl){
-            return ((ProcedureParameterRecordImpl) elementID).getDefaultValue();
-        } else {
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-
-    public Object getMinimumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getMinValue();            
-        } else if(elementID instanceof ProcedureParameterRecordImpl){
-            return null;
-        } else {
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-
-    public Object getMaximumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getMaxValue();            
-        } else if(elementID instanceof ProcedureParameterRecordImpl){
-            return null;
-        } else {
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#isVirtualGroup(java.lang.Object)
-     */
-    public boolean isVirtualGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        return ((TableRecordImpl) groupID).isVirtual();
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#isProcedureInputElement(java.lang.Object)
-     * @since 4.2
-     */
-    public boolean isProcedure(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-    	if(groupID instanceof ProcedureRecordImpl) {
-            return true;            
-        } 
-    	if(groupID instanceof TableRecordImpl){
-            return false;
-        } 
-    	throw createInvalidRecordTypeException(groupID);
-    }
-
-    public boolean isVirtualModel(final Object modelID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(ModelRecordImpl.class, modelID);
-        ModelRecordImpl modelRecord = (ModelRecordImpl) modelID;
-        return (modelRecord.getModelType() == ModelType.VIRTUAL);
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualPlan(java.lang.Object)
-     */
-    public QueryNode getVirtualPlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-        if (!tableRecord.isVirtual()) {
-            throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.QueryPlan_could_not_be_found_for_physical_group__6")+tableRecord.getFullName()); //$NON-NLS-1$
-        }
-        TransformationRecordImpl select = tableRecord.getSelectTransformation();
-        String transQuery = select.getTransformation();
-        QueryNode queryNode = new QueryNode(tableRecord.getFullName(), transQuery);
-
-        // get any bindings and add them onto the query node
-        List bindings = select.getBindings();
-        if(bindings != null) {
-            for(Iterator bindIter = bindings.iterator();bindIter.hasNext();) {
-                queryNode.addBinding((String)bindIter.next());
-            }
-        }
-
-        return queryNode;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getInsertPlan(java.lang.Object)
-     */
-    public String getInsertPlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-    	ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
-        if (!tableRecordImpl.isVirtual()) {
-            throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.InsertPlan_could_not_be_found_for_physical_group__8")+tableRecordImpl.getFullName()); //$NON-NLS-1$
-        }
-        return ((TableRecordImpl)groupID).getInsertPlan();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getUpdatePlan(java.lang.Object)
-     */
-    public String getUpdatePlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
-        if (!tableRecordImpl.isVirtual()) {
-        	throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.InsertPlan_could_not_be_found_for_physical_group__10")+tableRecordImpl.getFullName());         //$NON-NLS-1$
-        }
-        return ((TableRecordImpl)groupID).getUpdatePlan();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getDeletePlan(java.lang.Object)
-     */
-    public String getDeletePlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
-        if (!tableRecordImpl.isVirtual()) {
-            throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.DeletePlan_could_not_be_found_for_physical_group__12")+tableRecordImpl.getFullName()); //$NON-NLS-1$
-        }
-        return ((TableRecordImpl)groupID).getDeletePlan();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#modelSupports(java.lang.Object, int)
-     */
-    public boolean modelSupports(final Object modelID, final int modelConstant)
-        throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(ModelRecordImpl.class, modelID);
-
-        switch(modelConstant) {
-            default:
-                throw new UnsupportedOperationException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Unknown_support_constant___12") + modelConstant); //$NON-NLS-1$
-        }        
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#groupSupports(java.lang.Object, int)
-     */
-    public boolean groupSupports(final Object groupID, final int groupConstant)
-        throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-
-        switch(groupConstant) {
-            case SupportConstants.Group.UPDATE:
-                return tableRecord.supportsUpdate();
-            default:
-                throw new UnsupportedOperationException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Unknown_support_constant___12") + groupConstant); //$NON-NLS-1$
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#elementSupports(java.lang.Object, int)
-     */
-    public boolean elementSupports(final Object elementID, final int elementConstant)
-        throws MetaMatrixComponentException, QueryMetadataException {
-        
-        if(elementID instanceof ColumnRecordImpl) {
-            ColumnRecordImpl columnRecord = (ColumnRecordImpl) elementID;            
-            switch(elementConstant) {
-                case SupportConstants.Element.NULL:
-                    int ntype1 = columnRecord.getNullType();
-                    return (ntype1 == NULLABLE);
-                case SupportConstants.Element.NULL_UNKNOWN:
-                    int ntype2 = columnRecord.getNullType();
-                    return (ntype2 == NULLABLE_UNKNOWN);
-                case SupportConstants.Element.SEARCHABLE_COMPARE:
-                    int stype1 = columnRecord.getSearchType();
-                    return (stype1 == SEARCHABLE || stype1 == ALL_EXCEPT_LIKE);
-                case SupportConstants.Element.SEARCHABLE_LIKE:
-                    int stype2 = columnRecord.getSearchType();
-                    return (stype2 == SEARCHABLE || stype2 == LIKE_ONLY);
-                case SupportConstants.Element.SELECT:
-                    return columnRecord.isSelectable();
-                case SupportConstants.Element.UPDATE:
-                    return columnRecord.isUpdatable();
-                case SupportConstants.Element.DEFAULT_VALUE:
-                    Object defaultValue = columnRecord.getDefaultValue();
-                    if(defaultValue == null) {
-                        return false;
-                    }
-                    return true;
-                case SupportConstants.Element.AUTO_INCREMENT:
-                    return columnRecord.isAutoIncrementable();
-                case SupportConstants.Element.CASE_SENSITIVE:
-                    return columnRecord.isCaseSensitive();
-                case SupportConstants.Element.SIGNED:
-                    return columnRecord.isSigned();
-                default:
-                    throw new UnsupportedOperationException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Unknown_support_constant___12") + elementConstant); //$NON-NLS-1$
-            }
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            ProcedureParameterRecordImpl columnRecord = (ProcedureParameterRecordImpl) elementID;            
-            switch(elementConstant) {
-                case SupportConstants.Element.NULL:
-                    int ntype1 = columnRecord.getNullType();
-                    return (ntype1 == NULLABLE);
-                case SupportConstants.Element.NULL_UNKNOWN:
-                    int ntype2 = columnRecord.getNullType();
-                    return (ntype2 == NULLABLE_UNKNOWN);
-                case SupportConstants.Element.SEARCHABLE_COMPARE:
-                case SupportConstants.Element.SEARCHABLE_LIKE:
-                    return false;
-                case SupportConstants.Element.SELECT:
-                    
-                    if (columnRecord.getType() == MetadataConstants.PARAMETER_TYPES.IN_PARM) {
-                        return false;
-                    }
-                    
-                    return true;
-                case SupportConstants.Element.UPDATE:
-                    return false;
-                case SupportConstants.Element.DEFAULT_VALUE:
-                    Object defaultValue = columnRecord.getDefaultValue();
-                    if(defaultValue == null) {
-                        return false;
-                    }
-                    return true;
-                case SupportConstants.Element.AUTO_INCREMENT:
-                    return false;
-                case SupportConstants.Element.CASE_SENSITIVE:
-                    return false;
-                case SupportConstants.Element.SIGNED:
-                    return true;
-                default:
-                    throw new UnsupportedOperationException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Unknown_support_constant___12") + elementConstant); //$NON-NLS-1$
-            }
-            
-        } else {            
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-    
-    private IllegalArgumentException createInvalidRecordTypeException(Object elementID) {
-        return new IllegalArgumentException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Invalid_type", elementID.getClass().getName()));         //$NON-NLS-1$
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaxSetSize(java.lang.Object)
-     */
-    public int getMaxSetSize(final Object modelID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(ModelRecordImpl.class, modelID);
-        return ((ModelRecordImpl) modelID).getMaxSetSize();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
-     */
-    public Collection getIndexesInGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        return ((TableRecordImpl)groupID).getIndexes();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getUniqueKeysInGroup(java.lang.Object)
-     */
-    public Collection getUniqueKeysInGroup(final Object groupID)
-        throws MetaMatrixComponentException, QueryMetadataException {
-    	ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-    	TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
-    	if (tableRecordImpl.getPrimaryKey() != null) {
-	    	ArrayList<ColumnSetRecordImpl> result = new ArrayList<ColumnSetRecordImpl>(tableRecordImpl.getUniqueKeys());
-	    	result.add(tableRecordImpl.getPrimaryKey());
-	    	return result;
-    	}
-    	return tableRecordImpl.getUniqueKeys();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getForeignKeysInGroup(java.lang.Object)
-     */
-    public Collection getForeignKeysInGroup(final Object groupID)
-        throws MetaMatrixComponentException, QueryMetadataException {
-    	ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-    	return ((TableRecordImpl)groupID).getForeignKeys();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getPrimaryKeyIDForForeignKeyID(java.lang.Object)
-     */
-    public Object getPrimaryKeyIDForForeignKeyID(final Object foreignKeyID)
-        throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(ForeignKeyRecordImpl.class, foreignKeyID);
-        ForeignKeyRecordImpl fkRecord = (ForeignKeyRecordImpl) foreignKeyID;
-        return fkRecord.getPrimaryKey();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(java.lang.Object)
-     */
-    public Collection getAccessPatternsInGroup(final Object groupID)
-        throws MetaMatrixComponentException, QueryMetadataException {
-    	ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-    	return ((TableRecordImpl)groupID).getAccessPatterns();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
-     */
-    public List getElementIDsInIndex(final Object index) throws MetaMatrixComponentException, QueryMetadataException {
-    	ArgCheck.isInstanceOf(ColumnSetRecordImpl.class, index);
-    	return ((ColumnSetRecordImpl)index).getColumns();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInKey(java.lang.Object)
-     */
-    public List getElementIDsInKey(final Object key) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(ColumnSetRecordImpl.class, key);
-        return ((ColumnSetRecordImpl)key).getColumns();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(java.lang.Object)
-     */
-    public List getElementIDsInAccessPattern(final Object accessPattern)
-        throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(ColumnSetRecordImpl.class, accessPattern);
-        return ((ColumnSetRecordImpl)accessPattern).getColumns();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#isXMLGroup(java.lang.Object)
-     */
-    public boolean isXMLGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-        if(tableRecord.getTableType() == MetadataConstants.TABLE_TYPES.DOCUMENT_TYPE) {
-            return true;    
-        }
-        return false;
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
-     * @since 4.2
-     */
-    public boolean hasMaterialization(final Object groupID) throws MetaMatrixComponentException,
-                                                      QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-        return tableRecord.isMaterialized();
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
-     * @since 4.2
-     */
-    public Object getMaterialization(final Object groupID) throws MetaMatrixComponentException,
-                                                    QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-        if(tableRecord.isMaterialized()) {
-	        return this.getGroupID(tableRecord.getMaterializedTableName());
-        }
-        return null;
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
-     * @since 4.2
-     */
-    public Object getMaterializationStage(final Object groupID) throws MetaMatrixComponentException,
-                                                         QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-        if(tableRecord.isMaterialized()) {
-	        return this.getGroupID(tableRecord.getMaterializedStageTableName());
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMappingNode(java.lang.Object)
-     */
-    public MappingNode getMappingNode(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-		final String groupName = tableRecord.getFullName();
-        if(tableRecord.isVirtual()) {
-            // get the transform record for this group            
-            TransformationRecordImpl transformRecord = null;
-			// Query the index files
-			Collection results = getMetadataStore().findMetadataRecords(MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM,groupName,false);
-			int resultSize = results.size();
-			if(resultSize == 1) {
-				// get the columnset record for this result            
-				transformRecord = (TransformationRecordImpl) results.iterator().next();            
-			} else {
-				if(resultSize == 0) {
-					throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Could_not_find_transformation_record_for_the_group__1")+groupName); //$NON-NLS-1$
-				}
-				// there should be only one for a fully qualified elementName            
-				if(resultSize > 1) {
-					throw new MetaMatrixComponentException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Multiple_transformation_records_found_for_the_group___1")+groupName); //$NON-NLS-1$
-				}
-			}
-            // get mappin transform
-            String document = transformRecord.getTransformation();            
-            InputStream inputStream = new ByteArrayInputStream(document.getBytes());
-            MappingLoader reader = new MappingLoader();
-            MappingDocument mappingDoc = null;
-            try{
-                mappingDoc = reader.loadDocument(inputStream);
-                mappingDoc.setName(groupName);
-            } catch (Exception e){
-                throw new MetaMatrixComponentException(e, RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Error_trying_to_read_virtual_document_{0},_with_body__n{1}_1", groupName, mappingDoc)); //$NON-NLS-1$
-            } finally {
-            	try {
-					inputStream.close();
-            	} catch(Exception e) {}
-            }
-            return (MappingDocument)mappingDoc.clone();
-        }
-
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
-     */
-    public String getVirtualDatabaseName() throws MetaMatrixComponentException, QueryMetadataException {
-    	return this.getMetadataStore().getMetadataSource().getName();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
-     */
-    public Collection getXMLTempGroups(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-
-        int tableType = tableRecord.getTableType();
-        if(tableType == MetadataConstants.TABLE_TYPES.DOCUMENT_TYPE) {
-			return getMetadataStore().getXMLTempGroups(tableRecord);
-        }
-        return Collections.EMPTY_SET;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getCardinality(java.lang.Object)
-     */
-    public int getCardinality(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        return ((TableRecordImpl) groupID).getCardinality();
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLSchemas(java.lang.Object)
-     */
-    public List getXMLSchemas(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-
-        ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
-        TableRecordImpl tableRecord = (TableRecordImpl) groupID;
-
-        // lookup transformation record for the group
-        String groupName = tableRecord.getFullName();
-		TransformationRecordImpl transformRecord = null;
-
-		// Query the index files
-		Collection results = getMetadataStore().findMetadataRecords(MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM,groupName,false);
-		int resultSize = results.size();
-		if(resultSize == 1) {
-			// get the columnset record for this result            
-			transformRecord = (TransformationRecordImpl) results.iterator().next();            
-		} else {
-			if(resultSize == 0) {
-				throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Could_not_find_transformation_record_for_the_group__1")+groupName); //$NON-NLS-1$
-			}
-			// there should be only one for a fully qualified elementName            
-			if(resultSize > 1) {
-				throw new MetaMatrixComponentException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Multiple_transformation_records_found_for_the_group___1")+groupName); //$NON-NLS-1$
-			}
-		}
-
-        // get the schema Paths
-        List<String> schemaPaths = transformRecord.getSchemaPaths();
-        
-        List<String> schemas = new LinkedList<String>();
-        
-        File f = new File(transformRecord.getResourcePath());
-        String path = f.getParent();
-        
-        for (String string : schemaPaths) {
-        	String schema = getCharacterVDBResource(string);
-        	
-        	if (schema == null) {
-        		schema = getCharacterVDBResource(path + File.separator + string);
-        	}
-        	
-        	if (schema == null) {
-        		throw new MetaMatrixComponentException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Error_trying_to_read_schemas_for_the_document/table____1")+groupName);             //$NON-NLS-1$		
-        	}
-        }
-        
-        return schemas;
-    }
-
-    public String getNameInSource(final Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
-        return ((AbstractMetadataRecord) metadataID).getNameInSource();
-    }
-
-    public int getElementLength(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getLength();            
-        } else if(elementID instanceof ProcedureParameterRecordImpl){
-            return ((ProcedureParameterRecordImpl) elementID).getLength();
-        } else {
-            throw createInvalidRecordTypeException(elementID);
-        }
-    }
-
-    public int getPosition(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getPosition();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return ((ProcedureParameterRecordImpl) elementID).getPosition();            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-    
-    public int getPrecision(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getPrecision();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return ((ProcedureParameterRecordImpl) elementID).getPrecision();            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-    
-    public int getRadix(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getRadix();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return ((ProcedureParameterRecordImpl) elementID).getRadix();            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-    
-	public String getFormat(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getFormat();
-        } 
-        throw createInvalidRecordTypeException(elementID);            
-	}       
-    
-    public int getScale(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getScale();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return ((ProcedureParameterRecordImpl) elementID).getScale();            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-
-    public int getDistinctValues(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getDistinctValues();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return -1;            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-
-    public int getNullValues(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getNullValues();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return -1;            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-
-    public String getNativeType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        if(elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl) elementID).getNativeType();
-        } else if(elementID instanceof ProcedureParameterRecordImpl) {
-            return null;            
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-
-    /* 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
-     */
-    public Properties getExtensionProperties(final Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
-        AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) metadataID;
-        if (metadataRecord.getProperties() == null) {
-        	Properties p = new Properties();
-        	Collection<PropertyRecordImpl> props = getMetadataStore().getExtensionProperties(metadataRecord);
-        	for (PropertyRecordImpl propertyRecordImpl : props) {
-				p.setProperty(propertyRecordImpl.getPropertyName(), propertyRecordImpl.getPropertyValue());
-			}
-            metadataRecord.setProperties(p);
-        }
-        return metadataRecord.getProperties();
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.BasicQueryMetadata#getBinaryVDBResource(java.lang.String)
-     * @since 4.3
-     */
-    public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException,
-                                                           QueryMetadataException {
-        String content = this.getCharacterVDBResource(resourcePath);
-        if(content != null) {
-            return content.getBytes();
-        }
-        return null;
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.BasicQueryMetadata#getCharacterVDBResource(java.lang.String)
-     * @since 4.3
-     */
-    public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException,
-                                                              QueryMetadataException {
-    	return MetadataSourceUtil.getFileContentAsString(resourcePath, this.getMetadataStore().getMetadataSource());
-    }
-    
-    protected CompositeMetadataStore getMetadataStore() {
-    	return this.store;
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.BasicQueryMetadata#getVDBResourcePaths()
-     * @since 4.3
-     */
-    public String[] getVDBResourcePaths() throws MetaMatrixComponentException,
-                                         QueryMetadataException {
-        return getMetadataStore().getMetadataSource().getEntries().toArray(new String[0]);
-    }
-    
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
-     * @since 5.0
-     */
-    public String getModeledType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        DatatypeRecordImpl record = getDatatypeRecord(elementID);
-        if (record != null) {
-            return record.getDatatypeID();
-        }
-        return null;
-    }
-    
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
-     * @since 5.0
-     */
-    public String getModeledBaseType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        DatatypeRecordImpl record = getDatatypeRecord(elementID);
-        if (record != null) {
-            return record.getBasetypeID();
-        }
-        return null;
-    }
-
-    /** 
-     * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
-     * @since 5.0
-     */
-    public String getModeledPrimitiveType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
-        DatatypeRecordImpl record = getDatatypeRecord(elementID);
-        if (record != null) {
-            return record.getPrimitiveTypeID();
-        }
-        return null;
-    }
-
-    private DatatypeRecordImpl getDatatypeRecord(final Object elementID) {
-        if (elementID instanceof ColumnRecordImpl) {
-            return ((ColumnRecordImpl)elementID).getDatatype();
-        } else if (elementID instanceof ProcedureParameterRecordImpl) {
-            return ((ProcedureParameterRecordImpl)elementID).getDatatype();
-        } else {
-            throw createInvalidRecordTypeException(elementID);            
-        }
-    }
-
-	@Override
-	public Object addToMetadataCache(Object metadataID, String key, Object value)
-			throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
-        key = getCacheKey(key, (AbstractMetadataRecord)metadataID);
-    	return this.metadataCache.put(key, value); 
-	}
-
-	@Override
-	public Object getFromMetadataCache(Object metadataID, String key)
-			throws MetaMatrixComponentException, QueryMetadataException {
-        ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
-        key = getCacheKey(key, (AbstractMetadataRecord)metadataID);
-    	return this.metadataCache.get(key);
-	}
-
-	private String getCacheKey(String key, AbstractMetadataRecord record) {
-		return record.getRecordType() + "/" + record.getFullName() + "/" + key; //$NON-NLS-1$ //$NON-NLS-2$
-	}
-
-}
\ No newline at end of file

Deleted: trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *     MetaMatrix, Inc - repackaging and updates for use as a metadata store
- *******************************************************************************/
-
-package org.teiid.metadata.index;
-
-/**
- * This class is a collection of helper methods to manipulate char arrays.
- * 
- * @since 2.1
- */
-public final class CharOperation {
-
-	/**
-	 * Answers true if the pattern matches the given name, false otherwise. This
-	 * char[] pattern matching accepts wild-cards '*' and '?'.
-	 * 
-	 * When not case sensitive, the pattern is assumed to already be lowercased,
-	 * the name will be lowercased character per character as comparing. If name
-	 * is null, the answer is false. If pattern is null, the answer is true if
-	 * name is not null. <br>
-	 * <br>
-	 * For example:
-	 * <ol>
-	 * <li>
-	 * 
-	 * <pre>
-	 *    pattern = { '?', 'b', '*' }
-	 *    name = { 'a', 'b', 'c' , 'd' }
-	 *    isCaseSensitive = true
-	 *    result =&gt; true
-	 * </pre>
-	 * 
-	 * </li>
-	 * <li>
-	 * 
-	 * <pre>
-	 *    pattern = { '?', 'b', '?' }
-	 *    name = { 'a', 'b', 'c' , 'd' }
-	 *    isCaseSensitive = true
-	 *    result =&gt; false
-	 * </pre>
-	 * 
-	 * </li>
-	 * <li>
-	 * 
-	 * <pre>
-	 *    pattern = { 'b', '*' }
-	 *    name = { 'a', 'b', 'c' , 'd' }
-	 *    isCaseSensitive = true
-	 *    result =&gt; false
-	 * </pre>
-	 * 
-	 * </li>
-	 * </ol>
-	 * 
-	 * @param pattern
-	 *            the given pattern
-	 * @param name
-	 *            the given name
-	 * @param isCaseSensitive
-	 *            flag to know whether or not the matching should be case
-	 *            sensitive
-	 * @return true if the pattern matches the given name, false otherwise
-	 * 
-	 * TODO: this code was derived from eclipse CharOperation.  
-	 * It also lacks the ability to specify an escape character.
-	 * 
-	 */
-	public static final boolean match(char[] pattern, char[] name,
-			boolean isCaseSensitive) {
-
-		if (name == null)
-			return false; // null name cannot match
-		if (pattern == null)
-			return true; // null pattern is equivalent to '*'
-
-		int patternEnd = pattern.length;
-		int nameEnd = name.length;
-
-		int iPattern = 0;
-		int iName = 0;
-
-		/* check first segment */
-		char patternChar = 0;
-		while ((iPattern < patternEnd)
-				&& (patternChar = pattern[iPattern]) != '*') {
-			if (iName == nameEnd)
-				return false;
-			if (isCaseSensitive && patternChar != name[iName]
-					&& patternChar != '?') {
-				return false;
-			} else if (!isCaseSensitive
-					&& Character.toLowerCase(patternChar) != Character
-							.toLowerCase(name[iName]) && patternChar != '?') {
-				return false;
-			}
-			iName++;
-			iPattern++;
-		}
-		/* check sequence of star+segment */
-		int segmentStart;
-		if (patternChar == '*') {
-			if (patternEnd == 1) {
-				return true;
-			}
-			segmentStart = ++iPattern; // skip star
-		} else {
-			segmentStart = 0; // force iName check
-		}
-		int prefixStart = iName;
-		checkSegment: while (iName < nameEnd) {
-			if (iPattern == patternEnd) {
-				iPattern = segmentStart; // mismatch - restart current
-											// segment
-				iName = ++prefixStart;
-				continue checkSegment;
-			}
-			/* segment is ending */
-			if ((patternChar = pattern[iPattern]) == '*') {
-				segmentStart = ++iPattern; // skip start
-				if (segmentStart == patternEnd) {
-					return true;
-				}
-				prefixStart = iName;
-				continue checkSegment;
-			}
-			/* check current name character */
-			char matchChar = isCaseSensitive ? name[iName] : Character
-					.toLowerCase(name[iName]);
-			if ((isCaseSensitive ? ((matchChar != patternChar) && patternChar != '?')
-					: (matchChar != Character.toLowerCase(patternChar))
-							&& patternChar != '?')) {
-				iPattern = segmentStart; // mismatch - restart current
-											// segment
-				iName = ++prefixStart;
-				continue checkSegment;
-			}
-			iName++;
-			iPattern++;
-		}
-
-		return (segmentStart == patternEnd)
-				|| (iName == nameEnd && iPattern == patternEnd)
-				|| (iPattern == patternEnd - 1 && pattern[iPattern] == '*');
-	}
-
-    /**
-     * Answers true if the given name starts with the given prefix, false otherwise.
-     * isCaseSensitive is used to find out whether or not the comparison should be case sensitive.
-     * <br>
-     * <br>
-     * For example:
-     * <ol>
-     * <li><pre>
-     *    prefix = { 'a' , 'B' }
-     *    name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
-     *    isCaseSensitive = false
-     *    result => true
-     * </pre>
-     * </li>
-     * <li><pre>
-     *    prefix = { 'a' , 'B' }
-     *    name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
-     *    isCaseSensitive = true
-     *    result => false
-     * </pre>
-     * </li>
-     * </ol>
-     * 
-     * @param prefix the given prefix
-     * @param name the given name
-     * @param isCaseSensitive to find out whether or not the comparison should be case sensitive
-     * @return true if the given name starts with the given prefix, false otherwise
-     * @exception NullPointerException if the given name is null or if the given prefix is null
-     */
-	public static final boolean prefixEquals(char[] prefix, char[] name,
-			boolean isCaseSensitive) {
-
-		int max = prefix.length;
-		if (name.length < max)
-			return false;
-
-		for (int i = max; --i >= 0;) {
-			if (prefix[i] == name[i]
-					|| (isCaseSensitive && Character.toLowerCase(prefix[i]) == Character
-							.toLowerCase(name[i]))) {
-				continue;
-			}
-			return false;
-		}
-		return true;
-	}
-}

Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -22,7 +22,6 @@
 
 package org.teiid.metadata.index;
 
-import org.teiid.connector.metadata.runtime.MetadataConstants;
 
 /**
  * IndexConstants

Copied: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java (from rev 1529, trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java	                        (rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -0,0 +1,468 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata.index;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
+import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
+import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
+import org.teiid.connector.metadata.runtime.KeyRecord;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.connector.metadata.runtime.ModelRecordImpl;
+import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
+import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
+import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.core.index.IEntryResult;
+import org.teiid.internal.core.index.Index;
+import org.teiid.metadata.TransformationMetadata;
+
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.id.UUID;
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.metadata.runtime.api.MetadataSource;
+
+/**
+ * Loads MetadataRecords from index files.  
+ */
+public class IndexMetadataFactory {
+
+	private Index[] indexes;
+    private Map<String, DatatypeRecordImpl> datatypeCache;
+    private Map<String, KeyRecord> primaryKeyCache = new HashMap<String, KeyRecord>();
+    private MetadataStore store = new MetadataStore();
+    
+    public IndexMetadataFactory(MetadataSource source) throws IOException {
+    	ArrayList<Index> tmp = new ArrayList<Index>();
+		for (String fileName : source.getEntries()) {
+			if (SimpleIndexUtil.isIndexFile(fileName)) {
+				File f = source.getFile(fileName);
+	            tmp.add( new Index(f.getAbsolutePath(), true) );
+	        } 
+		}
+		this.indexes = tmp.toArray(new Index[tmp.size()]);
+		getDatatypeCache();
+		getModels();
+		getTables();
+		getProcedures();
+    }
+
+    public MetadataStore getMetadataStore() {
+		return store;
+	}
+    
+    public void getModels() {
+    	Collection<ModelRecordImpl> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.MODEL, null, false);
+    	for (ModelRecordImpl modelRecord : records) {
+			store.addModel(modelRecord);
+		}
+    }
+    
+    public void getTables() {
+		Collection<TableRecordImpl> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.TABLE, null, false);
+		for (TableRecordImpl tableRecord : records) {
+	    	List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.COLUMN));
+	        for (ColumnRecordImpl columnRecordImpl : columns) {
+	    		columnRecordImpl.setDatatype(getDatatypeCache().get(columnRecordImpl.getDatatypeUUID()));
+			}
+	        Collections.sort(columns);
+	        tableRecord.setColumns(columns);
+	        tableRecord.setAccessPatterns(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.ACCESS_PATTERN));
+	        Map<String, ColumnRecordImpl> uuidColumnMap = new HashMap<String, ColumnRecordImpl>();
+	        for (ColumnRecordImpl columnRecordImpl : columns) {
+				uuidColumnMap.put(columnRecordImpl.getUUID(), columnRecordImpl);
+			}
+	        for (KeyRecord columnSetRecordImpl : tableRecord.getAccessPatterns()) {
+				loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+				columnSetRecordImpl.setTable(tableRecord);
+			}
+	        tableRecord.setForiegnKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.FOREIGN_KEY));
+	        for (ForeignKeyRecordImpl foreignKeyRecord : tableRecord.getForeignKeys()) {
+	        	foreignKeyRecord.setPrimaryKey(getPrimaryKey(foreignKeyRecord.getUniqueKeyID()));
+	        	loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
+	        	foreignKeyRecord.setTable(tableRecord);
+			}
+	        tableRecord.setUniqueKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.UNIQUE_KEY));
+	        for (KeyRecord columnSetRecordImpl : tableRecord.getUniqueKeys()) {
+				loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+				columnSetRecordImpl.setTable(tableRecord);
+			}
+	        tableRecord.setIndexes(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.INDEX));
+	        for (KeyRecord columnSetRecordImpl : tableRecord.getIndexes()) {
+				loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+				columnSetRecordImpl.setTable(tableRecord);
+			}
+	        if (tableRecord.getPrimaryKey() != null) {
+	        	KeyRecord primaryKey = getPrimaryKey(tableRecord.getPrimaryKey().getUUID());
+	        	loadColumnSetRecords(primaryKey, uuidColumnMap);
+	        	primaryKey.setTable(tableRecord);
+	        	tableRecord.setPrimaryKey(primaryKey);
+	        }
+	        String groupName = tableRecord.getFullName();
+	        if (tableRecord.isVirtual()) {
+	        	TransformationRecordImpl update = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.UPDATE_TRANSFORM,false);
+		        if (update != null) {
+		        	tableRecord.setUpdatePlan(update.getTransformation());
+		        }
+		        TransformationRecordImpl insert = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.INSERT_TRANSFORM,false);
+		        if (insert != null) {
+		        	tableRecord.setInsertPlan(insert.getTransformation());
+		        }
+		        TransformationRecordImpl delete = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM,false);
+		        if (delete != null) {
+		        	tableRecord.setDeletePlan(delete.getTransformation());
+		        }
+		        TransformationRecordImpl select = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM,false);
+		        // this group may be an xml document            
+		        if(select == null) {
+			        select = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM,false);
+		        }
+		        if (select != null) {
+			        tableRecord.setSelectTransformation(select.getTransformation());
+			        tableRecord.setBindings(select.getBindings());
+			        tableRecord.setSchemaPaths(select.getSchemaPaths());
+			        tableRecord.setResourcePath(select.getResourcePath());
+		        }
+	        }
+	        if (tableRecord.isMaterialized()) {
+	        	tableRecord.setMaterializedStageTableName(((TableRecordImpl)getRecordByType(tableRecord.getMaterializedStageTableID(), MetadataConstants.RECORD_TYPE.TABLE)).getFullName());
+	        	tableRecord.setMaterializedTableName(((TableRecordImpl)getRecordByType(tableRecord.getMaterializedTableID(), MetadataConstants.RECORD_TYPE.TABLE)).getFullName());
+	        }
+			this.store.addTable(tableRecord);
+		}
+    }
+
+	private KeyRecord getPrimaryKey(String uuid) {
+		KeyRecord pk = this.primaryKeyCache.get(uuid);
+		if (pk == null) {
+			pk = (KeyRecord)this.getRecordByType(uuid, MetadataConstants.RECORD_TYPE.PRIMARY_KEY);
+			this.primaryKeyCache.put(uuid, pk);
+		}
+		return pk;
+	}
+	
+    public Map<String, DatatypeRecordImpl> getDatatypeCache() {
+		if (this.datatypeCache == null) {
+			this.datatypeCache = new HashMap<String, DatatypeRecordImpl>();
+			Collection<DatatypeRecordImpl> dataTypes = findMetadataRecords(MetadataConstants.RECORD_TYPE.DATATYPE, null, false);
+			for (DatatypeRecordImpl datatypeRecordImpl : dataTypes) {
+				datatypeCache.put(datatypeRecordImpl.getUUID(), datatypeRecordImpl);
+				this.store.addDatatype(datatypeRecordImpl);
+			}
+		}
+		return datatypeCache;
+	}
+	
+	private ColumnRecordImpl findElement(String fullName) {
+        ColumnRecordImpl columnRecord = (ColumnRecordImpl)getRecordByType(fullName, MetadataConstants.RECORD_TYPE.COLUMN);
+    	columnRecord.setDatatype(getDatatypeCache().get(columnRecord.getDatatypeUUID()));
+        return columnRecord;
+    }
+	    
+    private AbstractMetadataRecord getRecordByType(final String entityName, final char recordType) {
+    	return getRecordByType(entityName, recordType, true);
+    }
+    
+    private AbstractMetadataRecord getRecordByType(final String entityName, final char recordType, boolean mustExist) {
+    	// Query the index files
+		final Collection results = findMetadataRecords(recordType,entityName,false);
+        
+		int resultSize = results.size();
+        if(resultSize == 1) {
+            // get the columnset record for this result            
+            return (AbstractMetadataRecord) results.iterator().next();
+        }
+        if(resultSize == 0) {
+        	if (mustExist) {
+			// there should be only one for the UUID
+	            throw new MetaMatrixRuntimeException(entityName+TransformationMetadata.NOT_EXISTS_MESSAGE);
+        	} 
+        	return null;
+		} 
+        throw new MetaMatrixRuntimeException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.0", entityName)); //$NON-NLS-1$
+    }
+    
+    public void getProcedures() {
+		Collection<ProcedureRecordImpl> procedureRecordImpls = findMetadataRecords(MetadataConstants.RECORD_TYPE.CALLABLE, null, false);
+		for (ProcedureRecordImpl procedureRecord : procedureRecordImpls) {
+	    	procedureRecord.setParameters(new ArrayList<ProcedureParameterRecordImpl>(procedureRecord.getParameterIDs().size()));
+	    	
+	        // get the parameter metadata info
+	        for (String paramID : procedureRecord.getParameterIDs()) {
+	            ProcedureParameterRecordImpl paramRecord = (ProcedureParameterRecordImpl) this.getRecordByType(paramID, MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
+	            paramRecord.setDatatype(getDatatypeCache().get(paramRecord.getDatatypeUUID()));
+	            procedureRecord.getParameters().add(paramRecord);
+	        }
+	    	
+	        String resultID = procedureRecord.getResultSetID();
+	        if(resultID != null) {
+	            ColumnSetRecordImpl resultRecord = (ColumnSetRecordImpl) getRecordByType(resultID, MetadataConstants.RECORD_TYPE.RESULT_SET, false);
+	            if (resultRecord != null) {
+		            loadColumnSetRecords(resultRecord, null);
+		            procedureRecord.setResultSet(resultRecord);
+	            }
+	            //it is ok to be null here.  it will happen when a 
+	            //virtual stored procedure is created from a
+	            //physical stored procedrue without a result set
+	            //TODO: find a better fix for this
+	        }
+
+	        // if this is a virtual procedure get the procedure plan
+	        if(procedureRecord.isVirtual()) {
+	    		TransformationRecordImpl transformRecord = (TransformationRecordImpl)getRecordByType(procedureRecord.getFullName(), MetadataConstants.RECORD_TYPE.PROC_TRANSFORM, false);
+	    		if(transformRecord != null) {
+	    			procedureRecord.setQueryPlan(transformRecord.getTransformation());
+	    		}
+	        }
+			this.store.addProcedure(procedureRecord);
+		}
+    }
+    
+    /**
+     * Finds children by parent uuid - note that this is not the best way to query for columns,
+     * but it removes the need to store the parent uuid
+     * @param parentRecord
+     * @param childRecordType
+     * @return
+     */
+    private List findChildRecords(final AbstractMetadataRecord parentRecord, final char childRecordType) {
+    	// construct the pattern string
+        String patternStr = getUUIDMatchPattern(childRecordType, parentRecord.getUUID(), true);
+		// Query the model index files
+		IEntryResult[] results = queryIndex(childRecordType, patternStr.toCharArray(), false, true, false);
+
+		return loadRecords(results);        
+    }
+    
+	private void loadColumnSetRecords(ColumnSetRecordImpl indexRecord, Map<String, ColumnRecordImpl> columns) {
+		for (int i = 0; i < indexRecord.getColumns().size(); i++) {
+			String uuid = indexRecord.getColumns().get(i).getUUID();
+			if (columns != null) {
+				indexRecord.getColumns().set(i, columns.get(uuid));
+			} else {
+				indexRecord.getColumns().set(i, findElement(uuid));
+			}
+		}
+	}
+    
+	private Collection findMetadataRecords(final char recordType,
+			final String entityName, final boolean isPartialName) {
+		IEntryResult[] results = queryIndex(recordType, entityName, isPartialName);
+		Collection<AbstractMetadataRecord> records = loadRecords(results);
+		return records;
+	}
+
+	private List<AbstractMetadataRecord> loadRecords(
+			IEntryResult[] results) {
+		List<AbstractMetadataRecord> records = RecordFactory.getMetadataRecord(results);
+		
+		for (AbstractMetadataRecord metadataRecord : records) {
+			String uuid = metadataRecord.getUUID();
+			
+			String prefixString  = getUUIDMatchPattern(MetadataConstants.RECORD_TYPE.ANNOTATION, uuid, false);
+			IEntryResult[] annotations = queryIndex(MetadataConstants.RECORD_TYPE.ANNOTATION, prefixString.toCharArray(), false, true, true);
+			if (annotations.length > 0) {
+				metadataRecord.setAnnotation(RecordFactory.createAnnotationRecord(annotations[0].getWord()));
+			}
+			
+			prefixString = String.valueOf(MetadataConstants.RECORD_TYPE.PROPERTY) + IndexConstants.RECORD_STRING.RECORD_DELIMITER + uuid.trim() + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+			IEntryResult[] properties = queryIndex(MetadataConstants.RECORD_TYPE.PROPERTY, prefixString.toCharArray(), true, true, true);
+			metadataRecord.setProperties(RecordFactory.createPropertyRecord(properties));
+		}
+		return records;
+	}
+    
+    /**
+     * Return the pattern match string that could be used to match a UUID in 
+     * an index record. All index records contain a header portion of the form:  
+     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
+     * @param uuid The UUID for which the pattern match string is to be constructed.
+     * @return The pattern match string of the form: recordType|*|uuid|*
+     */
+    private String getUUIDMatchPattern(final char recordType, String uuid, boolean parent) {
+        ArgCheck.isNotNull(uuid);
+        // construct the pattern string
+        String patternStr = String.valueOf(recordType) + IndexConstants.RECORD_STRING.RECORD_DELIMITER + IndexConstants.RECORD_STRING.MATCH_CHAR + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+        if (parent) {
+        	for (int i = 0; i < 3;  i++) {
+        		patternStr += String.valueOf(IndexConstants.RECORD_STRING.MATCH_CHAR) + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+        	}
+        }
+        patternStr += uuid.toLowerCase() + IndexConstants.RECORD_STRING.RECORD_DELIMITER + IndexConstants.RECORD_STRING.MATCH_CHAR;                    
+        return patternStr;        
+    }
+        
+    /** 
+     * @see com.metamatrix.modeler.core.index.IndexSelector#getIndexes()
+     * @since 4.2
+     */
+    public synchronized Index[] getIndexes() {
+    	return this.indexes;
+    }
+
+	/**
+	 * Return all index file records that match the specified entity name  
+	 * @param indexName
+	 * @param entityName the name to match
+	 * @param isPartialName true if the entity name is a partially qualified
+	 * @return results
+	 * @throws QueryMetadataException
+	 */
+	private IEntryResult[] queryIndex(final char recordType, final String entityName, final boolean isPartialName) {
+
+		IEntryResult[] results = null;
+
+		// Query based on UUID
+		if (StringUtil.startsWithIgnoreCase(entityName,UUID.PROTOCOL)) {
+            String patternString = null;
+            if (recordType == MetadataConstants.RECORD_TYPE.DATATYPE) {
+                patternString = getDatatypeUUIDMatchPattern(entityName);
+            } else {
+                patternString = getUUIDMatchPattern(recordType,entityName, false);
+            }
+			results = queryIndex(recordType, patternString.toCharArray(), false, true, true);
+		}
+
+		// Query based on partially qualified name
+		else if (isPartialName) {
+			String patternString = getMatchPattern(recordType,entityName);
+			results = queryIndex(recordType, patternString.toCharArray(), false, true, false);
+		}
+
+		// Query based on fully qualified name
+		else {
+			String prefixString  = getPrefixPattern(recordType,entityName);
+			results = queryIndex(recordType, prefixString.toCharArray(), true, true, true);
+		}
+
+		return results;
+	}
+	
+    /**
+     * Return the pattern match string that could be used to match a UUID in 
+     * a datatype index record. The RECORD_TYPE.DATATYPE records contain a header portion of the form:  
+     * recordType|datatypeID|basetypeID|fullName|objectID|nameInSource|...
+     * @param uuid The UUID for which the pattern match string is to be constructed.
+     * @return The pattern match string of the form: recordType|*|*|*|uuid|*
+     */
+    private String getDatatypeUUIDMatchPattern(final String uuid) {
+        ArgCheck.isNotNull(uuid);
+        String uuidString = uuid;
+        if (StringUtil.startsWithIgnoreCase(uuid,UUID.PROTOCOL)) {
+            uuidString = uuid.toLowerCase();
+        }
+        // construct the pattern string
+        String patternStr = "" //$NON-NLS-1$
+                          + MetadataConstants.RECORD_TYPE.DATATYPE            //recordType
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + IndexConstants.RECORD_STRING.MATCH_CHAR        //datatypeID 
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + IndexConstants.RECORD_STRING.MATCH_CHAR        //basetypeID 
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + IndexConstants.RECORD_STRING.MATCH_CHAR        //fullName 
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + uuidString                                     //objectID
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + IndexConstants.RECORD_STRING.MATCH_CHAR;                    
+        return patternStr;        
+    }
+	
+    /**
+     * Return the prefix match string that could be used to exactly match a fully 
+     * qualified entity name in an index record. All index records 
+     * contain a header portion of the form:  
+     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
+     * @param name The fully qualified name for which the prefix match 
+     * string is to be constructed.
+     * @return The pattern match string of the form: recordType|name|
+     */
+    private String getPrefixPattern(final char recordType, final String name) {
+
+        // construct the pattern string
+        String patternStr = "" //$NON-NLS-1$
+                          + recordType
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+        if(name != null) {                          
+            patternStr = patternStr + name.trim().toUpperCase() + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+        }                    
+
+        return patternStr;
+    }
+	
+    /**
+     * Return the pattern match string that could be used to match a 
+     * partially/fully qualified entity name in an index record. All index records 
+     * contain a header portion of the form:  
+     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
+     * @param name The partially/fully qualified name for which
+     * the pattern match string is to be constructed.
+     * @return The pattern match string of the form: recordType|*name|* 
+     */
+    private String getMatchPattern(final char recordType, final String name) {
+        ArgCheck.isNotNull(name);
+
+        // construct the pattern string
+        String patternStr = "" //$NON-NLS-1$
+                          + recordType
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + IndexConstants.RECORD_STRING.MATCH_CHAR;
+        if(name != null) {
+            patternStr =  patternStr + name.trim().toUpperCase()
+                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+                          + IndexConstants.RECORD_STRING.MATCH_CHAR;
+        }                    
+        return patternStr;        
+    }
+
+    /**
+     * Return all index file records that match the specified record pattern.
+     * @param indexes the array of MtkIndex instances to query
+     * @param pattern
+     * @return results
+     * @throws QueryMetadataException
+     */
+    private IEntryResult[] queryIndex(char recordType, final char[] pattern, boolean isPrefix, boolean isCaseSensitive, boolean returnFirstMatch) {
+    	// The the index file name for the record type
+        final String indexName = SimpleIndexUtil.getIndexFileNameForRecordType(recordType);
+        Index[] search = SimpleIndexUtil.getIndexes(indexName, this.getIndexes());            
+
+    	try {
+            return SimpleIndexUtil.queryIndex(null, search, pattern, isPrefix, isCaseSensitive, returnFirstMatch);
+        } catch (MetaMatrixCoreException e) {
+            throw new MetaMatrixRuntimeException(e);
+        }
+    }
+    
+}


Property changes on: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -1,593 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.metadata.index;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
-import org.teiid.connector.metadata.runtime.MetadataConstants;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
-import org.teiid.connector.metadata.runtime.TransformationRecordImpl;
-import org.teiid.core.index.IEntryResult;
-import org.teiid.internal.core.index.Index;
-import org.teiid.metadata.RuntimeMetadataPlugin;
-import org.teiid.metadata.TransformationMetadata;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.id.UUID;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.query.metadata.MetadataStore;
-
-/**
- * Loads MetadataRecords from index files.  
- * Only datatypes are directly cached.
- */
-public class IndexMetadataStore implements MetadataStore {
-
-	private Index[] indexes;
-    private Map<String, DatatypeRecordImpl> datatypeCache;
-
-    public IndexMetadataStore(MetadataSource source) throws IOException {
-    	ArrayList<Index> tmp = new ArrayList<Index>();
-		for (String fileName : source.getEntries()) {
-			if (SimpleIndexUtil.isIndexFile(fileName)) {
-				File f = source.getFile(fileName);
-	            tmp.add( new Index(f.getAbsolutePath(), true) );
-	        } 
-		}
-		this.indexes = tmp.toArray(new Index[tmp.size()]);
-    }
-    
-    @Override
-    public boolean postProcessFindMetadataRecords() {
-    	return false;
-    }
-    
-    @Override
-    public Collection<String> getModelNames() {
-    	Collection<ModelRecordImpl> records;
-		try {
-			records = findMetadataRecords(MetadataConstants.RECORD_TYPE.MODEL, null, false);
-		} catch (MetaMatrixComponentException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-    	List<String> result = new ArrayList<String>(records.size());
-    	for (ModelRecordImpl modelRecord : records) {
-			result.add(modelRecord.getName());
-		}
-    	return result;
-    }
-    
-    public ModelRecordImpl getModel(String name) throws QueryMetadataException, MetaMatrixComponentException {
-    	return (ModelRecordImpl)getRecordByType(name, MetadataConstants.RECORD_TYPE.MODEL);
-    }
-    
-    @Override
-    public TableRecordImpl findGroup(String groupName) throws QueryMetadataException, MetaMatrixComponentException {
-        TableRecordImpl tableRecord = (TableRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.TABLE);
-    	List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.COLUMN, true));
-        for (ColumnRecordImpl columnRecordImpl : columns) {
-    		columnRecordImpl.setDatatype(getDatatypeCache().get(columnRecordImpl.getDatatypeUUID()));
-		}
-        Collections.sort(columns);
-        tableRecord.setColumns(columns);
-        tableRecord.setAccessPatterns(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.ACCESS_PATTERN, true));
-        Map<String, ColumnRecordImpl> uuidColumnMap = new HashMap<String, ColumnRecordImpl>();
-        for (ColumnRecordImpl columnRecordImpl : columns) {
-			uuidColumnMap.put(columnRecordImpl.getUUID(), columnRecordImpl);
-		}
-        for (ColumnSetRecordImpl columnSetRecordImpl : tableRecord.getAccessPatterns()) {
-			loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
-		}
-        tableRecord.setForiegnKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.FOREIGN_KEY, true));
-        for (ForeignKeyRecordImpl foreignKeyRecord : tableRecord.getForeignKeys()) {
-        	(foreignKeyRecord).setPrimaryKey((ColumnSetRecordImpl)this.getRecordByType(foreignKeyRecord.getUniqueKeyID(), MetadataConstants.RECORD_TYPE.PRIMARY_KEY));
-        	loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
-		}
-        tableRecord.setUniqueKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.UNIQUE_KEY, true));
-        for (ColumnSetRecordImpl columnSetRecordImpl : tableRecord.getUniqueKeys()) {
-			loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
-		}
-        if (tableRecord.getPrimaryKeyID() != null) {
-        	ColumnSetRecordImpl primaryKey = (ColumnSetRecordImpl)getRecordByType(tableRecord.getPrimaryKeyID(), MetadataConstants.RECORD_TYPE.PRIMARY_KEY);
-        	loadColumnSetRecords(primaryKey, uuidColumnMap);
-        	tableRecord.setPrimaryKey(primaryKey);
-        }
-        if (tableRecord.isVirtual()) {
-        	TransformationRecordImpl update = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.UPDATE_TRANSFORM,false);
-	        if (update != null) {
-	        	tableRecord.setUpdatePlan(update.getTransformation());
-	        }
-	        TransformationRecordImpl insert = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.INSERT_TRANSFORM,false);
-	        if (insert != null) {
-	        	tableRecord.setInsertPlan(insert.getTransformation());
-	        }
-	        TransformationRecordImpl delete = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM,false);
-	        if (delete != null) {
-	        	tableRecord.setDeletePlan(delete.getTransformation());
-	        }
-	        TransformationRecordImpl select = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM,false);
-	        // this group may be an xml document            
-	        if(select == null) {
-		        select = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM,false);
-	        }
-	        tableRecord.setSelectTransformation(select);
-        }
-        if (tableRecord.isMaterialized()) {
-        	tableRecord.setMaterializedStageTableName(getRecordByType(tableRecord.getMaterializedStageTableID(), MetadataConstants.RECORD_TYPE.TABLE).getFullName());
-        	tableRecord.setMaterializedTableName(getRecordByType(tableRecord.getMaterializedTableID(), MetadataConstants.RECORD_TYPE.TABLE).getFullName());
-        }
-        return tableRecord;
-    }
-
-	private Map<String, DatatypeRecordImpl> getDatatypeCache() throws MetaMatrixComponentException {
-		if (this.datatypeCache == null) {
-			this.datatypeCache = new HashMap<String, DatatypeRecordImpl>();
-			Collection<DatatypeRecordImpl> dataTypes = findMetadataRecords(MetadataConstants.RECORD_TYPE.DATATYPE, null, false);
-			for (DatatypeRecordImpl datatypeRecordImpl : dataTypes) {
-				datatypeCache.put(datatypeRecordImpl.getUUID(), datatypeRecordImpl);
-			}
-		}
-		return datatypeCache;
-	}
-	
-	public Collection<DatatypeRecordImpl> getDatatypes() throws MetaMatrixComponentException {
-		return getDatatypeCache().values();
-	}
-    
-    @Override
-    public ColumnRecordImpl findElement(String fullName) throws QueryMetadataException, MetaMatrixComponentException {
-        ColumnRecordImpl columnRecord = (ColumnRecordImpl)getRecordByType(fullName, MetadataConstants.RECORD_TYPE.COLUMN);
-    	columnRecord.setDatatype(getDatatypeCache().get(columnRecord.getDatatypeUUID()));
-        return columnRecord;
-    }
-    
-    @Override
-    public Collection<String> getGroupsForPartialName(String partialGroupName)
-    		throws MetaMatrixComponentException, QueryMetadataException {
-        // Query the index files
-		Collection<String> tableRecords = findMetadataRecords(MetadataConstants.RECORD_TYPE.TABLE,partialGroupName,true);
-
-		// Extract the fully qualified names to return
-		final Collection tableNames = new ArrayList(tableRecords.size());
-		for(Iterator recordIter = tableRecords.iterator();recordIter.hasNext();) {
-			// get the table record for this result            
-			TableRecordImpl tableRecord = (TableRecordImpl) recordIter.next();                    
-			tableNames.add(tableRecord.getFullName());
-		}
-		return tableNames;
-    }
-    
-    private AbstractMetadataRecord getRecordByType(final String entityName, final char recordType) throws MetaMatrixComponentException, QueryMetadataException {
-    	return getRecordByType(entityName, recordType, true);
-    }
-    
-    private AbstractMetadataRecord getRecordByType(final String entityName, final char recordType, boolean mustExist) throws MetaMatrixComponentException, QueryMetadataException {
-    	// Query the index files
-		final Collection results = findMetadataRecords(recordType,entityName,false);
-        
-		int resultSize = results.size();
-        if(resultSize == 1) {
-            // get the columnset record for this result            
-            return (AbstractMetadataRecord) results.iterator().next();
-        }
-        if(resultSize == 0) {
-        	if (mustExist) {
-			// there should be only one for the UUID
-	            throw new QueryMetadataException(entityName+TransformationMetadata.NOT_EXISTS_MESSAGE);
-        	} 
-        	return null;
-		} 
-        throw new QueryMetadataException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.0", entityName)); //$NON-NLS-1$
-    }
-    
-    @Override
-    public ProcedureRecordImpl getStoredProcedure(
-    		String fullyQualifiedProcedureName)
-    		throws MetaMatrixComponentException, QueryMetadataException {
-    	ProcedureRecordImpl procedureRecord = (ProcedureRecordImpl)getRecordByType(fullyQualifiedProcedureName, MetadataConstants.RECORD_TYPE.CALLABLE);
-
-    	procedureRecord.setParameters(new ArrayList<ProcedureParameterRecordImpl>(procedureRecord.getParameterIDs().size()));
-    	
-        // get the parameter metadata info
-        for (String paramID : procedureRecord.getParameterIDs()) {
-            ProcedureParameterRecordImpl paramRecord = (ProcedureParameterRecordImpl) this.getRecordByType(paramID, MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
-            paramRecord.setDatatype(getDatatypeCache().get(paramRecord.getDatatypeUUID()));
-            procedureRecord.getParameters().add(paramRecord);
-        }
-    	
-        String resultID = procedureRecord.getResultSetID();
-        if(resultID != null) {
-            try {
-                ColumnSetRecordImpl resultRecord = (ColumnSetRecordImpl) this.getRecordByType(resultID, MetadataConstants.RECORD_TYPE.RESULT_SET);
-                loadColumnSetRecords(resultRecord, null);
-                procedureRecord.setResultSet(resultRecord);
-            } catch (QueryMetadataException e) {
-                //it is ok to fail here.  it will happen when a 
-                //virtual stored procedure is created from a
-                //physical stored procedrue without a result set
-                //TODO: find a better fix for this
-            }
-        }
-
-        // if this is a virtual procedure get the procedure plan
-        if(procedureRecord.isVirtual()) {
-    		TransformationRecordImpl transformRecord = (TransformationRecordImpl)getRecordByType(fullyQualifiedProcedureName, MetadataConstants.RECORD_TYPE.PROC_TRANSFORM, false);
-    		if(transformRecord != null) {
-    			procedureRecord.setQueryPlan(transformRecord.getTransformation());
-    		}
-        }
-
-    	return procedureRecord;
-    }
-    
-	@Override
-	public Collection getXMLTempGroups(TableRecordImpl table) throws MetaMatrixComponentException {
-		// Query the index files
-		final Collection results = findChildRecords(table, MetadataConstants.RECORD_TYPE.TABLE, false);
-        Collection tempGroups = new HashSet(results.size());
-        for(Iterator resultIter = results.iterator();resultIter.hasNext();) {
-            TableRecordImpl record = (TableRecordImpl) resultIter.next();
-            if(record.getTableType() == MetadataConstants.TABLE_TYPES.XML_STAGING_TABLE_TYPE) {
-                tempGroups.add(record);
-            }
-        }
-        return tempGroups;
-	}
-	
-    private Collection findChildRecords(final AbstractMetadataRecord parentRecord, final char childRecordType, boolean filter) throws MetaMatrixComponentException {
-        IEntryResult[] results = queryIndexByParentPath(childRecordType, parentRecord.getFullName());
-		Collection records = RecordFactory.getMetadataRecord(results);        
-		
-        if (filter) {
-            final String groupUUID = parentRecord.getUUID();
-            
-            for( Iterator resultsIter = records.iterator(); resultsIter.hasNext(); ) {
-                AbstractMetadataRecord record = (AbstractMetadataRecord) resultsIter.next();
-                String parentUUID = record.getParentUUID();
-
-                if(parentUUID == null || !parentUUID.equalsIgnoreCase(groupUUID)) {
-                    resultsIter.remove();
-                }
-            }
-        }
-        
-        return records;
-    }
-    
-	private void loadColumnSetRecords(ColumnSetRecordImpl indexRecord, Map<String, ColumnRecordImpl> columns)
-			throws MetaMatrixComponentException, QueryMetadataException {
-		List uuids = indexRecord.getColumnIDs();
-		List<ColumnRecordImpl> columnRecords = new ArrayList<ColumnRecordImpl>(uuids.size());
-
-		for (Iterator uuidIter = uuids.iterator(); uuidIter.hasNext();) {
-			String uuid = (String) uuidIter.next();
-			if (columns != null) {
-				columnRecords.add(columns.get(uuid));
-			} else {
-				columnRecords.add(findElement(uuid));
-			}
-		}
-		indexRecord.setColumns(columnRecords);
-	}
-    
-    @Override
-	public Collection findMetadataRecords(final char recordType,
-			final String entityName, final boolean isPartialName)
-			throws MetaMatrixComponentException {
-		IEntryResult[] results = queryIndex(recordType, entityName, isPartialName);
-		Collection records = RecordFactory.getMetadataRecord(results);;
-		
-		if(StringUtil.startsWithIgnoreCase(entityName,UUID.PROTOCOL)) {		
-	        // Filter out ColumnRecord instances that do not match the specified uuid.
-	        // Due to the pattern matching used to query index files if an index record
-	        // matched the specified uuid string anywhere in that record it would be returned
-	        // in the results (for example, if the parent ObjectID in the index record
-	        // matched the specified uuid).
-			if (entityName != null && records != null) {
-	            for (final Iterator iter = records.iterator(); iter.hasNext();) {
-	                final AbstractMetadataRecord record = (AbstractMetadataRecord)iter.next();
-	                if (record == null || !entityName.equals(record.getUUID())) {
-	                    iter.remove();
-	                }
-	            }
-	        }
-		}
-
-		return records;
-	}
-    
-    @Override
-    public Collection<AbstractMetadataRecord> findMetadataRecords(String indexName,
-    		String pattern, boolean isPrefix,
-    		boolean isCaseSensitive) throws MetaMatrixCoreException {
-    	IEntryResult[] results = SimpleIndexUtil.queryIndex(null, SimpleIndexUtil.getIndexes(indexName, this), pattern==null?null:pattern.toCharArray(), isPrefix, isCaseSensitive, false);
-    	return RecordFactory.getMetadataRecord(results);
-    }
-    
-    @Override
-    public Collection<PropertyRecordImpl> getExtensionProperties(AbstractMetadataRecord metadataRecord) throws MetaMatrixComponentException {
-		// find the entities properties records
-		String uuid = metadataRecord.getUUID();
-		String prefixString  = getUUIDPrefixPattern(MetadataConstants.RECORD_TYPE.PROPERTY, uuid);
-
-		IEntryResult[] results = queryIndex(MetadataConstants.RECORD_TYPE.PROPERTY, prefixString.toCharArray(), true, true, true);
-		
-		return RecordFactory.getMetadataRecord(results);
-    }
-    
-    /**
-     * Return the pattern match string that could be used to match a UUID in 
-     * an index record. All index records contain a header portion of the form:  
-     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
-     * @param uuid The UUID for which the pattern match string is to be constructed.
-     * @return The pattern match string of the form: recordType|*|uuid|*
-     */
-    private String getUUIDMatchPattern(final char recordType, final String uuid) {
-        ArgCheck.isNotNull(uuid);
-        String uuidString = uuid;
-        if (StringUtil.startsWithIgnoreCase(uuid,UUID.PROTOCOL)) {
-            uuidString = uuid.toLowerCase();
-        }
-        // construct the pattern string
-        String patternStr = "" //$NON-NLS-1$
-                          + recordType
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR                    
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + uuidString
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR;                    
-        return patternStr;        
-    }
-    
-	private String getUUIDPrefixPattern(final char recordType, final String uuid) {
-
-		// construct the pattern string
-		String patternStr = "" //$NON-NLS-1$
-						  + recordType
-						  + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
-		if(uuid != null) {                          
-			patternStr = patternStr + uuid.trim() + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
-		}                    
-
-		return patternStr;
-	}
-    
-    /** 
-     * @see com.metamatrix.modeler.core.index.IndexSelector#getIndexes()
-     * @since 4.2
-     */
-    public synchronized Index[] getIndexes() {
-    	return this.indexes;
-    }
-
-    /**
-     * Return the array of MtkIndex instances representing temporary indexes
-     * @param selector
-     * @return
-     * @throws QueryMetadataException
-     */
-    private Index[] getIndexes(final char recordType) throws MetaMatrixComponentException {
-    	// The the index file name for the record type
-        try {
-            final String indexName = SimpleIndexUtil.getIndexFileNameForRecordType(recordType);
-            return SimpleIndexUtil.getIndexes(indexName, this);            
-        } catch(Exception e) {
-            throw new MetaMatrixComponentException(e, RuntimeMetadataPlugin.Util.getString("TransformationMetadata.Error_trying_to_obtain_index_file_using_IndexSelector_1",this)); //$NON-NLS-1$
-        }
-    }
-    
-	/**
-	 * Return all index file records that match the specified entity name  
-	 * @param indexName
-	 * @param entityName the name to match
-	 * @param isPartialName true if the entity name is a partially qualified
-	 * @return results
-	 * @throws QueryMetadataException
-	 */
-	private IEntryResult[] queryIndexByParentPath(final char recordType, final String parentFullName) throws MetaMatrixComponentException {
-
-		// Query based on fully qualified name
-		String prefixString  = getParentPrefixPattern(recordType,parentFullName);
-
-		// Query the model index files
-		IEntryResult[] results = queryIndex(recordType, prefixString.toCharArray(), true, true, false);
-
-		return results;
-	}
-	
-	/**
-	 * Return all index file records that match the specified entity name  
-	 * @param indexName
-	 * @param entityName the name to match
-	 * @param isPartialName true if the entity name is a partially qualified
-	 * @return results
-	 * @throws QueryMetadataException
-	 */
-	private IEntryResult[] queryIndex(final char recordType, final String entityName, final boolean isPartialName) throws MetaMatrixComponentException {
-
-		IEntryResult[] results = null;
-
-		// Query based on UUID
-		if (StringUtil.startsWithIgnoreCase(entityName,UUID.PROTOCOL)) {
-            String patternString = null;
-            if (recordType == MetadataConstants.RECORD_TYPE.DATATYPE) {
-                patternString = getDatatypeUUIDMatchPattern(entityName);
-            } else {
-                patternString = getUUIDMatchPattern(recordType,entityName);
-            }
-			results = queryIndex(recordType, patternString.toCharArray(), false, true, true);
-		}
-
-		// Query based on partially qualified name
-		else if (isPartialName) {
-			String patternString = getMatchPattern(recordType,entityName);
-			results = queryIndex(recordType, patternString.toCharArray(), false, true, false);
-		}
-
-		// Query based on fully qualified name
-		else {
-			String prefixString  = getPrefixPattern(recordType,entityName);
-			results = queryIndex(recordType, prefixString.toCharArray(), true, true, true);
-		}
-
-		return results;
-	}
-	
-    /**
-     * Return the pattern match string that could be used to match a UUID in 
-     * a datatype index record. The RECORD_TYPE.DATATYPE records contain a header portion of the form:  
-     * recordType|datatypeID|basetypeID|fullName|objectID|nameInSource|...
-     * @param uuid The UUID for which the pattern match string is to be constructed.
-     * @return The pattern match string of the form: recordType|*|*|*|uuid|*
-     */
-    private String getDatatypeUUIDMatchPattern(final String uuid) {
-        ArgCheck.isNotNull(uuid);
-        String uuidString = uuid;
-        if (StringUtil.startsWithIgnoreCase(uuid,UUID.PROTOCOL)) {
-            uuidString = uuid.toLowerCase();
-        }
-        // construct the pattern string
-        String patternStr = "" //$NON-NLS-1$
-                          + MetadataConstants.RECORD_TYPE.DATATYPE            //recordType
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR        //datatypeID 
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR        //basetypeID 
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR        //fullName 
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + uuidString                                     //objectID
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR;                    
-        return patternStr;        
-    }
-	
-    /**
-     * Return the prefix match string that could be used to exactly match a fully 
-     * qualified entity name in an index record. All index records 
-     * contain a header portion of the form:  
-     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
-     * @param name The fully qualified name for which the prefix match 
-     * string is to be constructed.
-     * @return The pattern match string of the form: recordType|name|
-     */
-    private String getParentPrefixPattern(final char recordType, final String name) {
-
-        // construct the pattern string
-        String patternStr = "" //$NON-NLS-1$
-                          + recordType
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
-        if(name != null) {                          
-            patternStr = patternStr + name.trim().toUpperCase()+ TransformationMetadata.DELIMITER_CHAR;
-        }                    
-
-        return patternStr;
-    }
-	
-    /**
-     * Return the prefix match string that could be used to exactly match a fully 
-     * qualified entity name in an index record. All index records 
-     * contain a header portion of the form:  
-     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
-     * @param name The fully qualified name for which the prefix match 
-     * string is to be constructed.
-     * @return The pattern match string of the form: recordType|name|
-     */
-    private String getPrefixPattern(final char recordType, final String name) {
-
-        // construct the pattern string
-        String patternStr = "" //$NON-NLS-1$
-                          + recordType
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
-        if(name != null) {                          
-            patternStr = patternStr + name.trim().toUpperCase() + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
-        }                    
-
-        return patternStr;
-    }
-	
-    /**
-     * Return the pattern match string that could be used to match a 
-     * partially/fully qualified entity name in an index record. All index records 
-     * contain a header portion of the form:  
-     * recordType|pathInModel|UUID|nameInSource|parentObjectID|
-     * @param name The partially/fully qualified name for which
-     * the pattern match string is to be constructed.
-     * @return The pattern match string of the form: recordType|*name|* 
-     */
-    private String getMatchPattern(final char recordType, final String name) {
-        ArgCheck.isNotNull(name);
-
-        // construct the pattern string
-        String patternStr = "" //$NON-NLS-1$
-                          + recordType
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR;
-        if(name != null) {
-            patternStr =  patternStr + name.trim().toUpperCase()
-                          + IndexConstants.RECORD_STRING.RECORD_DELIMITER
-                          + IndexConstants.RECORD_STRING.MATCH_CHAR;
-        }                    
-        return patternStr;        
-    }
-
-    /**
-     * Return all index file records that match the specified record pattern.
-     * @param indexes the array of MtkIndex instances to query
-     * @param pattern
-     * @return results
-     * @throws QueryMetadataException
-     */
-    private IEntryResult[] queryIndex(char recordType, final char[] pattern, boolean isPrefix, boolean isCaseSensitive, boolean returnFirstMatch) throws MetaMatrixComponentException {
-        try {
-            return SimpleIndexUtil.queryIndex(null, getIndexes(recordType), pattern, isPrefix, isCaseSensitive, returnFirstMatch);
-        } catch (MetaMatrixCoreException e) {
-            throw new MetaMatrixComponentException(e, e.getMessage());
-        }
-    }
-    
-}

Copied: trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java (from rev 1529, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataConstants.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java	                        (rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -0,0 +1,293 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata.index;
+
+import com.metamatrix.core.util.StringUtil;
+
+/**
+ * MetadataConstants are all the constant values used to identify all the valid values for a multi-value attribute.
+ * All assigned short values start with 1.  Therefore, when the get...TypeName(type) method is called, the
+ * method needs to subtract 1 from the argument.
+ */
+public final class MetadataConstants {
+    
+	/** Definition of not defined long type. */
+    public static final long NOT_DEFINED_LONG = Long.MIN_VALUE;
+	/**  Definition of not defined int type. */
+    public static final int NOT_DEFINED_INT = Integer.MIN_VALUE;
+	/**  Definition of not defined short type. */
+    public static final short NOT_DEFINED_SHORT = Short.MIN_VALUE;
+
+    public final static String BLANK = StringUtil.Constants.EMPTY_STRING;
+        
+    //properties
+    public static final String VERSION_DATE = "versionDate"; //$NON-NLS-1$
+
+	/**
+	 * These types are associated with a KEY, indicating the type of matching that can be performed on it.
+	 */
+    public final static class MATCH_TYPES {
+        public final static short FULL_MATCH    = 0;
+        public final static short PARTIAL_MATCH = 1;
+        public final static short NEITHER_MATCH = 2;
+        public final static short NA            = 3;
+        public final static String[] TYPE_NAMES = { "Full",  //$NON-NLS-1$
+                                                    "Partial",   //$NON-NLS-1$
+                                                    "Neither",  //$NON-NLS-1$
+                                                    "N/A" }; //$NON-NLS-1$
+    }
+
+    public final static String getMatchTypeName(short type) {
+        return  MATCH_TYPES.TYPE_NAMES[type];
+    }
+
+    
+	/**
+	 * These types indicate the type of KEY it is. 
+     * The values must be kept consistent with the values referenced in 
+     * KeyTypeEnumeration.properties in connector.metadata
+	 */
+    public final static class KEY_TYPES {
+        public final static short PRIMARY_KEY    = 0;
+        public final static short FOREIGN_KEY    = 1;
+        public final static short UNIQUE_KEY     = 2;
+        public final static short NON_UNIQUE_KEY = 3;
+        public final static short ACCESS_PATTERN = 4;
+        public final static short INDEX          = 5;
+        public final static String[] TYPE_NAMES = { "Primary",  //$NON-NLS-1$
+                                                    "Foreign",   //$NON-NLS-1$
+                                                    "Unique",  //$NON-NLS-1$
+                                                    "NonUnique",  //$NON-NLS-1$
+                                                    "AccessPattern",  //$NON-NLS-1$
+                                                    "Index" }; //$NON-NLS-1$
+    }
+    public final static String getKeyTypeName(short type) {
+        return  KEY_TYPES.TYPE_NAMES[type];
+    }
+
+    /**
+     * These types indicate the type of COLUMN_SET it is. 
+     * The values must be kept consistent with the values referenced in 
+     * KeyTypeEnumeration.properties in connector.metadata
+     */
+    public final static class COLUMN_SET_TYPES {
+        public final static short FOREIGN_KEY      = 0;
+        public final static short UNIQUE_KEY       = 1;
+        public final static short ACCESS_PATTERN   = 2;
+        public final static short INDEX            = 3;
+        public final static short PROCEDURE_RESULT = 4;
+        public final static short TABLE            = 5;
+        public final static String[] TYPE_NAMES = { "Foreign",   //$NON-NLS-1$
+                                                    "Unique",  //$NON-NLS-1$
+                                                    "AccessPattern",  //$NON-NLS-1$
+                                                    "Index",  //$NON-NLS-1$
+                                                    "Procedure_Result", //$NON-NLS-1$
+                                                    "Table"}; //$NON-NLS-1$
+    }
+    public final static String getColumnSetTypeName(short type) {
+        return  KEY_TYPES.TYPE_NAMES[type];
+    }
+
+	/**
+	 * These types indicate the type of PROCEDURE it is. 
+     * The values must be kept consistent with the values referenced in 
+     * ProcTypeEnumeration.properties in connector.metadata
+	 */
+    public final static class PROCEDURE_TYPES {
+        public final static short FUNCTION         = 0;
+        public final static short STORED_PROCEDURE = 1;
+        public final static short STORED_QUERY     = 2;
+        public final static String[] TYPE_NAMES = { "Function",  //$NON-NLS-1$
+                                                    "StoredProc", //$NON-NLS-1$
+                                                    "StoredQuery" }; //$NON-NLS-1$
+    }
+    public final static String getProcedureTypeName(short type) {
+        return PROCEDURE_TYPES.TYPE_NAMES[type];
+    }
+
+    /**
+     * These types indicate the type of TRANSFORMATION it it. 
+     */
+    public final static class SQL_TRANSFORMATION_TYPES {
+        public final static short MAPPING_DEFN            = 0;
+        public final static short QUERY_PLAN_SELECT_QUERY = 1;
+        public final static short QUERY_PLAN_INSERT_QUERY = 2;
+        public final static short QUERY_PLAN_UPDATE_QUERY = 3;
+        public final static short QUERY_PLAN_DELETE_QUERY = 4;
+        public final static short QUERY_PLAN_STORED_QUERY = 5;
+        public final static String[] TYPE_NAMES = { "MappingDefn",  //$NON-NLS-1$
+                                                    "QueryPlanSelectQuery", //$NON-NLS-1$
+                                                    "QueryPlanInsertQuery", //$NON-NLS-1$
+                                                    "QueryPlanUpdateQuery", //$NON-NLS-1$
+                                                    "QueryPlanDeleteQuery", //$NON-NLS-1$
+                                                    "QueryPlanStoredQuery"}; //$NON-NLS-1$
+    }
+    public final static String getSqlTransformationTypeName(short type) {
+        return SQL_TRANSFORMATION_TYPES.TYPE_NAMES[type];
+    }
+
+	/**
+	 * These types indicate the type of  PROCEDURE_PARAMETER it is.
+     * The values must be kept consistent with the DirectionKind enumeration in the relational
+     * metamodel and the values referenced in ProcParamDirectionEnumeration.properties in connector.metadata
+	 */
+    public final static class PARAMETER_TYPES {
+        public final static short IN_PARM      = 0;
+        public final static short OUT_PARM     = 1;
+        public final static short INOUT_PARM   = 2;
+        public final static short RETURN_VALUE = 3;
+        public final static short RESULT_SET   = 4;
+        public final static String[] TYPE_NAMES = { "In",  //$NON-NLS-1$
+                                                    "Out",   //$NON-NLS-1$
+                                                    "InOut",  //$NON-NLS-1$
+                                                    "ReturnValue",  //$NON-NLS-1$
+                                                    "ResultSet" }; //$NON-NLS-1$
+    }
+    public final static String getParameterTypeName(short type) {
+        return PARAMETER_TYPES.TYPE_NAMES[type];
+    }
+    
+	/**
+	 * These types are associated with the Element having valid search types. 
+     * The values must be kept consistent with the SearchabilityType enumeration in the relational
+     * metamodel and the values referenced in SearchTypeEnumeration.properties in connector.metadata
+	 */
+    public final static class SEARCH_TYPES {
+        public final static short SEARCHABLE    = 0;
+        public final static short ALLEXCEPTLIKE = 1;
+        public final static short LIKE_ONLY     = 2;
+        public final static short UNSEARCHABLE  = 3;
+        public final static String[] TYPE_NAMES = { "Searchable",  //$NON-NLS-1$
+                                                    "All Except Like",   //$NON-NLS-1$
+                                                    "Like Only",  //$NON-NLS-1$
+                                                    "Unsearchable" }; //$NON-NLS-1$
+    }
+    public final static String getSearchTypeName(short type) {
+        return SEARCH_TYPES.TYPE_NAMES[type];
+    }
+
+	/**
+	 * A DataType object will be identified as being of one of these types.
+     * The values must be kept consistent with the values referenced in 
+     * DatatypeTypeEnumeration.properties in connector.metadata
+	 */
+    public final static class DATATYPE_TYPES {
+        public final static short BASIC        = 0;
+        public final static short USER_DEFINED = 1;
+        public final static short RESULT_SET   = 2;
+        public final static String[] TYPE_NAMES = { "Basic",  //$NON-NLS-1$
+                                                    "UserDefined", //$NON-NLS-1$
+                                                    "ResultSet" }; //$NON-NLS-1$
+    }
+    public final static String getDataTypeTypeName(short type) {
+        return DATATYPE_TYPES.TYPE_NAMES[type];
+    }
+
+    /**
+     * User defined DataType objects will be categorized by a variety
+     * The values must be kept consistent with the XSDVariety enumeration in the xsd
+     * metamodel and the values referenced in DatatypeVarietyEnumeration.properties in 
+     * connector.metadata
+     */
+    public final static class DATATYPE_VARIETIES {
+        public final static short ATOMIC  = 0;
+        public final static short LIST    = 1;
+        public final static short UNION   = 2;
+        public final static short COMPLEX = 3;
+        public final static String[] TYPE_NAMES = { "Atomic",  //$NON-NLS-1$
+                                                    "List", //$NON-NLS-1$
+                                                    "Union", //$NON-NLS-1$
+                                                    "Complex" }; //$NON-NLS-1$
+    }
+    public final static String getDataTypeVarietyName(short type) {
+        return DATATYPE_VARIETIES.TYPE_NAMES[type];
+    }
+    
+	/**
+	 * These types represent the type of table a Group is. 
+	 */
+    public final static class TABLE_TYPES {
+        public static final short TABLE_TYPE             = 0;
+        public static final short VIEW_TYPE              = 1;
+        public static final short DOCUMENT_TYPE          = 2;
+        public static final short XML_MAPPING_CLASS_TYPE = 3;
+        public static final short XML_STAGING_TABLE_TYPE = 4;
+        public static final short MATERIALIZED_TYPE      = 5;
+        public final static String[] TYPE_NAMES = { "Table", //$NON-NLS-1$
+                                                    "View",  //$NON-NLS-1$
+                                                    "Document",  //$NON-NLS-1$
+                                                    "XmlMappingClass",  //$NON-NLS-1$
+                                                    "XmlStagingTable", //$NON-NLS-1$
+                                                    "MaterializedTable" }; //$NON-NLS-1$
+    }
+    public final static String getTableTypeName(short type) {
+        return TABLE_TYPES.TYPE_NAMES[type];
+    }
+
+	/**
+	 * These types are associated with a DataType or an Element needing the indication of null types. 
+     * The values must be kept consistent with the NullableType enumeration in the relational
+     * metamodel and the values referenced in NullTypeEnumeration.properties in connector.metadata
+	 */
+    public final static class NULL_TYPES {
+        public static final short NOT_NULL = 0;
+        public static final short NULLABLE = 1;
+        public static final short UNKNOWN  = 2;
+        public final static String[] TYPE_NAMES = { "No Nulls",  //$NON-NLS-1$
+                                                    "Nullable",   //$NON-NLS-1$
+                                                    "Unknown" }; //$NON-NLS-1$
+    }
+    //Record type Constants
+	public static class RECORD_TYPE {
+	    public final static char MODEL               = 'A';
+	    public final static char TABLE               = 'B';
+	    public final static char RESULT_SET          = 'C';
+	    public final static char JOIN_DESCRIPTOR     = 'D';
+	    public final static char CALLABLE            = 'E';
+	    public final static char CALLABLE_PARAMETER  = 'F';
+	    public final static char COLUMN              = 'G';
+	    public final static char ACCESS_PATTERN      = 'H';        
+	    public final static char UNIQUE_KEY          = 'I';
+	    public final static char FOREIGN_KEY         = 'J';
+	    public final static char PRIMARY_KEY         = 'K';                
+	    public final static char INDEX               = 'L';
+	    public final static char DATATYPE            = 'M';
+	    //public final static char DATATYPE_ELEMENT    = 'N';
+	    //public final static char DATATYPE_FACET      = 'O';
+	    public final static char SELECT_TRANSFORM    = 'P';
+	    public final static char INSERT_TRANSFORM    = 'Q';
+	    public final static char UPDATE_TRANSFORM    = 'R';
+	    public final static char DELETE_TRANSFORM    = 'S';
+	    public final static char PROC_TRANSFORM      = 'T';
+	    public final static char MAPPING_TRANSFORM   = 'U';
+	    public final static char VDB_ARCHIVE         = 'V';
+	    public final static char ANNOTATION          = 'W';
+	    public final static char PROPERTY            = 'X';
+	    public final static char FILE            	 = 'Z';
+	    public final static char RECORD_CONTINUATION = '&';
+	}
+
+	public final static String getNullTypeName(short type) {
+        return NULL_TYPES.TYPE_NAMES[type];
+    }
+}
\ No newline at end of file


Property changes on: trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -30,7 +30,6 @@
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 
-import org.teiid.metadata.RuntimeMetadataPlugin;
 
 
 import com.metamatrix.common.log.LogManager;
@@ -42,11 +41,6 @@
 
 public class ModelFileUtil {
 	
-	public interface XmiHeaderCache {
-		XMIHeader getCachedXmiHeader(File resource);
-		void setXmiHeaderToCache(File resource, XMIHeader header);
-	}
-	
 	public static final String MANIFEST_MODEL_NAME = "MetaMatrix-VdbManifestModel.xmi"; //$NON-NLS-1$
 	public static final String DOT_PROJECT = ".project"; //$NON-NLS-1$
 	public static final String FILE_COLON = "file:";  //$NON-NLS-1$
@@ -57,12 +51,6 @@
 	public static final String EXTENSION_ECORE = "ecore"; //$NON-NLS-1$
 	public static final String EXTENSION_WSDL = "wsdl"; //$NON-NLS-1$
 	    
-    private static XmiHeaderCache CACHE;
-
-	public static void setCache(XmiHeaderCache cache) {
-		ModelFileUtil.CACHE = cache;
-	}
-
 	/**
 	 * Return true if the File represents a MetaMatrix model file or an xsd file 
 	 * this method does not check if the file exists in a project with
@@ -196,23 +184,11 @@
      */
     public static XMIHeader getXmiHeader( final File resource ) {
         if (resource != null && resource.isFile() && resource.exists() && resource.canRead() ) {
-            //check cache
-            if(CACHE != null) {
-                XMIHeader header = CACHE.getCachedXmiHeader(resource);
-                if(header != null) {
-                    return header;
-                }
-            }
-            
             if(isVdbArchiveFile(resource)) {
                 return getXmiHeaderForVdbArchive(resource);
             }
             try {
                 XMIHeader header = XMIHeaderReader.readHeader(resource);
-                //add to cache
-                if(CACHE != null) {
-                    CACHE.setXmiHeaderToCache(resource, header);
-                }
                 return header;
             } catch (MetaMatrixCoreException e) {
             	LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage());

Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -23,25 +23,24 @@
 package org.teiid.metadata.index;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 
-import org.teiid.connector.metadata.FileRecordImpl;
 import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.AnnotationRecordImpl;
 import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
 import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
 import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
 import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
-import org.teiid.connector.metadata.runtime.MetadataConstants;
+import org.teiid.connector.metadata.runtime.KeyRecord;
 import org.teiid.connector.metadata.runtime.ModelRecordImpl;
 import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
 import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
 import org.teiid.connector.metadata.runtime.TableRecordImpl;
-import org.teiid.connector.metadata.runtime.TransformationRecordImpl;
+import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.connector.metadata.runtime.ColumnRecordImpl.SearchType;
+import org.teiid.connector.metadata.runtime.DatatypeRecordImpl.Variety;
 import org.teiid.core.index.IEntryResult;
 import org.teiid.internal.core.index.EntryResult;
 import org.teiid.internal.core.index.IIndexConstants;
@@ -149,8 +148,8 @@
      * @param queryResult
      * @param container Container reference to be set on the record
      */
-    public static Collection getMetadataRecord(final IEntryResult[] queryResult) {
-        final Collection records = new ArrayList(queryResult.length);
+    public static List<AbstractMetadataRecord> getMetadataRecord(final IEntryResult[] queryResult) {
+        final List records = new ArrayList(queryResult.length);
         for (int i = 0; i < queryResult.length; i++) {
             final AbstractMetadataRecord record = getMetadataRecord(queryResult[i].getWord());
             if (record != null) {
@@ -176,11 +175,11 @@
             case MetadataConstants.RECORD_TYPE.CALLABLE: return createProcedureRecord(record);
             case MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER: return createProcedureParameterRecord(record);
             case MetadataConstants.RECORD_TYPE.COLUMN: return createColumnRecord(record);
-            case MetadataConstants.RECORD_TYPE.ACCESS_PATTERN:
-            case MetadataConstants.RECORD_TYPE.INDEX:
-            case MetadataConstants.RECORD_TYPE.RESULT_SET: 
-            case MetadataConstants.RECORD_TYPE.UNIQUE_KEY:
-            case MetadataConstants.RECORD_TYPE.PRIMARY_KEY: return createColumnSetRecord(record);
+            case MetadataConstants.RECORD_TYPE.ACCESS_PATTERN: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.AccessPattern));
+            case MetadataConstants.RECORD_TYPE.INDEX: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.Index));
+            case MetadataConstants.RECORD_TYPE.RESULT_SET: return createColumnSetRecord(record, new ColumnSetRecordImpl());
+            case MetadataConstants.RECORD_TYPE.UNIQUE_KEY: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.Unique));
+            case MetadataConstants.RECORD_TYPE.PRIMARY_KEY: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.Primary));
             case MetadataConstants.RECORD_TYPE.FOREIGN_KEY: return createForeignKeyRecord(record);
             case MetadataConstants.RECORD_TYPE.DATATYPE: return createDatatypeRecord(record);
             case MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM:
@@ -189,9 +188,6 @@
             case MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM:
             case MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM:
             case MetadataConstants.RECORD_TYPE.PROC_TRANSFORM: return createTransformationRecord(record);
-            case MetadataConstants.RECORD_TYPE.ANNOTATION: return createAnnotationRecord(record);
-            case MetadataConstants.RECORD_TYPE.PROPERTY: return createPropertyRecord(record);
-            case MetadataConstants.RECORD_TYPE.FILE: return createFileRecord(record);
             default:
                 throw new IllegalArgumentException("Invalid record type for creating MetadataRecord "+record[0]); //$NON-NLS-1$
         }
@@ -325,10 +321,10 @@
                              (String)tokens.get(tokenIndex++));
         
         // The next token is the max set size
-        model.setMaxSetSize( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+        tokenIndex++;
         
         // The next token is the model type
-        model.setModelType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+        model.setModelType(ModelRecordImpl.Type.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
         
         // The next token is the primary metamodel Uri
         model.setPrimaryMetamodelUri(getObjectValue((String)tokens.get(tokenIndex++)));
@@ -336,11 +332,6 @@
         // The next token are the supports flags
         char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
         model.setVisible(getBooleanValue(supportFlags[0]));
-        model.setSupportsDistinct(getBooleanValue(supportFlags[1]));
-        model.setSupportsJoin(getBooleanValue(supportFlags[2]));
-        model.setSupportsOrderBy(getBooleanValue(supportFlags[3]));
-        model.setSupportsOuterJoin(getBooleanValue(supportFlags[4]));
-        model.setSupportsWhereAll(getBooleanValue(supportFlags[5]));
 
 		// The next tokens are footer values - the footer will contain the version number for the index record
 		setRecordFooterValues(model, tokens, tokenIndex);
@@ -360,15 +351,8 @@
         int indexVersion = getIndexVersion(record);
 
         // The tokens are the standard header values
-        int tokenIndex = 0;
+        int tokenIndex = 2;
         
-        char recordType = ((String)tokens.get(tokenIndex++)).charAt(0);
-        
-        // The next token is the transformation type        
-        transform.setTransformationType(getObjectValue(getTransformTypeForRecordType(recordType)));
-        // The next token is the name of the transformed object
-        transform.setFullName(getObjectValue(((String)tokens.get(tokenIndex++))));
-
         // The next token is the UUID of the transformed object
         getObjectValue((String)tokens.get(tokenIndex++));
 
@@ -394,19 +378,6 @@
         return transform;
     }
     
-    protected static String getTransformTypeForRecordType(final char recordType) {
-        switch (recordType) {
-            case MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM: return TransformationRecordImpl.Types.SELECT;
-            case MetadataConstants.RECORD_TYPE.INSERT_TRANSFORM: return TransformationRecordImpl.Types.INSERT;
-            case MetadataConstants.RECORD_TYPE.UPDATE_TRANSFORM: return TransformationRecordImpl.Types.UPDATE;
-            case MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM: return TransformationRecordImpl.Types.DELETE;
-            case MetadataConstants.RECORD_TYPE.PROC_TRANSFORM: return TransformationRecordImpl.Types.PROCEDURE;
-            case MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM: return TransformationRecordImpl.Types.MAPPING;
-            default:
-                throw new IllegalArgumentException("Invalid record type, for key " + recordType); //$NON-NLS-1$
-        }
-    }
-    
     protected static short getKeyTypeForRecordType(final char recordType) {
         switch (recordType) {
             case MetadataConstants.RECORD_TYPE.UNIQUE_KEY: return MetadataConstants.KEY_TYPES.UNIQUE_KEY;
@@ -441,7 +412,7 @@
         table.setCardinality( Integer.parseInt((String)tokens.get(tokenIndex++)) );
 
         // The next token is the tableType
-        table.setTableType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+        table.setTableType(TableRecordImpl.Type.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
 
         // The next token are the supports flags
         char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
@@ -452,12 +423,16 @@
             table.setMaterialized(getBooleanValue(supportFlags[3]));
         }
 
-        // The next token are the UUIDs for the column references
-        List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
-        table.setColumnIDs(uuids);
+        // The next token are the UUIDs for the column references (no longer stored on the record)
+        tokenIndex++;
 
         // The next token is the UUID of the primary key
-        table.setPrimaryKeyID(getObjectValue((String)tokens.get(tokenIndex++)));
+        String id = getObjectValue((String)tokens.get(tokenIndex++));
+        if (id != null) {
+        	KeyRecord pk = new KeyRecord(KeyRecord.Type.Primary);
+        	pk.setUUID(id);
+        	table.setPrimaryKey(pk);
+        }
 
         tokenIndex+=4; //skip reading uuids for associated records
 
@@ -474,6 +449,16 @@
         return table;
     }
 
+	private static List<ColumnRecordImpl> createColumns(List<String> uuids) {
+		List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(uuids.size());
+        for (String uuid : uuids) {
+        	ColumnRecordImpl column = new ColumnRecordImpl();
+        	column.setUUID(uuid);
+			columns.add(column);
+		}
+		return columns;
+	}
+
     /**
      * Create a ColumnRecord instance from the specified index record
      */
@@ -500,15 +485,12 @@
         column.setSigned(getBooleanValue(supportFlags[4]));
         column.setCurrency(getBooleanValue(supportFlags[5]));
         column.setFixedLength(getBooleanValue(supportFlags[6]));
-        if (includeInputParameterFlag(indexVersion)) {
-            column.setTransformationInputParameter(getBooleanValue(supportFlags[7]));
-        }
 
         // The next token is the search type
-        column.setNullType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+        column.setNullType(NullType.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
 
         // The next token is the search type
-        column.setSearchType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+        column.setSearchType(SearchType.values()[3 - Integer.parseInt((String)tokens.get(tokenIndex++))]);
 
         // The next token is the length
         column.setLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
@@ -567,10 +549,9 @@
     /**
      * Create a ColumnSetRecord instance from the specified index record
      */
-    public static ColumnSetRecordImpl createColumnSetRecord(final char[] record) {
+    public static ColumnSetRecordImpl createColumnSetRecord(final char[] record, ColumnSetRecordImpl columnSet) {
         final String str = new String(record);
         final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
-        final ColumnSetRecordImpl columnSet = new ColumnSetRecordImpl(getKeyTypeForRecordType(record[0]));
 
         // Extract the index version information from the record 
         int indexVersion = getIndexVersion(record);
@@ -583,7 +564,7 @@
 
         // The next token are the UUIDs for the column references
         List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
-        columnSet.setColumnIDs(uuids);
+        columnSet.setColumns(createColumns(uuids));
 
         if (record[0] == MetadataConstants.RECORD_TYPE.UNIQUE_KEY || record[0] == MetadataConstants.RECORD_TYPE.PRIMARY_KEY) {
         	//read the values from the index to update the tokenindex, but we don't actually use them.
@@ -614,7 +595,7 @@
         
         // The next token are the UUIDs for the column references
         List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
-        fkRecord.setColumnIDs(uuids);
+        fkRecord.setColumns(createColumns(uuids));
 
         // The next token is the UUID of the unique key
         fkRecord.setUniqueKeyID(getObjectValue((String)tokens.get(tokenIndex++)));        
@@ -640,7 +621,7 @@
         int tokenIndex = 0;
 
         // Set the record type
-        dt.setRecordType(((String)tokens.get(tokenIndex++)).toCharArray()[0]);
+        tokenIndex++;
 
         // Set the datatype and basetype identifiers
         dt.setDatatypeID(getObjectValue((String)tokens.get(tokenIndex++)));
@@ -652,22 +633,21 @@
         dt.setNameInSource(getObjectValue((String)tokens.get(tokenIndex++)));
         
         // Set the variety type and its properties
-        dt.setVarietyType( Short.parseShort((String)tokens.get(tokenIndex++)) );
-        List props = getIDs((String)tokens.get(tokenIndex++), indexVersion);
-        dt.setVarietyProps(props);
+        dt.setVarietyType(Variety.values()[Short.parseShort((String)tokens.get(tokenIndex++))]);
+        getIDs((String)tokens.get(tokenIndex++), indexVersion);
         
         // Set the runtime and java class names
         dt.setRuntimeTypeName(getObjectValue((String)tokens.get(tokenIndex++)));
         dt.setJavaClassName(getObjectValue((String)tokens.get(tokenIndex++)));
         
         // Set the datatype type
-        dt.setType( Short.parseShort((String)tokens.get(tokenIndex++)) );
+        dt.setType(DatatypeRecordImpl.Type.values()[Short.parseShort((String)tokens.get(tokenIndex++))]);
         
         // Set the search type
-        dt.setSearchType( Short.parseShort((String)tokens.get(tokenIndex++)) );
+        dt.setSearchType(SearchType.values()[3 - Integer.parseInt((String)tokens.get(tokenIndex++))]);
         
         // Set the null type
-        dt.setNullType( Short.parseShort((String)tokens.get(tokenIndex++)) );
+        dt.setNullType(NullType.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
  
         // Set the boolean flags
         char[] booleanValues = ((String)tokens.get(tokenIndex++)).toCharArray();
@@ -780,7 +760,7 @@
         paramRd.setScale(Integer.parseInt((String)tokens.get(tokenIndex++)) );
 
         // The next token is the null type
-        paramRd.setNullType(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+        paramRd.setNullType(NullType.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
 
         // The next token is the precision
         paramRd.setPrecision(Integer.parseInt((String)tokens.get(tokenIndex++)) );
@@ -788,8 +768,26 @@
         // The next token is the position
         paramRd.setPosition(Integer.parseInt((String)tokens.get(tokenIndex++)) );
 
-        // The next token is parameter type        
-        paramRd.setType(Short.parseShort((String)tokens.get(tokenIndex++)));
+        // The next token is parameter type
+        ProcedureParameterRecordImpl.Type type = null;
+        switch (Short.parseShort((String)tokens.get(tokenIndex++))) {
+        case MetadataConstants.PARAMETER_TYPES.IN_PARM:
+        	type = ProcedureParameterRecordImpl.Type.In;
+        	break;
+        case MetadataConstants.PARAMETER_TYPES.INOUT_PARM:
+        	type = ProcedureParameterRecordImpl.Type.InOut;
+        	break;
+        case MetadataConstants.PARAMETER_TYPES.OUT_PARM:
+        	type = ProcedureParameterRecordImpl.Type.Out;
+        	break;
+        case MetadataConstants.PARAMETER_TYPES.RESULT_SET:
+        	type = ProcedureParameterRecordImpl.Type.ResultSet;
+        	break;
+        case MetadataConstants.PARAMETER_TYPES.RETURN_VALUE:
+        	type = ProcedureParameterRecordImpl.Type.ReturnValue;
+        	break;
+        }
+        paramRd.setType(type);
 
         // The next token is flag for parameter optional prop
         char[] flags = ((String)tokens.get(tokenIndex++)).toCharArray();
@@ -804,19 +802,15 @@
     /**
      * Create a AnnotationRecord instance from the specified index record
      */
-    public static AnnotationRecordImpl createAnnotationRecord(final char[] record) {
+    public static String createAnnotationRecord(final char[] record) {
         final String str = new String(record);
         final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
-        final AnnotationRecordImpl annotation = new AnnotationRecordImpl();
 
         // Extract the index version information from the record 
         int indexVersion = getIndexVersion(record);
 
         // The tokens are the standard header values
-        int tokenIndex = 0;
-        setRecordHeaderValues(annotation, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
-                             (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
-                             (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+        int tokenIndex = 6;
 
         if(includeAnnotationProperties(indexVersion)) {
 			// The next token are the properties, ignore it not going to be read any way
@@ -824,75 +818,32 @@
         }
 
         // The next token is the description
-        annotation.setDescription((String)tokens.get(tokenIndex++));
-
-        // The next tokens are footer values
-		setRecordFooterValues(annotation, tokens, tokenIndex);        
-
-        return annotation;
+        return (String)tokens.get(tokenIndex++);
     }
 
     /**
      * Create a PropertyRecord instance from the specified index record
      */
-    public static PropertyRecordImpl createPropertyRecord(final char[] record) {
-        final String str = new String(record);
-        final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
-        final PropertyRecordImpl property = new PropertyRecordImpl();
-
-        int indexVersion = getIndexVersion(record);
-
-        // The tokens are the standard header values
-        int tokenIndex = 0;
-
-        // The next token is the record type
-        String recordType = (String)tokens.get(tokenIndex++);
-        property.setRecordType(recordType.toCharArray()[0]);
-
-        // The next token is the object ID
-        String objectID = (String)tokens.get(tokenIndex++);
-        property.setUUID(getObjectValue(objectID));
-
-        // The next token is the property name
-        property.setPropertyName( (String)tokens.get(tokenIndex++) );
-
-        // The next token is the property value
-        property.setPropertyValue((String)tokens.get(tokenIndex++));
+    public static LinkedHashMap<String, String> createPropertyRecord(IEntryResult[] records) {
+    	if (records == null || records.length == 0) {
+    		return null;
+    	}
+    	LinkedHashMap<String, String> result = new LinkedHashMap<String, String>();
         
-        // for newer records
-        if(!includeAnnotationProperties(indexVersion)) {
-	        // The next token is extension boolean
-	        tokenIndex++;
-        }
+    	for (IEntryResult iEntryResult : records) {
+        	final String str = new String(iEntryResult.getWord());
+            final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
 
-		// The next tokens are footer values
-		setRecordFooterValues(property, tokens, tokenIndex);
+            // The tokens are the standard header values
+            int tokenIndex = 2;
 
-        return property;
+            result.put( (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+		}
+
+        return result;
     }
     
     /**
-     * Create a FileRecord instance from the specified index record
-     */
-    public static FileRecordImpl createFileRecord(final char[] record) {
-        final String str = new String(record);
-        final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
-        final FileRecordImpl file = new FileRecordImpl();
-
-        // The tokens are the standard header values
-        int tokenIndex = 0;
-
-        // The next token is the record type
-        String recordType = (String)tokens.get(tokenIndex++);
-        file.setRecordType(recordType.toCharArray()[0]);
-
-        // The next token is the relative path to the file in vdb
-        file.setPathInVdb((String)tokens.get(tokenIndex++) );
-
-        return file;
-    }
-
-    /**
      * Search for and return the version number associated with this record.
      * If no version information is found encoded in the record then the
      * version number of NONVERSIONED_RECORD_INDEX_VERSION will be returned.
@@ -930,7 +881,7 @@
         return false;
     }
 
-    public static List getIDs(final String values, final int indexVersionNumber) {
+    public static List<String> getIDs(final String values, final int indexVersionNumber) {
         if (StringUtil.isEmpty(values)) {
             return Collections.EMPTY_LIST;
         }
@@ -1055,11 +1006,9 @@
                                               final String nameInSource, 
                                               final String parentObjectID) {
         
-        record.setRecordType(recordType.toCharArray()[0]);
         record.setUUID(getObjectValue(objectID));
         record.setFullName(fullName);
         record.setNameInSource(getObjectValue(nameInSource));
-        record.setParentUUID(getObjectValue(parentObjectID));
     }
 
     /**

Copied: trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java (from rev 1529, trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java	                        (rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata.index;
+
+import java.util.ResourceBundle;
+
+import com.metamatrix.core.BundleUtil;
+
+/**
+ * CommonPlugin
+ * <p>Used here in <code>metadata.runtime</code> to have access to the new
+ * logging framework for <code>LogManager</code>.</p>
+ */
+public class RuntimeMetadataPlugin {
+
+	/**
+     * The plug-in identifier of this plugin
+     * (value <code>"com.metamatrix.metadata.runtime"</code>).
+	 */
+	public static final String PLUGIN_ID = "org.teiid.metadata"; //$NON-NLS-1$
+
+	public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
+	                                                         PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
+}


Property changes on: trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -27,7 +27,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.teiid.connector.metadata.runtime.MetadataConstants;
 import org.teiid.core.index.IEntryResult;
 import org.teiid.internal.core.index.Index;
 
@@ -248,10 +247,9 @@
 	 * @throws MetamatrixCoreException If there is an error looking up indexes
 	 * @since 4.2
 	 */
-    public static Index[] getIndexes(final String indexName, final IndexMetadataStore selector) {
+    public static Index[] getIndexes(final String indexName, Index[] indexes) {
 		ArgCheck.isNotEmpty(indexName);
         // The the index file name for the record type
-        final Index[] indexes = selector.getIndexes();
         final List<Index> tmp = new ArrayList<Index>(indexes.length);
         for (int i = 0; i < indexes.length; i++) {
             Index coreIndex = indexes[i];

Copied: trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java (from rev 1529, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TransformationRecordImpl.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java	                        (rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata.index;
+
+import java.util.List;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+
+/**
+ * TransformationRecordImpl
+ */
+public class TransformationRecordImpl extends AbstractMetadataRecord {
+
+    public static interface Types {
+	    public static final String MAPPING            = "Mapping"; //$NON-NLS-1$
+	    public static final String SELECT             = "Select"; //$NON-NLS-1$
+	    public static final String INSERT             = "Insert"; //$NON-NLS-1$
+	    public static final String UPDATE             = "Update"; //$NON-NLS-1$
+	    public static final String DELETE             = "Delete"; //$NON-NLS-1$
+	    public static final String PROCEDURE          = "Procedure"; //$NON-NLS-1$
+	}
+
+	private String transformation;
+    private String transformationType;
+    private List bindings;
+    private List schemaPaths;
+    private String resourcePath;
+    
+    /**
+     * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getTransformation()
+     */
+    public String getTransformation() {
+        return transformation;
+    }
+
+    /*
+     * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getBindings()
+     */
+    public List getBindings() {
+        return this.bindings;
+    }
+
+    /*
+     * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getSchemaPaths()
+     */
+    public List getSchemaPaths() {
+        return schemaPaths;
+    }
+
+    /*
+     * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getTransformationType()
+     */
+    public String getTransformationType() {
+        return transformationType;
+    }
+
+    /**
+     * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getType()
+     */
+    public String getType() {
+        return this.transformationType;
+    }
+
+    // ==================================================================================
+    //                      P U B L I C   M E T H O D S
+    // ==================================================================================
+
+    /**
+     * @param string
+     */
+    public void setTransformation(final String string) {
+        transformation = string;
+    }
+
+    /**
+     * @param string
+     */
+    public void setTransformationType(String string) {
+        transformationType = string;
+    }
+
+    /**
+     * @param collection
+     */
+    public void setBindings(List bindings) {
+        this.bindings = bindings;
+    }
+
+    /**
+     * @param collection
+     */
+    public void setSchemaPaths(List collection) {
+        schemaPaths = collection;
+    }
+    
+    /**
+     * @return
+     */
+    public String getResourcePath() {
+        return resourcePath;
+    }
+
+    /**
+     * @param path
+     */
+    public void setResourcePath(String path) {
+        resourcePath = path;
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer(100);
+        sb.append(getClass().getSimpleName());
+        sb.append(" name="); //$NON-NLS-1$
+        sb.append(getName());
+        sb.append(", nameInSource="); //$NON-NLS-1$
+        sb.append(getNameInSource());
+        sb.append(", uuid="); //$NON-NLS-1$
+        sb.append(getUUID());
+        return sb.toString();
+    }
+
+}
\ No newline at end of file


Property changes on: trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java	2009-10-24 18:07:35 UTC (rev 1536)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java	2009-10-25 02:00:37 UTC (rev 1537)
@@ -23,44 +23,44 @@
 package org.teiid.metadata.index;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
 
 import com.metamatrix.common.vdb.api.VDBArchive;
 import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.LRUCache;
 import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.query.metadata.MetadataStore;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 
 public class VDBMetadataFactory {
 	
+	public static LRUCache<URL, QueryMetadataInterface> VDB_CACHE = new LRUCache<URL, QueryMetadataInterface>(10);
+	
 	public static QueryMetadataInterface getVDBMetadata(String vdbFile) {
-		MetadataSource source;
 		try {
-			source = new VDBArchive(new FileInputStream(vdbFile));
+			return getVDBMetadata(new File(vdbFile).toURI().toURL());
 		} catch (IOException e) {
 			throw new MetaMatrixRuntimeException(e);
 		}
-		IndexMetadataStore selector;
-		try {
-			selector = new IndexMetadataStore(source);
-		} catch (IOException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-        return new TransformationMetadata(new CompositeMetadataStore(Arrays.asList(selector), source)); 
     }
 	
 	public static QueryMetadataInterface getVDBMetadata(URL vdbURL) throws IOException {
+		QueryMetadataInterface vdb = VDB_CACHE.get(vdbURL);
+		if (vdb != null) {
+			return vdb;
+		}
 		MetadataSource source = new VDBArchive(vdbURL.openStream());
-		IndexMetadataStore selector = new IndexMetadataStore(source);
-        return new TransformationMetadata(new CompositeMetadataStore(Arrays.asList(selector), source)); 
+		IndexMetadataFactory selector = new IndexMetadataFactory(source);
+        vdb = new TransformationMetadata(new CompositeMetadataStore(Arrays.asList(selector.getMetadataStore()), source));
+        VDB_CACHE.put(vdbURL, vdb);
+        return vdb;
     }	
 	
 	public static QueryMetadataInterface getVDBMetadata(String[] vdbFile) {
@@ -73,7 +73,7 @@
 	        	if (i == 0) {
 	        		source = tempSource;
 	        	}
-				selectors.add(new IndexMetadataStore(tempSource));
+				selectors.add(new IndexMetadataFactory(tempSource).getMetadataStore());
 			} catch (IOException e) {
 				throw new MetaMatrixRuntimeException(e);
 			}        



More information about the teiid-commits mailing list