Author: shawkins
Date: 2009-07-08 00:55:17 -0400 (Wed, 08 Jul 2009)
New Revision: 1107
Added:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseException.java
trunk/metadata/src/main/java/org/
trunk/metadata/src/main/java/org/teiid/
trunk/metadata/src/main/java/org/teiid/connector/
trunk/metadata/src/main/java/org/teiid/connector/metadata/
trunk/metadata/src/main/java/org/teiid/connector/metadata/FileRecordImpl.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/IObjectQuery.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexCriteriaBuilder.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexFile.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorConstants.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorMetadata.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataLiteralCriteria.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataResultsPostProcessor.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataSearchCriteria.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/MultiObjectSource.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/ObjectQueryProcessor.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyFileObjectSource.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyHolder.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/ReflectionWrapper.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/ResultsIterator.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/RuntimeVdbRecord.java
trunk/metadata/src/main/java/org/teiid/connector/metadata/VdbMetadataContext.java
trunk/metadata/src/main/java/org/teiid/core/
trunk/metadata/src/main/java/org/teiid/core/index/
trunk/metadata/src/main/java/org/teiid/core/index/IDocument.java
trunk/metadata/src/main/java/org/teiid/core/index/IEntryResult.java
trunk/metadata/src/main/java/org/teiid/core/index/IIndex.java
trunk/metadata/src/main/java/org/teiid/core/index/IIndexer.java
trunk/metadata/src/main/java/org/teiid/core/index/IIndexerOutput.java
trunk/metadata/src/main/java/org/teiid/core/index/IQueryResult.java
trunk/metadata/src/main/java/org/teiid/internal/
trunk/metadata/src/main/java/org/teiid/internal/core/
trunk/metadata/src/main/java/org/teiid/internal/core/index/
trunk/metadata/src/main/java/org/teiid/internal/core/index/Block.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexOutput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/CodeByteStream.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/EntryResult.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/Field.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/FileDocument.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/FileListBlock.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/GammaCompressedIndexBlock.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IIndexConstants.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/InMemoryIndex.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexBlock.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexInput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexOutput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexSummary.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFile.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFileHashedArray.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexerOutput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/MergeFactory.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/PropertyDocument.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/SafeRandomAccessFile.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexBlock.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexInput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/Util.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/WordEntry.java
trunk/metadata/src/main/java/org/teiid/metadata/
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/
trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.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
trunk/metadata/src/main/resources/org/
trunk/metadata/src/main/resources/org/teiid/
trunk/metadata/src/main/resources/org/teiid/metadata/i18n.properties
Removed:
trunk/engine/src/main/java/com/metamatrix/metadata/runtime/exception/VirtualDatabaseDoesNotExistException.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/FileRecordImpl.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/IndexFile.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MetadataConnectorConstants.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MultiObjectSource.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyFileObjectSource.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyHolder.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/ResultsIterator.java
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/RuntimeVdbRecord.java
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataPlugin.java
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/VDBMetadataFactory.java
Modified:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/RuntimeMetadataAdminAPI.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataLiteralCriteria.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestMetadataSearchCriteriaBuilder.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectProcedure.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQuery.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/TestPropertyFileObjectSource.java
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestIndexCriteriaBuilder.java
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataConnectorMetadata.java
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataResultsPostProcessor.java
trunk/metadata/src/test/java/com/metamatrix/core/util/TestCharOperation.java
trunk/metadata/src/test/java/com/metamatrix/internal/core/index/TestGammaCompressedIndexBlock.java
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeQueryMetadata.java
trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java
trunk/server/src/main/java/com/metamatrix/dqp/service/metadata/IndexMetadataService.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataCatalog.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeVDBDeleteUtility.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/VDBTreeUtility.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceAPI.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseMetadata.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/exception/InvalidStateException.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicElementID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicGroupID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicKeyID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataObject.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicModelID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicProcedureID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseID.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseMetadata.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/MetadataCache.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/UpdateController.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataWriter.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBDefnFactory.java
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java
trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformVDBService.java
trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeMetadataCatalog.java
trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerConfigAdminImpl.java
trunk/server/src/test/java/com/metamatrix/dqp/service/metadata/TestIndexMetadataService.java
trunk/server/src/test/java/com/metamatrix/server/admin/apiimpl/TestRuntimeMetadataHelper.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModel.java
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModelSelf.java
Log:
TEIID-684 repackaging remaining metadata classes to ensure there are no overlapping
classes with designer
Modified:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -24,7 +24,6 @@
import java.util.Properties;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
public interface MetadataObject extends java.io.Serializable{
Copied:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
(from rev 1105,
trunk/engine/src/main/java/com/metamatrix/metadata/runtime/exception/VirtualDatabaseDoesNotExistException.java)
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
(rev 0)
+++
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,79 @@
+/*
+ * 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 com.metamatrix.metadata.runtime.api;
+
+
+/**
+ * Thrown when the VirtualDatabase is not found.
+ */
+public class VirtualDatabaseDoesNotExistException extends VirtualDatabaseException {
+
+ /**
+ * No-arg costructor required by Externalizable semantics
+ */
+ public VirtualDatabaseDoesNotExistException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public VirtualDatabaseDoesNotExistException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public VirtualDatabaseDoesNotExistException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param code A code denoting the exception
+ * @param e An exception to nest within this one
+ */
+ public VirtualDatabaseDoesNotExistException( Exception e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public VirtualDatabaseDoesNotExistException( Exception e, String code, String message
) {
+ super( e, code, message );
+ }
+}
+
Property changes on:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseException.java
(from rev 1098,
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/exception/VirtualDatabaseException.java)
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseException.java
(rev 0)
+++
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseException.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,91 @@
+/*
+ * 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 com.metamatrix.metadata.runtime.api;
+
+import com.metamatrix.vdb.edit.loader.VdbProcessingException;
+/**
+ * The base exception from which all Runtime Metadata Exceptions extend.
+ */
+public class VirtualDatabaseException extends VdbProcessingException {
+
+ public static final String NO_MODELS = "1"; //$NON-NLS-1$
+ public static final String MODEL_NON_DEPLOYABLE_STATE = "2";
//$NON-NLS-1$
+ public static final String VDB_NON_DEPLOYABLE_STATE = "3"; //$NON-NLS-1$
+
+ /**
+ * No-arg costructor required by Externalizable semantics
+ */
+ public VirtualDatabaseException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public VirtualDatabaseException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public VirtualDatabaseException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from an exception to chain to this one.
+ *
+ * @param e An exception to nest within this one
+ */
+ public VirtualDatabaseException(Exception e) {
+ super(e);
+ }
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param code A code denoting the exception
+ * @param e An exception to nest within this one
+ */
+ public VirtualDatabaseException( Exception e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public VirtualDatabaseException( Exception e, String code, String message ) {
+ super( e, code, message );
+ }
+}
+
Property changes on:
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseException.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/RuntimeMetadataAdminAPI.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/RuntimeMetadataAdminAPI.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/RuntimeMetadataAdminAPI.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -32,8 +32,8 @@
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.vdb.api.VDBDefn;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
import com.metamatrix.platform.admin.api.PermissionDataNode;
import com.metamatrix.platform.admin.api.SubSystemAdminAPI;
Modified:
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java
===================================================================
---
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -30,13 +30,12 @@
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
import org.teiid.connector.language.IQuery;
+import org.teiid.connector.metadata.IObjectQuery;
+import org.teiid.connector.metadata.ObjectQueryProcessor;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
-import com.metamatrix.connector.metadata.internal.IObjectQuery;
-import com.metamatrix.connector.metadata.internal.MetadataException;
import com.metamatrix.connector.metadata.internal.ObjectQuery;
-import com.metamatrix.connector.metadata.internal.ObjectQueryProcessor;
/**
* Adapter to expose the object processing logic via the standard connector API.
@@ -63,12 +62,7 @@
this.processor = new ObjectQueryProcessor(connection.getMetadataObjectSource());
this.query = new ObjectQuery(metadata, command);
- try {
- queryResults = processor.process(this.query);
- } catch (MetadataException e) {
- throw new ConnectorException(e);
- }
-
+ queryResults = processor.process(this.query);
}
@Override
Modified:
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java
===================================================================
---
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -36,11 +36,11 @@
import org.teiid.connector.language.IParameter;
import org.teiid.connector.language.IQuery;
import org.teiid.connector.language.ICompareCriteria.Operator;
+import org.teiid.connector.metadata.MetadataConnectorConstants;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.connector.metadata.MetadataConnectorConstants;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
-import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.StringUtil;
Modified:
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java
===================================================================
---
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -35,13 +35,13 @@
import org.teiid.connector.language.IParameter;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.language.IParameter.Direction;
+import org.teiid.connector.metadata.MetadataConnectorConstants;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
import org.teiid.connector.metadata.runtime.Element;
import org.teiid.connector.metadata.runtime.MetadataObject;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.metadata.MetadataConnectorConstants;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
-import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.StringUtil;
Modified:
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java
===================================================================
---
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -34,11 +34,12 @@
import javax.sql.rowset.serial.SerialClob;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.metadata.MetadataConnectorConstants;
+import org.teiid.connector.metadata.ReflectionWrapper;
+import org.teiid.connector.metadata.ResultsIterator;
import com.metamatrix.common.types.ClobType;
import com.metamatrix.common.vdb.api.VDBFile;
-import com.metamatrix.connector.metadata.MetadataConnectorConstants;
-import com.metamatrix.connector.metadata.ResultsIterator;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.ObjectConverterUtil;
Modified:
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java
===================================================================
---
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -37,6 +37,7 @@
import org.teiid.connector.language.IMetadataReference;
import org.teiid.connector.language.IQuery;
import org.teiid.connector.language.ISelectSymbol;
+import org.teiid.connector.metadata.IObjectQuery;
import org.teiid.connector.metadata.runtime.Element;
import org.teiid.connector.metadata.runtime.MetadataObject;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -86,12 +87,8 @@
/* (non-Javadoc)
* @see com.metamatrix.connector.metadata.internal.IObjectQuery#getTableNameInSource()
*/
- public String getTableNameInSource() throws MetadataException {
- try {
- return getMetadataObjectName(getGroup());
- } catch (ConnectorException e) {
- throw new MetadataException(e);
- }
+ public String getTableNameInSource() throws ConnectorException {
+ return getMetadataObjectName(getGroup());
}
private IGroup getGroup() {
@@ -205,12 +202,8 @@
/* (non-Javadoc)
* @see com.metamatrix.connector.metadata.internal.IObjectQuery#getCriteria()
*/
- public Map getCriteria() throws MetadataException {
- try {
- initCriteria();
- } catch (ConnectorException e) {
- throw new MetadataException(e);
- }
+ public Map getCriteria() throws ConnectorException {
+ initCriteria();
return this.criteriaMap;
}
Modified:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataLiteralCriteria.java
===================================================================
---
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataLiteralCriteria.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataLiteralCriteria.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.metadata.index;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
+
import junit.framework.TestCase;
Modified:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestMetadataSearchCriteriaBuilder.java
===================================================================
---
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestMetadataSearchCriteriaBuilder.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestMetadataSearchCriteriaBuilder.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -30,11 +30,11 @@
import junit.framework.TestCase;
import org.teiid.connector.language.ICommand;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.sql.lang.Command;
Modified:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectProcedure.java
===================================================================
---
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectProcedure.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectProcedure.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -24,11 +24,11 @@
import java.util.Map;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import junit.framework.TestCase;
import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.query.unittest.QueryMetadataInterfaceBuilder;
Modified:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQuery.java
===================================================================
---
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQuery.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQuery.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,12 +22,12 @@
package com.metamatrix.connector.metadata.internal;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
+import org.teiid.connector.metadata.MetadataSearchCriteria;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import junit.framework.TestCase;
import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
-import com.metamatrix.connector.metadata.index.MetadataSearchCriteria;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.query.unittest.QueryMetadataInterfaceBuilder;
Modified:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java
===================================================================
---
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -30,6 +30,7 @@
import java.util.List;
import org.teiid.connector.language.ICommand;
+import org.teiid.connector.metadata.ObjectQueryProcessor;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-07-08
03:42:18 UTC (rev 1106)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -42,12 +42,12 @@
import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
import org.teiid.dqp.internal.datamgr.language.BatchedUpdatesImpl;
+import org.teiid.metadata.index.VDBMetadataFactory;
import com.metamatrix.cdk.IConnectorHost;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
/**
* A simple test environment to execute commands on a connector.
Modified:
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java
===================================================================
---
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -28,9 +28,9 @@
import org.teiid.connector.language.ICommand;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.metadata.index.VDBMetadataFactory;
import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
import com.metamatrix.query.metadata.QueryMetadataInterface;
/**
Modified:
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java
===================================================================
---
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -77,8 +77,6 @@
assertEquals("SUMMITDATA", group.getName()); //$NON-NLS-1$
assertEquals("SummitData.SUMMITDATA", group.getFullName());
//$NON-NLS-1$
assertEquals(14, group.getColumns().size());
- group = tableIter.next();
-
assertNotNull(group.getUUID());
}
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -26,6 +26,7 @@
import java.util.Properties;
import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.metadata.QueryMetadataCache;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationEnvironment;
@@ -38,7 +39,6 @@
import com.metamatrix.dqp.service.MetadataService;
import com.metamatrix.dqp.service.VDBLifeCycleListener;
import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.service.metadata.QueryMetadataCache;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -47,8 +47,8 @@
import com.metamatrix.dqp.service.VDBLifeCycleListener;
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.jdbc.JDBCPlugin;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.vdb.runtime.BasicModelInfo;
import com.metamatrix.vdb.runtime.BasicVDBDefn;
Modified:
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/embedded/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -52,8 +52,8 @@
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -28,7 +28,7 @@
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
/**
* This interface defines methods which are specific to dealing with VDBs
Deleted:
trunk/engine/src/main/java/com/metamatrix/metadata/runtime/exception/VirtualDatabaseDoesNotExistException.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/metadata/runtime/exception/VirtualDatabaseDoesNotExistException.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/engine/src/main/java/com/metamatrix/metadata/runtime/exception/VirtualDatabaseDoesNotExistException.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,78 +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 com.metamatrix.metadata.runtime.exception;
-
-/**
- * Thrown when the VirtualDatabase is not found.
- */
-public class VirtualDatabaseDoesNotExistException extends VirtualDatabaseException {
-
- /**
- * No-arg costructor required by Externalizable semantics
- */
- public VirtualDatabaseDoesNotExistException() {
- super();
- }
-
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public VirtualDatabaseDoesNotExistException( String message ) {
- super( message );
- }
-
- /**
- * Construct an instance with the message and error code specified.
- *
- * @param message A message describing the exception
- * @param code The error code
- */
- public VirtualDatabaseDoesNotExistException( String code, String message ) {
- super( code, message );
- }
-
- /**
- * Construct an instance from a message and an exception to chain to this one.
- *
- * @param code A code denoting the exception
- * @param e An exception to nest within this one
- */
- public VirtualDatabaseDoesNotExistException( Exception e, String message ) {
- super( e, message );
- }
-
- /**
- * Construct an instance from a message and a code and an exception to
- * chain to this one.
- *
- * @param e An exception to nest within this one
- * @param message A message describing the exception
- * @param code A code denoting the exception
- */
- public VirtualDatabaseDoesNotExistException( Exception e, String code, String message
) {
- super( e, code, message );
- }
-}
-
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/FileRecordImpl.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/FileRecordImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/FileRecordImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,234 +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 com.metamatrix.connector.metadata;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
-import com.metamatrix.modeler.internal.core.index.ModelFileUtil;
-
-/**
- * @since 4.2
- */
-public class FileRecordImpl extends AbstractMetadataRecord {
-
- /**
- * Constants for names of accessor methods on the FileRecords.
- * Note the names do have "get" on them, this is also the nameInsource
- * of the parameters on SystemPhysicalModel.
- * @since 4.3
- */
- public static interface MetadataMethodNames {
- String PATH_IN_VDB_FIELD = "getPathInVdb"; //$NON-NLS-1$
- }
-
- public final static String INDEX_EXT = "INDEX"; //$NON-NLS-1$
-
- private String pathInVdb;
- private String[] tokens;
- private String[] tokenReplacements;
- private MetadataSource selector;
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getPathInVdb()
- * @since 4.2
- */
- public String getPathInVdb() {
- return this.pathInVdb;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#isBinary()
- * @since 4.2
- */
- public boolean getBinary() {
- if(this.pathInVdb != null && this.pathInVdb.endsWith(INDEX_EXT)) {
- return true;
- }
- return false;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getContent()
- * @since 4.2
- */
- public InputStream getContent() {
- if(this.tokens != null) {
- return MetadataSourceUtil.getFileContent(getPathInVdb(), selector, tokens,
tokenReplacements);
- }
- File f = this.selector.getFile(getPathInVdb());
- if (f != null) {
- try {
- return new FileInputStream(f);
- } catch (FileNotFoundException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
- return null;
- }
-
- /**
- * @param pathInVdb The pathInVdb to set.
- * @since 4.2
- */
- public void setPathInVdb(final String pathInVdb) {
- this.pathInVdb = pathInVdb;
- }
-
- /**
- * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#getTokenReplacementString1()
- * @since 4.2
- */
- public String[] getTokens() {
- return this.tokens;
- }
-
- /**
- * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#getTokenReplacements()
- * @since 4.2
- */
- public String[] getTokenReplacements() {
- return this.tokenReplacements;
- }
- /**
- * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#setTokens(java.lang.String[])
- * @since 4.2
- */
- public void setTokens(final String[] tokens) {
- this.tokens = tokens;
- }
- /**
- * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#setTokenReplacementString2(java.lang.String[])
- * @since 4.2
- */
- public void setTokenReplacements(final String[] tokenReplacements) {
- this.tokenReplacements = tokenReplacements;
- }
-
- /**
- * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#setIndexSelector(com.metamatrix.modeler.core.index.IndexSelector)
- * @since 4.2
- */
- public void setIndexSelector(final MetadataSource selector) {
- this.selector = selector;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getFileRecord()
- * @since 4.2
- */
- public FileRecordImpl getFileRecord() {
- return this;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getModelName()
- * @since 4.2
- */
- public String getModelName() {
- if(isModelFile()) {
- return FileUtils.getBaseFileNameWithoutExtension(this.pathInVdb);
- }
- return null;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#isIndexFile()
- * @since 4.2
- */
- public boolean isIndexFile() {
- if(this.pathInVdb != null && this.pathInVdb.endsWith(INDEX_EXT)) {
- return true;
- }
- return false;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getModelName()
- * @since 4.2
- */
- public boolean isModelFile() {
- if(this.pathInVdb != null) {
- File fileInVdb = this.selector.getFile(this.pathInVdb);
- return ModelFileUtil.isModelFile(fileInVdb);
- }
- return false;
- }
-
- /**
- * Compare two records for equality.
- */
- public boolean equals(Object obj) {
-
- if(obj == this) {
- return true;
- }
-
- if(obj == null || obj.getClass() != this.getClass()) {
- return false;
- }
-
- FileRecordImpl other = (FileRecordImpl)obj;
-
- if(!EquivalenceUtil.areEqual(this.getPathInVdb(), other.getPathInVdb())) { return
false; }
- if(!EquivalenceUtil.areEqual(this.getTokens(), other.getTokens())) { return
false; }
- if(!EquivalenceUtil.areEqual(this.getTokenReplacements(),
other.getTokenReplacements())) { return false; }
-
- return true;
- }
-
- /**
- * Get hashcode for From. WARNING: The hash code relies on the variables
- * in the record, so changing the variables will change the hash code, causing
- * a select to be lost in a hash structure. Do not hash a record if you plan
- * to change it.
- */
- public int hashCode() {
- int myHash = 0;
- if (this.pathInVdb != null) {
- myHash = HashCodeUtil.hashCode(myHash, this.pathInVdb);
- }
- if (this.tokens != null) {
- myHash = HashCodeUtil.hashCode(myHash, this.tokens);
- }
- if (this.tokenReplacements != null) {
- myHash = HashCodeUtil.hashCode(myHash, this.tokenReplacements);
- }
-
- return myHash;
- }
-
- public String toString() {
- return this.getPathInVdb();
- }
-}
\ No newline at end of file
Deleted: trunk/metadata/src/main/java/com/metamatrix/connector/metadata/IndexFile.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/IndexFile.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/IndexFile.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,76 +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 com.metamatrix.connector.metadata;
-
-import java.util.Collection;
-import java.util.Map;
-
-import com.metamatrix.connector.metadata.index.MetadataConnectorMetadata;
-import com.metamatrix.connector.metadata.index.VdbMetadataContext;
-import com.metamatrix.connector.metadata.internal.IObjectSource;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.service.metadata.CompositeMetadataStore;
-
-/**
- * Adapter to present metadata from a VDB file as an IObjectSource.
- */
-public class IndexFile implements IObjectSource {
-
- // metadata instance used for querying indexfiles
- private final MetadataConnectorMetadata queryTransformationMetadata;
-
- /**
- * Constructor IndexFile
- * @param indexSelector Selector pointing to vdbs with index files
- * @param vdbName The name of the vdb the user logged on with
- * @param vdbVersion The version of the vdb the user logged on with
- * @param vdbService The service object used to lookup additional info about vdb like
visibility
- * may be null, will assume default settings if null.
- * @since 4.3
- */
- public IndexFile(final CompositeMetadataStore indexSelector, final String vdbName,
final String vdbVersion, final VDBService vdbService) {
- ArgCheck.isNotNull(indexSelector);
- ArgCheck.isNotNull(vdbName);
- ArgCheck.isNotNull(vdbVersion);
-
- // construct a context object used to pass onto metadata
- VdbMetadataContext context = new VdbMetadataContext();
- context.setVdbName(vdbName);
- context.setVdbVersion(vdbVersion);
- context.setVdbService(vdbService);
-
- // construct the metadata instance
- this.queryTransformationMetadata = new MetadataConnectorMetadata(context,
indexSelector);
- }
-
- /**
- * @see
com.metamatrix.connector.metadata.internal.IObjectSource#getObjects(java.lang.String,
java.util.Map)
- * @since 4.3
- */
- public Collection getObjects(String tableName, Map criteria) {
- ArgCheck.isNotNull(tableName);
- ArgCheck.isNotNull(criteria);
- return queryTransformationMetadata.getObjects(tableName, criteria);
- }
-}
\ No newline at end of file
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MetadataConnectorConstants.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MetadataConnectorConstants.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MetadataConnectorConstants.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,79 +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 com.metamatrix.connector.metadata;
-
-
-/**
- * Constants used in MetadataConnector, some of the values for these constants
- * are used in NameInSource of the SystemPhysical model.
- * @since 4.3
- */
-public class MetadataConnectorConstants {
-
- /**
- * Extension for property files containing enumeration of property values,
- * some of the properties in the files are like standard ModelTypes, Search types
etc.
- * This is used in nameinsource for a table which would get populated with the
values
- * from the property file.
- */
- public static final String PROPERTIES_FILE_EXTENSION = ".properties";
//$NON-NLS-1$
-
- /**
- * Charcter used in NameInSource of a table, the table is be populated by object
resulting
- * from calling the method enclosed in () charcters on the metadata record for the
table.
- */
- public static final char START_METHOD_NAME_CHAR = '(';
-
- /**
- * Charcter used in NameInSource of a table, the table is be populated by object
resulting
- * from calling the method enclosed in () charcters on the metadata record for the
table.
- */
- public static final char END_METHOD_NAME_CHAR = ')';
-
- /**
- * Charcter used to seperate method names used in NameInSource, if multiple
- * methods need to be invoked to arrive at value for a column of object from the
table,
- * each method to be invoked on the resulting object is seperated by this
charachter.
- */
- public static final char METHOD_DELIMITER = '.';
-
- /**
- * Charcter used in NameInSource of a table to seperate the index file and the record
type
- * charchter. This may be necessary if a given index file has multiple types of
records.
- */
- public static final char RECORD_TYPE_SEPERATOR = '#';
-
- /**
- * The prefix to the NameInsource for column/parameter to arrive at a method name
- * to be invoked on a MetadataRecord to get the value used to populate the
column/parameter.
- */
- public static final String GET_METHOD_PREFIX = "get"; //$NON-NLS-1$
-
-
- /**
- * The prefix to the NameInSource for column/parameter to arrive at a method name to
be invoked
- * on a MetadataRecord to set the value used for some computation using the record.
- */
- public static final String SET_METHOD_PREFIX = "set"; //$NON-NLS-1$
-
-}
\ No newline at end of file
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MultiObjectSource.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MultiObjectSource.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MultiObjectSource.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,53 +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 com.metamatrix.connector.metadata;
-
-import java.util.Collection;
-import java.util.Map;
-
-import com.metamatrix.connector.metadata.internal.IObjectSource;
-
-/**
- * Holds two object sources and routes queries to them based on the suffix of the group
name.
- */
-public class MultiObjectSource implements IObjectSource {
- private IObjectSource primaryObjectSource;
- private IObjectSource secondaryObjectSource;
- private String secondaryGroupNameSuffix;
-
- public MultiObjectSource(IObjectSource primaryObjectSource, String
secondaryGroupNameSuffix, IObjectSource objectSource) {
- this.primaryObjectSource = primaryObjectSource;
- this.secondaryGroupNameSuffix = secondaryGroupNameSuffix;
- this.secondaryObjectSource = objectSource;
- }
-
- /*
- * @see
com.metamatrix.connector.metadata.internal.ISimpleObjectSource#getObjects(java.lang.String,
java.util.Map)
- */
- public Collection getObjects(String groupName, Map criteria) {
- if (groupName.endsWith(secondaryGroupNameSuffix)) {
- return secondaryObjectSource.getObjects(groupName, criteria);
- }
- return primaryObjectSource.getObjects(groupName, criteria);
- }
-}
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyFileObjectSource.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyFileObjectSource.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyFileObjectSource.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,100 +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 com.metamatrix.connector.metadata;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.metamatrix.connector.metadata.internal.IObjectSource;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-/**
- * Read a property file and deliver the results as an object source.
- * This plugs into the object connector to make a property file visible as a relational
table.
- */
-public class PropertyFileObjectSource implements IObjectSource {
- private String propertyFilePath;
-
- public PropertyFileObjectSource() {
- this("com/metamatrix/connector/metadata/enum/"); //$NON-NLS-1$
- }
-
- public PropertyFileObjectSource(String propertyFilePath) {
- this.propertyFilePath = propertyFilePath;
- }
-
- /*
- * @see
com.metamatrix.connector.metadata.internal.IObjectSource#getObjects(java.lang.String,
java.util.Map)
- */
- public Collection getObjects(String propertyFileName, Map criteria) {
- if (criteria != null && criteria.size() >0) {
- throw new UnsupportedOperationException("Criteria is not
supported"); //$NON-NLS-1$
- }
- InputStream input = null;
- try {
- propertyFileName = expandPropertyFileName(propertyFileName);
-
- input =
this.getClass().getClassLoader().getResourceAsStream(propertyFileName);
- if (input == null) {
- throw new MetaMatrixRuntimeException(propertyFileName+" file not
found");
- }
- //input = new BufferedInputStream(new FileInputStream(propertyFileName));
- Properties properties = new Properties();
- properties.load(input);
- List results = new ArrayList();
- for (Iterator iterator=properties.entrySet().iterator(); iterator.hasNext();
) {
- Map.Entry entry = (Map.Entry) iterator.next();
- PropertyHolder holder = new PropertyHolder(new Integer((String)
entry.getKey()));
- holder.setValue(entry.getValue());
- results.add(holder);
- }
- return results;
- } catch (FileNotFoundException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (IOException e) {
- throw new MetaMatrixRuntimeException(e);
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- private String expandPropertyFileName(String propertyFileName) {
- if (propertyFilePath == null) {
- return propertyFileName;
- }
- return propertyFilePath + propertyFileName;
- }
-
-}
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyHolder.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyHolder.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyHolder.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,62 +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 com.metamatrix.connector.metadata;
-
-import java.util.Map;
-
-/**
- */
-public class PropertyHolder implements Map.Entry {
- private Object key;
- private String value;
-
- /**
- *
- */
- public PropertyHolder(Object key) {
- this.key = key;
- }
-
- /*
- * @see java.util.Map.Entry#getKey()
- */
- public Object getKey() {
- return key;
- }
-
- /*
- * @see java.util.Map.Entry#getValue()
- */
- public Object getValue() {
- return value;
- }
-
- /*
- * @see java.util.Map.Entry#setValue(java.lang.Object)
- */
- public Object setValue(Object value) {
- this.value = (String) value;
- return this.value;
- }
-
-}
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/ResultsIterator.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/ResultsIterator.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/ResultsIterator.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,69 +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 com.metamatrix.connector.metadata;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-public class ResultsIterator implements Iterator {
-
- public interface ResultsProcessor {
-
- void createRows(Object resultObject, List rows);
-
- }
-
- private final ResultsProcessor objectQueryProcessor;
- private LinkedList rowBuffer = new LinkedList();
- private Iterator resultsIter;
-
- public ResultsIterator(ResultsProcessor objectQueryProcessor, Iterator resultsIter) {
- this.objectQueryProcessor = objectQueryProcessor;
- this.resultsIter = resultsIter;
- }
-
- public boolean hasNext() {
- return rowBuffer.size() > 0 || resultsIter.hasNext();
- }
-
- public Object next() {
- if (rowBuffer.size() > 0) {
- return rowBuffer.removeFirst();
- }
- if (!resultsIter.hasNext()) {
- throw new NoSuchElementException();
- }
- this.objectQueryProcessor.createRows(resultsIter.next(), rowBuffer);
- return rowBuffer.removeFirst();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
-}
\ No newline at end of file
Deleted:
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/RuntimeVdbRecord.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/RuntimeVdbRecord.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/RuntimeVdbRecord.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,49 +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 com.metamatrix.connector.metadata;
-
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-
-
-/**
- * Extends a VdbRecord object with additional runtime data.
- * This allows the System model to obtain the VDB name and VDB version of the deployed
VDB.
- */
-public class RuntimeVdbRecord extends AbstractMetadataRecord {
- private String vdbRuntimeName;
- private String vdbRuntimeVersion;
-
- public RuntimeVdbRecord(String vdbRuntimeName, String vdbRuntimeVersion) {
- this.vdbRuntimeName = vdbRuntimeName;
- this.vdbRuntimeVersion = vdbRuntimeVersion;
- }
-
- public String getVdbRuntimeName() {
- return vdbRuntimeName;
- }
-
- public String getVdbRuntimeVersion() {
- return vdbRuntimeVersion;
- }
-
-}
Deleted:
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataPlugin.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataPlugin.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataPlugin.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -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 com.metamatrix.metadata.runtime;
-
-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 = "com.metamatrix.metadata.runtime";
//$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/com/metamatrix/metadata/runtime/VDBMetadataFactory.java
===================================================================
---
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/VDBMetadataFactory.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/main/java/com/metamatrix/metadata/runtime/VDBMetadataFactory.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -1,84 +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 com.metamatrix.metadata.runtime;
-
-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 com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.service.metadata.CompositeMetadataStore;
-import com.metamatrix.dqp.service.metadata.TransformationMetadata;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.modeler.internal.core.index.IndexMetadataStore;
-import com.metamatrix.query.metadata.MetadataStore;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-public class VDBMetadataFactory {
-
- public static QueryMetadataInterface getVDBMetadata(String vdbFile) {
- MetadataSource source;
- try {
- source = new VDBArchive(new FileInputStream(vdbFile));
- } 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 {
- MetadataSource source = new VDBArchive(vdbURL.openStream());
- IndexMetadataStore selector = new IndexMetadataStore(source);
- return new TransformationMetadata(new
CompositeMetadataStore(Arrays.asList(selector), source));
- }
-
- public static QueryMetadataInterface getVDBMetadata(String[] vdbFile) {
-
- List<MetadataStore> selectors = new ArrayList<MetadataStore>();
- MetadataSource source = null;
- for (int i = 0; i < vdbFile.length; i++){
- try {
- MetadataSource tempSource = new VDBArchive(new File(vdbFile[i]));
- if (i == 0) {
- source = tempSource;
- }
- selectors.add(new IndexMetadataStore(tempSource));
- } catch (IOException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- return new TransformationMetadata(new CompositeMetadataStore(selectors,
source));
- }
-}
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/FileRecordImpl.java
(from rev 1105,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/FileRecordImpl.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/FileRecordImpl.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/FileRecordImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,234 @@
+/*
+ * 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.connector.metadata;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.metadata.index.ModelFileUtil;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.EquivalenceUtil;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.metadata.runtime.api.MetadataSource;
+import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
+
+/**
+ * @since 4.2
+ */
+public class FileRecordImpl extends AbstractMetadataRecord {
+
+ /**
+ * Constants for names of accessor methods on the FileRecords.
+ * Note the names do have "get" on them, this is also the nameInsource
+ * of the parameters on SystemPhysicalModel.
+ * @since 4.3
+ */
+ public static interface MetadataMethodNames {
+ String PATH_IN_VDB_FIELD = "getPathInVdb"; //$NON-NLS-1$
+ }
+
+ public final static String INDEX_EXT = "INDEX"; //$NON-NLS-1$
+
+ private String pathInVdb;
+ private String[] tokens;
+ private String[] tokenReplacements;
+ private MetadataSource selector;
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getPathInVdb()
+ * @since 4.2
+ */
+ public String getPathInVdb() {
+ return this.pathInVdb;
+ }
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#isBinary()
+ * @since 4.2
+ */
+ public boolean getBinary() {
+ if(this.pathInVdb != null && this.pathInVdb.endsWith(INDEX_EXT)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getContent()
+ * @since 4.2
+ */
+ public InputStream getContent() {
+ if(this.tokens != null) {
+ return MetadataSourceUtil.getFileContent(getPathInVdb(), selector, tokens,
tokenReplacements);
+ }
+ File f = this.selector.getFile(getPathInVdb());
+ if (f != null) {
+ try {
+ return new FileInputStream(f);
+ } catch (FileNotFoundException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param pathInVdb The pathInVdb to set.
+ * @since 4.2
+ */
+ public void setPathInVdb(final String pathInVdb) {
+ this.pathInVdb = pathInVdb;
+ }
+
+ /**
+ * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#getTokenReplacementString1()
+ * @since 4.2
+ */
+ public String[] getTokens() {
+ return this.tokens;
+ }
+
+ /**
+ * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#getTokenReplacements()
+ * @since 4.2
+ */
+ public String[] getTokenReplacements() {
+ return this.tokenReplacements;
+ }
+ /**
+ * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#setTokens(java.lang.String[])
+ * @since 4.2
+ */
+ public void setTokens(final String[] tokens) {
+ this.tokens = tokens;
+ }
+ /**
+ * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#setTokenReplacementString2(java.lang.String[])
+ * @since 4.2
+ */
+ public void setTokenReplacements(final String[] tokenReplacements) {
+ this.tokenReplacements = tokenReplacements;
+ }
+
+ /**
+ * @see
com.metamatrix.modeler.core.metadata.runtime.FileRecord#setIndexSelector(com.metamatrix.modeler.core.index.IndexSelector)
+ * @since 4.2
+ */
+ public void setIndexSelector(final MetadataSource selector) {
+ this.selector = selector;
+ }
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getFileRecord()
+ * @since 4.2
+ */
+ public FileRecordImpl getFileRecord() {
+ return this;
+ }
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getModelName()
+ * @since 4.2
+ */
+ public String getModelName() {
+ if(isModelFile()) {
+ return FileUtils.getBaseFileNameWithoutExtension(this.pathInVdb);
+ }
+ return null;
+ }
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#isIndexFile()
+ * @since 4.2
+ */
+ public boolean isIndexFile() {
+ if(this.pathInVdb != null && this.pathInVdb.endsWith(INDEX_EXT)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see com.metamatrix.modeler.core.metadata.runtime.FileRecord#getModelName()
+ * @since 4.2
+ */
+ public boolean isModelFile() {
+ if(this.pathInVdb != null) {
+ File fileInVdb = this.selector.getFile(this.pathInVdb);
+ return ModelFileUtil.isModelFile(fileInVdb);
+ }
+ return false;
+ }
+
+ /**
+ * Compare two records for equality.
+ */
+ public boolean equals(Object obj) {
+
+ if(obj == this) {
+ return true;
+ }
+
+ if(obj == null || obj.getClass() != this.getClass()) {
+ return false;
+ }
+
+ FileRecordImpl other = (FileRecordImpl)obj;
+
+ if(!EquivalenceUtil.areEqual(this.getPathInVdb(), other.getPathInVdb())) { return
false; }
+ if(!EquivalenceUtil.areEqual(this.getTokens(), other.getTokens())) { return
false; }
+ if(!EquivalenceUtil.areEqual(this.getTokenReplacements(),
other.getTokenReplacements())) { return false; }
+
+ return true;
+ }
+
+ /**
+ * Get hashcode for From. WARNING: The hash code relies on the variables
+ * in the record, so changing the variables will change the hash code, causing
+ * a select to be lost in a hash structure. Do not hash a record if you plan
+ * to change it.
+ */
+ public int hashCode() {
+ int myHash = 0;
+ if (this.pathInVdb != null) {
+ myHash = HashCodeUtil.hashCode(myHash, this.pathInVdb);
+ }
+ if (this.tokens != null) {
+ myHash = HashCodeUtil.hashCode(myHash, this.tokens);
+ }
+ if (this.tokenReplacements != null) {
+ myHash = HashCodeUtil.hashCode(myHash, this.tokenReplacements);
+ }
+
+ return myHash;
+ }
+
+ public String toString() {
+ return this.getPathInVdb();
+ }
+}
\ No newline at end of file
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/IObjectQuery.java (from
rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/internal/IObjectQuery.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/IObjectQuery.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/connector/metadata/IObjectQuery.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,47 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.Map;
+
+import org.teiid.connector.api.ConnectorException;
+
+public interface IObjectQuery {
+
+ public static Integer NO_CASE = new Integer(0);
+ public static Integer UPPER_CASE = new Integer(1);
+ public static Integer LOWER_CASE = new Integer(2);
+
+ String getTableNameInSource() throws ConnectorException;
+
+ String[] getColumnNames();
+
+ void checkType(int i, Object value);
+
+ void checkCaseType(int i, Object value);
+
+ Integer getCaseType(int i);
+
+ Map getCriteria() throws ConnectorException;
+
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/IObjectQuery.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexCriteriaBuilder.java (from
rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/index/IndexCriteriaBuilder.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexCriteriaBuilder.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexCriteriaBuilder.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,524 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
+import org.teiid.metadata.index.IndexConstants;
+import org.teiid.metadata.index.SimpleIndexUtil;
+
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.StringUtil;
+
+
+/**
+ * This is used by MetadataConnector to build criteria patterns used to query index
files.
+ * This has generic methods to build criteria that matches a particular header patterns
that
+ * is part of most index records. It also can be extended to create a pattern that
matches
+ * the record pattern for a given record type.
+ * @since 4.3
+ */
+public class IndexCriteriaBuilder {
+
+ private static final String RECORD_STRING_SPACE =
StringUtil.Constants.EMPTY_STRING+IndexConstants.RECORD_STRING.SPACE;
+ private static final String RECORD_STRING_TRUE =
StringUtil.Constants.EMPTY_STRING+IndexConstants.RECORD_STRING.TRUE;
+ private static final String RECORD_STRING_FALSE =
StringUtil.Constants.EMPTY_STRING+IndexConstants.RECORD_STRING.FALSE;
+
+ /**
+ * Return the prefix match string constructed from a map of
+ * match criteria values. The match criteria map is keyed
+ * on field names found in the MetadataRecord.
+ * @param indexName The name of the index file that would be queried using the prefix
returned.
+ * @param criteria the map of match criteria to use
+ * @return the prefix string
+ */
+ public static String getMatchPrefix(final String indexName, final Map criteria) {
+ ArgCheck.isNotEmpty(indexName);
+ ArgCheck.isNotNull(criteria);
+
+ // get updated criteria map
+ Map updatedCriteria = getUpdatedCriteria(indexName, criteria);
+
+ // if there is no criteria return prefix with just the record type
+ // if available from indexName
+ if(criteria.isEmpty()) {
+ return getRecordDefaultMatchPrefix(updatedCriteria);
+ }
+
+ // datatype records have a different pattern that most index records, create
+ // a match prefix specific to datatypes
+ if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.DATATYPES_INDEX)) {
+ return getDatatypeRecordMatchPrefix(updatedCriteria);
+ // property records have a different pattern that most index records, create
+ // a match prefix specific to properties
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROPERTIES_INDEX))
{
+ return getPropertiesRecordMatchPrefix(updatedCriteria);
+ // model records have a different pattern that most index records, create
+ // a match prefix specific to models
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MODELS_INDEX)) {
+ return getModelRecordMatchPrefix(updatedCriteria);
+ }
+ // for all other records get the generic header prefix
+ // append header prefix first
+ return getRecordHeaderMatchPrefix(updatedCriteria);
+ }
+
+ /**
+ * Return the pattern match string constructed from a map of
+ * match criteria values. The match criteria map is keyed
+ * on field names found in the MetadataRecord.
+ * @param indexName The name of the index file that would be queried using the
pattern returned.
+ * @param criteria the map of match criteria to use
+ * @return the pattern string
+ */
+ public static String getMatchPattern(final String indexName, final Map criteria) {
+ ArgCheck.isNotEmpty(indexName);
+ ArgCheck.isNotNull(criteria);
+
+ // get updated criteria map
+ Map updatedCriteria = getUpdatedCriteria(indexName, criteria);
+
+
+ final StringBuffer sb = new StringBuffer(100);
+ // if there is no criteria match everything
+ if(criteria.isEmpty()) {
+ sb.append(getRecordDefaultMatchPattern(updatedCriteria));
+ } else {
+ // datatype records have a different pattern that most index records, create
+ // a match pattern specific to datatypes
+ if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.DATATYPES_INDEX)) {
+ sb.append(getDatatypeRecordMatchPattern(updatedCriteria));
+ // property records have a different pattern that most index records, create
+ // a match pattern specific to properties
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROPERTIES_INDEX)) {
+ sb.append(getPropertiesRecordMatchPattern(updatedCriteria));
+ } else {
+ // for all other records get the generic header pattern
+ // append header pattern first
+ sb.append(getRecordHeaderMatchPattern(updatedCriteria));
+ }
+ }
+ // append a wildcard char to the end of the header contructed
+ sb.append(IndexConstants.RECORD_STRING.MATCH_CHAR);
+ // currently cannot match footern without knowing the number of tokens in each
record
+ //sb.append(getRecordFooterMatchPattern(tmp));
+
+ return sb.toString();
+ }
+
+ /**
+ * Return a map of crteria with upper cased key names and include addition criteria
+ * for record type if available.
+ * @param indexName The name of the index file / may be used to look up recordtype
criteria
+ * @param criteria The criteria built from metadata query
+ * @return The updated criteria map
+ * @since 4.3
+ */
+ private static Map getUpdatedCriteria(final String indexName, final Map criteria) {
+
+ final Map tmp = new HashMap(criteria.size());
+ // based on the indexName try to derive the recordtype and make it part of
criteria
+ if(getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD) == null) {
+ String record_type =
SimpleIndexUtil.getRecordTypeForIndexFileName(indexName);
+ if(record_type != null) {
+ MetadataLiteralCriteria literalCriteria = new
MetadataLiteralCriteria(AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD,
record_type);
+
tmp.put(AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD.toUpperCase(),
literalCriteria);
+ }
+ }
+ // Copy the map so that the keys, corresponding to field names in the
+ // metadatarecord classes, can be converted to upper case
+ for (Iterator iter = criteria.entrySet().iterator(); iter.hasNext();) {
+ final Map.Entry entry = (Map.Entry)iter.next();
+ final String key = (String)entry.getKey();
+ final Object value = entry.getValue();
+ tmp.put(key.toUpperCase(),value);
+ }
+
+ return tmp;
+ }
+
+ /**
+ * Construct a prefix string based on the values found in the map
+ * Every index records contain a header portion of the form:
+ * Header : recordType|
+ * @param criteria the map of match criteria to use
+ * @return The prefix string matching the header
+ * @since 4.3
+ */
+ private static String getRecordDefaultMatchPrefix(final Map criteria) {
+
+ String recordTypeCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ if(isPrefixCriteriaString(recordTypeCriteria)) {
+ final StringBuffer sb = new StringBuffer(2);
+ // record type
+ sb.append(recordTypeCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+
+ return sb.toString();
+ }
+ return null;
+ }
+
+ /**
+ * Construct a prefix string based on the values found in the map
+ * Every index records contain a header portion of the form:
+ * Header : recordType|
+ * @param criteria the map of match criteria to use
+ * @return The pattern string matching the header
+ * @since 4.3
+ */
+ private static String getRecordDefaultMatchPattern(final Map criteria) {
+ final StringBuffer sb = new StringBuffer(2);
+ // record type
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD, sb);
+ return sb.toString();
+ }
+
+ /**
+ * Construct a pattern string based on the values found in the map
+ * Most index records contain a header portion of the form:
+ * Header : recordType|upperFullName|objectID|fullName|nameInSource|parentObjectID
+ * @param criteria the map of match criteria to use
+ * @return The pattern strig matching the header
+ * @since 4.3
+ */
+ private static String getRecordHeaderMatchPattern(final Map criteria) {
+
+ final StringBuffer sb = new StringBuffer(100);
+ // record type
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD, sb);
+ // name matching is already done in fourth field, just a wild card
+ appendMultiMatchField(sb);
+ // uuid
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.UUID_FIELD, sb);
+ // fullName or ModelName and/or Name
+ // if fullName is not available in the criteria, use the ModerName and/or Name in
criteria
+ String fullNameCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.FULL_NAME_FIELD);
+ if(fullNameCriteria == null) {
+ String recordTypeCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ // if its a model or vdb record only criteria possible is on Name
+ if(recordTypeCriteria != null &&
+
(recordTypeCriteria.equalsIgnoreCase(StringUtil.Constants.EMPTY_STRING+IndexConstants.RECORD_TYPE.MODEL)))
{
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_FIELD, sb);
+ } else {
+ String modelNameCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.MODEL_NAME_FIELD);
+ if(modelNameCriteria != null) {
+ sb.append(modelNameCriteria);
+ sb.append(IndexConstants.NAME_DELIM_CHAR);
+ }
+ sb.append(IndexConstants.RECORD_STRING.MATCH_CHAR);
+ String nameCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_FIELD);
+ if(nameCriteria != null) {
+ sb.append(IndexConstants.NAME_DELIM_CHAR);
+ sb.append(nameCriteria);
+ }
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ }
+ } else {
+ appendFieldValue(fullNameCriteria, sb);
+ }
+ // name in source
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_IN_SOURCE_FIELD,sb);
+ // parent uuid
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.PARENT_UUID_FIELD, sb);
+
+ return sb.toString();
+ }
+
+ /**
+ * Construct a prefix string based on the values found in the map
+ * Most index records contain a header portion of the form:
+ * Header : recordType|upperFullName|objectID|fullName|nameInSource|parentObjectID
+ * @param criteria the map of match criteria to use
+ * @return The prefix string matching the header
+ * @since 4.3
+ */
+ private static String getRecordHeaderMatchPrefix(final Map criteria) {
+
+ String recordTypeCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ String fullNameCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.FULL_NAME_FIELD);
+ if(isPrefixCriteriaString(recordTypeCriteria) &&
isPrefixCriteriaString(fullNameCriteria)) {
+ final StringBuffer sb = new StringBuffer(30);
+ sb.append(recordTypeCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ // full name
+ sb.append(fullNameCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+
+ return sb.toString();
+ }
+ return null;
+ }
+// /**
+// * Construct a pattern string based on the values found in the map
+// * Most index records contain a footer portion of the form:
+// * Header : modelPath|name
+// * @param criteria the map of match criteria to use
+// * @return The pattern strig matching the footer
+// * @since 4.3
+// */
+// private static String getRecordFooterMatchPattern(final Map criteria) {
+//
+// final StringBuffer sb = new StringBuffer(100);
+// appendCriteriaValue(criteria,
MetadataRecord.MetadataFieldNames.PATH_IN_MODEL_FIELD, sb);
+// appendCriteriaValue(criteria, MetadataRecord.MetadataFieldNames.NAME_FIELD,sb);
+//
+// return sb.toString();
+// }
+//
+// /**
+// * Try finding the given fieldName among the keys of the given criteria map, if
available
+// * include its value in the pattern string returned else include a wild card match
char.
+// * @param criteria the map of match criteria to use
+// * @param fieldName The name of the field to look for in the criteria
+// * @return The pattern string matching the fildName
+// * @since 4.3
+// */
+// private static String getMatchPatternForField(final Map criteria, final String
fieldName) {
+// final StringBuffer sb = new StringBuffer(10);
+// String fieldValue = getValueInCriteria(criteria, fieldName);
+// if (fieldValue != null) {
+// sb.append( fieldValue );
+// } else {
+// sb.append( IndexConstants.RECORD_STRING.MATCH_CHAR );
+// }
+// sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+// return sb.toString();
+// }
+
+ /**
+ * Look for the value for the given field in the criteria map, translate it if
+ * necessary to the format stored in index files and return it.
+ * @param criteria the map of match criteria to use
+ * @param fieldName The name of the field to look for in the criteria
+ * @return The value for the given field in the criteria
+ * @since 4.3
+ */
+ protected static String getValueInCriteria(final Map criteria, String fieldName) {
+ // use uppercase value as key
+ fieldName = fieldName.toUpperCase();
+ if (criteria.containsKey(fieldName) && criteria.get(fieldName) != null)
{
+ Object value = criteria.get(fieldName);
+ // only literal criteria are handles here, all other criteria may
+ // be used during post processing.
+ if (value instanceof MetadataLiteralCriteria) {
+ MetadataLiteralCriteria literalCriteria = (MetadataLiteralCriteria)
value;
+ Object literalValue = literalCriteria.getFieldValue();
+ if (literalValue == null) {
+ return RECORD_STRING_SPACE;
+ } else if (literalValue instanceof Boolean) {
+ Boolean booleanValue = (Boolean) literalValue;
+ if (booleanValue.booleanValue()) {
+ return RECORD_STRING_TRUE;
+ }
+ return RECORD_STRING_FALSE;
+ }
+ return literalValue.toString();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Try finding the given fieldName among the keys of the given criteria map, if
available
+ * include its value in the pattern string returned else include a wild card match
char.
+ * @param criteria the map of match criteria to use
+ * @param fieldName The name of the field to look for in the criteria
+ * @param sb The string buffer to append match patern to
+ * @since 4.3
+ */
+ private static void appendCriteriaValue(final Map criteria, final String fieldName,
final StringBuffer sb) {
+ String fieldValue = getValueInCriteria(criteria, fieldName);
+ appendFieldValue(fieldValue, sb);
+ }
+
+ /**
+ * Applend the value of a field and a delimiter if the value is not null include a
wild card match char.
+ * @param criteria the map of match criteria to use
+ * @param fieldValue The value of the field
+ * @param sb The string buffer to append match patern to
+ * @since 4.3
+ */
+ private static void appendFieldValue(final String fieldValue, final StringBuffer sb)
{
+ if (fieldValue != null) {
+ sb.append( fieldValue );
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ } else {
+ appendMultiMatchField(sb);
+ }
+ }
+
+ /**
+ * Append a wild card char to macth any string to the given string buffer.
+ * @param sb The string buffer to append match patern to
+ * @since 4.3
+ */
+ private static void appendMultiMatchField(final StringBuffer sb) {
+ appendFieldValue(IndexConstants.RECORD_STRING.MATCH_CHAR_STRING , sb);
+ }
+
+ /**
+ * This create match prefix specific to model records, gets appended at the end of
the
+ * header. The model records are of the form:
+ * header|maxSetSize|modelType|primaryMetamodelUri|isVisible *|footer|
+ * @param criteria the map of match criteria to use
+ * @return The match prefix for model records
+ * @since 4.3
+ */
+ private static String getModelRecordMatchPrefix(final Map criteria) {
+ String recordTypeCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ String nameCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_FIELD);
+ if(isPrefixCriteriaString(recordTypeCriteria) &&
isPrefixCriteriaString(nameCriteria)) {
+ final StringBuffer sb = new StringBuffer(30);
+ // uuidCriteria
+ sb.append(recordTypeCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ // name
+ sb.append(nameCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+
+ return sb.toString();
+ }
+ return null;
+ }
+
+ /**
+ * This create match pattern specific to property records, gets appended at the end
of the
+ * header. The properties records are of the form:
+ * recordType|objectID|propertyName|value|isExtention|footer|
+ * @param criteria the map of match criteria to use
+ * @return The match pattern for properties records
+ * @since 4.3
+ */
+ private static String getPropertiesRecordMatchPattern(final Map criteria) {
+ final StringBuffer sb = new StringBuffer(100);
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD, sb);
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.UUID_FIELD, sb);
+ appendCriteriaValue(criteria,
PropertyRecordImpl.MetadataFieldNames.PROPERTY_NAME_FIELD, sb);
+ appendCriteriaValue(criteria,
PropertyRecordImpl.MetadataFieldNames.PROPERTY_VALUE_FIELD, sb);
+
+ return sb.toString();
+ }
+
+ /**
+ * This create match prefix specific to property records, gets appended at the end of
the
+ * header. The properties records are of the form:
+ * recordType|objectID|propertyName|value|isExtention|footer|
+ * @param criteria the map of match criteria to use
+ * @return The match prefix for properties records
+ * @since 4.3
+ */
+ private static String getPropertiesRecordMatchPrefix(final Map criteria) {
+ String recordTypeCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ String uuidCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.UUID_FIELD);
+ if(isPrefixCriteriaString(recordTypeCriteria) &&
isPrefixCriteriaString(uuidCriteria)) {
+ final StringBuffer sb = new StringBuffer(100);
+ // record type
+ sb.append(recordTypeCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ // uuidCriteria
+ sb.append(uuidCriteria.toLowerCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ return sb.toString();
+ }
+ return null;
+ }
+
+ /**
+ * This create match pattern specific to datatype records, gets appended at the end
of the
+ * header. The datatype records are of the form:
+ *
recordType|datatypeID|basetypeID|fullName|objectID|nameInSource|varietyType|varietyProps|
+ *
runtimeTypeName|javaClassName|type|searchType|nullType|booleanValues|length|precisionLength|
+ * scale|radix|primitiveTypeID|footer|
+ * @param criteria the map of match criteria to use
+ * @return The match pattern for datatype records
+ * @since 4.3
+ */
+ private static String getDatatypeRecordMatchPattern(final Map criteria) {
+ final StringBuffer sb = new StringBuffer(100);
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD, sb);
+ appendCriteriaValue(criteria,
DatatypeRecordImpl.MetadataFieldNames.DATA_TYPE_UUID, sb);
+ appendCriteriaValue(criteria,
DatatypeRecordImpl.MetadataFieldNames.BASE_TYPE_UUID, sb);
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_FIELD,sb);
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.UUID_FIELD, sb);
+ appendCriteriaValue(criteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_IN_SOURCE_FIELD,sb);
+ appendMultiMatchField(sb);
+ appendMultiMatchField(sb);
+ appendCriteriaValue(criteria,
DatatypeRecordImpl.MetadataFieldNames.RUN_TYPE_NAME, sb);
+
+ return sb.toString();
+ }
+
+ /**
+ * This create match prefix specific to datatype records, gets appended at the end of
the
+ * header. The datatype records are of the form:
+ *
recordType|datatypeID|basetypeID|fullName|objectID|nameInSource|varietyType|varietyProps|
+ *
runtimeTypeName|javaClassName|type|searchType|nullType|booleanValues|length|precisionLength|
+ * scale|radix|primitiveTypeID|footer|
+ * @param criteria the map of match criteria to use
+ * @return The match prefix for datatype records
+ * @since 4.3
+ */
+ private static String getDatatypeRecordMatchPrefix(final Map criteria) {
+ String recordTypeCriteria = getValueInCriteria(criteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ String uuidCriteria = getValueInCriteria(criteria,
DatatypeRecordImpl.MetadataFieldNames.DATA_TYPE_UUID);
+ if(isPrefixCriteriaString(recordTypeCriteria) &&
isPrefixCriteriaString(uuidCriteria)) {
+ final StringBuffer sb = new StringBuffer(100);
+ // record type
+ sb.append(recordTypeCriteria.toUpperCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+ // uuidCriteria
+ sb.append(uuidCriteria.toLowerCase());
+ sb.append(IndexConstants.RECORD_STRING.RECORD_DELIMITER);
+
+ return sb.toString();
+ }
+ return null;
+ }
+
+ /**
+ * Check if the given criteria string can be used in a match prefix.
+ * Makes sure its not empty and there are no wild card charachters in it.
+ * @param criteria Teh string to be used in a preifix
+ * @return true if can be used else false
+ * @since 4.3
+ */
+ private static boolean isPrefixCriteriaString(final String criteria) {
+ boolean prefixCriteria = true;
+ if(StringUtil.isEmpty(criteria)) {
+ prefixCriteria = false;
+ } else {
+ if(criteria.indexOf(IndexConstants.RECORD_STRING.MATCH_CHAR) != -1) {
+ prefixCriteria = false;
+ } else if(criteria.indexOf(IndexConstants.RECORD_STRING.SINGLE_CHAR_MATCH) !=
-1) {
+ prefixCriteria = false;
+ }
+ }
+ return prefixCriteria;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexCriteriaBuilder.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexFile.java (from rev
1105, trunk/metadata/src/main/java/com/metamatrix/connector/metadata/IndexFile.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexFile.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexFile.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,75 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.teiid.metadata.CompositeMetadataStore;
+
+import com.metamatrix.connector.metadata.internal.IObjectSource;
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.dqp.service.VDBService;
+
+/**
+ * Adapter to present metadata from a VDB file as an IObjectSource.
+ */
+public class IndexFile implements IObjectSource {
+
+ // metadata instance used for querying indexfiles
+ private final MetadataConnectorMetadata queryTransformationMetadata;
+
+ /**
+ * Constructor IndexFile
+ * @param indexSelector Selector pointing to vdbs with index files
+ * @param vdbName The name of the vdb the user logged on with
+ * @param vdbVersion The version of the vdb the user logged on with
+ * @param vdbService The service object used to lookup additional info about vdb like
visibility
+ * may be null, will assume default settings if null.
+ * @since 4.3
+ */
+ public IndexFile(final CompositeMetadataStore indexSelector, final String vdbName,
final String vdbVersion, final VDBService vdbService) {
+ ArgCheck.isNotNull(indexSelector);
+ ArgCheck.isNotNull(vdbName);
+ ArgCheck.isNotNull(vdbVersion);
+
+ // construct a context object used to pass onto metadata
+ VdbMetadataContext context = new VdbMetadataContext();
+ context.setVdbName(vdbName);
+ context.setVdbVersion(vdbVersion);
+ context.setVdbService(vdbService);
+
+ // construct the metadata instance
+ this.queryTransformationMetadata = new MetadataConnectorMetadata(context,
indexSelector);
+ }
+
+ /**
+ * @see
com.metamatrix.connector.metadata.internal.IObjectSource#getObjects(java.lang.String,
java.util.Map)
+ * @since 4.3
+ */
+ public Collection getObjects(String tableName, Map criteria) {
+ ArgCheck.isNotNull(tableName);
+ ArgCheck.isNotNull(criteria);
+ return queryTransformationMetadata.getObjects(tableName, criteria);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/IndexFile.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorConstants.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MetadataConnectorConstants.java)
===================================================================
---
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorConstants.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorConstants.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,79 @@
+/*
+ * 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.connector.metadata;
+
+
+/**
+ * Constants used in MetadataConnector, some of the values for these constants
+ * are used in NameInSource of the SystemPhysical model.
+ * @since 4.3
+ */
+public class MetadataConnectorConstants {
+
+ /**
+ * Extension for property files containing enumeration of property values,
+ * some of the properties in the files are like standard ModelTypes, Search types
etc.
+ * This is used in nameinsource for a table which would get populated with the
values
+ * from the property file.
+ */
+ public static final String PROPERTIES_FILE_EXTENSION = ".properties";
//$NON-NLS-1$
+
+ /**
+ * Charcter used in NameInSource of a table, the table is be populated by object
resulting
+ * from calling the method enclosed in () charcters on the metadata record for the
table.
+ */
+ public static final char START_METHOD_NAME_CHAR = '(';
+
+ /**
+ * Charcter used in NameInSource of a table, the table is be populated by object
resulting
+ * from calling the method enclosed in () charcters on the metadata record for the
table.
+ */
+ public static final char END_METHOD_NAME_CHAR = ')';
+
+ /**
+ * Charcter used to seperate method names used in NameInSource, if multiple
+ * methods need to be invoked to arrive at value for a column of object from the
table,
+ * each method to be invoked on the resulting object is seperated by this
charachter.
+ */
+ public static final char METHOD_DELIMITER = '.';
+
+ /**
+ * Charcter used in NameInSource of a table to seperate the index file and the record
type
+ * charchter. This may be necessary if a given index file has multiple types of
records.
+ */
+ public static final char RECORD_TYPE_SEPERATOR = '#';
+
+ /**
+ * The prefix to the NameInsource for column/parameter to arrive at a method name
+ * to be invoked on a MetadataRecord to get the value used to populate the
column/parameter.
+ */
+ public static final String GET_METHOD_PREFIX = "get"; //$NON-NLS-1$
+
+
+ /**
+ * The prefix to the NameInSource for column/parameter to arrive at a method name to
be invoked
+ * on a MetadataRecord to set the value used for some computation using the record.
+ */
+ public static final String SET_METHOD_PREFIX = "set"; //$NON-NLS-1$
+
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorConstants.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorMetadata.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/index/MetadataConnectorMetadata.java)
===================================================================
---
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorMetadata.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorMetadata.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,301 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.index.CharOperation;
+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.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.StringUtil;
+
+/**
+ * Extends the ServerRuntimeMetadata class with additional methods for querying the
indexes.
+ */
+public class MetadataConnectorMetadata {
+
+ // processor for postprocessing metadata results
+ private final MetadataResultsPostProcessor processor;
+ private final CompositeMetadataStore metadataStore;
+ private boolean needSearchPostProcess = false;
+ private VdbMetadataContext context;
+
+ /**
+ * Constructor MetadataConnectorMetadata.
+ * @param context The context object used to pass in info needed by metadata
+ * @since 4.3
+ */
+ public MetadataConnectorMetadata(final VdbMetadataContext context,
CompositeMetadataStore metadataStore) {
+ this.context = context;
+ this.processor = new MetadataResultsPostProcessor(context);
+ this.metadataStore = metadataStore;
+ }
+
+ /**
+ * Get the metadataRecords by querying the indexFile with the given table name
+ * and a Map of criteria to be applied to limit the results.
+ * @param tableName The name of index file with/out a record seperator
+ * @param criteria Map of fieldNames to MetadataSearchCriteria objects
+ * @return Collection of metadata records.
+ * @since 4.3
+ */
+ public Collection getObjects(final String tableName, final Map criteria) {
+ // name of index file could be same as table name (name in source)
+ String indexFileName = tableName;
+ // check if there is record type seperator
+ int separatorLocation =
tableName.indexOf(MetadataConnectorConstants.RECORD_TYPE_SEPERATOR);
+ // if there is a seperator
+ if(separatorLocation != -1) {
+ // arrive at the correct index file name
+ indexFileName = tableName.substring(0,separatorLocation);
+ // get the record type
+ char recordType = tableName.substring(separatorLocation+1).charAt(0);
+ // build a search criteria
+ MetadataSearchCriteria recordTypeCriteria = new
MetadataLiteralCriteria(AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD, new
Character(recordType));
+ // update the criteria map
+
criteria.put(AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD.toUpperCase(),
recordTypeCriteria);
+ }
+
+ // search for metadata records given the indexFileName and criteria
+ try {
+ // initialize the post processing flag to false before very search
+ this.needSearchPostProcess = false;
+ Collection results = findMetadataRecords(indexFileName, criteria);
+ // post process results
+ if(!results.isEmpty()) {
+ return processor.processMetadataRecords(indexFileName, results, criteria,
this.needSearchPostProcess);
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Return all index records in the index file that match the given critera.
+ * @param indexName The name of the index file to be searched
+ * @param criteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @return Collection of metadata records
+ * @throws QueryMetadataException
+ */
+ private Collection findMetadataRecords(final String indexName, final Map criteria)
throws MetaMatrixComponentException {
+
+ // if file records are needed no need to query index files, these are
+ // based on paths of files in vdbs
+ if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.FILES_INDEX)) {
+ return getFileRecords(criteria, false);
+ } else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.VDBS_INDEX)) {
+ return Arrays.asList(new RuntimeVdbRecord(context.getVdbName(),
context.getVdbVersion()));
+ }
+
+ try {
+ // collect prefixes or patterns based on criteria
+ String prefix = null, pattern = null;
+ // short circuit if there is a false criteria
+ if(!hasFalseCriteria(criteria)) {
+ // get a prefix from the criteria if possible
+ String prefixPattern = IndexCriteriaBuilder.getMatchPrefix(indexName,
criteria);
+ // if cannot build a prefix, build a match pattern instead
+ if(prefixPattern == null) {
+ pattern = IndexCriteriaBuilder.getMatchPattern(indexName, criteria);
+ } else {
+ prefix = prefixPattern;
+ }
+ }
+ // find results from the collection of prefix match patterns
+ // or pattern match patterns
+ Collection<AbstractMetadataRecord> records= null;
+ // check if any case functions are used
+ boolean hasCaseFunctions = hasCaseFunctions(criteria);
+ // no prefixes
+ if(pattern != null) {
+ // if no case functions involved do a case sensitive match
+ records = metadataStore.findMetadataRecords(indexName, pattern, false,
!hasCaseFunctions);
+
+ } else if(prefix != null) {
+ // prefix match is always case insensitive (since names in our prefixes are
upper cased)
+ // filter case mismatches in post processing
+ records = metadataStore.findMetadataRecords(indexName, prefix, true, true);
+
+ if(!hasCaseFunctions) {
+ // need post processing since prefix search is case insensitive
+ // if only criteria is record type criteria no post processing
needed
+ if(!criteria.isEmpty()) {
+ if(criteria.size() == 1 &&
criteria.get(AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD.toUpperCase()) !=
null) {
+ needSearchPostProcess = false;
+ } else {
+ needSearchPostProcess = true;
+ }
+ }
+ }
+ }
+ needSearchPostProcess |= (!criteria.isEmpty() &&
this.metadataStore.postProcessFindMetadataRecords());
+ // if there are results get records
+ if (records != null && records.size() > 0) {
+ return getMetadataRecords(records, criteria, hasCaseFunctions);
+ }
+ } catch (MetaMatrixCoreException e) {
+ throw new MetaMatrixComponentException(e, e.getMessage());
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Return the collection of MetadataRecord objects built from the specified array of
IEntryResult.
+ * The resultant collection will be filtered based on the supplied criteria to ensure
no
+ * MetadataRecord instances are returned that do not match the criteria
+ * @param results The array of IEntryResult instances
+ * @param criteria Map of fieldNames to MetadataSearchCriteria objects to use
+ * @return Collection of metadata records
+ * @throws QueryMetadataException
+ */
+ private Collection getMetadataRecords(Collection records, final Map criteria,
+ final boolean hasCaseFunctions) {
+
+ // Filter the records according to the specified criteria
+
+ // Map a copy of the criteria map converting all keys in the map to be
upper-cased
+ final Map updatedCriteria = new HashMap(criteria.size());
+ for (Iterator j = criteria.entrySet().iterator(); j.hasNext();) {
+ final Map.Entry entry = (Map.Entry)j.next();
+ final String key = (String)entry.getKey();
+ updatedCriteria.put(key.toUpperCase(),entry.getValue());
+ }
+
+ // Filter based on name criteria ...
+ String nameCriteria = IndexCriteriaBuilder.getValueInCriteria(updatedCriteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_FIELD);
+ if (!StringUtil.isEmpty(nameCriteria)) {
+ for (Iterator j = records.iterator(); j.hasNext();) {
+ AbstractMetadataRecord record = (AbstractMetadataRecord)j.next();
+ if (!StringUtil.isEmpty(record.getName())) {
+ String recordName = record.getName();
+ if (hasCaseFunctions) {
+ nameCriteria = nameCriteria.toUpperCase();
+ recordName = recordName.toUpperCase();
+ }
+ if (!CharOperation.match(nameCriteria.toCharArray(),
recordName.toCharArray(), true)) {
+ j.remove();
+ }
+ }
+ }
+ }
+
+ return records;
+ }
+
+ /**
+ * Check if any of the criteria in this map evaluates to a false, if it does then no
need to proceed,
+ * can return no records.
+ * @param criteria Map of fieldNames to MetadataSearchCriteria objects used to search
+ * @return true if there is a false criteria else false
+ * @since 4.3
+ */
+ private boolean hasFalseCriteria(final Map criteria) {
+ boolean falseCriteria = false;
+ for(final Iterator iter = criteria.values().iterator(); iter.hasNext();) {
+ Object criteriaObj = iter.next();
+ if(criteriaObj instanceof MetadataLiteralCriteria) {
+ falseCriteria = ((MetadataLiteralCriteria)
criteriaObj).isFalseCriteria();
+ if(falseCriteria) {
+ break;
+ }
+ }
+ }
+ return falseCriteria;
+ }
+
+ /**
+ * Check if any of the criteria in this map has case functions on the fields
involved.
+ * @param criteria Map of fieldNames to MetadataSearchCriteria objects used to search
+ * @return true if there is a case criteria else false
+ * @since 4.3
+ */
+ private boolean hasCaseFunctions(final Map criteria) {
+ boolean caserFunctions = false;
+ for(final Iterator iter = criteria.values().iterator(); iter.hasNext();) {
+ Object criteriaObj = iter.next();
+ if(criteriaObj instanceof MetadataLiteralCriteria) {
+ caserFunctions = ((MetadataLiteralCriteria)
criteriaObj).hasFieldWithCaseFunctions();
+ if(caserFunctions) {
+ break;
+ }
+ }
+ }
+ return caserFunctions;
+ }
+
+ /**
+ * Get all the file records for the available files in vdbs given the match criteria
+ * @param criteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @param returnFirstMatch Boolean indicating if first match is to be returned
+ * @return Collection of file records
+ * @throws MetaMatrixComponentException
+ * @since 4.3
+ */
+ private Collection getFileRecords(final Map criteria, boolean returnFirstMatch) {
+
+ // get the criteria for path in vdb
+ MetadataLiteralCriteria literalCriteria = (MetadataLiteralCriteria)
criteria.get(FileRecordImpl.MetadataMethodNames.PATH_IN_VDB_FIELD.toUpperCase());
+ // if the criteria exists get the path invdb
+ String pathInVDb = literalCriteria != null ? (String)
literalCriteria.getEvaluatedValue() : null;
+
+ Collection fileRecords = new ArrayList();
+ // get the file paths from the selector
+ Set<String> filePaths = metadataStore.getMetadataSource().getEntries();
+ for (String filePath : filePaths) {
+ FileRecordImpl record = new FileRecordImpl();
+ record.setIndexSelector(metadataStore.getMetadataSource());
+ record.setPathInVdb(filePath);
+ // check if pattern specified matches the filePath
+ if(!fileRecords.contains(record)) {
+ // if its a non-null criteria path get the records that match the path
+ if(pathInVDb != null) {
+ if(CharOperation.match(pathInVDb.toCharArray(),
filePath.toCharArray(), false)) {
+ fileRecords.add(record);
+ if(returnFirstMatch) {
+ return fileRecords;
+ }
+ }
+ } else {
+ fileRecords.add(record);
+ }
+ }
+ }
+ return fileRecords;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataConnectorMetadata.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataLiteralCriteria.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/index/MetadataLiteralCriteria.java)
===================================================================
---
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataLiteralCriteria.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataLiteralCriteria.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,163 @@
+/*
+ * 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.connector.metadata;
+
+import com.metamatrix.core.util.ArgCheck;
+
+
+/**
+ * This object is used for construting match patterns used to query index files
+ * containing metadata information. This object can also be used to post process
+ * results after querying index files. This object directly mapps to a single criteria
+ * in a SQL query.
+ *
+ * @since 4.3
+ */
+public class MetadataLiteralCriteria implements MetadataSearchCriteria {
+
+ private final String fieldName;
+ private final Object fieldValue;
+ private String fieldFunction;
+ private String valueFunction;
+
+ /**
+ * Constructor MetadataLiteralCriteria
+ * @param fieldName The name of field used on criteria which gets matched against a
literal.
+ * @param fieldValue The value of field used on criteria which is a literal used as
part of seach criteria.
+ * @since 4.3
+ */
+ public MetadataLiteralCriteria(final String fieldName, final Object fieldValue) {
+ ArgCheck.isNotNull(fieldName);
+
+ this.fieldName = fieldName;
+ this.fieldValue = fieldValue;
+ }
+
+ /**
+ * Get the name of the function applied on the field part of criteria.
+ * @return returns the fieldFunction.
+ * @since 4.3
+ */
+ public String getFieldFunction() {
+ return this.fieldFunction;
+ }
+
+ /**
+ * Set the name of the function applied on the field part of criteria.
+ * @param fieldFunction The fieldFunction to set.
+ * @since 4.3
+ */
+ public void setFieldFunction(String fieldFunction) {
+ this.fieldFunction = fieldFunction;
+ }
+
+ /**
+ * Get the name of field used on criteria which gets matched against a literal.
+ * @return returns the fieldName.
+ * @since 4.3
+ */
+ public String getFieldName() {
+ return this.fieldName;
+ }
+
+ /**
+ * Get the value of field used on criteria which is a literal used as part of seach
criteria.
+ * @return returns the fieldValue.
+ * @since 4.3
+ */
+ public Object getFieldValue() {
+ return this.fieldValue;
+ }
+
+ /**
+ * Check if this criteria evaluates to a false criteria.
+ * @return true if this evaluates to a false criteria else false
+ * @since 4.3
+ */
+ public boolean isFalseCriteria() {
+ Object evaluatedValue = getEvaluatedValue();
+ if(evaluatedValue instanceof String && this.fieldFunction != null) {
+ String stringValue = evaluatedValue.toString();
+ if(this.fieldFunction.equalsIgnoreCase("UPPER") ||
this.fieldFunction.equalsIgnoreCase("UCASE")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return !stringValue.equals(stringValue.toUpperCase());
+ }
+ if(this.fieldFunction.equalsIgnoreCase("LOWER") ||
this.fieldFunction.equalsIgnoreCase("LCASE")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return !stringValue.equals(stringValue.toLowerCase());
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the value of the literal field used in the criteria with any function on it
evaluated.
+ * @return returns the fieldValue.
+ * @since 4.3
+ */
+ public Object getEvaluatedValue() {
+ if(this.valueFunction != null) {
+ if(this.fieldValue instanceof String) {
+ if(this.valueFunction.equalsIgnoreCase("UPPER") ||
this.valueFunction.equalsIgnoreCase("UCASE")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return this.fieldValue.toString().toUpperCase();
+ }
+ if(this.valueFunction.equalsIgnoreCase("LOWER") ||
this.valueFunction.equalsIgnoreCase("LCASE")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return this.fieldValue.toString().toLowerCase();
+ }
+ }
+ }
+ return this.getFieldValue();
+ }
+
+ /**
+ * Get the name of the function applied on the literal part of criteria.
+ * @return returns the valueFunction.
+ * @since 4.3
+ */
+ public String getValueFunction() {
+ return this.valueFunction;
+ }
+
+ /**
+ * Set the name of the function applied on the literal part of criteria.
+ * @param valueFunction The valueFunction to set.
+ * @since 4.3
+ */
+ public void setValueFunction(String valueFunction) {
+ this.valueFunction = valueFunction;
+ }
+
+ /**
+ * Return true if any case functions are involved on the fieldName of this criteria
+ * @return true if there are any functions else false.
+ * @since 4.3
+ */
+ public boolean hasFieldWithCaseFunctions() {
+ if(this.fieldFunction != null) {
+ if(this.fieldFunction.equalsIgnoreCase("UPPER") ||
this.fieldFunction.equalsIgnoreCase("UCASE") || //$NON-NLS-1$ //$NON-NLS-2$
+ this.fieldFunction.equalsIgnoreCase("LOWER") ||
this.fieldFunction.equalsIgnoreCase("LCASE")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataLiteralCriteria.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataResultsPostProcessor.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/index/MetadataResultsPostProcessor.java)
===================================================================
---
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataResultsPostProcessor.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataResultsPostProcessor.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,363 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.ModelRecordImpl;
+import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
+import org.teiid.metadata.index.CharOperation;
+import org.teiid.metadata.index.IndexConstants;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.common.vdb.api.SystemVdbUtility;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.service.VDBService;
+
+
+/**
+ * This is used to post process metadata records found by querying index files available
+ * to the metadata connector. Some of the post processing steps:
+ * 1) VdbRecords get wrapped into an object that has the name and version used by the
user to logon.
+ * 2) Update ModelRecods with the visibility info from VDBService.
+ * 3) Filter FileRecords that are not visible.
+ * 4) Apply serch criteria to take care of case sensitive matches that get ingnore when
querying indexes.
+ * @since 4.3
+ */
+public class MetadataResultsPostProcessor {
+
+ // real vdb information
+ private final String vdbName;
+ private final String vdbVersion;
+ private final VDBService vdbService;
+
+ /**
+ * Constructor MetadataResultsPostProcessor
+ * @param context
+ * @since 4.3
+ */
+ public MetadataResultsPostProcessor(final VdbMetadataContext context) {
+ this.vdbName = context.getVdbName();
+ this.vdbVersion = context.getVdbVersion();
+ this.vdbService = context.getVdbService();
+ Assertion.isNotNull(this.vdbName);
+ Assertion.isNotNull(this.vdbVersion);
+ }
+
+ /**
+ * Post process metadata records, to update record information and filter out recods.
+ * @param records Collection of MetadataRecods from querying index files
+ * @param searchCriteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @param needSearchFiltering boolean to indicate to post processing of metadata
records is
+ * needed by applying search criteria
+ * @return Collection of processed MetadataRecods.
+ * @since 4.3
+ */
+ public Collection processMetadataRecords(final String indexFileName, final Collection
records, final Map searchCriteria, final boolean needSearchFiltering) {
+ ArgCheck.isNotNull(records);
+ ArgCheck.isNotNull(searchCriteria);
+ ArgCheck.isNotNull(indexFileName);
+
+ // short circuit, no need to walk records for following conditions
+ if(!needSearchFiltering) {
+ if(!indexFileName.equalsIgnoreCase(IndexConstants.INDEX_NAME.VDBS_INDEX)
&&
+ !indexFileName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MODELS_INDEX)
&&
+ !indexFileName.equalsIgnoreCase(IndexConstants.INDEX_NAME.FILES_INDEX)) {
+ return records;
+ }
+ }
+
+ Collection processedRecods = new ArrayList(records.size());
+ for (Iterator iterator = records.iterator(); iterator.hasNext(); ) {
+ AbstractMetadataRecord record = (AbstractMetadataRecord) iterator.next();
+
+ // filterout private fileRecords
+ if (record instanceof FileRecordImpl) {
+ FileRecordImpl fileRecord =
filterFileRecordsByVisibility((FileRecordImpl)record);
+ if(fileRecord != null) {
+ processedRecods.add(fileRecord);
+ }
+ continue;
+ }
+
+ // if its a modelRecord update visibility with the one available on
+ // vdb service
+ if(record instanceof ModelRecordImpl) {
+ AbstractMetadataRecord modelRecord =
getModelRecordWithUpdatedVisibility((ModelRecordImpl)record);
+ if(modelRecord != null) {
+ record = modelRecord;
+ }
+ }
+
+ // apply search criteria and filterout unmatched records
+ if(needSearchFiltering) {
+ AbstractMetadataRecord filteredRecord = filterBySearchCriteria(record,
searchCriteria);
+ if(filteredRecord != null) {
+ processedRecods.add(filteredRecord);
+ continue;
+ }
+ } else {
+ processedRecods.add(record);
+ }
+ }
+
+ return processedRecods;
+ }
+
+ /**
+ * Update the ModelRecord with the visibility from vdb service, if vdb service is not
available
+ * there is nothing to update.
+ * @param record The ModelRecord object.
+ * @return The updated ModelRecord
+ * @since 4.3
+ */
+ public ModelRecordImpl getModelRecordWithUpdatedVisibility(final ModelRecordImpl
record) {
+ if(record instanceof ModelRecordImpl){
+ //set visibility
+ ModelRecordImpl mRecord = (ModelRecordImpl)record;
+ String modelName = mRecord.getName();
+ if(!SystemVdbUtility.isSystemModelWithSystemTableType(modelName)){
+ int visibility = ModelInfo.PUBLIC;
+ if(this.vdbService != null) {
+ try {
+ visibility = vdbService.getModelVisibility(vdbName, vdbVersion,
modelName);
+ } catch (MetaMatrixComponentException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+ mRecord.setVisible(visibility == ModelInfo.PUBLIC);
+ return mRecord;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Filter the FileReod based on visibility, if visible return record else
+ * return null.
+ * @param record The FileRecord object
+ * @return The visible FileReord
+ * @since 4.3
+ */
+ private FileRecordImpl filterFileRecordsByVisibility(final FileRecordImpl record) {
+ // begin with assumption that all files are public
+ int visibility = ModelInfo.PUBLIC;
+ // if its a model file check visibility
+ if(this.vdbService != null) {
+ try {
+ visibility = vdbService.getFileVisibility(vdbName, vdbVersion,
record.getPathInVdb());
+ } catch (MetaMatrixComponentException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+ // add only visible records
+ if(visibility == ModelInfo.PUBLIC) {
+ // file records are special always addem to the result
+ return record;
+ }
+
+ return null;
+ }
+
+ /**
+ * Apply the given search criteria and filter out records, currently used to apply
case sensitive matches
+ * since records matched in indexes are case insensitive matches.
+ * @param record The metadata reord to be filterd
+ * @param searchCriteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @return The record that passed filtering
+ * @since 4.3
+ */
+ public AbstractMetadataRecord filterBySearchCriteria(final AbstractMetadataRecord
record, final Map searchCriteria) {
+ if(!searchCriteria.isEmpty()) {
+ // appply criteria for generic metadata record
+ if(!applyMetadataRecordCriteria(record, searchCriteria)) {
+ return null;
+ }
+ // appply criteria for datatype record
+ if(record instanceof DatatypeRecordImpl) {
+ if(!applyDatatypeRecordCriteria((DatatypeRecordImpl)record,
searchCriteria)) {
+ return null;
+ }
+ }
+ // appply criteria for property record
+ if(record instanceof PropertyRecordImpl) {
+ if(!applyPropertyRecordCriteria((PropertyRecordImpl)record,
searchCriteria)) {
+ return null;
+ }
+ }
+ }
+ // if record type is not available or criteria satisfied apply other criteria
+ return record;
+ }
+
+ /**
+ * Apply the given search criteria and filter out datatype records, currently used to
apply case sensitive matches
+ * since records matched in indexes are case insensitive matches.
+ * @param record The metadata reord to be filterd
+ * @param searchCriteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @return The record that passed filtering
+ * @since 4.3
+ */
+ private boolean applyDatatypeRecordCriteria(final DatatypeRecordImpl record, final
Map searchCriteria) {
+ // runtimetype criteria
+ MetadataSearchCriteria runtypeCriteria = getSearchCriteria(searchCriteria,
DatatypeRecordImpl.MetadataFieldNames.RUN_TYPE_NAME);
+ if(!applyCriteria(runtypeCriteria, record.getRuntimeTypeName())) {
+ return false;
+ }
+ // basetype id criteria
+ MetadataSearchCriteria baseTypeCriteria = getSearchCriteria(searchCriteria,
DatatypeRecordImpl.MetadataFieldNames.BASE_TYPE_UUID);
+ if(!applyCriteria(baseTypeCriteria, record.getBasetypeID())) {
+ return false;
+ }
+ // datatype id criteria
+ MetadataSearchCriteria dataTypeCriteria = getSearchCriteria(searchCriteria,
DatatypeRecordImpl.MetadataFieldNames.DATA_TYPE_UUID);
+ if(!applyCriteria(dataTypeCriteria, record.getDatatypeID())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Apply the given search criteria and filter out property records, currently used to
apply case sensitive matches
+ * since records matched in indexes are case insensitive matches.
+ * @param record The metadata reord to be filterd
+ * @param searchCriteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @return The record that passed filtering
+ * @since 4.3
+ */
+ private boolean applyPropertyRecordCriteria(final PropertyRecordImpl record, final
Map searchCriteria) {
+ // prop name criteria
+ MetadataSearchCriteria propNameCriteria = getSearchCriteria(searchCriteria,
PropertyRecordImpl.MetadataFieldNames.PROPERTY_NAME_FIELD);
+ if(!applyCriteria(propNameCriteria, record.getPropertyName())) {
+ return false;
+ }
+ // prop value criteria
+ MetadataSearchCriteria propValueCriteria = getSearchCriteria(searchCriteria,
PropertyRecordImpl.MetadataFieldNames.PROPERTY_VALUE_FIELD);
+ if(!applyCriteria(propValueCriteria, record.getPropertyValue())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Apply the given search criteria and filter out metadata records, currently used to
apply case sensitive matches
+ * since records matched in indexes are case insensitive matches.
+ * @param record The metadata reord to be filterd
+ * @param searchCriteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @return The record that passed filtering
+ * @since 4.3
+ */
+ private boolean applyMetadataRecordCriteria(final AbstractMetadataRecord record,
final Map searchCriteria) {
+ // apply record type criteria first
+ MetadataSearchCriteria recordTypeCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.RECORD_TYPE_FIELD);
+ if(!applyCriteria(recordTypeCriteria, new Character(record.getRecordType()))) {
+ return false;
+ }
+ // full name criteria
+ MetadataSearchCriteria fullNameCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.FULL_NAME_FIELD);
+ if(!applyCriteria(fullNameCriteria, record.getFullName())) {
+ return false;
+ }
+ // name criteria
+ MetadataSearchCriteria nameCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_FIELD);
+ if(!applyCriteria(nameCriteria, record.getName())) {
+ return false;
+ }
+ // model name criteria
+ MetadataSearchCriteria modelNameCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.MODEL_NAME_FIELD);
+ if(!applyCriteria(modelNameCriteria, record.getModelName())) {
+ return false;
+ }
+ // nameInSource criteria
+ MetadataSearchCriteria nameInSourceCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.NAME_IN_SOURCE_FIELD);
+ if(!applyCriteria(nameInSourceCriteria, record.getNameInSource())) {
+ return false;
+ }
+ // uuid criteria
+ MetadataSearchCriteria uuidCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.UUID_FIELD);
+ if(!applyCriteria(uuidCriteria, record.getUUID())) {
+ return false;
+ }
+ // parent uuid criteria
+ MetadataSearchCriteria parentUuidCriteria = getSearchCriteria(searchCriteria,
AbstractMetadataRecord.MetadataFieldNames.PARENT_UUID_FIELD);
+ if(!applyCriteria(parentUuidCriteria, record.getParentUUID())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Get the search criteria given the fild name
+ * @param searchCriteria Map of fieldNames to MetadataSearchCriteria objects used to
search
+ * @param key The field name
+ * @return The search criteria onj.
+ * @since 4.3
+ */
+ private MetadataSearchCriteria getSearchCriteria(final Map searchCriteria, final
String key) {
+ return (MetadataSearchCriteria) searchCriteria.get(key.toUpperCase());
+ }
+
+ /**
+ * Apply the search criteria on the given value, try to match the criteria to value.
+ * @param criteria The search criteria the value needs to satisfy
+ * @param value The value from a metadata record
+ * @return true if it satisfies the criteria else false
+ * @since 4.3
+ */
+ private boolean applyCriteria(final MetadataSearchCriteria criteria, final Object
value) {
+ boolean criteriaPassed = true;
+ // post processing literal criteria
+ if(criteria instanceof MetadataLiteralCriteria) {
+ MetadataLiteralCriteria literalCriteria = (MetadataLiteralCriteria)
criteria;
+ // get the valu in criteria with any functions on the value side of criteria
+ // already evaluated
+ Object evaluatedLiteral = literalCriteria.getEvaluatedValue();
+ // if both are string apply case checks
+ if(value instanceof String && evaluatedLiteral instanceof String) {
+ String literalString = evaluatedLiteral.toString();
+ String valueString = value.toString();
+ // if no fucnction just do case sensitive match
+ if(!CharOperation.match(literalString.toCharArray(),
valueString.toCharArray(), !literalCriteria.hasFieldWithCaseFunctions())) {
+ criteriaPassed = false;
+ }
+ } else {
+ // non string just check if they equal
+ if(value != null && !value.equals(evaluatedLiteral)) {
+ criteriaPassed = false;
+ } else if(value == null && evaluatedLiteral != null) {
+ criteriaPassed = false;
+ }
+ }
+ // post processing literal criteria
+ }
+ return criteriaPassed;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataResultsPostProcessor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataSearchCriteria.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/index/MetadataSearchCriteria.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataSearchCriteria.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataSearchCriteria.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,32 @@
+/*
+ * 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.connector.metadata;
+
+
+/**
+ * Marker interface for criteria objects used to search metadata in index files.
+ * @since 4.3
+ */
+public interface MetadataSearchCriteria {
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MetadataSearchCriteria.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/MultiObjectSource.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/MultiObjectSource.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/MultiObjectSource.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/MultiObjectSource.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,53 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.Collection;
+import java.util.Map;
+
+import com.metamatrix.connector.metadata.internal.IObjectSource;
+
+/**
+ * Holds two object sources and routes queries to them based on the suffix of the group
name.
+ */
+public class MultiObjectSource implements IObjectSource {
+ private IObjectSource primaryObjectSource;
+ private IObjectSource secondaryObjectSource;
+ private String secondaryGroupNameSuffix;
+
+ public MultiObjectSource(IObjectSource primaryObjectSource, String
secondaryGroupNameSuffix, IObjectSource objectSource) {
+ this.primaryObjectSource = primaryObjectSource;
+ this.secondaryGroupNameSuffix = secondaryGroupNameSuffix;
+ this.secondaryObjectSource = objectSource;
+ }
+
+ /*
+ * @see
com.metamatrix.connector.metadata.internal.ISimpleObjectSource#getObjects(java.lang.String,
java.util.Map)
+ */
+ public Collection getObjects(String groupName, Map criteria) {
+ if (groupName.endsWith(secondaryGroupNameSuffix)) {
+ return secondaryObjectSource.getObjects(groupName, criteria);
+ }
+ return primaryObjectSource.getObjects(groupName, criteria);
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/MultiObjectSource.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/ObjectQueryProcessor.java (from
rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQueryProcessor.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/ObjectQueryProcessor.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/ObjectQueryProcessor.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,134 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.connector.api.ConnectorException;
+
+
+import com.metamatrix.connector.metadata.internal.IObjectSource;
+
+/**
+ * Uses an IObjectSource to process ObjectQuery requests and to produce results which are
Lists of Lists of objects.
+ * Each inner List corresponds to a row in the result set. Each object in the inner List
corresponds to the value
+ * for a specific column and row in the result set.
+ *
+ * If the table name contains a method name in "()" at the end of the string
then the method name will be called
+ * on each result object. And each result of the method call will result in a new row
being added to the result set.
+ * In effect, this facility allows multi-valued method calls to serve as the basis of
table definitions.
+ *
+ * So a table name of the form "TABLE_NAME(getList)" will cause the method
"getList" to be called on all result objects.
+ *
+ * The method name will be stripped off when the table name is passed down to the object
source.
+ */
+public class ObjectQueryProcessor implements ResultsIterator.ResultsProcessor {
+ private final IObjectSource objectSource;
+ private String tableDefiningMethodName = null;
+ private IObjectQuery query;
+
+ public ObjectQueryProcessor(final IObjectSource objectSource) {
+ this.objectSource = objectSource;
+ }
+
+ public ResultsIterator process(final IObjectQuery query) throws ConnectorException {
+ tableDefiningMethodName = null;
+ String tableName = query.getTableNameInSource();
+ String tableNameForObjectSource = tableName;
+ int startMethodNameIndex =
tableName.lastIndexOf(String.valueOf(MetadataConnectorConstants.START_METHOD_NAME_CHAR));
+ if (startMethodNameIndex > 0) {
+ int endMethodNameIndex =
tableName.lastIndexOf(String.valueOf(MetadataConnectorConstants.END_METHOD_NAME_CHAR));
+ if ( endMethodNameIndex > 0) {
+ if (endMethodNameIndex > startMethodNameIndex) {
+ tableDefiningMethodName = tableName.substring(startMethodNameIndex +
1, endMethodNameIndex);
+ tableNameForObjectSource = tableName.substring(0,
startMethodNameIndex);
+ }
+ }
+ }
+
+ this.query = query;
+ Collection results = objectSource.getObjects(tableNameForObjectSource,
query.getCriteria());
+ return new ResultsIterator(this, results.iterator());
+ }
+
+ /* (non-Javadoc)
+ * @see
com.metamatrix.connector.metadata.internal.ResultsProcessor#createRows(java.lang.Object,
java.util.List)
+ */
+ public void createRows(Object resultObject, List rows) {
+ ReflectionWrapper wrapper = new ReflectionWrapper(resultObject);
+ if (tableDefiningMethodName == null) {
+ addRow(wrapper, null, rows);
+ } else {
+ Collection subTableCollection = null;
+ Object subTableResults = wrapper.get(tableDefiningMethodName);
+ if (subTableResults.getClass().isArray()) {
+ subTableCollection = Arrays.asList((Object[]) subTableResults);
+ } else if (subTableResults instanceof Collection) {
+ subTableCollection = (Collection) subTableResults;
+ }
+ createRowsFor(wrapper, subTableCollection, rows);
+ }
+ }
+
+ private void createRowsFor(ReflectionWrapper wrapperAroundResultObject, Collection
subTableCollection, List rows) {
+ for (Iterator iterator=subTableCollection.iterator(); iterator.hasNext(); ) {
+ Object subTableObject = iterator.next();
+ addRow(wrapperAroundResultObject, subTableObject, rows);
+ }
+ }
+
+ private void addRow(ReflectionWrapper wrapper, Object subTableObject, List rows) {
+ List newRow = new ArrayList();
+ String[] columnNames = query.getColumnNames();
+ //Class[] columnTypes = query.getColumnTypes();
+ for (int i = 0; i < columnNames.length; i++) {
+ Object value = null;
+
+ if (columnNames[i].equals(tableDefiningMethodName)) {
+ value = subTableObject;
+ } else if (columnNames[i].startsWith(tableDefiningMethodName +
MetadataConnectorConstants.METHOD_DELIMITER)) {
+ ReflectionWrapper subWrapper = new ReflectionWrapper( subTableObject );
+ String columnMethodName =
columnNames[i].substring(tableDefiningMethodName.length()+1);
+ value = subWrapper.get(columnMethodName);
+ } else {
+ value = wrapper.get(columnNames[i]);
+ }
+ query.checkType(i, value);
+ if(value != null) {
+ query.checkCaseType(i, value);
+ Integer caseType = query.getCaseType(i);
+ if(caseType.equals(IObjectQuery.UPPER_CASE)) {
+ value = value.toString().toUpperCase();
+ } else if(caseType.equals(IObjectQuery.LOWER_CASE)) {
+ value = value.toString().toLowerCase();
+ }
+ }
+ newRow.add(value);
+ }
+ rows.add(newRow);
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/ObjectQueryProcessor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyFileObjectSource.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyFileObjectSource.java)
===================================================================
---
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyFileObjectSource.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyFileObjectSource.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,100 @@
+/*
+ * 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.connector.metadata;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import com.metamatrix.connector.metadata.internal.IObjectSource;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+/**
+ * Read a property file and deliver the results as an object source.
+ * This plugs into the object connector to make a property file visible as a relational
table.
+ */
+public class PropertyFileObjectSource implements IObjectSource {
+ private String propertyFilePath;
+
+ public PropertyFileObjectSource() {
+ this("org/teiid/connector/metadata/enum/"); //$NON-NLS-1$
+ }
+
+ public PropertyFileObjectSource(String propertyFilePath) {
+ this.propertyFilePath = propertyFilePath;
+ }
+
+ /*
+ * @see
com.metamatrix.connector.metadata.internal.IObjectSource#getObjects(java.lang.String,
java.util.Map)
+ */
+ public Collection getObjects(String propertyFileName, Map criteria) {
+ if (criteria != null && criteria.size() >0) {
+ throw new UnsupportedOperationException("Criteria is not
supported"); //$NON-NLS-1$
+ }
+ InputStream input = null;
+ try {
+ propertyFileName = expandPropertyFileName(propertyFileName);
+
+ input =
this.getClass().getClassLoader().getResourceAsStream(propertyFileName);
+ if (input == null) {
+ throw new MetaMatrixRuntimeException(propertyFileName+" file not
found");
+ }
+ //input = new BufferedInputStream(new FileInputStream(propertyFileName));
+ Properties properties = new Properties();
+ properties.load(input);
+ List results = new ArrayList();
+ for (Iterator iterator=properties.entrySet().iterator(); iterator.hasNext();
) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ PropertyHolder holder = new PropertyHolder(new Integer((String)
entry.getKey()));
+ holder.setValue(entry.getValue());
+ results.add(holder);
+ }
+ return results;
+ } catch (FileNotFoundException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } catch (IOException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ private String expandPropertyFileName(String propertyFileName) {
+ if (propertyFilePath == null) {
+ return propertyFileName;
+ }
+ return propertyFilePath + propertyFileName;
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyFileObjectSource.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyHolder.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/PropertyHolder.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyHolder.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyHolder.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,62 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.Map;
+
+/**
+ */
+public class PropertyHolder implements Map.Entry {
+ private Object key;
+ private String value;
+
+ /**
+ *
+ */
+ public PropertyHolder(Object key) {
+ this.key = key;
+ }
+
+ /*
+ * @see java.util.Map.Entry#getKey()
+ */
+ public Object getKey() {
+ return key;
+ }
+
+ /*
+ * @see java.util.Map.Entry#getValue()
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /*
+ * @see java.util.Map.Entry#setValue(java.lang.Object)
+ */
+ public Object setValue(Object value) {
+ this.value = (String) value;
+ return this.value;
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/PropertyHolder.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/ReflectionWrapper.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/internal/ReflectionWrapper.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/ReflectionWrapper.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/ReflectionWrapper.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,102 @@
+/*
+ * 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.connector.metadata;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+/**
+ * Wraps a target object to allow methods on the target object to be accessed via
+ * a generic "get" and "set" methods.
+ */
+public class ReflectionWrapper {
+
+ private final Object target;
+ private final Class targetClass;
+
+ public ReflectionWrapper(final Object target) {
+ this.target = target;
+ this.targetClass = target.getClass();
+ }
+
+ /**
+ * The get method takes a property name and attempts to find a matching method on the
target class.
+ * If a matching method is found then the method is invoked and the results are
returned.
+ */
+ public Object get(final String propertyName) {
+ Method method = null;
+ try {
+ method = targetClass.getMethod(propertyName, new Class[0]);
+ } catch (NoSuchMethodException e) {
+ try {
+ method = targetClass.getMethod(MetadataConnectorConstants.GET_METHOD_PREFIX +
propertyName, new Class[0]);
+ } catch (NoSuchMethodException e1) {
+ throw new MetaMatrixRuntimeException(e1);
+ }
+ }
+ try {
+ return method.invoke(target, new Object[0]);
+ } catch (IllegalAccessException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+
+ /**
+ * The set method takes a property name and value and attempts to find a matching
method on the target class.
+ * If a matching method is found then the method is invoked and the results are
returned.
+ */
+ public Object set(final String propertyName, final Object[] propertyValues) {
+ Method method = null;
+ // get parameter types
+ Class[] types = null;
+ if(propertyValues != null) {
+ types = new Class[propertyValues.length];
+ for(int i=0; i<propertyValues.length; i++) {
+ types[i] = propertyValues[i].getClass();
+ }
+ }
+
+ try {
+ method = targetClass.getMethod(propertyName, types);
+ } catch (NoSuchMethodException e) {
+ try {
+ method = targetClass.getMethod(MetadataConnectorConstants.SET_METHOD_PREFIX +
propertyName, types);
+ } catch (NoSuchMethodException e1) {
+ throw new MetaMatrixRuntimeException(e1);
+ }
+ }
+ try {
+ // execute the method with arguments
+ return method.invoke(target, propertyValues);
+ } catch (IllegalAccessException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/ReflectionWrapper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/ResultsIterator.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/ResultsIterator.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/ResultsIterator.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/ResultsIterator.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,69 @@
+/*
+ * 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.connector.metadata;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+public class ResultsIterator implements Iterator {
+
+ public interface ResultsProcessor {
+
+ void createRows(Object resultObject, List rows);
+
+ }
+
+ private final ResultsProcessor objectQueryProcessor;
+ private LinkedList rowBuffer = new LinkedList();
+ private Iterator resultsIter;
+
+ public ResultsIterator(ResultsProcessor objectQueryProcessor, Iterator resultsIter) {
+ this.objectQueryProcessor = objectQueryProcessor;
+ this.resultsIter = resultsIter;
+ }
+
+ public boolean hasNext() {
+ return rowBuffer.size() > 0 || resultsIter.hasNext();
+ }
+
+ public Object next() {
+ if (rowBuffer.size() > 0) {
+ return rowBuffer.removeFirst();
+ }
+ if (!resultsIter.hasNext()) {
+ throw new NoSuchElementException();
+ }
+ this.objectQueryProcessor.createRows(resultsIter.next(), rowBuffer);
+ return rowBuffer.removeFirst();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/ResultsIterator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/RuntimeVdbRecord.java
(from rev 1105,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/RuntimeVdbRecord.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/RuntimeVdbRecord.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/RuntimeVdbRecord.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,49 @@
+/*
+ * 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.connector.metadata;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+
+
+/**
+ * Extends a VdbRecord object with additional runtime data.
+ * This allows the System model to obtain the VDB name and VDB version of the deployed
VDB.
+ */
+public class RuntimeVdbRecord extends AbstractMetadataRecord {
+ private String vdbRuntimeName;
+ private String vdbRuntimeVersion;
+
+ public RuntimeVdbRecord(String vdbRuntimeName, String vdbRuntimeVersion) {
+ this.vdbRuntimeName = vdbRuntimeName;
+ this.vdbRuntimeVersion = vdbRuntimeVersion;
+ }
+
+ public String getVdbRuntimeName() {
+ return vdbRuntimeName;
+ }
+
+ public String getVdbRuntimeVersion() {
+ return vdbRuntimeVersion;
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/RuntimeVdbRecord.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/java/org/teiid/connector/metadata/VdbMetadataContext.java
(from rev 1098,
trunk/metadata/src/main/java/com/metamatrix/connector/metadata/index/VdbMetadataContext.java)
===================================================================
--- trunk/metadata/src/main/java/org/teiid/connector/metadata/VdbMetadataContext.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/connector/metadata/VdbMetadataContext.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,92 @@
+/*
+ * 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.connector.metadata;
+
+import com.metamatrix.dqp.service.VDBService;
+
+
+/**
+ * Context for vdb and index information needed by MetadataConnectorMetadata.
+ * @since 4.3
+ */
+public class VdbMetadataContext {
+
+ private String vdbName;
+ private String vdbVersion;
+ private VDBService vdbService;
+
+ /**
+ * VdbMetadataContext
+ * @param indexSelector The indexSelector to set.
+ * @since 4.2
+ */
+ public VdbMetadataContext() {}
+
+ /**
+ * @return Returns the vdbName.
+ * @since 4.3
+ */
+ public String getVdbName() {
+ return this.vdbName;
+ }
+
+
+ /**
+ * @param vdbName The vdbName to set.
+ * @since 4.3
+ */
+ public void setVdbName(String vdbName) {
+ this.vdbName = vdbName;
+ }
+
+ public VDBService getVdbService() {
+ return this.vdbService;
+ }
+
+
+ /**
+ * @param vdbService The vdbService to set.
+ * @since 4.3
+ */
+ public void setVdbService(VDBService vdbService) {
+ this.vdbService = vdbService;
+ }
+
+
+ /**
+ * @return Returns the vdbVersion.
+ * @since 4.3
+ */
+ public String getVdbVersion() {
+ return this.vdbVersion;
+ }
+
+
+ /**
+ * @param vdbVersion The vdbVersion to set.
+ * @since 4.3
+ */
+ public void setVdbVersion(String vdbVersion) {
+ this.vdbVersion = vdbVersion;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/connector/metadata/VdbMetadataContext.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: trunk/metadata/src/main/java/org/teiid/core/index/IDocument.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/core/index/IDocument.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/core/index/IDocument.java 2009-07-08 04:55:17
UTC (rev 1107)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.core.index;
+
+
+/**
+ * An <code>IDocument</code> represent a data source, e.g. a
<code>File</code> (<code>FileDocument</code>),
+ * an <code>IFile</code> (<code>IFileDocument</code>),
+ * or other kinds of data sources (URL, ...). An <code>IIndexer</code>
indexes an<code>IDocument</code>.
+ */
+
+public interface IDocument {
+ /**
+ * Returns the encoding for this document
+ */
+ String getEncoding();
+ /**
+ * returns the name of the document (e.g. its path for a <code>File</code>,
or its relative path
+ * in the workbench for an <code>IFile</code>).
+ */
+ String getName();
+ /**
+ * Returns the type of the document.
+ */
+ String getType();
+}
Property changes on: trunk/metadata/src/main/java/org/teiid/core/index/IDocument.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/core/index/IEntryResult.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/core/index/IEntryResult.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/core/index/IEntryResult.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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.core.index;
+
+public interface IEntryResult {
+ public int[] getFileReferences();
+ public char[] getWord();
+}
Property changes on: trunk/metadata/src/main/java/org/teiid/core/index/IEntryResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/core/index/IIndex.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/core/index/IIndex.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/core/index/IIndex.java 2009-07-08 04:55:17 UTC
(rev 1107)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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.core.index;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * An IIndex is the interface used to generate an index file, and to make queries on
+ * this index.
+ */
+
+public interface IIndex {
+ /**
+ * Adds the given document to the index.
+ */
+ void add(IDocument document, IIndexer indexer) throws IOException;
+ /**
+ * Empties the index.
+ */
+ void empty() throws IOException;
+ /**
+ * Returns the index file on the disk.
+ */
+ File getIndexFile();
+ /**
+ * Returns the number of documents indexed.
+ */
+ int getNumDocuments() throws IOException;
+ /**
+ * Returns the number of unique words indexed.
+ */
+ int getNumWords() throws IOException;
+ /**
+ * Returns the path corresponding to a given document number
+ */
+ String getPath(int documentNumber) throws IOException;
+ /**
+ * Ansers true if has some changes to save.
+ */
+ boolean hasChanged();
+ /**
+ * Returns the paths of the documents containing the given word.
+ */
+ IQueryResult[] query(String word) throws IOException;
+ /**
+ * Returns all entries for a given word.
+ */
+ IEntryResult[] queryEntries(char[] pattern) throws IOException;
+ /**
+ * Returns the paths of the documents whose names contain the given word.
+ */
+ IQueryResult[] queryInDocumentNames(String word) throws IOException;
+ /**
+ * Returns the paths of the documents containing the given word prefix.
+ */
+ IQueryResult[] queryPrefix(char[] prefix) throws IOException;
+ /**
+ * Removes the corresponding document from the index.
+ */
+ void remove(String documentName) throws IOException;
+ /**
+ * Saves the index on the disk.
+ */
+ void save() throws IOException;
+
+ /**
+ * Closes the index file if open
+ *
+ * @since 5.0
+ */
+ void close();
+
+ /**
+ * closes the index file then deletes it.
+ *
+ * @since 5.0
+ */
+ void dispose();
+
+ /**
+ * sets a boolean indicating the index file will be cached and should remain open and
in-memory
+ * @param doCache
+ * @since 5.0
+ */
+ void setDoCache(boolean doCache);
+}
Property changes on: trunk/metadata/src/main/java/org/teiid/core/index/IIndex.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/core/index/IIndexer.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/core/index/IIndexer.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/core/index/IIndexer.java 2009-07-08 04:55:17
UTC (rev 1107)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.core.index;
+
+/**
+ * An <code>IIndexer</code> indexes ONE document at each time. It adds the
document names and
+ * the words references to an IIndex. Each IIndexer can index certain types of document,
and should
+ * not index the other files.
+ */
+public interface IIndexer {
+ /**
+ * Returns the file types the <code>IIndexer</code> handles.
+ */
+
+ String[] getFileTypes();
+ /**
+ * Indexes the given document, adding the document name and the word references
+ * to this document to the given <code>IIndex</code>.The caller should use
+ * <code>shouldIndex()</code> first to determine whether this indexer
handles
+ * the given type of file, and only call this method if so.
+ */
+
+ void index(IDocument document, IIndexerOutput output) throws java.io.IOException;
+ /**
+ * Sets the document types the <code>IIndexer</code> handles.
+ */
+
+ public void setFileTypes(String[] fileTypes);
+ /**
+ * Returns whether the <code>IIndexer</code> can index the given document or
not.
+ */
+
+ public boolean shouldIndex(IDocument document);
+}
Property changes on: trunk/metadata/src/main/java/org/teiid/core/index/IIndexer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/core/index/IIndexerOutput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/core/index/IIndexerOutput.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/core/index/IIndexerOutput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.core.index;
+/**
+ * This class represents the output from an indexer to an index
+ * for a single document.
+ */
+
+public interface IIndexerOutput {
+ public void addDocument(IDocument document);
+ public void addRef(char[] word);
+ public void addRef(String word);
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/core/index/IIndexerOutput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/core/index/IQueryResult.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/core/index/IQueryResult.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/core/index/IQueryResult.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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.core.index;
+
+public interface IQueryResult {
+ String getPath();
+}
Property changes on: trunk/metadata/src/main/java/org/teiid/core/index/IQueryResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/Block.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/Block.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/Block.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * A block is a container that can hold information (a list of file names, a list of
+ * words, ...), be saved on the disk and loaded in memory.
+ */
+
+public abstract class Block {
+ /**
+ * Size of the block
+ */
+ protected int blockSize;
+
+ /**
+ * Field in which the information is stored
+ */
+ protected Field field;
+
+ public Block(int blockSize) {
+ this.blockSize= blockSize;
+ field= new Field(blockSize);
+ }
+ /**
+ * Empties the block.
+ */
+ public void clear() {
+ field.clear();
+ }
+ /**
+ * Flushes the block
+ */
+ public void flush() {
+ }
+ /**
+ * Loads the block with the given number in memory, reading it from a RandomAccessFile.
+ */
+ public void read(RandomAccessFile raf, int blockNum) throws IOException {
+ raf.seek(blockNum * (long) blockSize);
+ raf.readFully(field.buffer());
+ }
+ /**
+ * Writes the block in a RandomAccessFile, giving it a block number.
+ */
+ public void write(RandomAccessFile raf, int blockNum) throws IOException {
+ raf.seek(blockNum * (long) blockSize);
+ raf.write(field.buffer());
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/Block.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,453 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IEntryResult;
+import org.teiid.core.index.IQueryResult;
+import org.teiid.metadata.index.CharOperation;
+
+import com.metamatrix.core.util.LRUCache;
+
+/**
+ * This input is used for reading indexes saved using a BlocksIndexOutput.
+ */
+public class BlocksIndexInput extends IndexInput {
+ public static final int CACHE_SIZE= 16; // Cache 16 blocks of 8K each, for a cache size
of 128K
+ protected FileListBlock currentFileListBlock;
+ protected int currentFileListBlockNum;
+ protected int currentIndexBlockNum;
+ protected IndexBlock currentIndexBlock;
+ private RandomAccessFile raf;
+ protected File indexFile;
+ protected LRUCache blockCache;
+
+ protected IndexSummary summary;
+
+ public BlocksIndexInput(File inputFile) {
+ this.indexFile= inputFile;
+ blockCache= new LRUCache(CACHE_SIZE);
+ }
+
+ /**
+ * @see IndexInput#clearCache()
+ */
+ public void clearCache() {
+ blockCache= new LRUCache(CACHE_SIZE);
+ }
+
+ /**
+ * @see IndexInput#close()
+ */
+ public void close() throws IOException {
+ if (isOpen()) {
+ //System.out.println(" Closing Index File: " +
this.indexFile.getName());
+ summary= null;
+ setOpen(false);
+ if (raf != null)
+ raf.close();
+ }
+ }
+
+ /**
+ * @see IndexInput#getCurrentFile()
+ */
+ public IndexedFile getCurrentFile() throws IOException {
+ if (!hasMoreFiles())
+ return null;
+ IndexedFile file= null;
+ if ((file= currentFileListBlock.getFile(filePosition)) == null) {
+ currentFileListBlockNum= summary.getBlockNumForFileNum(filePosition);
+ currentFileListBlock= getFileListBlock(currentFileListBlockNum);
+ file= currentFileListBlock.getFile(filePosition);
+ }
+ return file;
+ }
+
+ /**
+ * Returns the entry corresponding to the given word.
+ */
+ protected WordEntry getEntry(char[] word) throws IOException {
+ int blockNum= summary.getBlockNumForWord(word);
+ if (blockNum == -1) return null;
+ IndexBlock block= getIndexBlock(blockNum);
+ return block.findExactEntry(word);
+ }
+
+ /**
+ * Returns the FileListBlock with the given number.
+ */
+ protected FileListBlock getFileListBlock(int blockNum) throws IOException {
+ Integer key= new Integer(blockNum);
+ Block block= (Block) blockCache.get(key);
+ if (block != null && block instanceof FileListBlock)
+ return (FileListBlock) block;
+ FileListBlock fileListBlock= new FileListBlock(IIndexConstants.BLOCK_SIZE);
+ fileListBlock.read(raf, blockNum);
+ blockCache.put(key, fileListBlock);
+ return fileListBlock;
+ }
+
+ /**
+ * Returns the IndexBlock (containing words) with the given number.
+ */
+ protected IndexBlock getIndexBlock(int blockNum) throws IOException {
+ Integer key= new Integer(blockNum);
+ Block block= (Block) blockCache.get(key);
+ if (block != null && block instanceof IndexBlock)
+ return (IndexBlock) block;
+ IndexBlock indexBlock= new GammaCompressedIndexBlock(IIndexConstants.BLOCK_SIZE);
+ indexBlock.read(raf, blockNum);
+ blockCache.put(key, indexBlock);
+ return indexBlock;
+ }
+
+ /**
+ * @see IndexInput#getIndexedFile(int)
+ */
+ public IndexedFile getIndexedFile(int fileNum) throws IOException {
+ int blockNum= summary.getBlockNumForFileNum(fileNum);
+ if (blockNum == -1)
+ return null;
+ FileListBlock block= getFileListBlock(blockNum);
+ return block.getFile(fileNum);
+ }
+
+ /**
+ * @see IndexInput#getIndexedFile(IDocument)
+ */
+ public IndexedFile getIndexedFile(IDocument document) throws java.io.IOException {
+ setFirstFile();
+ String name= document.getName();
+ while (hasMoreFiles()) {
+ IndexedFile file= getCurrentFile();
+ String path= file.getPath();
+ if (path.equals(name))
+ return file;
+ moveToNextFile();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the list of numbers of files containing the given word.
+ */
+ protected int[] getMatchingFileNumbers(char[] word) throws IOException {
+ int blockNum= summary.getBlockNumForWord(word);
+ if (blockNum == -1)
+ return new int[0];
+ IndexBlock block= getIndexBlock(blockNum);
+ WordEntry entry= block.findExactEntry(word);
+ return entry == null ? new int[0] : entry.getRefs();
+ }
+
+ /**
+ * @see IndexInput#getNumFiles()
+ */
+ public int getNumFiles() {
+ return summary.getNumFiles();
+ }
+
+ /**
+ * @see IndexInput#getNumWords()
+ */
+ public int getNumWords() {
+ return summary.getNumWords();
+ }
+
+ /**
+ * @see IndexInput#getSource()
+ */
+ public Object getSource() {
+ return indexFile;
+ }
+
+ /**
+ * Initialises the blocksIndexInput
+ */
+ protected void init() throws IOException {
+ clearCache();
+ setFirstFile();
+ setFirstWord();
+ }
+ /**
+ * @see IndexInput#moveToNextFile()
+ */
+ public void moveToNextFile() throws IOException {
+ filePosition++;
+ }
+
+ /**
+ * @see IndexInput#moveToNextWordEntry()
+ */
+ public void moveToNextWordEntry() throws IOException {
+ wordPosition++;
+ if (!hasMoreWords()) {
+ return;
+ }
+ //if end of the current block, we load the next one.
+ boolean endOfBlock= !currentIndexBlock.nextEntry(currentWordEntry);
+ if (endOfBlock) {
+ currentIndexBlock= getIndexBlock(++currentIndexBlockNum);
+ currentIndexBlock.nextEntry(currentWordEntry);
+ }
+ }
+
+ /**
+ * @see IndexInput#open()
+ */
+ public void open() throws IOException {
+ if (!isOpen()) {
+ raf= new SafeRandomAccessFile(indexFile, "r"); //$NON-NLS-1$
+ String sig= raf.readUTF();
+ if (!sig.equals(IIndexConstants.SIGNATURE))
+ throw new IOException(Util.bind("exception.wrongFormat")); //$NON-NLS-1$
+ int summaryBlockNum= raf.readInt();
+ raf.seek(summaryBlockNum * (long) IIndexConstants.BLOCK_SIZE);
+ summary= new IndexSummary();
+ summary.read(raf);
+ init();
+ setOpen(true);
+ }
+ }
+
+ /**
+ * @see IndexInput#query(String)
+ */
+ public IQueryResult[] query(String word) throws IOException {
+ open();
+ int[] fileNums= getMatchingFileNumbers(word.toCharArray());
+ int size= fileNums.length;
+ IQueryResult[] files= new IQueryResult[size];
+ for (int i= 0; i < size; ++i) {
+ files[i]= getIndexedFile(fileNums[i]);
+ }
+ return files;
+ }
+
+ /**
+ * Overloaded the method in BlocksIndexInput to allow a user to specify if the
+ * query should be case sensitive.
+ * @param pattern
+ * @param isCaseSensitive
+ * @return
+ * @throws IOException
+ */
+ public IEntryResult[] queryEntriesMatching(char[] pattern, boolean isCaseSensitive)
throws IOException {
+ open();
+
+ if (pattern == null || pattern.length == 0) return null;
+ int[] blockNums = null;
+ int firstStar = indexOf('*', pattern);
+ switch (firstStar){
+ case -1 :
+ WordEntry entry = getEntry(pattern);
+ if (entry == null) return null;
+ return new IEntryResult[]{ new EntryResult(entry.getWord(),
entry.getRefs()) };
+ case 0 :
+ blockNums = summary.getAllBlockNums();
+ break;
+ default :
+ char[] prefix = new char[firstStar];
+ System.arraycopy(pattern, 0, prefix, 0, firstStar);
+ blockNums = summary.getBlockNumsForPrefix(prefix);
+ }
+ if (blockNums == null || blockNums.length == 0) return null;
+
+ IEntryResult[] entries = new IEntryResult[5];
+ int count = 0;
+ for (int i = 0, max = blockNums.length; i < max; i++) {
+ IndexBlock block = getIndexBlock(blockNums[i]);
+ block.reset();
+ WordEntry entry = new WordEntry();
+ while (block.nextEntry(entry)) {
+ // Switch argument order to fix bug in BlocksIndexInput
+ if (CharOperation.match(pattern, entry.getWord(), isCaseSensitive)) {
+ if (count == entries.length){
+ System.arraycopy(entries, 0, entries = new IEntryResult[count*2],
0, count);
+ }
+ entries[count++] = new EntryResult(entry.getWord(),
entry.getRefs());
+ }
+ }
+ }
+ if (count != entries.length){
+ System.arraycopy(entries, 0, entries = new IEntryResult[count], 0, count);
+ }
+ return entries;
+ }
+
+ static final int indexOf(char toBeFound, char[] array) {
+ for (int i = 0; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ public IEntryResult[] queryEntriesPrefixedBy(char[] prefix) throws IOException {
+ open();
+
+ int blockLoc = summary.getFirstBlockLocationForPrefix(prefix);
+ if (blockLoc < 0) return null;
+
+ IEntryResult[] entries = new IEntryResult[5];
+ int count = 0;
+ while(blockLoc >= 0){
+ IndexBlock block = getIndexBlock(summary.getBlockNum(blockLoc));
+ block.reset();
+ boolean found = false;
+ WordEntry entry = new WordEntry();
+ while (block.nextEntry(entry)) {
+ if (CharOperation.prefixEquals(prefix, entry.getWord(), true)) {
+ if (count == entries.length){
+ System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count);
+ }
+ entries[count++] = new EntryResult(entry.getWord(), entry.getRefs());
+ found = true;
+ } else {
+ if (found) break;
+ }
+ }
+ /* consider next block ? */
+ blockLoc = summary.getNextBlockLocationForPrefix(prefix, blockLoc);
+ }
+ if (count == 0) return null;
+ if (count != entries.length){
+ System.arraycopy(entries, 0, entries = new IEntryResult[count], 0, count);
+ }
+ return entries;
+ }
+
+ /**
+ * Overloaded the method in BlocksIndexInput to allow a user to specify if the
+ * query should be case sensitive.
+ */
+ public IEntryResult[] queryEntriesPrefixedBy(char[] prefix, boolean isCaseSensitive)
throws IOException {
+ open();
+
+ int blockLoc = summary.getFirstBlockLocationForPrefix(prefix);
+ if (blockLoc < 0) return null;
+
+ IEntryResult[] entries = new IEntryResult[5];
+ int count = 0;
+ while(blockLoc >= 0){
+ IndexBlock block = getIndexBlock(summary.getBlockNum(blockLoc));
+ block.reset();
+ boolean found = false;
+ WordEntry entry = new WordEntry();
+ while (block.nextEntry(entry)) {
+ if (CharOperation.prefixEquals(prefix, entry.getWord(), isCaseSensitive))
{
+ if (count == entries.length){
+ System.arraycopy(entries, 0, entries = new IEntryResult[count*2],
0, count);
+ }
+ entries[count++] = new EntryResult(entry.getWord(),
entry.getRefs());
+ found = true;
+ } else {
+ if (found) break;
+ }
+ }
+ /* consider next block ? */
+ blockLoc = summary.getNextBlockLocationForPrefix(prefix, blockLoc);
+ }
+ if (count == 0) return null;
+ if (count != entries.length){
+ System.arraycopy(entries, 0, entries = new IEntryResult[count], 0, count);
+ }
+ return entries;
+ }
+
+ public IQueryResult[] queryFilesReferringToPrefix(char[] prefix) throws IOException {
+ open();
+
+ int blockLoc = summary.getFirstBlockLocationForPrefix(prefix);
+ if (blockLoc < 0) return null;
+
+ // each filename must be returned already once
+ HashMap<Integer, IndexedFile> fileMatches = new HashMap<Integer,
IndexedFile>();
+ int count = 0;
+ while(blockLoc >= 0){
+ IndexBlock block = getIndexBlock(summary.getBlockNum(blockLoc));
+ block.reset();
+ boolean found = false;
+ WordEntry entry = new WordEntry();
+ while (block.nextEntry(entry)) {
+ if (CharOperation.prefixEquals(prefix, entry.getWord(), true)) {
+ int [] refs = entry.getRefs();
+ for (int i = 0, max = refs.length; i < max; i++){
+ int ref = refs[i];
+ Integer key = Integer.valueOf(ref);
+ if (!fileMatches.containsKey(key)){
+ count++;
+ fileMatches.put(key, getIndexedFile(ref));
+ }
+ }
+ found = true;
+ } else {
+ if (found) break;
+ }
+ }
+ /* consider next block ? */
+ blockLoc = summary.getNextBlockLocationForPrefix(prefix, blockLoc);
+ }
+ /* extract indexed files */
+ IQueryResult[] files = fileMatches.values().toArray(new IQueryResult[count]);
+ return files;
+ }
+
+ /**
+ * @see IndexInput#queryInDocumentNames(String)
+ */
+ public IQueryResult[] queryInDocumentNames(String word) throws IOException {
+ open();
+ ArrayList matches= new ArrayList();
+ setFirstFile();
+ while (hasMoreFiles()) {
+ IndexedFile file= getCurrentFile();
+ if (file.getPath().indexOf(word) != -1)
+ matches.add(file);
+ moveToNextFile();
+ }
+ IQueryResult[] match= new IQueryResult[matches.size()];
+ matches.toArray(match);
+ return match;
+ }
+
+ /**
+ * @see IndexInput#setFirstFile()
+ */
+ protected void setFirstFile() throws IOException {
+ filePosition= 1;
+ if (getNumFiles() > 0) {
+ currentFileListBlockNum= summary.getBlockNumForFileNum(1);
+ currentFileListBlock= getFileListBlock(currentFileListBlockNum);
+ }
+ }
+
+ /**
+ * @see IndexInput#setFirstWord()
+ */
+ protected void setFirstWord() throws IOException {
+ wordPosition= 1;
+ if (getNumWords() > 0) {
+ currentIndexBlockNum= summary.getFirstWordBlockNum();
+ currentIndexBlock= getIndexBlock(currentIndexBlockNum);
+ currentWordEntry= new WordEntry();
+ currentIndexBlock.reset();
+ currentIndexBlock.nextEntry(currentWordEntry);
+ }
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexOutput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexOutput.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexOutput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * A blocksIndexOutput is used to save an index in a file with the given
structure:<br>
+ * - Signature of the file;<br>
+ * - FileListBlocks;<br>
+ * - IndexBlocks;<br>
+ * - Summary of the index.
+ */
+
+public class BlocksIndexOutput extends IndexOutput {
+ protected RandomAccessFile indexOut;
+ protected int blockNum;
+ protected boolean opened= false;
+ protected File indexFile;
+ protected FileListBlock fileListBlock;
+ protected IndexBlock indexBlock;
+ protected int numWords= 0;
+ protected IndexSummary summary;
+ protected int numFiles= 0;
+ protected boolean firstInBlock;
+ protected boolean firstIndexBlock;
+ protected boolean firstFileListBlock;
+
+ public BlocksIndexOutput(File indexFile) {
+ this.indexFile= indexFile;
+ summary= new IndexSummary();
+ blockNum= 1;
+ firstInBlock= true;
+ firstIndexBlock= true;
+ firstFileListBlock= true;
+ }
+ /**
+ * @see IndexOutput#addFile
+ */
+ public void addFile(IndexedFile indexedFile) throws IOException {
+ if (firstFileListBlock) {
+ firstInBlock= true;
+ fileListBlock= new FileListBlock(IIndexConstants.BLOCK_SIZE);
+ firstFileListBlock= false;
+ }
+ if (fileListBlock.addFile(indexedFile)) {
+ if (firstInBlock) {
+ summary.addFirstFileInBlock(indexedFile, blockNum);
+ firstInBlock= false;
+ }
+ numFiles++;
+ } else {
+ if (fileListBlock.isEmpty()) {
+ return;
+ }
+ flushFiles();
+ addFile(indexedFile);
+ }
+ }
+ /**
+ * @see IndexOutput#addWord
+ */
+ public void addWord(WordEntry entry) throws IOException {
+ if (firstIndexBlock) {
+ indexBlock= new GammaCompressedIndexBlock(IIndexConstants.BLOCK_SIZE);
+ firstInBlock= true;
+ firstIndexBlock= false;
+ }
+ if (entry.getNumRefs() == 0)
+ return;
+ if (indexBlock.addEntry(entry)) {
+ if (firstInBlock) {
+ summary.addFirstWordInBlock(entry.getWord(), blockNum);
+ firstInBlock= false;
+ }
+ numWords++;
+ } else {
+ if (indexBlock.isEmpty()) {
+ return;
+ }
+ flushWords();
+ addWord(entry);
+ }
+ }
+ /**
+ * @see IndexOutput#close
+ */
+ public void close() throws IOException {
+ if (opened) {
+ indexOut.close();
+ summary= null;
+ numFiles= 0;
+ opened= false;
+ }
+ }
+ /**
+ * @see IndexOutput#flush
+ */
+ public void flush() throws IOException {
+
+ summary.setNumFiles(numFiles);
+ summary.setNumWords(numWords);
+ indexOut.seek(blockNum * (long) IIndexConstants.BLOCK_SIZE);
+ summary.write(indexOut);
+ indexOut.seek(0);
+ indexOut.writeUTF(IIndexConstants.SIGNATURE);
+ indexOut.writeInt(blockNum);
+ }
+ /**
+ * Writes the current fileListBlock on the disk and initialises it
+ * (when it's full or it's the end of the index).
+ */
+ protected void flushFiles() throws IOException {
+ if (!firstFileListBlock
+ && fileListBlock != null) {
+ fileListBlock.flush();
+ fileListBlock.write(indexOut, blockNum++);
+ fileListBlock.clear();
+ firstInBlock= true;
+ }
+ }
+ /**
+ * Writes the current indexBlock on the disk and initialises it
+ * (when it's full or it's the end of the index).
+ */
+ protected void flushWords() throws IOException {
+ if (!firstInBlock
+ && indexBlock != null) { // could have added a document without any indexed
word, no block created yet
+ indexBlock.flush();
+ indexBlock.write(indexOut, blockNum++);
+ indexBlock.clear();
+ firstInBlock= true;
+ }
+ }
+ /**
+ * @see IndexOutput#getDestination
+ */
+ public Object getDestination() {
+ return indexFile;
+ }
+ /**
+ * @see IndexOutput#open
+ */
+ public void open() throws IOException {
+ if (!opened) {
+ summary= new IndexSummary();
+ numFiles= 0;
+ numWords= 0;
+ blockNum= 1;
+ firstInBlock= true;
+ firstIndexBlock= true;
+ firstFileListBlock= true;
+ indexOut= new SafeRandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$
+ opened= true;
+ }
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexOutput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/CodeByteStream.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/CodeByteStream.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/CodeByteStream.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,343 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.UTFDataFormatException;
+
+public class CodeByteStream {
+ protected byte[] bytes;
+ protected int byteOffset= 0;
+ protected int bitOffset= 0;
+ protected int markByteOffset= -1;
+ protected int markBitOffset= -1;
+
+ public CodeByteStream() {
+ this(16);
+ }
+ public CodeByteStream(byte[] bytes) {
+ this.bytes= bytes;
+ }
+ public CodeByteStream(int initialByteLength) {
+ bytes= new byte[initialByteLength];
+ }
+ public int byteLength() {
+ return (bitOffset + 7) / 8 + byteOffset;
+ }
+ public byte[] getBytes(int startOffset, int endOffset) {
+ int byteLength= byteLength();
+ if (startOffset > byteLength || endOffset > byteLength || startOffset >
endOffset)
+ throw new IndexOutOfBoundsException();
+ int length= endOffset - startOffset;
+ byte[] result= new byte[length];
+ System.arraycopy(bytes, startOffset, result, 0, length);
+ if (endOffset == byteLength && bitOffset != 0) {
+ int mask= (1 << bitOffset) - 1;
+ result[length - 1] &= (mask << 8 - bitOffset);
+ }
+ return result;
+ }
+ protected void grow() {
+ byte[] newBytes= new byte[bytes.length * 2 + 1];
+ System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
+ bytes= newBytes;
+ }
+ public void mark() {
+ markByteOffset= byteOffset;
+ markBitOffset= bitOffset;
+ }
+ /**
+ * Reads a single bit (value == 0 or == 1).
+ */
+ public int readBit() {
+ int value= (bytes[byteOffset] >> (7 - bitOffset)) & 1;
+ if (++bitOffset >= 8) {
+ bitOffset= 0;
+ ++byteOffset;
+ }
+ return value;
+ }
+ /**
+ * Read up to 32 bits from the stream.
+ */
+ public int readBits(int numBits) {
+ int value= 0;
+ while (numBits > 0) {
+ int bitsToRead= 8 - bitOffset;
+ if (bitsToRead > numBits)
+ bitsToRead= numBits;
+ int mask= (1 << bitsToRead) - 1;
+ value |= ((bytes[byteOffset] >> (8 - bitOffset - bitsToRead)) & mask)
<< (numBits - bitsToRead);
+ numBits -= bitsToRead;
+ bitOffset += bitsToRead;
+ if (bitOffset >= 8) {
+ bitOffset -= 8;
+ byteOffset += 1;
+ }
+ }
+ return value;
+ }
+ public final int readByte() {
+
+ // no need to rebuild byte value from bit sequences
+ if (bitOffset == 0) return bytes[byteOffset++] & 255;
+
+ int value= 0;
+ int numBits = 8;
+ while (numBits > 0) {
+ int bitsToRead= 8 - bitOffset;
+ if (bitsToRead > numBits)
+ bitsToRead= numBits;
+ int mask= (1 << bitsToRead) - 1;
+ value |= ((bytes[byteOffset] >> (8 - bitOffset - bitsToRead)) & mask)
<< (numBits - bitsToRead);
+ numBits -= bitsToRead;
+ bitOffset += bitsToRead;
+ if (bitOffset >= 8) {
+ bitOffset -= 8;
+ byteOffset += 1;
+ }
+ }
+ return value;
+ }
+ /**
+ * Reads a value using Gamma coding.
+ */
+ public int readGamma() {
+ int numBits= readUnary();
+ return readBits(numBits - 1) | (1 << (numBits - 1));
+ }
+ public char[] readUTF() throws UTFDataFormatException {
+ int utflen= readByte();
+ if (utflen == 255) {
+ // long UTF
+ int high = readByte();
+ int low = readByte();
+ utflen = (high << 8) + low;
+ }
+ char str[]= new char[utflen];
+ int count= 0;
+ int strlen= 0;
+ while (count < utflen) {
+ int c= readByte();
+ int char2, char3;
+ switch (c >> 4) {
+ case 0 :
+ case 1 :
+ case 2 :
+ case 3 :
+ case 4 :
+ case 5 :
+ case 6 :
+ case 7 :
+ // 0xxxxxxx
+ count++;
+ str[strlen++]= (char) c;
+ break;
+ case 12 :
+ case 13 :
+ // 110x xxxx 10xx xxxx
+ count += 2;
+ if (count > utflen)
+ throw new UTFDataFormatException();
+ char2= readByte();
+ if ((char2 & 0xC0) != 0x80)
+ throw new UTFDataFormatException();
+ str[strlen++]= (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
+ break;
+ case 14 :
+ // 1110 xxxx 10xx xxxx 10xx xxxx
+ count += 3;
+ if (count > utflen)
+ throw new UTFDataFormatException();
+ char2= readByte();
+ char3= readByte();
+ if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
+ throw new UTFDataFormatException();
+ str[strlen++]= (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) <<
6) | ((char3 & 0x3F) << 0));
+ break;
+ default :
+ // 10xx xxxx, 1111 xxxx
+ throw new UTFDataFormatException();
+ }
+ }
+ if (strlen < utflen)
+ System.arraycopy(str, 0, str= new char[strlen], 0, strlen);
+ return str;
+ }
+ /**
+ * Reads a value in unary.
+ */
+ public int readUnary() {
+ int value= 1;
+ int mask= 1 << (7 - bitOffset);
+ while ((bytes[byteOffset] & mask) != 0) {
+ ++value;
+ if (++bitOffset >= 8) {
+ bitOffset= 0;
+ ++byteOffset;
+ mask= 0x80;
+ } else {
+ mask >>>= 1;
+ }
+ }
+ // skip the 0 bit
+ if (++bitOffset >= 8) {
+ bitOffset= 0;
+ ++byteOffset;
+ }
+ return value;
+ }
+ public void reset() {
+ byteOffset= bitOffset= 0;
+ markByteOffset= markBitOffset= -1;
+ }
+ public void reset(byte[] bytes) {
+ this.bytes= bytes;
+ reset();
+ }
+ public void reset(byte[] bytes, int byteOffset) {
+ reset(bytes);
+ this.byteOffset= byteOffset;
+ }
+ public boolean resetToMark() {
+ if (markByteOffset == -1)
+ return false;
+ byteOffset= markByteOffset;
+ bitOffset= markBitOffset;
+ markByteOffset= markBitOffset= -1;
+ return true;
+ }
+ public void skipBits(int numBits) {
+ int newOffset= byteOffset * 8 + bitOffset + numBits;
+ if (newOffset < 0 || (newOffset + 7) / 8 >= bytes.length)
+ throw new IllegalArgumentException();
+ byteOffset= newOffset / 8;
+ bitOffset= newOffset % 8;
+ }
+ public byte[] toByteArray() {
+ return getBytes(0, byteLength());
+ }
+ /**
+ * Writes a single bit (value == 0 or == 1).
+ */
+ public void writeBit(int value) {
+ bytes[byteOffset] |= (value & 1) << (7 - bitOffset);
+ if (++bitOffset >= 8) {
+ bitOffset= 0;
+ if (++byteOffset >= bytes.length)
+ grow();
+ }
+ }
+ /**
+ * Write up to 32 bits to the stream.
+ * The least significant numBits bits of value are written.
+ */
+ public void writeBits(int value, int numBits) {
+ while (numBits > 0) {
+ int bitsToWrite= 8 - bitOffset;
+ if (bitsToWrite > numBits)
+ bitsToWrite= numBits;
+ int shift= 8 - bitOffset - bitsToWrite;
+ int mask= ((1 << bitsToWrite) - 1) << shift;
+ bytes[byteOffset]= (byte) ((bytes[byteOffset] & ~mask) | (((value >>>
(numBits - bitsToWrite)) << shift) & mask));
+ numBits -= bitsToWrite;
+ bitOffset += bitsToWrite;
+ if (bitOffset >= 8) {
+ bitOffset -= 8;
+ if (++byteOffset >= bytes.length)
+ grow();
+ }
+ }
+ }
+ public void writeByte(int value) {
+ writeBits(value, 8);
+ }
+ /**
+ * Writes the given value using Gamma coding, in which positive integer x
+ * is represented by coding floor(log2(x) in unary followed by the value
+ * of x - 2**floor(log2(x)) in binary.
+ * The value must be >= 1.
+ */
+ public void writeGamma(int value) {
+ if (value < 1)
+ throw new IllegalArgumentException();
+ int temp= value;
+ int numBits= 0;
+ while (temp != 0) {
+ temp >>>= 1;
+ ++numBits;
+ }
+ writeUnary(numBits);
+ writeBits(value, numBits - 1);
+ }
+ public void writeUTF(char[] str, int start, int end) {
+ int utflen= 0;
+ for (int i= start; i < end; i++) {
+ int c= str[i];
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ utflen++;
+ } else if (c > 0x07FF) {
+ utflen += 3;
+ } else {
+ utflen += 2;
+ }
+ }
+ if (utflen < 255) {
+ writeByte(utflen & 0xFF);
+ } else if (utflen > 65535) {
+ throw new IllegalArgumentException();
+ } else {
+ writeByte(255); // marker for long UTF
+ writeByte((utflen >>> 8) & 0xFF); // high byte
+ writeByte((utflen >>> 0) & 0xFF); // low byte
+ }
+ for (int i= start; i < end; i++) {
+ int c= str[i];
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ writeByte(c);
+ } else if (c > 0x07FF) {
+ writeByte(0xE0 | ((c >> 12) & 0x0F));
+ writeByte(0x80 | ((c >> 6) & 0x3F));
+ writeByte(0x80 | ((c >> 0) & 0x3F));
+ } else {
+ writeByte(0xC0 | ((c >> 6) & 0x1F));
+ writeByte(0x80 | ((c >> 0) & 0x3F));
+ }
+ }
+ }
+ /**
+ * Write the given value in unary. The value must be >= 1.
+ */
+ public void writeUnary(int value) {
+ if (value < 1)
+ throw new IllegalArgumentException();
+ int mask= 1 << (7 - bitOffset);
+ // write N-1 1-bits
+ while (--value > 0) {
+ bytes[byteOffset] |= mask;
+ if (++bitOffset >= 8) {
+ bitOffset= 0;
+ if (++byteOffset >= bytes.length)
+ grow();
+ mask= 0x80;
+ } else {
+ mask >>>= 1;
+ }
+ }
+ // write a 0-bit
+ bytes[byteOffset] &= ~mask;
+ if (++bitOffset >= 8) {
+ bitOffset= 0;
+ if (++byteOffset >= bytes.length)
+ grow();
+ }
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/CodeByteStream.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/EntryResult.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/EntryResult.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/EntryResult.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.util.Arrays;
+
+import org.teiid.core.index.IEntryResult;
+
+
+public class EntryResult implements IEntryResult {
+ private char[] word;
+ private int[] fileRefs;
+
+ public EntryResult(char[] word, int[] refs) {
+ this.word = word;
+ this.fileRefs = refs;
+ }
+
+ public boolean equals(Object anObject) {
+
+ if (this == anObject) {
+ return true;
+ }
+ if ((anObject != null) && (anObject instanceof EntryResult)) {
+ EntryResult anEntryResult = (EntryResult) anObject;
+ if (!Arrays.equals(this.word, anEntryResult.word))
+ return false;
+
+ int length;
+ int[] refs, otherRefs;
+ if ((length = (refs = this.fileRefs).length) != (otherRefs =
anEntryResult.fileRefs).length)
+ return false;
+ for (int i = 0; i < length; i++) {
+ if (refs[i] != otherRefs[i])
+ return false;
+ }
+ return true;
+ }
+ return false;
+
+ }
+
+ public int[] getFileReferences() {
+ return fileRefs;
+ }
+
+ public char[] getWord() {
+ return word;
+ }
+
+ public int hashCode() {
+ return Arrays.hashCode(word);
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(word.length * 2);
+ buffer.append("EntryResult: word="); //$NON-NLS-1$
+ buffer.append(word);
+ buffer.append(", refs={"); //$NON-NLS-1$
+ for (int i = 0; i < fileRefs.length; i++) {
+ if (i > 0)
+ buffer.append(',');
+ buffer.append(' ');
+ buffer.append(fileRefs[i]);
+ }
+ buffer.append(" }"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/EntryResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/Field.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/Field.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/Field.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.UTFDataFormatException;
+
+public class Field {
+ protected byte[] buffer; // contents
+ protected int offset; // offset of the field within the byte array
+ protected int length; // length of the field
+
+ /**
+ * ByteSegment constructor comment.
+ */
+ public Field(byte[] bytes) {
+ this.buffer= bytes;
+ this.offset= 0;
+ this.length= bytes.length;
+ }
+ /**
+ * ByteSegment constructor comment.
+ */
+ public Field(byte[] bytes, int length) {
+ this.buffer= bytes;
+ this.offset= 0;
+ this.length= length;
+ }
+ /**
+ * ByteSegment constructor comment.
+ */
+ public Field(byte[] bytes, int offset, int length) {
+ this.buffer= bytes;
+ this.offset= offset;
+ this.length= length;
+ }
+ /**
+ * Creates a new field containing an empty buffer of the given length.
+ */
+ public Field(int length) {
+ this.buffer= new byte[length];
+ this.offset= 0;
+ this.length= length;
+ }
+ public byte[] buffer() {
+ return buffer;
+ }
+ public Field buffer(byte[] buffer) {
+ this.buffer= buffer;
+ return this;
+ }
+ public Field clear() {
+ clear(buffer, offset, length);
+ return this;
+ }
+ protected static void clear(byte[] buffer, int offset, int length) {
+ int n= offset;
+ for (int i= 0; i < length; i++) {
+ buffer[n]= 0;
+ n++;
+ }
+ }
+ public Field clear(int length) {
+ clear(buffer, offset, length);
+ return this;
+ }
+ public Field clear(int offset, int length) {
+ clear(buffer, this.offset + offset, length);
+ return this;
+ }
+ protected static int compare(byte[] buffer1, int offset1, int length1, byte[] buffer2,
int offset2, int length2) {
+ int n= Math.min(length1, length2);
+ for (int i= 0; i < n; i++) {
+ int j1= buffer1[offset1 + i] & 255;
+ int j2= buffer2[offset2 + i] & 255;
+ if (j1 > j2)
+ return 1;
+ if (j1 < j2)
+ return -1;
+ }
+ if (length1 > n) {
+ for (int i= n; i < length1; i++)
+ if (buffer1[offset1 + i] != 0)
+ return 1;
+ return 0;
+ }
+ for (int i= n; i < length2; i++)
+ if (buffer2[offset2 + i] != 0)
+ return -1;
+ return 0;
+ }
+ public static int compare(Field f1, Field f2) {
+ return compare(f1.buffer, f1.offset, f1.length, f2.buffer, f2.offset, f2.length);
+ }
+ // copy bytes from one offset to another within the field
+ public Field copy(int fromOffset, int toOffset, int length) {
+ System.arraycopy(buffer, offset + fromOffset, buffer, offset + toOffset, length);
+ return this;
+ }
+ public Field dec(int n) {
+ offset -= n;
+ return this;
+ }
+ public byte[] get() {
+ byte[] result= new byte[length];
+ System.arraycopy(buffer, offset, result, 0, length);
+ return result;
+ }
+ public byte[] get(int offset, int length) {
+ byte[] result= new byte[length];
+ System.arraycopy(buffer, this.offset + offset, result, 0, length);
+ return result;
+ }
+ public Field getField(int offset, int length) {
+ return new Field(buffer, this.offset + offset, length);
+ }
+ public int getInt1() {
+ return buffer[this.offset];
+ }
+ public int getInt1(int offset) {
+ return buffer[this.offset + offset];
+ }
+ public int getInt2() {
+ int i= this.offset;
+ int v= buffer[i++];
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getInt2(int offset) {
+ int i= this.offset + offset;
+ int v= buffer[i++];
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getInt3() {
+ int i= this.offset;
+ int v= buffer[i++];
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getInt3(int offset) {
+ int i= this.offset + offset;
+ int v= buffer[i++];
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getInt4() {
+ int i= this.offset;
+ int v= buffer[i++];
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getInt4(int offset) {
+ int i= this.offset + offset;
+ int v= buffer[i++];
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getUInt1() {
+ return buffer[this.offset] & 255;
+ }
+ public int getUInt1(int offset) {
+ return buffer[this.offset + offset] & 255;
+ }
+ public int getUInt2() {
+ int i= this.offset;
+ int v= (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getUInt2(int offset) {
+ int i= this.offset + offset;
+ int v= (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getUInt3() {
+ int i= this.offset;
+ int v= (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public int getUInt3(int offset) {
+ int i= this.offset + offset;
+ int v= (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ v= (v << 8) | (buffer[i++] & 255);
+ return v;
+ }
+ public char[] getUTF(int offset) throws UTFDataFormatException {
+ int pos= this.offset + offset;
+ int utflen= getUInt2(pos);
+ pos += 2;
+ char str[]= new char[utflen];
+ int count= 0;
+ int strlen= 0;
+ while (count < utflen) {
+ int c= buffer[pos++] & 0xFF;
+ int char2, char3;
+ switch (c >> 4) {
+ case 0 :
+ case 1 :
+ case 2 :
+ case 3 :
+ case 4 :
+ case 5 :
+ case 6 :
+ case 7 :
+ // 0xxxxxxx
+ count++;
+ str[strlen++]= (char) c;
+ break;
+ case 12 :
+ case 13 :
+ // 110x xxxx 10xx xxxx
+ count += 2;
+ if (count > utflen)
+ throw new UTFDataFormatException();
+ char2= buffer[pos++] & 0xFF;
+ if ((char2 & 0xC0) != 0x80)
+ throw new UTFDataFormatException();
+ str[strlen++]= (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
+ break;
+ case 14 :
+ // 1110 xxxx 10xx xxxx 10xx xxxx
+ count += 3;
+ if (count > utflen)
+ throw new UTFDataFormatException();
+ char2= buffer[pos++] & 0xFF;
+ char3= buffer[pos++] & 0xFF;
+ if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
+ throw new UTFDataFormatException();
+ str[strlen++]= (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) <<
6) | ((char3 & 0x3F) << 0));
+ break;
+ default :
+ // 10xx xxxx, 1111 xxxx
+ throw new UTFDataFormatException();
+ }
+ }
+ if (strlen < utflen)
+ System.arraycopy(str, 0, str= new char[strlen], 0, strlen);
+ return str;
+ }
+ public Field inc(int n) {
+ offset += n;
+ return this;
+ }
+ public int length() {
+ return length;
+ }
+ public Field length(int length) {
+ this.length= length;
+ return this;
+ }
+ /**
+ Returns the offset into the underlying byte array that this field is defined over.
+ */
+ public int offset() {
+ return offset;
+ }
+ public Field offset(int offset) {
+ this.offset= offset;
+ return this;
+ }
+ public Field pointTo(int offset) {
+ return new Field(buffer, this.offset + offset, 0);
+ }
+ public Field put(byte[] b) {
+ return put(0, b);
+ }
+ public Field put(int offset, byte[] b) {
+ System.arraycopy(b, 0, buffer, this.offset + offset, b.length);
+ return this;
+ }
+ public Field put(int offset, Field f) {
+ System.arraycopy(f.buffer, f.offset, buffer, this.offset + offset, f.length);
+ return this;
+ }
+ public Field put(Field f) {
+ System.arraycopy(f.buffer, f.offset, buffer, offset, f.length);
+ return this;
+ }
+ public Field putInt1(int n) {
+ buffer[offset]= (byte) (n);
+ return this;
+ }
+ public Field putInt1(int offset, int n) {
+ buffer[this.offset + offset]= (byte) (n);
+ return this;
+ }
+ public Field putInt2(int n) {
+ int i= offset;
+ buffer[i++]= (byte) (n >> 8);
+ buffer[i++]= (byte) (n >> 0);
+ return this;
+ }
+ public Field putInt2(int offset, int n) {
+ int i= this.offset + offset;
+ buffer[i++]= (byte) (n >> 8);
+ buffer[i++]= (byte) (n >> 0);
+ return this;
+ }
+ public Field putInt3(int n) {
+ int i= offset;
+ buffer[i++]= (byte) (n >> 16);
+ buffer[i++]= (byte) (n >> 8);
+ buffer[i++]= (byte) (n >> 0);
+ return this;
+ }
+ public Field putInt3(int offset, int n) {
+ int i= this.offset + offset;
+ buffer[i++]= (byte) (n >> 16);
+ buffer[i++]= (byte) (n >> 8);
+ buffer[i++]= (byte) (n >> 0);
+ return this;
+ }
+ public Field putInt4(int n) {
+ int i= offset;
+ buffer[i++]= (byte) (n >> 24);
+ buffer[i++]= (byte) (n >> 16);
+ buffer[i++]= (byte) (n >> 8);
+ buffer[i++]= (byte) (n >> 0);
+ return this;
+ }
+ public Field putInt4(int offset, int n) {
+ int i= this.offset + offset;
+ buffer[i++]= (byte) (n >> 24);
+ buffer[i++]= (byte) (n >> 16);
+ buffer[i++]= (byte) (n >> 8);
+ buffer[i++]= (byte) (n >> 0);
+ return this;
+ }
+ public int putUTF(int offset, char[] str) {
+ int strlen= str.length;
+ int utflen= 0;
+ for (int i= 0; i < strlen; i++) {
+ int c= str[i];
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ utflen++;
+ } else if (c > 0x07FF) {
+ utflen += 3;
+ } else {
+ utflen += 2;
+ }
+ }
+ if (utflen > 65535)
+ throw new IllegalArgumentException();
+ int pos= this.offset + offset;
+ buffer[pos++]= (byte) ((utflen >>> 8) & 0xFF);
+ buffer[pos++]= (byte) ((utflen >>> 0) & 0xFF);
+ for (int i= 0; i < strlen; i++) {
+ int c= str[i];
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ buffer[pos++]= ((byte) c);
+ } else if (c > 0x07FF) {
+ buffer[pos++]= ((byte) (0xE0 | ((c >> 12) & 0x0F)));
+ buffer[pos++]= ((byte) (0x80 | ((c >> 6) & 0x3F)));
+ buffer[pos++]= ((byte) (0x80 | ((c >> 0) & 0x3F)));
+ } else {
+ buffer[pos++]= ((byte) (0xC0 | ((c >> 6) & 0x1F)));
+ buffer[pos++]= ((byte) (0x80 | ((c >> 0) & 0x3F)));
+ }
+ }
+ return 2 + utflen;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/Field.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/FileDocument.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/FileDocument.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/FileDocument.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.File;
+
+import org.teiid.core.index.IDocument;
+
+
+/**
+ * A <code>FileDocument</code> represents a java.io.File.
+ */
+
+public class FileDocument extends PropertyDocument {
+ File file;
+
+ public FileDocument(File file) {
+ super();
+ this.file= file;
+ }
+ /**
+ * @see org.teiid.core.index.IDocument#getEncoding()
+ */
+ public String getEncoding() {
+ return null; // no custom encoding
+ }
+
+ /**
+ * @see IDocument#getName
+ */
+ public String getName() {
+ return file.getAbsolutePath().replace(File.separatorChar,
IIndexConstants.FILE_SEPARATOR);
+ }
+ /**
+ * @see IDocument#getType
+ */
+ public String getType() {
+ int lastDot= file.getPath().lastIndexOf('.');
+ if (lastDot == -1)
+ return ""; //$NON-NLS-1$
+ return file.getPath().substring(lastDot + 1);
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/FileDocument.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/FileListBlock.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/FileListBlock.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/FileListBlock.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class FileListBlock extends Block {
+
+ protected int offset= 0;
+ protected String prevPath= null;
+ protected String[] paths= null;
+
+ public FileListBlock(int blockSize) {
+ super(blockSize);
+ }
+ /**
+ * add the name of the indexedfile to the buffr of the field.
+ * The name is not the entire name of the indexedfile, but the
+ * difference between its name and the name of the previous indexedfile ...
+ */
+ public boolean addFile(IndexedFile indexedFile) {
+ int offset= this.offset;
+ if (isEmpty()) {
+ field.putInt4(offset, indexedFile.getFileNumber());
+ offset += 4;
+ }
+ String path= indexedFile.getPath();
+ int prefixLen= prevPath == null ? 0 : Util.prefixLength(prevPath, path);
+ int sizeEstimate= 2 + 2 + (path.length() - prefixLen) * 3;
+ if (offset + sizeEstimate > blockSize - 2)
+ return false;
+ field.putInt2(offset, prefixLen);
+ offset += 2;
+ char[] chars= new char[path.length() - prefixLen];
+ path.getChars(prefixLen, path.length(), chars, 0);
+ offset += field.putUTF(offset, chars);
+ this.offset= offset;
+ prevPath= path;
+ return true;
+ }
+ public void clear() {
+ reset();
+ super.clear();
+ }
+ public void flush() {
+ if (offset > 0) {
+ field.putInt2(offset, 0);
+ field.putInt2(offset + 2, 0);
+ offset= 0;
+ }
+ }
+ public IndexedFile getFile(int fileNum) throws IOException {
+ IndexedFile resp= null;
+ try {
+ String[] paths= getPaths();
+ int i= fileNum - field.getInt4(0);
+ resp= new IndexedFile(paths[i], fileNum);
+ } catch (Exception e) {
+ //fileNum too big
+ }
+ return resp;
+ }
+ /**
+ * Creates a vector of paths reading the buffer of the field.
+ */
+ protected String[] getPaths() throws IOException {
+ if (paths == null) {
+ ArrayList v= new ArrayList();
+ int offset= 4;
+ char[] prevPath= null;
+ for (;;) {
+ int prefixLen= field.getUInt2(offset);
+ offset += 2;
+ int utfLen= field.getUInt2(offset);
+ char[] path= field.getUTF(offset);
+ offset += 2 + utfLen;
+ if (prefixLen != 0) {
+ char[] temp= new char[prefixLen + path.length];
+ System.arraycopy(prevPath, 0, temp, 0, prefixLen);
+ System.arraycopy(path, 0, temp, prefixLen, path.length);
+ path= temp;
+ }
+ if (path.length == 0)
+ break;
+ v.add(new String(path));
+ prevPath= path;
+ }
+ paths= new String[v.size()];
+ v.toArray(paths);
+ }
+ return paths;
+ }
+ public boolean isEmpty() {
+ return offset == 0;
+ }
+ public void reset() {
+ offset= 0;
+ prevPath= null;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/FileListBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/metadata/src/main/java/org/teiid/internal/core/index/GammaCompressedIndexBlock.java
===================================================================
---
trunk/metadata/src/main/java/org/teiid/internal/core/index/GammaCompressedIndexBlock.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/GammaCompressedIndexBlock.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.UTFDataFormatException;
+
+/**
+ * Uses prefix coding on words, and gamma coding of document numbers differences.
+ */
+public class GammaCompressedIndexBlock extends IndexBlock {
+ CodeByteStream writeCodeStream= new CodeByteStream();
+ CodeByteStream readCodeStream;
+ char[] prevWord= null;
+ int offset= 0;
+
+ public GammaCompressedIndexBlock(int blockSize) {
+ super(blockSize);
+ readCodeStream= new CodeByteStream(field.buffer());
+ }
+ /**
+ * @see IndexBlock#addEntry
+ */
+ public boolean addEntry(WordEntry entry) {
+ writeCodeStream.reset();
+ encodeEntry(entry, prevWord, writeCodeStream);
+ if (offset + writeCodeStream.byteLength() > this.blockSize - 2) {
+ return false;
+ }
+ byte[] bytes= writeCodeStream.toByteArray();
+ field.put(offset, bytes);
+ offset += bytes.length;
+ prevWord= entry.getWord();
+ return true;
+ }
+ protected void encodeEntry(WordEntry entry, char[] prevWord, CodeByteStream codeStream)
{
+ char[] word= entry.getWord();
+ int prefixLen= prevWord == null ? 0 : Math.min(Util.prefixLength(prevWord, word),
255);
+ codeStream.writeByte(prefixLen);
+ codeStream.writeUTF(word, prefixLen, word.length);
+ int n= entry.getNumRefs();
+ codeStream.writeGamma(n);
+ int prevRef= 0;
+ for (int i= 0; i < n; ++i) {
+ int ref= entry.getRef(i);
+ if (ref <= prevRef)
+ throw new IllegalArgumentException();
+ codeStream.writeGamma(ref - prevRef);
+ prevRef= ref;
+ }
+ }
+ /**
+ * @see IndexBlock#flush
+ */
+ public void flush() {
+ if (offset > 0) {
+ field.putInt2(offset, 0);
+ offset= 0;
+ prevWord= null;
+ }
+ }
+ /**
+ * @see IndexBlock#isEmpty
+ */
+ public boolean isEmpty() {
+ return offset == 0;
+ }
+ /**
+ * @see IndexBlock#nextEntry
+ */
+ public boolean nextEntry(WordEntry entry) {
+ try {
+ readCodeStream.reset(field.buffer(), offset);
+ int prefixLength= readCodeStream.readByte();
+ char[] word= readCodeStream.readUTF();
+ if (prevWord != null && prefixLength > 0) {
+ char[] temp= new char[prefixLength + word.length];
+ System.arraycopy(prevWord, 0, temp, 0, Math.min(prefixLength, prevWord.length));
+ System.arraycopy(word, 0, temp, Math.min(prefixLength, prevWord.length),
word.length);
+ word= temp;
+ }
+ if (word.length == 0) {
+ return false;
+ }
+ entry.reset(word);
+ int n= readCodeStream.readGamma();
+ int prevRef= 0;
+ for (int i= 0; i < n; ++i) {
+ int ref= prevRef + readCodeStream.readGamma();
+ if (ref < prevRef)
+ throw new InternalError();
+ entry.addRef(ref);
+ prevRef= ref;
+ }
+ offset= readCodeStream.byteLength();
+ prevWord= word;
+ return true;
+ } catch (UTFDataFormatException e) {
+ return false;
+ }
+ }
+ /**
+ * @see IndexBlock#reset
+ */
+ public void reset() {
+ super.reset();
+ offset= 0;
+ prevWord= null;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/GammaCompressedIndexBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IIndexConstants.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IIndexConstants.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/IIndexConstants.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+/**
+ * This interface provides constants used by the search engine.
+ */
+public interface IIndexConstants {
+ /**
+ * The signature of the index file.
+ */
+ public static final String SIGNATURE= "INDEX FILE 0.012"; //$NON-NLS-1$
+ /**
+ * The separator for files in the index file.
+ */
+ public static final char FILE_SEPARATOR= '/';
+ /**
+ * The size of a block for a <code>Block</code>.
+ */
+ public static final int BLOCK_SIZE= 8192;
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IIndexConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/InMemoryIndex.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/InMemoryIndex.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/InMemoryIndex.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IIndex;
+
+
+/**
+ * This index stores the document names in an <code>ArrayList</code>, and the
words in
+ * an <code>HashtableOfObjects</code>.
+ */
+
+public class InMemoryIndex {
+
+ /**
+ * hashtable of WordEntrys = words+numbers of the files they appear in.
+ */
+ protected List<WordEntry> words;
+
+ /**
+ * List of IndexedFiles = file name + a unique number.
+ */
+ protected IndexedFileHashedArray files;
+
+ /**
+ * Size of the index.
+ */
+ protected long footprint;
+
+ private WordEntry[] sortedWordEntries;
+ private IndexedFile[] sortedFiles;
+ public InMemoryIndex() {
+ init();
+ }
+
+ public IndexedFile addDocument(IDocument document) {
+ IndexedFile indexedFile= this.files.add(document);
+ this.footprint += indexedFile.footprint() + 4;
+ this.sortedFiles = null;
+ return indexedFile;
+ }
+
+ /**
+ * Looks if the word already exists in the index and add the fileNum to this word.
+ * If the word does not exist, it adds it in the index.
+ */
+ protected void addRef(char[] word, int fileNum) {
+ // Assuming that our indexes are already unique we shouldn't
+ // worry about whether or not one exists already in the list
+ // So let's change this a little and improve performance.
+ // WordEntry entry= (WordEntry) this.words.get(word);
+ // if (entry == null) {
+ // entry= new WordEntry(word);
+ // entry.addRef(fileNum);
+ // this.words.add(entry);
+ // this.sortedWordEntries= null;
+ // this.footprint += entry.footprint();
+ // } else {
+ // this.footprint += entry.addRef(fileNum);
+ // }
+ // return;
+
+ // NEW CODE BELOW
+ WordEntry entry= new WordEntry(word);
+ entry.addRef(fileNum);
+ this.words.add(entry);
+ this.sortedWordEntries= null;
+ this.footprint += entry.footprint();
+ }
+
+ public void addRef(IndexedFile indexedFile, char[] word) {
+ addRef(word, indexedFile.getFileNumber());
+ }
+
+ /**
+ * Returns the footprint of the index.
+ */
+ public long getFootprint() {
+ return this.footprint;
+ }
+
+ /**
+ * Returns the indexed file with the given path, or null if such file does not exist.
+ */
+ public IndexedFile getIndexedFile(String path) {
+ return files.get(path);
+ }
+
+ /**
+ * @see IIndex#getNumDocuments()
+ */
+ public int getNumFiles() {
+ return files.size();
+ }
+
+ /**
+ * @see IIndex#getNumWords()
+ */
+ public int getNumWords() {
+ return words.size();
+ }
+
+ /**
+ * Returns the words contained in the hashtable of words, sorted by alphabetical order.
+ */
+ protected IndexedFile[] getSortedFiles() {
+ if (this.sortedFiles == null) {
+ IndexedFile[] indexedFiles= files.asArray();
+ Arrays.sort(indexedFiles);
+ this.sortedFiles= indexedFiles;
+ }
+ return this.sortedFiles;
+ }
+ /**
+ * Returns the word entries contained in the hashtable of words, sorted by alphabetical
order.
+ */
+ protected WordEntry[] getSortedWordEntries() {
+ if (this.sortedWordEntries == null) {
+ WordEntry[] words= this.words.toArray(new WordEntry[this.words.size()]);
+ Arrays.sort(words);
+ this.sortedWordEntries= words;
+ }
+ return this.sortedWordEntries;
+ }
+
+ /**
+ * Initialises the fields of the index
+ */
+ public void init() {
+ words= new ArrayList<WordEntry>(256);
+ files= new IndexedFileHashedArray(101);
+ footprint= 0;
+ sortedWordEntries= null;
+ sortedFiles= null;
+ }
+ /**
+ * Saves the index in the given file.
+ * Structure of the saved Index :
+ * - IndexedFiles in sorted order.
+ * + example:
+ * "c:/com/Test.java 1"
+ * "c:/com/UI.java 2"
+ * - References with the words in sorted order
+ * + example:
+ * "classDecl/Test 1"
+ * "classDecl/UI 2"
+ * "ref/String 1 2"
+ */
+
+ public void save(File file) throws IOException {
+ BlocksIndexOutput output= new BlocksIndexOutput(file);
+ save(output);
+ }
+ /**
+ * Saves the index in the given IndexOutput.
+ * Structure of the saved Index :
+ * - IndexedFiles in sorted order.
+ * + example:
+ * "c:/com/Test.java 1"
+ * "c:/com/UI.java 2"
+ * - References with the words in sorted order
+ * + example:
+ * "classDecl/Test 1"
+ * "classDecl/UI 2"
+ * "ref/String 1 2"
+ */
+
+ protected void save(IndexOutput output) throws IOException {
+ boolean ok= false;
+ try {
+ output.open();
+ IndexedFile[] indexedFiles= files.asArray();
+ for (int i= 0, length = indexedFiles.length; i < length; ++i)
+ output.addFile(indexedFiles[i]); // written out in order BUT not alphabetical
+ getSortedWordEntries(); // init the slot
+ for (int i= 0, numWords= sortedWordEntries.length; i < numWords; ++i)
+ output.addWord(sortedWordEntries[i]);
+ output.flush();
+ output.close();
+ ok= true;
+ } finally {
+ if (!ok && output != null)
+ output.close();
+ }
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/InMemoryIndex.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,516 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IEntryResult;
+import org.teiid.core.index.IIndex;
+import org.teiid.core.index.IIndexer;
+import org.teiid.core.index.IQueryResult;
+
+
+/**
+ * An Index is used to create an index on the disk, and to make queries. It uses a set of
+ * indexers and a mergeFactory. The index fills an inMemoryIndex up
+ * to it reaches a certain size, and then merges it with a main index on the disk.
+ * <br> <br>
+ * The changes are only taken into account by the queries after a merge.
+ */
+
+public class Index implements IIndex {
+ /**
+ * Maximum size of the index in memory.
+ */
+ public static final int MAX_FOOTPRINT= 10000000;
+
+ /**
+ * Index in memory, who is merged with mainIndex each times it
+ * reaches a certain size.
+ */
+ protected InMemoryIndex addsIndex;
+ protected IndexInput addsIndexInput;
+
+ /**
+ * State of the indexGenerator: addsIndex empty <=> MERGED, or
+ * addsIndex not empty <=> CAN_MERGE
+ */
+ protected int state;
+
+ /**
+ * Files removed form the addsIndex.
+ */
+ protected Map removedInAdds;
+
+ /**
+ * Files removed form the oldIndex.
+ */
+ protected Map removedInOld;
+ protected static final int CAN_MERGE= 0;
+ protected static final int MERGED= 1;
+ private File indexFile;
+
+ /*
+ * Caching the index input object so we can keep it open for multiple pass querying
rather than
+ * opening/closing and wasting CPU for file IO
+ */
+ private BlocksIndexInput cachedInput;
+ protected boolean doCache = false;
+ private String resourceFileName;
+
+ /**
+ * String representation of this index.
+ */
+ public String toString;
+
+ public Index(File indexDirectory, boolean reuseExistingFile) throws IOException {
+ this(indexDirectory,".index", reuseExistingFile); //$NON-NLS-1$
+ }
+
+ public Index(File indexDirectory, String indexName, boolean reuseExistingFile) throws
IOException {
+ super();
+ state= MERGED;
+ indexFile= new File(indexDirectory, indexName);
+ initialize(reuseExistingFile);
+ //System.out.println(" Index() Name = " + indexName);
+ }
+
+ public Index(String indexName, boolean reuseExistingFile) throws IOException {
+ this(indexName, null, null, reuseExistingFile);
+ }
+
+ public Index(String indexName, String resourceFileName, boolean reuseExistingFile)
throws IOException {
+ this(indexName, resourceFileName, null, reuseExistingFile);
+ }
+
+ public Index(String indexName, String resourceFileName, String toString, boolean
reuseExistingFile) throws IOException {
+ super();
+ state= MERGED;
+ indexFile= new File(indexName);
+ this.toString = toString;
+ this.resourceFileName = resourceFileName;
+ initialize(reuseExistingFile);
+ }
+ /**
+ * Indexes the given document, using the appropriate indexer registered in the
indexerRegistry.
+ * If the document already exists in the index, it overrides the previous one. The
changes will be
+ * taken into account after a merge.
+ */
+ public void add(IDocument document, IIndexer indexer) throws IOException {
+ if (timeToMerge()) {
+ merge();
+ }
+
+ IndexedFile indexedFile= addsIndex.getIndexedFile(document.getName());
+ if (indexedFile != null /*&& removedInAdds.get(document.getName()) == null*/
+ ) {
+ remove(indexedFile, MergeFactory.ADDS_INDEX);
+ }
+ IndexerOutput output= new IndexerOutput(addsIndex);
+ indexer.index(document, output);
+ state= CAN_MERGE;
+ }
+
+ /**
+ * Returns true if the index in memory is not empty, so
+ * merge() can be called to fill the mainIndex with the files and words
+ * contained in the addsIndex.
+ */
+ protected boolean canMerge() {
+ return state == CAN_MERGE;
+ }
+
+ /**
+ * Initialises the indexGenerator.
+ */
+ public void empty() throws IOException {
+
+ if (indexFile.exists()){
+ //System.out.println(" Index.empty(): Deleting Index file = " +
indexFile.getName());
+ indexFile.delete();
+ //initialisation of mainIndex
+ InMemoryIndex mainIndex= new InMemoryIndex();
+ IndexOutput mainIndexOutput= new BlocksIndexOutput(indexFile);
+ if (!indexFile.exists())
+ mainIndex.save(mainIndexOutput);
+ }
+
+ //initialisation of addsIndex
+ addsIndex= new InMemoryIndex();
+ addsIndexInput= new SimpleIndexInput(addsIndex);
+
+ //vectors who keep track of the removed Files
+ removedInAdds= new HashMap(11);
+ removedInOld= new HashMap(11);
+ }
+
+ /**
+ * @see IIndex#getIndexFile
+ */
+ public File getIndexFile() {
+ return indexFile;
+ }
+
+ /**
+ * @see IIndex#getNumDocuments
+ */
+ public int getNumDocuments() throws IOException {
+ BlocksIndexInput input = getBlocksIndexInput();
+ try {
+ input.open();
+ return input.getNumFiles();
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * @see IIndex#getNumWords
+ */
+ public int getNumWords() throws IOException {
+ BlocksIndexInput input = getBlocksIndexInput();
+ try {
+ input.open();
+ return input.getNumWords();
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * Returns the path corresponding to a given document number
+ */
+ public String getPath(int documentNumber) throws IOException {
+ BlocksIndexInput input = getBlocksIndexInput();
+ try {
+ input.open();
+ IndexedFile file = input.getIndexedFile(documentNumber);
+ if (file == null) return null;
+ return file.getPath();
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * see IIndex.hasChanged
+ */
+ public boolean hasChanged() {
+ return canMerge();
+ }
+
+ /**
+ * Initialises the indexGenerator.
+ */
+ public void initialize(boolean reuseExistingFile) throws IOException {
+
+ //initialisation of addsIndex
+ addsIndex= new InMemoryIndex();
+ addsIndexInput= new SimpleIndexInput(addsIndex);
+
+ //vectors who keep track of the removed Files
+ removedInAdds= new HashMap(11);
+ removedInOld= new HashMap(11);
+
+ // check whether existing index file can be read
+ if (reuseExistingFile && indexFile.exists() && indexFile.length() >
0) {
+ BlocksIndexInput mainIndexInput= getBlocksIndexInput();
+ try {
+ mainIndexInput.open();
+ } catch(IOException e) {
+ BlocksIndexInput input = mainIndexInput;
+ try {
+ input.setOpen(true);
+ input.close();
+ } finally {
+ input.setOpen(false);
+ }
+ //System.out.println(" Index.initialize(): Deleting Index file =
" + indexFile.getName());
+ indexFile.delete();
+ mainIndexInput = null;
+ throw e;
+ }
+ if( !doCache ) {
+ mainIndexInput.close();
+ }
+ } else {
+ InMemoryIndex mainIndex= new InMemoryIndex();
+ IndexOutput mainIndexOutput= new BlocksIndexOutput(indexFile);
+ mainIndex.save(mainIndexOutput);
+ }
+ }
+
+ /**
+ * Merges the in memory index and the index on the disk, and saves the results on the
disk.
+ */
+ protected void merge() throws IOException {
+ //initialisation of tempIndex
+ File tempFile= new File(indexFile.getAbsolutePath() + "TempVA");
//$NON-NLS-1$
+
+ IndexInput mainIndexInput= getBlocksIndexInput();
+ BlocksIndexOutput tempIndexOutput= new BlocksIndexOutput(tempFile);
+
+ try {
+ //invoke a mergeFactory
+ new MergeFactory(
+ mainIndexInput,
+ addsIndexInput,
+ tempIndexOutput,
+ removedInOld,
+ removedInAdds).merge();
+
+ //rename the file created to become the main index
+ File mainIndexFile= (File) mainIndexInput.getSource();
+ File tempIndexFile= (File) tempIndexOutput.getDestination();
+ //System.out.println(" Index.merge(): Deleting Index file = " +
mainIndexFile.getName());
+
+ mainIndexFile.delete();
+ tempIndexFile.renameTo(mainIndexFile);
+ //if( doCache ) {
+ //mainIndexInput.open();
+ //}
+ //System.out.println(" Index.merge(): Renaming Index file = " +
mainIndexFile.getName());
+ } finally {
+ //initialise remove vectors and addsindex, and change the state
+ removedInAdds.clear();
+ removedInOld.clear();
+ addsIndex.init();
+ addsIndexInput= new SimpleIndexInput(addsIndex);
+ if( tempFile.exists() ) {
+ // remove it
+ if( !tempFile.delete() ) {
+ tempFile.deleteOnExit();
+ }
+ }
+ state= MERGED;
+ }
+ }
+
+ /**
+ * @see IIndex#query
+ */
+ public IQueryResult[] query(String word) throws IOException {
+ BlocksIndexInput input= getBlocksIndexInput();
+ try {
+ return input.query(word);
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ public IEntryResult[] queryEntries(char[] prefix) throws IOException {
+ BlocksIndexInput input= getBlocksIndexInput();
+ try {
+ return input.queryEntriesPrefixedBy(prefix);
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * @see IIndex#queryInDocumentNames
+ */
+ public IQueryResult[] queryInDocumentNames(String word) throws IOException {
+ BlocksIndexInput input= getBlocksIndexInput();
+ try {
+ return input.queryInDocumentNames(word);
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * @see IIndex#queryPrefix
+ */
+ public IQueryResult[] queryPrefix(char[] prefix) throws IOException {
+ BlocksIndexInput input= getBlocksIndexInput();
+ try {
+ return input.queryFilesReferringToPrefix(prefix);
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * Overloaded the method in Index to allow a user to specify if the
+ * query should be case sensitive.
+ */
+ public IEntryResult[] queryEntriesMatching(char[] prefix, boolean isCaseSensitive)
throws IOException {
+ BlocksIndexInput input= getBlocksIndexInput();
+ try {
+ return input.queryEntriesMatching(prefix,isCaseSensitive);
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * Overloaded the method in Index to allow a user to specify if the
+ * query should be case sensitive.
+ */
+ public IEntryResult[] queryEntries(char[] prefix, boolean isCaseSensitive) throws
IOException {
+ BlocksIndexInput input = getBlocksIndexInput();
+ try {
+ return input.queryEntriesPrefixedBy(prefix,isCaseSensitive);
+ } finally {
+ if( !doCache ) {
+ input.close();
+ }
+ }
+ }
+
+ /**
+ * @see IIndex#remove
+ */
+ public void remove(String documentName) throws IOException {
+ IndexedFile file= addsIndex.getIndexedFile(documentName);
+ if (file != null) {
+ //the file is in the adds Index, we remove it from this one
+ int[] lastRemoved= (int[]) removedInAdds.get(documentName);
+ if (lastRemoved != null) {
+ int fileNum= file.getFileNumber();
+ if (lastRemoved[0] < fileNum)
+ lastRemoved[0] = fileNum;
+ } else
+ removedInAdds.put(documentName, new int[] {file.getFileNumber()});
+ } else {
+ //we remove the file from the old index
+ removedInOld.put(documentName, new int[] {1});
+ }
+ state= CAN_MERGE;
+ }
+
+ /**
+ * Removes the given document from the given index (MergeFactory.ADDS_INDEX for the
+ * in memory index, MergeFactory.OLD_INDEX for the index on the disk).
+ */
+ protected void remove(IndexedFile file, int index) throws IOException {
+ String name= file.getPath();
+ if (index == MergeFactory.ADDS_INDEX) {
+ int[] lastRemoved= (int[])removedInAdds.get(name);
+ if (lastRemoved != null) {
+ if (lastRemoved[0] < file.getFileNumber())
+ lastRemoved[0] = file.getFileNumber();
+ } else
+ removedInAdds.put(name, new int[] {file.getFileNumber()});
+ } else if (index == MergeFactory.OLD_INDEX)
+ removedInOld.put(name, new int[] {1});
+ else
+ throw new Error();
+ state= CAN_MERGE;
+ }
+
+ /**
+ * @see IIndex#save
+ */
+ public void save() throws IOException {
+ if (canMerge()) {
+ //System.out.println(" Index.save(): Index file = " +
indexFile.getName() + " Model = " + resourceFileName);
+ merge();
+ }
+ }
+
+ protected BlocksIndexInput getBlocksIndexInput() {
+ if( doCache ) {
+ if( getCachedInput() == null ) {
+ boolean wasLoaded = false;
+ try {
+ if( getCachedInput() == null ) {
+ setCachedInput( new BlocksIndexInput(indexFile) );
+ getCachedInput().open();
+ wasLoaded = true;
+ }
+ } catch ( IOException theException ) {
+
+ } finally {
+ if( wasLoaded && getCachedInput() != null ) {
+ return getCachedInput();
+ }
+ setCachedInput(null);
+ }
+ } else {
+ return getCachedInput();
+ }
+ }
+
+ return new BlocksIndexInput(indexFile);
+ }
+
+ public void close() {
+ if( getCachedInput() != null ) {
+ try {
+ getCachedInput().close();
+ } catch (IOException theException) {
+ } finally {
+ setCachedInput(null);
+ }
+ }
+ }
+
+ public void dispose() {
+ close();
+ if( !indexFile.delete() ) {
+ indexFile.deleteOnExit();
+ }
+ }
+
+ /**
+ * Returns true if the in memory index reaches a critical size,
+ * to merge it with the index on the disk.
+ */
+ protected boolean timeToMerge() {
+ return (addsIndex.getFootprint() >= MAX_FOOTPRINT);
+ }
+
+ public String toString() {
+ String str = this.toString;
+ if (str == null) str = super.toString();
+ str += "(length: "+ getIndexFile().length() +")"; //$NON-NLS-1$
//$NON-NLS-2$
+ return str;
+ }
+
+ public void setDoCache(boolean theDoCache) {
+ this.doCache = theDoCache;
+ }
+
+ public BlocksIndexInput getCachedInput() {
+ return this.cachedInput;
+ }
+
+ public void setCachedInput(BlocksIndexInput theCachedInput) {
+ this.cachedInput = theCachedInput;
+ }
+
+ public String getResourceFileName() {
+ return this.resourceFileName;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexBlock.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexBlock.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexBlock.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.util.Arrays;
+
+import org.teiid.metadata.index.CharOperation;
+
+
+/**
+ * An indexBlock stores wordEntries.
+ */
+
+public abstract class IndexBlock extends Block {
+
+ public IndexBlock(int blockSize) {
+ super(blockSize);
+ }
+ /**
+ * Adds the given wordEntry to the indexBlock.
+ */
+
+ public abstract boolean addEntry(WordEntry entry);
+ /**
+ * @see Block#clear()
+ */
+ public void clear() {
+ reset();
+ super.clear();
+ }
+ public WordEntry findEntryPrefixedBy(char[] word, boolean isCaseSensitive) {
+ reset();
+ WordEntry entry= new WordEntry();
+ while (nextEntry(entry)) {
+ if (CharOperation.prefixEquals(entry.getWord(), word, isCaseSensitive)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+ public WordEntry findExactEntry(char[] word) {
+ reset();
+ WordEntry entry= new WordEntry();
+ while (nextEntry(entry)) {
+ if (Arrays.equals(entry.getWord(), word)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+ /**
+ * Returns whether the block is empty or not (if it doesn't contain any wordEntry).
+ */
+ public abstract boolean isEmpty();
+
+ /**
+ * Finds the next wordEntry and stores it in the given entry.
+ */
+ public abstract boolean nextEntry(WordEntry entry);
+
+ public void reset() {
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexInput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexInput.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexInput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IEntryResult;
+import org.teiid.core.index.IQueryResult;
+
+
+
+/**
+ * This class provides an input on an index, after it has been generated.
+ * You can access all the files of an index via getNextFile(), getCurrentFile()
+ * and moveToNextFile() (idem for the word entries).
+ * The usage is the same for every subclass: creation (constructor), opening
+ * (the open() method), usage, and closing (the close() method), to release the
+ * data source used by this input.
+ */
+public abstract class IndexInput {
+ protected int filePosition;
+ protected WordEntry currentWordEntry;
+ protected int wordPosition;
+
+ // Cache the open state of the Index
+ private boolean openState;
+
+
+ public IndexInput() {
+ super();
+ wordPosition= 1;
+ filePosition= 1;
+ }
+ /**
+ * clears the cache of this indexInput, if it keeps track of the information already
read.
+ */
+ public abstract void clearCache();
+ /**
+ * Closes the IndexInput. For example, if the input is on a RandomAccessFile,
+ * it calls the close() method of RandomAccessFile.
+ */
+ public abstract void close() throws IOException;
+ /**
+ * Returns the current file the indexInput is pointing to in the index.
+ */
+ public abstract IndexedFile getCurrentFile() throws IOException;
+ /**
+ * Returns the current file the indexInput is pointing to in the index.
+ */
+ public WordEntry getCurrentWordEntry() throws IOException {
+ if (!hasMoreWords())
+ return null;
+ return currentWordEntry;
+ }
+ /**
+ * Returns the position of the current file the input is pointing to in the index.
+ */
+ public int getFilePosition() {
+ return filePosition;
+ }
+ /**
+ * Set the open state of the Index
+ * @since 5.0
+ */
+ public void setOpen(boolean state) {
+ this.openState = state;
+ }
+
+ /**
+ * returns the open state of the index
+ * @since 5.0
+ */
+ public boolean isOpen() {
+ return this.openState;
+ }
+
+ /**
+ * Returns the indexedFile corresponding to the given document number in the index the
input
+ * reads in, or null if such indexedFile does not exist.
+ */
+ public abstract IndexedFile getIndexedFile(int fileNum) throws IOException;
+ /**
+ * Returns the indexedFile corresponding to the given document in the index the input
+ * reads in (e.g. the indexedFile with the same path in this index), or null if such
+ * indexedFile does not exist.
+ */
+ public abstract IndexedFile getIndexedFile(IDocument document) throws IOException;
+ /**
+ * Returns the number of files in the index.
+ */
+ public abstract int getNumFiles();
+ /**
+ * Returns the number of unique words in the index.
+ */
+ public abstract int getNumWords();
+ /**
+ * Returns the Object the input is reading from. It can be an IIndex,
+ * a File, ...
+ */
+ public abstract Object getSource();
+ /**
+ * Returns true if the input has not reached the end of the index for the files.
+ */
+ public boolean hasMoreFiles() {
+ return getFilePosition() <= getNumFiles();
+ }
+ /**
+ * Returns true if the input has not reached the end of the index for the files.
+ */
+ public boolean hasMoreWords() {
+ return wordPosition <= getNumWords();
+ }
+ /**
+ * Moves the pointer on the current file to the next file in the index.
+ */
+ public abstract void moveToNextFile() throws IOException;
+ /**
+ * Moves the pointer on the current word to the next file in the index.
+ */
+ public abstract void moveToNextWordEntry() throws IOException;
+ /**
+ * Open the Source where the input gets the information from.
+ */
+ public abstract void open() throws IOException;
+ /**
+ * Returns the list of the files containing the given word in the index.
+ */
+ public abstract IEntryResult[] queryEntriesPrefixedBy(char[] prefix) throws
IOException;
+ public abstract IQueryResult[] queryFilesReferringToPrefix(char[] prefix) throws
IOException;
+ /**
+ * Returns the list of the files whose name contain the given word in the index.
+ */
+ public abstract IQueryResult[] queryInDocumentNames(String word) throws IOException;
+ /**
+ * Set the pointer on the current file to the first file of the index.
+ */
+ protected abstract void setFirstFile() throws IOException;
+ /**
+ * Set the pointer on the current word to the first word of the index.
+ */
+ protected abstract void setFirstWord() throws IOException;
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexInput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexOutput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexOutput.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexOutput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+
+/**
+ * An indexOutput is used to write an index into a different object (a File, ...).
+ */
+public abstract class IndexOutput {
+ /**
+ * Adds a File to the destination.
+ */
+ public abstract void addFile(IndexedFile file) throws IOException;
+ /**
+ * Adds a word to the destination.
+ */
+ public abstract void addWord(WordEntry word) throws IOException;
+ /**
+ * Closes the output, releasing the resources it was using.
+ */
+ public abstract void close() throws IOException;
+ /**
+ * Flushes the output.
+ */
+ public abstract void flush() throws IOException;
+ /**
+ * Returns the Object the output is writing to. It can be a file, another type of index,
...
+ */
+ public abstract Object getDestination();
+ /**
+ * Opens the output, before writing any information.
+ */
+ public abstract void open() throws IOException;
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexOutput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexSummary.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexSummary.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexSummary.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+
+import org.teiid.metadata.index.CharOperation;
+
+
+
+/**
+ * An indexSummary is used when saving an index into a BlocksIndexOuput or
+ * reading it from a BlocksIndexInput. It contains basic informations about
+ * an index: first files/words in each block, number of files/words.
+ */
+
+public class IndexSummary {
+ /**
+ * First file for each block.
+ */
+ protected ArrayList firstFilesInBlocks= new ArrayList();
+
+ /**
+ * First word for each block.
+ */
+ protected ArrayList firstWordsInBlocks= new ArrayList();
+
+ /**
+ * Number of files in the index.
+ */
+ protected int numFiles;
+
+ /**
+ * Number of words in the index.
+ */
+ protected int numWords;
+
+ static class FirstFileInBlock {
+ IndexedFile indexedFile;
+ int blockNum;
+ }
+
+ static class FirstWordInBlock {
+ char[] word;
+ int blockNum;
+ public String toString(){
+ return "FirstWordInBlock: " + new String(word) + ", blockNum: " +
blockNum; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ protected int firstWordBlockNum;
+ protected boolean firstWordAdded= true;
+ /**
+ * Adds the given file as the first file for the given Block number.
+ */
+ public void addFirstFileInBlock(IndexedFile indexedFile, int blockNum) {
+ FirstFileInBlock entry= new FirstFileInBlock();
+ entry.indexedFile= indexedFile;
+ entry.blockNum= blockNum;
+ firstFilesInBlocks.add(entry);
+ }
+ /**
+ * Adds the given word as the first word for the given Block number.
+ */
+ public void addFirstWordInBlock(char[] word, int blockNum) {
+ if (firstWordAdded) {
+ firstWordBlockNum= blockNum;
+ firstWordAdded= false;
+ }
+ FirstWordInBlock entry= new FirstWordInBlock();
+ entry.word= word;
+ entry.blockNum= blockNum;
+ firstWordsInBlocks.add(entry);
+ }
+ /**
+ * Returns the numbers of all the blocks
+ */
+ public int[] getAllBlockNums() {
+
+ int max = firstWordsInBlocks.size();
+ int[] blockNums = new int[max];
+ for (int i = 0; i < max; i++){
+ blockNums[i] = ((FirstWordInBlock)firstWordsInBlocks.get(i)).blockNum;
+ }
+ return blockNums;
+ }
+ public int getBlockNum(int blockLocation) {
+ return ((FirstWordInBlock) firstWordsInBlocks.get(blockLocation)).blockNum;
+ }
+ /**
+ * Returns the number of the Block containing the file with the given number.
+ */
+ public int getBlockNumForFileNum(int fileNum) {
+ int min= 0;
+ int max= firstFilesInBlocks.size() - 1;
+ while (min <= max) {
+ int mid= (min + max) / 2;
+ FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(mid);
+ int compare= fileNum - entry.indexedFile.getFileNumber();
+ if (compare == 0)
+ return entry.blockNum;
+ if (compare < 0)
+ max= mid - 1;
+ else
+ min= mid + 1;
+ }
+ if (max < 0)
+ return -1;
+ FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(max);
+ return entry.blockNum;
+ }
+ /**
+ * Returns the number of the Block containing the given word.
+ */
+ public int getBlockNumForWord(char[] word) {
+ int min= 0;
+ int max= firstWordsInBlocks.size() - 1;
+ while (min <= max) {
+ int mid= (min + max) / 2;
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(mid);
+ int compare= Util.compare(word, entry.word);
+ if (compare == 0)
+ return entry.blockNum;
+ if (compare < 0)
+ max= mid - 1;
+ else
+ min= mid + 1;
+ }
+ if (max < 0)
+ return -1;
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(max);
+ return entry.blockNum;
+ }
+
+ public int[] getBlockNumsForPrefix(char[] prefix) {
+ int min= 0;
+ int size= firstWordsInBlocks.size();
+ int max= size - 1;
+ int match= -1;
+ while (min <= max && match < 0) {
+ int mid= (min + max) / 2;
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(mid);
+ int compare= compareWith(entry.word, prefix, true);
+ if (compare == 0) {
+ match= mid;
+ break;
+ }
+ if (compare >= 0)
+ max= mid - 1;
+ else
+ min= mid + 1;
+ }
+ if (max < 0)
+ return new int[0];
+
+ if (match < 0)
+ match= max;
+
+ int firstBlock= match - 1;
+ // Look if previous blocks are affected
+ for (; firstBlock >= 0; firstBlock--) {
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(firstBlock);
+ if (!CharOperation.prefixEquals(prefix, entry.word, true))
+ break;
+ }
+ if (firstBlock < 0)
+ firstBlock= 0;
+
+ // Look if next blocks are affected
+ int firstNotIncludedBlock= match + 1;
+ for (; firstNotIncludedBlock < size; firstNotIncludedBlock++) {
+ FirstWordInBlock entry= (FirstWordInBlock)
firstWordsInBlocks.get(firstNotIncludedBlock);
+ if (!CharOperation.prefixEquals(prefix, entry.word, true))
+ break;
+ }
+
+ int numberOfBlocks= firstNotIncludedBlock - firstBlock;
+ int[] result= new int[numberOfBlocks];
+ int pos= firstBlock;
+ for (int i= 0; i < numberOfBlocks; i++, pos++) {
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(pos);
+ result[i]= entry.blockNum;
+ }
+ return result;
+ }
+
+ public int getFirstBlockLocationForPrefix(char[] prefix) {
+ int min = 0;
+ int size = firstWordsInBlocks.size();
+ int max = size - 1;
+ int match = -1;
+ while (min <= max) {
+ int mid = (min + max) / 2;
+ FirstWordInBlock entry = (FirstWordInBlock) firstWordsInBlocks.get(mid);
+ int compare = compareWith(entry.word, prefix, false);
+ if (compare == 0) {
+ match = mid;
+ break;
+ }
+ if (compare >= 0) {
+ max = mid - 1;
+ } else {
+ match = mid; // not perfect match, but could be inside
+ min = mid + 1;
+ }
+ }
+ if (max < 0) return -1;
+
+ // no match at all, might be some matching entries inside max block
+ if (match < 0){
+ match = max;
+ } else {
+ // look for possible matches inside previous blocks
+ while (match > 0){
+ FirstWordInBlock entry = (FirstWordInBlock) firstWordsInBlocks.get(match);
+ if (!CharOperation.prefixEquals(prefix, entry.word, true))
+ break;
+ match--;
+ }
+ }
+ return match;
+ }
+
+ static final int compareWith(char[] array, char[] prefix, boolean caseSensitive) {
+ int arrayLength = array.length;
+ int prefixLength = prefix.length;
+ int min = Math.min(arrayLength, prefixLength);
+ int i = 0;
+ while (min-- != 0) {
+ char c1 = array[i];
+ char c2 = prefix[i++];
+ int diff = c1 - c2;
+ if (diff != 0) {
+ if(!caseSensitive && Character.toLowerCase(c1) ==
Character.toLowerCase(c2)) {
+ continue;
+ }
+ return diff;
+ }
+ }
+ if (prefixLength == i)
+ return 0;
+ return -1; // array is shorter than prefix (e.g. array:'ab' <
prefix:'abc').
+ }
+
+ /**
+ * Returns the number of the first IndexBlock (containing words).
+ */
+ public int getFirstWordBlockNum() {
+ return firstWordBlockNum;
+ }
+ /**
+ * Blocks are contiguous, so the next one is a potential candidate if its first word
starts with
+ * the given prefix
+ */
+ public int getNextBlockLocationForPrefix(char[] prefix, int blockLoc) {
+ if (++blockLoc < firstWordsInBlocks.size()){
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(blockLoc);
+ if (CharOperation.prefixEquals(prefix, entry.word, true)) return blockLoc;
+ }
+ return -1;
+ }
+ /**
+ * Returns the number of files contained in the index.
+ */
+ public int getNumFiles() {
+ return numFiles;
+ }
+ /**
+ * Returns the number of words contained in the index.
+ */
+ public int getNumWords() {
+ return numWords;
+ }
+ /**
+ * Loads the summary in memory.
+ */
+ public void read(RandomAccessFile raf) throws IOException {
+ numFiles= raf.readInt();
+ numWords= raf.readInt();
+ firstWordBlockNum= raf.readInt();
+ int numFirstFiles= raf.readInt();
+ for (int i= 0; i < numFirstFiles; ++i) {
+ FirstFileInBlock entry= new FirstFileInBlock();
+ String path= raf.readUTF();
+ int fileNum= raf.readInt();
+ entry.indexedFile= new IndexedFile(path, fileNum);
+ entry.blockNum= raf.readInt();
+ firstFilesInBlocks.add(entry);
+ }
+ int numFirstWords= raf.readInt();
+ for (int i= 0; i < numFirstWords; ++i) {
+ FirstWordInBlock entry= new FirstWordInBlock();
+ entry.word= raf.readUTF().toCharArray();
+ entry.blockNum= raf.readInt();
+ firstWordsInBlocks.add(entry);
+ }
+ }
+ /**
+ * Sets the number of files of the index.
+ */
+
+ public void setNumFiles(int numFiles) {
+ this.numFiles= numFiles;
+ }
+ /**
+ * Sets the number of words of the index.
+ */
+
+ public void setNumWords(int numWords) {
+ this.numWords= numWords;
+ }
+ /**
+ * Saves the summary on the disk.
+ */
+ public void write(RandomAccessFile raf) throws IOException {
+ raf.writeInt(numFiles);
+ raf.writeInt(numWords);
+ raf.writeInt(firstWordBlockNum);
+ raf.writeInt(firstFilesInBlocks.size());
+ for (int i= 0, size= firstFilesInBlocks.size(); i < size; ++i) {
+ FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(i);
+ raf.writeUTF(entry.indexedFile.getPath());
+ raf.writeInt(entry.indexedFile.getFileNumber());
+ raf.writeInt(entry.blockNum);
+ }
+ raf.writeInt(firstWordsInBlocks.size());
+ for (int i= 0, size= firstWordsInBlocks.size(); i < size; ++i) {
+ FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(i);
+ raf.writeUTF(new String(entry.word));
+ raf.writeInt(entry.blockNum);
+ }
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexSummary.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFile.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFile.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFile.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IQueryResult;
+
+/**
+ * An indexedFile associates a number to a document path, and document properties.
+ * It is what we add into an index, and the result of a query.
+ */
+
+public class IndexedFile implements IQueryResult, Comparable<IndexedFile> {
+ protected String path;
+ protected int fileNumber;
+
+ public IndexedFile(String path, int fileNum) {
+ if (fileNum < 1)
+ throw new IllegalArgumentException();
+ this.fileNumber= fileNum;
+ this.path= path;
+ }
+ public IndexedFile(IDocument document, int fileNum) {
+ if (fileNum < 1)
+ throw new IllegalArgumentException();
+ this.path= document.getName();
+ this.fileNumber= fileNum;
+ }
+
+ /**
+ * Returns the size of the indexedFile.
+ */
+ public int footprint() {
+ //object+ 2 slots + size of the string (header + 4 slots + char[])
+ return 8 + (2 * 4) + (8 + (4 * 4) + 8 + path.length() * 2);
+ }
+ /**
+ * Returns the file number.
+ */
+ public int getFileNumber() {
+ return fileNumber;
+ }
+ /**
+ * Returns the path.
+ */
+ public String getPath() {
+ return path;
+ }
+ /**
+ * Sets the file number.
+ */
+ public void setFileNumber(int fileNumber) {
+ this.fileNumber= fileNumber;
+ }
+ public String toString() {
+ return "IndexedFile(" + fileNumber + ": " + path + ")";
//$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ }
+ public int compareTo(IndexedFile other) {
+ return this.path.compareTo(other.path);
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFile.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFileHashedArray.java
===================================================================
---
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFileHashedArray.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFileHashedArray.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.util.ArrayList;
+
+import org.teiid.core.index.IDocument;
+
+
+public final class IndexedFileHashedArray {
+
+private IndexedFile elements[];
+private int elementSize; // number of elements in the table
+private int threshold;
+private int lastId;
+private ArrayList replacedElements;
+
+public IndexedFileHashedArray(int size) {
+ if (size < 7) size = 7;
+ this.elements = new IndexedFile[2 * size + 1];
+ this.elementSize = 0;
+ this.threshold = size + 1; // size is the expected number of elements
+ this.lastId = 0;
+ this.replacedElements = null;
+}
+
+public IndexedFile add(IDocument document) {
+ return add(new IndexedFile(document, ++lastId));
+}
+
+private IndexedFile add(IndexedFile file) {
+ int length = elements.length;
+ String path = file.getPath();
+ int index = (path.hashCode() & 0x7FFFFFFF) % length;
+ IndexedFile current;
+ while ((current = elements[index]) != null) {
+ if (current.getPath().equals(path)) {
+ if (replacedElements == null) replacedElements = new ArrayList(5);
+ replacedElements.add(current);
+ return elements[index] = file;
+ }
+ if (++index == length) index = 0;
+ }
+ elements[index] = file;
+
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold) grow();
+ return file;
+}
+
+public IndexedFile[] asArray() {
+ IndexedFile[] array = new IndexedFile[lastId];
+ for (int i = 0, length = elements.length; i < length; i++) {
+ IndexedFile current = elements[i];
+ if (current != null)
+ array[current.fileNumber - 1] = current;
+ }
+ if (replacedElements != null) {
+ for (int i = 0, length = replacedElements.size(); i < length; i++) {
+ IndexedFile current = (IndexedFile) replacedElements.get(i);
+ array[current.fileNumber - 1] = current;
+ }
+ }
+ return array;
+}
+
+public IndexedFile get(String path) {
+ int length = elements.length;
+ int index = (path.hashCode() & 0x7FFFFFFF) % length;
+ IndexedFile current;
+ while ((current = elements[index]) != null) {
+ if (current.getPath().equals(path)) return current;
+ if (++index == length) index = 0;
+ }
+ return null;
+}
+
+private void grow() {
+ IndexedFileHashedArray newArray = new IndexedFileHashedArray(elementSize * 2); // double
the number of expected elements
+ for (int i = 0, length = elements.length; i < length; i++)
+ if (elements[i] != null)
+ newArray.add(elements[i]);
+
+ // leave replacedElements as is
+ this.elements = newArray.elements;
+ this.elementSize = newArray.elementSize;
+ this.threshold = newArray.threshold;
+}
+
+public int size() {
+ return elementSize + (replacedElements == null ? 0 : replacedElements.size());
+}
+
+public String toString() {
+ String s = ""; //$NON-NLS-1$
+ IndexedFile[] files = asArray();
+ for (int i = 0, length = files.length; i < length; i++)
+ s += files[i].toString() + "\n"; //$NON-NLS-1$
+ return s;
+}
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexedFileHashedArray.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexerOutput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexerOutput.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexerOutput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IIndexerOutput;
+
+/**
+ * An indexerOutput is used by an indexer to add documents and word references to
+ * an inMemoryIndex. It keeps track of the document being indexed and add the
+ * word references to this document (so you do not need to precise the document
+ * each time you add a word).
+ */
+
+public class IndexerOutput implements IIndexerOutput {
+ protected InMemoryIndex index;
+ protected IndexedFile indexedFile;
+ protected IDocument document;
+ /**
+ * IndexerOutput constructor comment.
+ */
+ public IndexerOutput(InMemoryIndex index) {
+ this.index= index;
+ }
+ /**
+ * Adds the given document to the inMemoryIndex.
+ */
+
+ public void addDocument(IDocument document) {
+ if (indexedFile == null) {
+ indexedFile= index.addDocument(document);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+ /**
+ * Adds a reference to the given word to the inMemoryIndex.
+ */
+ public void addRef(char[] word) {
+ if (indexedFile == null) {
+ throw new IllegalStateException();
+ }
+ index.addRef(indexedFile, word);
+ }
+ /**
+ * Adds a reference to the given word to the inMemoryIndex.
+ */
+ public void addRef(String word) {
+ addRef(word.toCharArray());
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/IndexerOutput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/MergeFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/MergeFactory.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/MergeFactory.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * A mergeFactory is used to merge 2 indexes into one. One of the indexes
+ * (oldIndex) is on the disk and the other(addsIndex) is in memory.
+ * The merge respects the following rules: <br>
+ * - The files are sorted in alphabetical order;<br>
+ * - if a file is in oldIndex and addsIndex, the one which is added
+ * is the one in the addsIndex.<br>
+ */
+public class MergeFactory {
+ /**
+ * Input on the addsIndex.
+ */
+ protected IndexInput addsInput;
+
+ /**
+ * Input on the oldIndex.
+ */
+ protected IndexInput oldInput;
+
+ /**
+ * Output to write the result of the merge in.
+ */
+ protected BlocksIndexOutput mergeOutput;
+
+ /**
+ * Files removed from oldIndex.
+ */
+ protected Map removedInOld;
+
+ /**
+ * Files removed from addsIndex.
+ */
+ protected Map removedInAdds;
+ protected int[] mappingOld;
+ protected int[] mappingAdds;
+ public static final int ADDS_INDEX= 0;
+ public static final int OLD_INDEX= 1;
+ /**
+ * MergeFactory constructor comment.
+ * @param directory java.io.File
+ */
+ public MergeFactory(IndexInput oldIndexInput, IndexInput addsIndexInput,
BlocksIndexOutput mergeIndexOutput, Map removedInOld, Map removedInAdds) {
+ oldInput= oldIndexInput;
+ addsInput= addsIndexInput;
+ mergeOutput= mergeIndexOutput;
+ this.removedInOld= removedInOld;
+ this.removedInAdds= removedInAdds;
+ }
+ /**
+ * Initialise the merge.
+ */
+ protected void init() {
+ mappingOld= new int[oldInput.getNumFiles() + 1];
+ mappingAdds= new int[addsInput.getNumFiles() + 1];
+
+ }
+ /**
+ * Merges the 2 indexes into a new one on the disk.
+ */
+ public void merge() throws IOException {
+ try {
+ //init
+ addsInput.open();
+ oldInput.open();
+ mergeOutput.open();
+ init();
+ //merge
+ //findChanges();
+ mergeFiles();
+ mergeReferences();
+ mergeOutput.flush();
+ } finally {
+ //closes everything
+ oldInput.close();
+ addsInput.close();
+ mergeOutput.close();
+ }
+ }
+ /**
+ * Merges the files of the 2 indexes in the new index, removes the files
+ * to be removed, and records the changes made to propagate them to the
+ * word references.
+ */
+
+ protected void mergeFiles() throws IOException {
+ int positionInMerge= 1;
+ int compare;
+ while (oldInput.hasMoreFiles() || addsInput.hasMoreFiles()) {
+ IndexedFile file1= oldInput.getCurrentFile();
+ IndexedFile file2= addsInput.getCurrentFile();
+
+ //if the file has been removed we don't take it into account
+ while (file1 != null && wasRemoved(file1, OLD_INDEX)) {
+ oldInput.moveToNextFile();
+ file1= oldInput.getCurrentFile();
+ }
+ while (file2 != null && wasRemoved(file2, ADDS_INDEX)) {
+ addsInput.moveToNextFile();
+ file2= addsInput.getCurrentFile();
+ }
+
+ //the addsIndex was empty, we just removed files from the oldIndex
+ if (file1 == null && file2 == null)
+ break;
+
+ //test if we reached the end of one the 2 index
+ if (file1 == null)
+ compare= 1;
+ else if (file2 == null)
+ compare= -1;
+ else
+ compare= file1.getPath().compareTo(file2.getPath());
+
+ //records the changes to Make
+ if (compare == 0) {
+ //the file has been modified:
+ //we remove it from the oldIndex and add it to the addsIndex
+ removeFile(file1, OLD_INDEX);
+ mappingAdds[file2.getFileNumber()]= positionInMerge;
+ file1.setFileNumber(positionInMerge);
+ mergeOutput.addFile(file1);
+ oldInput.moveToNextFile();
+ addsInput.moveToNextFile();
+ } else if (compare < 0) {
+ mappingOld[file1.getFileNumber()]= positionInMerge;
+ file1.setFileNumber(positionInMerge);
+ mergeOutput.addFile(file1);
+ oldInput.moveToNextFile();
+ } else {
+ mappingAdds[file2.getFileNumber()]= positionInMerge;
+ file2.setFileNumber(positionInMerge);
+ mergeOutput.addFile(file2);
+ addsInput.moveToNextFile();
+ }
+ positionInMerge++;
+ }
+ mergeOutput.flushFiles();
+ }
+ /**
+ * Merges the files of the 2 indexes in the new index, according to the changes
+ * recorded during mergeFiles().
+ */
+ protected void mergeReferences() throws IOException {
+ int compare;
+ while (oldInput.hasMoreWords() || addsInput.hasMoreWords()) {
+ WordEntry word1= oldInput.getCurrentWordEntry();
+ WordEntry word2= addsInput.getCurrentWordEntry();
+
+ if (word1 == null && word2 == null)
+ break;
+
+ if (word1 == null)
+ compare= 1;
+ else if (word2 == null)
+ compare= -1;
+ else
+ compare= Util.compare(word1.getWord(), word2.getWord());
+ if (compare < 0) {
+ word1.mapRefs(mappingOld);
+ mergeOutput.addWord(word1);
+ oldInput.moveToNextWordEntry();
+ } else if (compare > 0) {
+ word2.mapRefs(mappingAdds);
+ mergeOutput.addWord(word2);
+ addsInput.moveToNextWordEntry();
+ } else {
+ word1.mapRefs(mappingOld);
+ word2.mapRefs(mappingAdds);
+ word1.addRefs(word2.getRefs());
+ mergeOutput.addWord(word1);
+ addsInput.moveToNextWordEntry();
+ oldInput.moveToNextWordEntry();
+ }
+ }
+ mergeOutput.flushWords();
+ }
+ /**
+ * Records the deletion of one file.
+ */
+ protected void removeFile(IndexedFile file, int index) {
+ if (index == OLD_INDEX)
+ mappingOld[file.getFileNumber()]= -1;
+ else
+ mappingAdds[file.getFileNumber()]= -1;
+ }
+ /**
+ * Returns whether the given file has to be removed from the given index
+ * (ADDS_INDEX or OLD_INDEX). If it has to be removed, the mergeFactory
+ * deletes it and records the changes.
+ */
+
+ protected boolean wasRemoved(IndexedFile indexedFile, int index) {
+ String path= indexedFile.getPath();
+ if (index == OLD_INDEX) {
+ if (removedInOld.remove(path) != null) {
+ mappingOld[indexedFile.getFileNumber()]= -1;
+ return true;
+ }
+ } else if (index == ADDS_INDEX) {
+ int[] lastRemoved= (int[]) removedInAdds.get(path);
+ if (lastRemoved != null) {
+ int fileNum= indexedFile.getFileNumber();
+ if (lastRemoved[0] >= fileNum) {
+ mappingAdds[fileNum]= -1;
+ //if (lastRemoved.value == fileNum) // ONLY if files in sorted order for names AND
fileNums
+ //removedInAdds.remove(path);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/MergeFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/PropertyDocument.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/PropertyDocument.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/PropertyDocument.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.teiid.core.index.IDocument;
+
+
+/**
+ * The properties of a document are stored into a hashtable.
+ * @see IDocument
+ */
+
+public abstract class PropertyDocument implements IDocument {
+ protected Hashtable properties;
+ public PropertyDocument() {
+ properties= new Hashtable(5);
+ }
+ /**
+ * @see IDocument#getProperty
+ */
+ public String getProperty(String property) {
+ return (String) properties.get(property);
+ }
+ /**
+ * @see IDocument#getPropertyNames
+ */
+
+ public Enumeration getPropertyNames() {
+ return properties.keys();
+ }
+ /**
+ * @see IDocument#setProperty
+ */
+
+ public void setProperty(String property, String value) {
+ properties.put(property, value);
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/PropertyDocument.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/metadata/src/main/java/org/teiid/internal/core/index/SafeRandomAccessFile.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/SafeRandomAccessFile.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/SafeRandomAccessFile.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * A safe subclass of RandomAccessFile, which ensure that it's closed
+ * on finalize.
+ */
+public class SafeRandomAccessFile extends RandomAccessFile {
+ public SafeRandomAccessFile(java.io.File file, String mode) throws java.io.IOException
{
+ super(file, mode);
+ }
+ public SafeRandomAccessFile(String name, String mode) throws java.io.IOException {
+ super(name, mode);
+ }
+ protected void finalize() throws IOException {
+ close();
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/SafeRandomAccessFile.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexBlock.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexBlock.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexBlock.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.UTFDataFormatException;
+import java.util.Arrays;
+/**
+ * Does no compression of words, and uses 4-byte ints for file numbers and number of
files.
+ */
+public class SimpleIndexBlock extends IndexBlock {
+ protected int offset= 0;
+
+ public SimpleIndexBlock(int blockSize) {
+ super(blockSize);
+ }
+ /**
+ * @see IndexBlock#addEntry
+ */
+ public boolean addEntry(WordEntry entry) {
+ char[] word= entry.getWord();
+ int n= entry.getNumRefs();
+ int sizeEstimate= 2 + word.length * 3 + 4 + n * 4;
+ int offset= this.offset;
+ if (offset + sizeEstimate > this.blockSize - 2)
+ return false;
+ offset += field.putUTF(offset, word);
+ field.putInt4(offset, n);
+ offset += 4;
+ for (int i= 0; i < n; ++i) {
+ field.putInt4(offset, entry.getRef(i));
+ offset += 4;
+ }
+ this.offset= offset;
+ return true;
+ }
+ public WordEntry findEntry(char[] word) {
+ try {
+ int offset= 0;
+ int byteLen;
+ while ((byteLen= field.getUInt2(offset)) != 0) {
+ char[] tempWord= field.getUTF(offset);
+ offset += byteLen + 2;
+ if (Arrays.equals(tempWord, word)) {
+ WordEntry entry= new WordEntry(word);
+ int n= field.getInt4(offset);
+ offset += 4;
+ for (int i= 0; i < n; ++i) {
+ int ref= field.getInt4(offset);
+ offset += 4;
+ entry.addRef(ref);
+ }
+ return entry;
+ }
+ int n= field.getInt4(offset);
+ offset += 4 + 4 * n;
+ }
+ return null;
+ } catch (UTFDataFormatException e) {
+ return null;
+ }
+ }
+ /**
+ * @see IndexBlock#flush
+ */
+ public void flush() {
+ if (offset > 0) {
+ field.putInt2(offset, 0);
+ offset= 0;
+ }
+ }
+ /**
+ * @see IndexBlock#isEmpty
+ */
+ public boolean isEmpty() {
+ return offset == 0;
+ }
+ /**
+ * @see IndexBlock#nextEntry
+ */
+ public boolean nextEntry(WordEntry entry) {
+ try {
+ int offset= this.offset;
+ int byteLen= field.getUInt2(offset);
+ if (byteLen == 0)
+ return false;
+ char[] word= field.getUTF(offset);
+ offset += byteLen + 2;
+ entry.reset(word);
+ int n= field.getInt4(offset);
+ offset += 4;
+ for (int i= 0; i < n; ++i) {
+ int ref= field.getInt4(offset);
+ offset += 4;
+ entry.addRef(ref);
+ }
+ this.offset= offset;
+ return true;
+ } catch (UTFDataFormatException e) {
+ return false;
+ }
+ }
+ /**
+ * @see IndexBlock#reset
+ */
+ public void reset() {
+ super.reset();
+ this.offset= 0;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexInput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexInput.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexInput.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.teiid.core.index.IDocument;
+import org.teiid.core.index.IEntryResult;
+import org.teiid.core.index.IQueryResult;
+
+
+/**
+ * A simpleIndexInput is an input on an in memory Index.
+ */
+
+public class SimpleIndexInput extends IndexInput {
+ protected WordEntry[] sortedWordEntries;
+ protected IndexedFile currentFile;
+ protected IndexedFile[] sortedFiles;
+ protected InMemoryIndex index;
+
+ public SimpleIndexInput(InMemoryIndex index) {
+ super();
+ this.index= index;
+ }
+ /**
+ * @see IndexInput#clearCache()
+ */
+ public void clearCache() {
+ }
+ /**
+ * @see IndexInput#close()
+ */
+ public void close() throws IOException {
+ sortedFiles= null;
+ }
+ /**
+ * @see IndexInput#getCurrentFile()
+ */
+ public IndexedFile getCurrentFile() throws IOException {
+ if (!hasMoreFiles())
+ return null;
+ return currentFile;
+ }
+ /**
+ * @see IndexInput#getIndexedFile(int)
+ */
+ public IndexedFile getIndexedFile(int fileNum) throws IOException {
+ for (int i= 0; i < sortedFiles.length; i++)
+ if (sortedFiles[i].getFileNumber() == fileNum)
+ return sortedFiles[i];
+ return null;
+ }
+ /**
+ * @see IndexInput#getIndexedFile(IDocument)
+ */
+ public IndexedFile getIndexedFile(IDocument document) throws IOException {
+ String name= document.getName();
+ for (int i= index.getNumFiles(); i >= 1; i--) {
+ IndexedFile file= getIndexedFile(i);
+ if (name.equals(file.getPath()))
+ return file;
+ }
+ return null;
+ }
+ /**
+ * @see IndexInput#getNumFiles()
+ */
+ public int getNumFiles() {
+ return index.getNumFiles();
+ }
+ /**
+ * @see IndexInput#getNumWords()
+ */
+ public int getNumWords() {
+ return sortedWordEntries.length;
+ }
+ /**
+ * @see IndexInput#getSource()
+ */
+ public Object getSource() {
+ return index;
+ }
+ public void init() {
+ index.init();
+
+ }
+ /**
+ * @see IndexInput#moveToNextFile()
+ */
+ public void moveToNextFile() throws IOException {
+ filePosition++;
+ if (!hasMoreFiles()) {
+ return;
+ }
+ currentFile= sortedFiles[filePosition - 1];
+ }
+ /**
+ * @see IndexInput#moveToNextWordEntry()
+ */
+ public void moveToNextWordEntry() throws IOException {
+ wordPosition++;
+ if (hasMoreWords())
+ currentWordEntry= sortedWordEntries[wordPosition - 1];
+ }
+ /**
+ * @see IndexInput#open()
+ */
+ public void open() throws IOException {
+ sortedWordEntries= index.getSortedWordEntries();
+ sortedFiles= index.getSortedFiles();
+ filePosition= 1;
+ wordPosition= 1;
+ setFirstFile();
+ setFirstWord();
+ }
+
+ public IEntryResult[] queryEntriesPrefixedBy(char[] prefix) throws IOException {
+ return null;
+ }
+ public IQueryResult[] queryFilesReferringToPrefix(char[] prefix) throws IOException {
+ return null;
+ }
+ /**
+ * @see IndexInput#queryInDocumentNames(String)
+ */
+ public IQueryResult[] queryInDocumentNames(String word) throws IOException {
+ setFirstFile();
+ ArrayList matches= new ArrayList();
+ while (hasMoreFiles()) {
+ IndexedFile file= getCurrentFile();
+ if (file.getPath().indexOf(word) != -1)
+ matches.add(file.getPath());
+ moveToNextFile();
+ }
+ IQueryResult[] match= new IQueryResult[matches.size()];
+ matches.toArray(match);
+ return match;
+ }
+ /**
+ * @see IndexInput#setFirstFile()
+ */
+ protected void setFirstFile() throws IOException {
+ filePosition= 1;
+ if (sortedFiles.length > 0) {
+ currentFile= sortedFiles[0];
+ }
+ }
+ /**
+ * @see IndexInput#setFirstWord()
+ */
+ protected void setFirstWord() throws IOException {
+ wordPosition= 1;
+ if (sortedWordEntries.length > 0)
+ currentWordEntry= sortedWordEntries[0];
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/SimpleIndexInput.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/Util.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/Util.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/Util.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Util {
+
+ private Util() {
+ }
+
+ /* Bundle containing messages */
+ protected static ResourceBundle bundle;
+ private final static String bundleName = "com.metamatrix.core.index.i18n";
//$NON-NLS-1$
+
+ /**
+ * Lookup the message with the given ID in this catalog
+ */
+ public static String bind(String id) {
+ return bind(id, (String[]) null);
+ }
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string values.
+ */
+ public static String bind(String id, String[] arguments) {
+ if (id == null)
+ return "No message available"; //$NON-NLS-1$
+ String message = null;
+ try {
+ message = bundle.getString(id);
+ } catch (MissingResourceException e) {
+ // If we got an exception looking for the message, fail gracefully by just
returning
+ // the id we were looking for. In most cases this is semi-informative so is
not too bad.
+ return "Missing message: " + id + " in: " + bundleName;
//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ return MessageFormat.format(message, (Object[])arguments);
+ }
+
+ /**
+ * Compares two strings lexicographically.
+ * The comparison is based on the Unicode value of each character in
+ * the strings.
+ *
+ * @return the value <code>0</code> if the str1 is equal to str2;
+ * a value less than <code>0</code> if str1
+ * is lexicographically less than str2;
+ * and a value greater than <code>0</code> if str1 is
+ * lexicographically greater than str2.
+ */
+ public static int compare(char[] str1, char[] str2) {
+ int len1= str1.length;
+ int len2= str2.length;
+ int n= Math.min(len1, len2);
+ int i= 0;
+ while (n-- != 0) {
+ char c1= str1[i];
+ char c2= str2[i++];
+ if (c1 != c2) {
+ return c1 - c2;
+ }
+ }
+ return len1 - len2;
+ }
+
+ /**
+ * Returns the length of the common prefix between s1 and s2.
+ */
+ public static int prefixLength(char[] s1, char[] s2) {
+ int len= 0;
+ int max= Math.min(s1.length, s2.length);
+ for (int i= 0; i < max && s1[i] == s2[i]; ++i)
+ ++len;
+ return len;
+ }
+ /**
+ * Returns the length of the common prefix between s1 and s2.
+ */
+ public static int prefixLength(String s1, String s2) {
+ int len= 0;
+ int max= Math.min(s1.length(), s2.length());
+ for (int i= 0; i < max && s1.charAt(i) == s2.charAt(i); ++i)
+ ++len;
+ return len;
+ }
+}
Property changes on: trunk/metadata/src/main/java/org/teiid/internal/core/index/Util.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/internal/core/index/WordEntry.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/WordEntry.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/WordEntry.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * 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.internal.core.index;
+
+import java.util.Arrays;
+
+
+public class WordEntry implements Comparable<WordEntry> {
+ protected char[] fWord;
+ protected int fNumRefs;
+ protected int[] fRefs;
+ public WordEntry() {
+ this(new char[0]);
+ }
+ public WordEntry(char[] word) {
+ fWord= word;
+ fNumRefs= 0;
+ fRefs= new int[1];
+ }
+ /**
+ * Adds a reference and records the change in footprint.
+ */
+ public int addRef(int fileNum) {
+ if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) {
+ return 0;
+ }
+ if (fNumRefs < fRefs.length) {
+ fRefs[fNumRefs++]= fileNum;
+ return 0;
+ }
+
+ // For rt.jar, 73265 word entries are created. 51997 have 1 ref, then 9438, 3738, 1980,
1214, 779, 547, 429, 371 etc.
+ int newSize= fNumRefs < 4 ? 4 : fNumRefs * 2; // so will start @ 1, grow to 4, 8,
16, 32, 64 etc.
+ System.arraycopy(fRefs, 0, fRefs= new int[newSize], 0, fNumRefs);
+ fRefs[fNumRefs++]= fileNum;
+ return (newSize - fNumRefs + 1) * 4;
+ }
+ /**
+ * Adds a set of references and records the change in footprint.
+ */
+ public void addRefs(int[] refs) {
+ int[] newRefs= new int[fNumRefs + refs.length];
+ int pos1= 0;
+ int pos2= 0;
+ int posNew= 0;
+ int compare;
+ int r1= 0;
+ int r2= 0;
+ while (pos1 < fNumRefs || pos2 < refs.length) {
+ if (pos1 >= fNumRefs) {
+ r2= refs[pos2];
+ compare= -1;
+ } else if (pos2 >= refs.length) {
+ compare= 1;
+ r1= fRefs[pos1];
+ } else {
+ r1= fRefs[pos1];
+ r2= refs[pos2];
+ compare= r2 - r1;
+ }
+ if (compare > 0) {
+ newRefs[posNew]= r1;
+ posNew++;
+ pos1++;
+ } else {
+ if (r2 != 0) {
+ newRefs[posNew]= r2;
+ posNew++;
+ }
+ pos2++;
+ }
+ }
+ fRefs= newRefs;
+ fNumRefs= posNew;
+ /*for (int i = 0; i < refs.length; i++)
+ addRef(refs[i]);
+ int[] newRefs = new int[fNumRefs];
+ System.arraycopy(fRefs, 0, newRefs, 0, fNumRefs);
+ fRefs = newRefs;
+ Util.sort(fRefs);*/
+ }
+ /**
+ * Returns the size of the wordEntry
+ */
+
+ public int footprint() {
+ return 8 + (3 * 4) + (8 + fWord.length * 2) + (8 + fRefs.length * 4);
+ }
+ /**
+ * Returns the number of references, e.g. the number of files this word appears in.
+ */
+ public int getNumRefs() {
+ return fNumRefs;
+ }
+ /**
+ * returns the file number in the i position in the list of references.
+ */
+ public int getRef(int i) {
+ if (i < fNumRefs) return fRefs[i];
+ throw new IndexOutOfBoundsException();
+ }
+ /**
+ * Returns the references of the wordEntry (the number of the files it appears in).
+ */
+
+ public int[] getRefs() {
+ int[] result= new int[fNumRefs];
+ System.arraycopy(fRefs, 0, result, 0, fNumRefs);
+ return result;
+ }
+ /**
+ * returns the word of the wordEntry.
+ */
+
+ public char[] getWord() {
+ return fWord;
+ }
+ /**
+ * Changes the references of the wordEntry to match the mapping. For example,<br>
+ * if the current references are [1 3 4]<br>
+ * and mapping is [1 2 3 4 5]<br>
+ * in references 1 becomes mapping[1] = 2, 3->4, and 4->5<br>
+ * => references = [2 4 5].<br>
+ */
+ public void mapRefs(int[] mappings) {
+ int position= 0;
+ for (int i= 0; i < fNumRefs; i++) {
+ int map= mappings[fRefs[i]];
+ if (map != -1 && map != 0)
+ fRefs[position++]= map;
+ }
+ fNumRefs= position;
+
+ //to be changed!
+ System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
+ Arrays.sort(fRefs);
+ }
+ /**
+ * Clears the wordEntry.
+ */
+
+ public void reset(char[] word) {
+ for (int i= fNumRefs; i-- > 0;) {
+ fRefs[i]= 0;
+ }
+ fNumRefs= 0;
+ fWord= word;
+ }
+ public String toString() {
+ return new String(fWord);
+ }
+ public int compareTo(WordEntry other) {
+ return Util.compare(this.fWord, other.fWord);
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/internal/core/index/WordEntry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,167 @@
+/*
+ * 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.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;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
+
+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 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 StoredProcedureInfo getStoredProcedureInfoForProcedure(
+ 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)).getStoredProcedureInfoForProcedure(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;
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,227 @@
+/*
+ * 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.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.dqp.service.DataService;
+import com.metamatrix.query.metadata.MetadataStore;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
+import com.metamatrix.vdb.runtime.VDBKey;
+
+public class ConnectorMetadataStore implements MetadataStore {
+
+ private ConnectorMetadata metadata;
+ private String modelName;
+
+ public ConnectorMetadataStore(VDBKey key, String modelName, DataService dataService)
throws MetaMatrixComponentException {
+ this.modelName = modelName;
+ this.metadata = dataService.getConnectorMetadata(key.getName(), key.getVersion(),
modelName);
+ }
+
+ @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 StoredProcedureInfo getStoredProcedureInfoForProcedure(
+ String fullyQualifiedProcedureName)
+ throws MetaMatrixComponentException, QueryMetadataException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @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 IndexConstants.RECORD_TYPE.CALLABLE:
+ return metadata.getProcedures();
+ case IndexConstants.RECORD_TYPE.CALLABLE_PARAMETER:
+ return Collections.emptyList();
+ case IndexConstants.RECORD_TYPE.RESULT_SET:
+ return Collections.emptyList();
+
+ case IndexConstants.RECORD_TYPE.ACCESS_PATTERN: {
+ Collection<ColumnSetRecordImpl> results = new
ArrayList<ColumnSetRecordImpl>();
+ for (TableRecordImpl table : metadata.getTables()) {
+ if (table.getAccessPatterns() != null) {
+ results.addAll(table.getAccessPatterns());
+ }
+ }
+ return results;
+ }
+ case IndexConstants.RECORD_TYPE.UNIQUE_KEY: {
+ Collection<ColumnSetRecordImpl> results = new
ArrayList<ColumnSetRecordImpl>();
+ for (TableRecordImpl table : metadata.getTables()) {
+ if (table.getUniqueKeys() != null) {
+ results.addAll(table.getUniqueKeys());
+ }
+ }
+ return results;
+ }
+ case IndexConstants.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 IndexConstants.RECORD_TYPE.FOREIGN_KEY: {
+ Collection<ColumnSetRecordImpl> results = new
ArrayList<ColumnSetRecordImpl>();
+ for (TableRecordImpl table : metadata.getTables()) {
+ if (table.getForeignKeys() != null) {
+ results.addAll(table.getForeignKeys());
+ }
+ }
+ return results;
+ }
+ case IndexConstants.RECORD_TYPE.INDEX: {
+ Collection<ColumnSetRecordImpl> results = new
ArrayList<ColumnSetRecordImpl>();
+ for (TableRecordImpl table : metadata.getTables()) {
+ if (table.getIndexes() != null) {
+ results.addAll(table.getIndexes());
+ }
+ }
+ return results;
+ }
+ case IndexConstants.RECORD_TYPE.MODEL:
+ return Arrays.asList(metadata.getModel());
+ case IndexConstants.RECORD_TYPE.TABLE:
+ return metadata.getTables();
+ case IndexConstants.RECORD_TYPE.COLUMN: {
+ Collection<ColumnRecordImpl> results = new ArrayList<ColumnRecordImpl>();
+ for (TableRecordImpl table : metadata.getTables()) {
+ if (table.getColumns() != null) {
+ results.addAll(table.getColumns());
+ }
+ }
+ return results;
+ }
+ }
+ 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(IndexConstants.RECORD_TYPE.COLUMN);
+ } else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.KEYS_INDEX)) {
+ List<AbstractMetadataRecord> result = new
ArrayList<AbstractMetadataRecord>();
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.ACCESS_PATTERN));
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.UNIQUE_KEY));
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.PRIMARY_KEY));
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.FOREIGN_KEY));
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.INDEX));
+ return result;
+ } else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MODELS_INDEX)) {
+ return getRecordsByType(IndexConstants.RECORD_TYPE.MODEL);
+ } else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROCEDURES_INDEX)) {
+ List<AbstractMetadataRecord> result = new
ArrayList<AbstractMetadataRecord>();
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.CALLABLE));
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.CALLABLE_PARAMETER));
+ result.addAll(getRecordsByType(IndexConstants.RECORD_TYPE.RESULT_SET));
+ return result;
+ } else if (indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.TABLES_INDEX)) {
+ return getRecordsByType(IndexConstants.RECORD_TYPE.TABLE);
+ }
+ 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();
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/ConnectorMetadataStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,243 @@
+/*
+ * 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.IOException;
+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.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) {
+ metadataStores.add(new ConnectorMetadataStore(vdbID, modelName,
dataService));
+ }
+ }
+ 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);
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/RuntimeMetadataPlugin.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -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;
+
+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/RuntimeMetadataPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,983 @@
+/*
+ * 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.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.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;
+
+/**
+ * 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 avaid i18n lookup each time
+ public static String NOT_EXISTS_MESSAGE =
StringUtil.Constants.SPACE+RuntimeMetadataPlugin.Util.getString("TransformationMetadata.does_not_exist._1");
//$NON-NLS-1$
+
+ // context object all the info needed for metadata lookup
+ 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>(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 {
+ ArgCheck.isInstanceOf(TableRecordImpl.class, groupOrElementID);
+
+ return ((TableRecordImpl)groupOrElementID).getModel();
+ }
+
+ /* (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 result = this.procedureCache.get(upperGroupName);
+
+ if (result == null) {
+ result =
getMetadataStore().getStoredProcedureInfoForProcedure(fullyQualifiedProcedureName);
+ this.procedureCache.put(upperGroupName, result);
+ }
+ return result;
+ }
+
+ /* (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) {
+ LinkedList<ColumnSetRecordImpl> result = new
LinkedList<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(IndexConstants.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(IndexConstants.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
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/TransformationMetadata.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * 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 => true
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = { '?', 'b', '?' }
+ * name = { 'a', 'b', 'c' , 'd' }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = { 'b', '*' }
+ * name = { 'a', 'b', 'c' , 'd' }
+ * isCaseSensitive = true
+ * result => 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;
+
+ if (patternEnd < 0)
+ patternEnd = pattern.length;
+ if (nameEnd < 0)
+ nameEnd = name.length;
+
+ /* 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 == '*') {
+ 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;
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/CharOperation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,185 @@
+/*
+ * 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;
+
+/**
+ * IndexConstants
+ */
+public class IndexConstants {
+
+
//############################################################################################################################
+ //# Constants
#
+
//############################################################################################################################
+
+ public final static String INDEX_EXT = "INDEX"; //$NON-NLS-1$
+ public final static String SEARCH_INDEX_EXT = "SEARCH_INDEX";
//$NON-NLS-1$
+ public static final String EXTENSION_CHAR = "."; //$NON-NLS-1$
+
+ public final static char NAME_DELIM_CHAR = '.';
+
+ //Index file name Constants
+ public static class INDEX_NAME {
+ public final static String TABLES_INDEX = "TABLES.INDEX";
//$NON-NLS-1$
+ public final static String KEYS_INDEX = "KEYS.INDEX";
//$NON-NLS-1$
+ public final static String COLUMNS_INDEX = "COLUMNS.INDEX";
//$NON-NLS-1$
+ public final static String MODELS_INDEX = "MODELS.INDEX";
//$NON-NLS-1$
+ public final static String VDBS_INDEX = "VDBS.INDEX";
//$NON-NLS-1$
+ public final static String PROCEDURES_INDEX =
"PROCEDURES.INDEX"; //$NON-NLS-1$
+ public final static String DATATYPES_INDEX = "DATATYPES.INDEX";
//$NON-NLS-1$
+ public final static String SELECT_TRANSFORM_INDEX =
"SELECT_TRANSFORM.INDEX"; //$NON-NLS-1$
+ public final static String INSERT_TRANSFORM_INDEX =
"INSERT_TRANSFORM.INDEX"; //$NON-NLS-1$
+ public final static String UPDATE_TRANSFORM_INDEX =
"UPDATE_TRANSFORM.INDEX"; //$NON-NLS-1$
+ public final static String DELETE_TRANSFORM_INDEX =
"DELETE_TRANSFORM.INDEX"; //$NON-NLS-1$
+ public final static String PROC_TRANSFORM_INDEX =
"PROC_TRANSFORM.INDEX"; //$NON-NLS-1$
+ public final static String MAPPING_TRANSFORM_INDEX =
"MAPPING_TRANSFORM.INDEX"; //$NON-NLS-1$
+ public final static String ANNOTATION_INDEX =
"ANNOTATION.INDEX"; //$NON-NLS-1$
+ public final static String PROPERTIES_INDEX =
"PROPERTIES.INDEX"; //$NON-NLS-1$
+ public final static String FILES_INDEX = "FILES.INDEX";
//$NON-NLS-1$
+ public final static String[] INDEX_NAMES = new String[]{TABLES_INDEX,
KEYS_INDEX,
+ COLUMNS_INDEX,
PROCEDURES_INDEX, MODELS_INDEX,
+ VDBS_INDEX,
DATATYPES_INDEX, SELECT_TRANSFORM_INDEX,
+ INSERT_TRANSFORM_INDEX,
UPDATE_TRANSFORM_INDEX,
+ DELETE_TRANSFORM_INDEX,
PROC_TRANSFORM_INDEX,
+
MAPPING_TRANSFORM_INDEX, ANNOTATION_INDEX, PROPERTIES_INDEX, FILES_INDEX};
+
+ public final static boolean isKnownIndex(String indexName) {
+ for (int i = 0; i < INDEX_NAMES.length; i++) {
+ if (INDEX_NAMES[i].equalsIgnoreCase(indexName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ //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 = '&';
+ }
+
+ //Search Record type Constants
+ public static class SEARCH_RECORD_TYPE {
+ public final static char RESOURCE = 'A';
+ public final static char MODEL_IMPORT = 'B';
+ public final static char OBJECT = 'C';
+ public final static char OBJECT_REF = 'D';
+ public final static char RELATIONSHIP = 'E';
+ public final static char RELATED_OBJECT = 'F';
+ public final static char RELATIONSHIP_TYPE = 'G';
+ public final static char RELATIONSHIP_ROLE = 'H';
+ public final static char TYPED_OBJECT = 'I';
+ public final static char ANNOTATION = 'J';
+ }
+
+ public static final char[] SEARCH_RECORD_TYPES = new char[]{
+ SEARCH_RECORD_TYPE.RESOURCE,
+ SEARCH_RECORD_TYPE.MODEL_IMPORT,
+ SEARCH_RECORD_TYPE.OBJECT,
+ SEARCH_RECORD_TYPE.OBJECT_REF,
+ SEARCH_RECORD_TYPE.RELATIONSHIP,
+ SEARCH_RECORD_TYPE.RELATED_OBJECT,
+ SEARCH_RECORD_TYPE.RELATIONSHIP_TYPE,
+ SEARCH_RECORD_TYPE.RELATIONSHIP_ROLE,
+ SEARCH_RECORD_TYPE.TYPED_OBJECT,
+ SEARCH_RECORD_TYPE.ANNOTATION
+ };
+
+ public static final char[] RECORD_TYPES = new char[]{
+ RECORD_TYPE.MODEL,
+ RECORD_TYPE.TABLE,
+ RECORD_TYPE.RESULT_SET,
+ RECORD_TYPE.JOIN_DESCRIPTOR,
+ RECORD_TYPE.CALLABLE,
+ RECORD_TYPE.CALLABLE_PARAMETER,
+ RECORD_TYPE.COLUMN,
+ RECORD_TYPE.ACCESS_PATTERN,
+ RECORD_TYPE.UNIQUE_KEY,
+ RECORD_TYPE.FOREIGN_KEY,
+ RECORD_TYPE.PRIMARY_KEY,
+ RECORD_TYPE.INDEX,
+ RECORD_TYPE.DATATYPE,
+ //RECORD_TYPE.DATATYPE_ELEMENT,
+ //RECORD_TYPE.DATATYPE_FACET,
+ RECORD_TYPE.SELECT_TRANSFORM,
+ RECORD_TYPE.INSERT_TRANSFORM,
+ RECORD_TYPE.UPDATE_TRANSFORM,
+ RECORD_TYPE.DELETE_TRANSFORM,
+ RECORD_TYPE.PROC_TRANSFORM,
+ RECORD_TYPE.MAPPING_TRANSFORM,
+ RECORD_TYPE.VDB_ARCHIVE,
+ RECORD_TYPE.ANNOTATION,
+ RECORD_TYPE.PROPERTY,
+ RECORD_TYPE.FILE,
+ RECORD_TYPE.RECORD_CONTINUATION
+ };
+
+ public static class RECORD_STRING {
+ public final static char TRUE = '1';
+ public final static char FALSE = '0';
+ public final static char SPACE = ' ';
+ // The record delimiter is the character used to delineate the fields of an index
record.
+ // Since a field in our index records may represent a description, sql string, or
xml/html text
+ // a delimiter was chosen that will never be present in typed text.
+ public final static char RECORD_DELIMITER = '\u00A0'; // separator
between data values (ASCII no-break space)
+// public final static char RECORD_DELIMITER = '|'; // separator between
data values
+
+ // Fix for defect 13393
+ public final static char LIST_DELIMITER_OLD = ','; // separator used
when the data value is a list
+ public final static char PROP_DELIMITER_OLD = '='; // separator used to
seperate prop-value pairs
+ public final static char LIST_DELIMITER = '\u001F'; // separator
used when the data value is a list (ASCII unit separator)
+ public final static char PROP_DELIMITER = '\u2060'; // separator
used to seperate prop-value pairs (ASCII word joiner)
+
+ public final static char MATCH_CHAR = '*'; // wild card that may
match one or more characters
+ public final static char SINGLE_CHAR_MATCH = '?'; // match a single
character
+ public final static String MATCH_CHAR_STRING = (new
Character(MATCH_CHAR)).toString(); // wild card that may match one or more
characters
+ public final static String SINGLE_CHAR_MATCH_STRING = (new
Character(SINGLE_CHAR_MATCH)).toString(); // match a single character
+
+ public final static char INDEX_VERSION_MARKER = '\u00A1'; // marker to
indicate index version information (ASCII inverted exclamation mark)
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,645 @@
+/*
+ * 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.common.types.DataTypeManager;
+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.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.MetadataStore;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
+import com.metamatrix.query.sql.lang.SPParameter;
+
+public class IndexMetadataStore implements MetadataStore {
+ // size of file being returned by content methods
+ 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(IndexConstants.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;
+ }
+
+ @Override
+ public TableRecordImpl findGroup(String groupName) throws QueryMetadataException,
MetaMatrixComponentException {
+ TableRecordImpl tableRecord = (TableRecordImpl)getRecordByType(groupName,
IndexConstants.RECORD_TYPE.TABLE);
+ List<ColumnRecordImpl> columns = new
ArrayList<ColumnRecordImpl>(findChildRecords(tableRecord,
IndexConstants.RECORD_TYPE.COLUMN, true));
+ for (ColumnRecordImpl columnRecordImpl : columns) {
+
columnRecordImpl.setDatatype(getDatatypeCache().get(columnRecordImpl.getDatatypeUUID()));
+ }
+ Collections.sort(columns);
+ tableRecord.setColumns(columns);
+ tableRecord.setAccessPatterns(findChildRecords(tableRecord,
IndexConstants.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,
IndexConstants.RECORD_TYPE.FOREIGN_KEY, true));
+ for (ForeignKeyRecordImpl foreignKeyRecord : tableRecord.getForeignKeys()) {
+
(foreignKeyRecord).setPrimaryKey((ColumnSetRecordImpl)this.getRecordByType(foreignKeyRecord.getUniqueKeyID(),
IndexConstants.RECORD_TYPE.PRIMARY_KEY));
+ loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
+ }
+ tableRecord.setUniqueKeys(findChildRecords(tableRecord,
IndexConstants.RECORD_TYPE.UNIQUE_KEY, true));
+ for (ColumnSetRecordImpl columnSetRecordImpl : tableRecord.getUniqueKeys()) {
+ loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+ }
+ if (tableRecord.getPrimaryKeyID() != null) {
+ ColumnSetRecordImpl primaryKey =
(ColumnSetRecordImpl)getRecordByType(tableRecord.getPrimaryKeyID(),
IndexConstants.RECORD_TYPE.PRIMARY_KEY);
+ loadColumnSetRecords(primaryKey, uuidColumnMap);
+ tableRecord.setPrimaryKey(primaryKey);
+ }
+ tableRecord.setModel((ModelRecordImpl)getRecordByType(tableRecord.getModelName(),
IndexConstants.RECORD_TYPE.MODEL));
+ if (tableRecord.isVirtual()) {
+ TransformationRecordImpl update =
(TransformationRecordImpl)getRecordByType(groupName,
IndexConstants.RECORD_TYPE.UPDATE_TRANSFORM,false);
+ if (update != null) {
+ tableRecord.setUpdatePlan(update.getTransformation());
+ }
+ TransformationRecordImpl insert =
(TransformationRecordImpl)getRecordByType(groupName,
IndexConstants.RECORD_TYPE.INSERT_TRANSFORM,false);
+ if (insert != null) {
+ tableRecord.setInsertPlan(insert.getTransformation());
+ }
+ TransformationRecordImpl delete =
(TransformationRecordImpl)getRecordByType(groupName,
IndexConstants.RECORD_TYPE.DELETE_TRANSFORM,false);
+ if (delete != null) {
+ tableRecord.setDeletePlan(delete.getTransformation());
+ }
+ TransformationRecordImpl select =
(TransformationRecordImpl)getRecordByType(groupName,
IndexConstants.RECORD_TYPE.SELECT_TRANSFORM,false);
+ // this group may be an xml document
+ if(select == null) {
+ select = (TransformationRecordImpl)getRecordByType(groupName,
IndexConstants.RECORD_TYPE.MAPPING_TRANSFORM,false);
+ }
+ tableRecord.setSelectTransformation(select);
+ }
+ if (tableRecord.isMaterialized()) {
+
tableRecord.setMaterializedStageTableName(getRecordByType(tableRecord.getMaterializedStageTableID(),
IndexConstants.RECORD_TYPE.TABLE).getFullName());
+
tableRecord.setMaterializedTableName(getRecordByType(tableRecord.getMaterializedTableID(),
IndexConstants.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(IndexConstants.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,
IndexConstants.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(IndexConstants.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$
+ }
+
+ /* (non-Javadoc)
+ * @see
com.metamatrix.query.metadata.QueryMetadataInterface#getStoredProcedureInfoForProcedure(java.lang.String)
+ */
+ public StoredProcedureInfo getStoredProcedureInfoForProcedure(final String
fullyQualifiedProcedureName)
+ throws MetaMatrixComponentException, QueryMetadataException {
+
+ ProcedureRecordImpl procRecord = (ProcedureRecordImpl)
getRecordByType(fullyQualifiedProcedureName, IndexConstants.RECORD_TYPE.CALLABLE);
+
+ String procedureFullName = procRecord.getFullName();
+
+ // create the storedProcedure info object that would hold procedure's
metadata
+ StoredProcedureInfo procInfo = new StoredProcedureInfo();
+ procInfo.setProcedureCallableName(procRecord.getName());
+ procInfo.setProcedureID(procRecord);
+
+ // modelID for the procedure
+ AbstractMetadataRecord modelRecord = getRecordByType(procRecord.getModelName(),
IndexConstants.RECORD_TYPE.MODEL);
+ procInfo.setModelID(modelRecord);
+
+ // get the parameter metadata info
+ for(Iterator paramIter =
procRecord.getParameterIDs().iterator();paramIter.hasNext();) {
+ String paramID = (String) paramIter.next();
+ ProcedureParameterRecordImpl paramRecord = (ProcedureParameterRecordImpl)
this.getRecordByType(paramID, IndexConstants.RECORD_TYPE.CALLABLE_PARAMETER);
+ 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);
+ if (paramRecord.getDatatypeUUID() != null) {
+
paramRecord.setDatatype((DatatypeRecordImpl)getRecordByType(paramRecord.getDatatypeUUID(),
IndexConstants.RECORD_TYPE.DATATYPE));
+ }
+ spParam.setClassType(DataTypeManager.getDataTypeClass(runtimeType));
+ procInfo.addParameter(spParam);
+ }
+
+ // if the procedure returns a resultSet, obtain resultSet metadata
+ String resultID = procRecord.getResultSetID();
+ if(resultID != null) {
+ try {
+ ColumnSetRecordImpl resultRecord = (ColumnSetRecordImpl)
this.getRecordByType(resultID, IndexConstants.RECORD_TYPE.RESULT_SET);
+ // 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);
+
+ loadColumnSetRecords(resultRecord, null);
+ for (ColumnRecordImpl columnRecord : resultRecord.getColumns()) {
+ String colType = columnRecord.getRuntimeType();
+ param.addResultSetColumn(columnRecord.getFullName(),
DataTypeManager.getDataTypeClass(colType), columnRecord);
+ }
+
+ procInfo.addParameter(param);
+ } 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(procRecord.isVirtual()) {
+ TransformationRecordImpl transformRecord =
(TransformationRecordImpl)getRecordByType(procedureFullName,
IndexConstants.RECORD_TYPE.PROC_TRANSFORM, false);
+ if(transformRecord != null) {
+ QueryNode queryNode = new QueryNode(procedureFullName,
transformRecord.getTransformation());
+ procInfo.setQueryPlan(queryNode);
+
+ }
+ }
+
+ //subtract 1, to match up with the server
+ procInfo.setUpdateCount(procRecord.getUpdateCount() -1);
+
+ 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;
+ }
+ }
+
+ @Override
+ public Collection getXMLTempGroups(TableRecordImpl table) throws
MetaMatrixComponentException {
+ // Query the index files
+ final Collection results = findChildRecords(table, IndexConstants.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(IndexConstants.RECORD_TYPE.PROPERTY,
uuid);
+
+ IEntryResult[] results = queryIndex(IndexConstants.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 == IndexConstants.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$
+ + IndexConstants.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());
+ }
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,332 @@
+/*
+ * 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.io.InputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
+
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.internal.core.xml.xmi.XMIHeader;
+import com.metamatrix.internal.core.xml.xmi.XMIHeaderReader;
+
+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$
+ public static final String EXTENSION_XML = "xml"; //$NON-NLS-1$
+ public static final String EXTENSION_XMI = "xmi"; //$NON-NLS-1$
+ public static final String EXTENSION_XSD = "xsd"; //$NON-NLS-1$
+ public static final String EXTENSION_VDB = "vdb"; //$NON-NLS-1$
+ 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
+ * model nature. Returns a false for vdb files.
+ * @param resource The file that may be a model file
+ * @return true if it is a ModelFile.
+ */
+ public static boolean isModelFile( final File resource ) {
+ if (resource == null) {
+ return false;
+ }
+
+ // If the file does not yet exist then the only thing
+ // we can do is to check the name and extension.
+ if (!resource.exists()) {
+ final String extension = FileUtils.getExtension(resource.getAbsolutePath());
+ return isModelFileExtension(extension, true);
+ }
+
+ //If this is an xsd resource return true
+ if(isXsdFile(resource) ){
+ return true;
+ }
+
+ //If this is an vdb resource return false
+ if(isVdbArchiveFile(resource) ){
+ return false;
+ }
+
+ //If the resource does not have the correct lower-case extension then return false
+ if ( !EXTENSION_XMI.equals(getFileExtension(resource)) ) {
+ return false;
+ }
+
+ XMIHeader header = getXmiHeader(resource);
+ // If the header is not null then we know the file is, at least,
+ // a well formed xml document.
+ if (header != null) {
+ // If the XMI version for the header is not null, then return
+ // false if the file represents an older 1.X model file
+ if (header.getXmiVersion() != null &&
header.getXmiVersion().startsWith("1.")) { //$NON-NLS-1$
+ return false;
+ }
+ // If the UUID for the header is not null, then the file is a
+ // MetaMatrix model file containing a ModelAnnotation element.
+ if (header.getUUID() != null) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Return true if the IResource represents a xsd file.
+ * @param resource The file that may be a xsd file
+ * @return true if it is a xsd
+ */
+ public static boolean isXsdFile( final File resource ) {
+ // Check that the resource has the correct lower-case extension
+ if ( EXTENSION_XSD.equals(getFileExtension(resource)) ) {
+ return true;
+ }
+ return false;
+ }
+ /**<p>
+ * </p>
+ * @since 4.0
+ */
+ public static boolean isVdbArchiveFile( final File resource ) {
+ // Check that the resource has the correct lower-case extension
+ if ( EXTENSION_VDB.equals(getFileExtension(resource)) ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the file extension portion of this file, or an empty string if there is
none.
+ * <p>
+ * The file extension portion is defined as the string
+ * following the last period (".") character in the file name.
+ * If there is no period in the file name, the file has no
+ * file extension portion. If the name ends in a period,
+ * the file extension portion is the empty string.
+ * </p>
+ * @param resource
+ * @return the file extension or <code>null</code>
+ * @since 4.3
+ */
+ public static String getFileExtension( final File resource ) {
+ if ( resource != null ) {
+ return FileUtils.getExtension(resource);
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Return true if a file with the specified name and extension
+ * represents a MetaMatrix model file.
+ * @param name
+ * @param extension
+ * @return
+ */
+ public static boolean isModelFileExtension(final String extension, boolean
caseSensitive) {
+ // Check if the extension is one of the well-known extensions
+ // The method assumes the extension is lower-case. Relaxing
+ // this assumption may cause the Modeler to work incorrectly.
+ if (extension == null) {
+ return false;
+ }
+
+ final String exten = (caseSensitive ? extension : extension.toLowerCase());
+ if ( EXTENSION_XMI.equals(exten) ) {
+ return true;
+ }
+ if ( EXTENSION_XSD.equals(exten) ) {
+ return true;
+ }
+ if ( EXTENSION_VDB.equals(exten) ) {
+ return false;
+ }
+ return false;
+ }
+
+ /**
+ * Return the XMIHeader for the specified File or null
+ * if the file does not represent a MetaMatrix model file.
+ * @param resource The file of a metamatrix model file.
+ * @return The XMIHeader for the model file
+ */
+ 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());
+ } catch (IllegalArgumentException iae ) {
+ // Swallowing this exception because we're doing all three checks
that would produce it.
+ // If this exception is caught, it's because the files really were
closed/deleted in another thread and this
+ // thread didn't know about it.
+ // Fixes Defect 22117
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the XMIHeader for the given vdb file or null
+ * if the file does not represent a vdb.
+ * @param vdbArchiveJar The file for the vdb.
+ * @return The XMIHeader for the vdb manifest file
+ */
+ public static XMIHeader getXmiHeaderForVdbArchive( final File vdbArchiveJar ) {
+ if (isVdbArchiveFile(vdbArchiveJar)) {
+
+ // vdb file is empty there is nothing to read
+ if(vdbArchiveJar.length() == 0) {
+ return null;
+ }
+
+ ZipFile zipFile = null;
+ XMIHeader header = null;
+ InputStream manifestStream = null;
+ try {
+ zipFile = new ZipFile(vdbArchiveJar);
+ manifestStream = getManifestModelContentsFromVdbArchive(zipFile);
+ header = getXmiHeader(manifestStream);
+ } catch (ZipException e) {
+ LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage());
+ } catch (IOException e) {
+ LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage());
+ } finally {
+ if (manifestStream != null) {
+ try {
+ manifestStream.close();
+ } catch (IOException err) {
+ // do nothing
+ }
+ }
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ }
+
+ return header;
+ }
+ return null;
+ }
+
+ /**
+ * Return a java.io.InputStream reference for the MetaMatrix-VdbManifestModel.xmi
model file
+ * contained within the Vdb archive. If the specified file is not a Vdb archive
+ * file or the archive does not contain a manifest model then null is returned.
+ * @param zip the Vdb archive
+ * @return the inputstream for the manifest file entry
+ */
+ public static InputStream getManifestModelContentsFromVdbArchive( final ZipFile
zipFile ) {
+ return ModelFileUtil.getFileContentsFromArchive(zipFile, MANIFEST_MODEL_NAME);
+ }
+
+ /**
+ * Return a java.io.InputStream reference for the specified zip entry name
+ * @param zip
+ * @param zipEntryName the fully qualified name of the zip entry
+ * @return the inputstream for the zipfile entry
+ */
+ public static InputStream getFileContentsFromArchive( final ZipFile zipFile, final
String zipEntryName ) {
+ ArgCheck.isNotNull(zipFile);
+ ArgCheck.isNotEmpty(zipEntryName);
+ try {
+ // Iterate over all entries in the zip file ...
+ for(final Enumeration entries = zipFile.entries();entries.hasMoreElements();)
{
+ ZipEntry entry = (ZipEntry) entries.nextElement();
+ if (entry == null) {
+ continue;
+ }
+ // If the specified zip entry is found ...
+ if (entry.getName().equalsIgnoreCase(zipEntryName)) {
+ // return the contents of the entry
+ return zipFile.getInputStream(entry);
+ }
+ }
+ } catch(IOException e) {
+ LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e, e.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Return the XMIHeader for the specified inputstream of a model file.
+ * @param resourceStream The inputStream of a metamatrix model file.
+ * @return The XMIHeader for the model file
+ */
+ public static XMIHeader getXmiHeader( final InputStream resourceStream ) {
+ if (resourceStream != null) {
+ try {
+ return XMIHeaderReader.readHeader(resourceStream);
+ } catch (MetaMatrixCoreException e) {
+ LogManager.logWarning(RuntimeMetadataPlugin.PLUGIN_ID, e,
e.getMessage());
+ }
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/ModelFileUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,1106 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+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.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.EntryResult;
+import org.teiid.internal.core.index.IIndexConstants;
+
+import com.metamatrix.core.id.UUID;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.core.util.StringUtil;
+
+/**
+ * RuntimeAdapter
+ */
+public class RecordFactory {
+
+ public static final int INDEX_RECORD_BLOCK_SIZE = IIndexConstants.BLOCK_SIZE - 32;
+
+ /**
+ * The version number associated with any index records prior to the point
+ * when version information was encoded in newly created records
+ */
+ public static final int NONVERSIONED_RECORD_INDEX_VERSION = 0;
+
+ /**
+ * The version number that is associated with the change made to change the list
+ * delimiter from {@link
com.metamatrix.modeler.core.index.IndexConstants.LIST_DELIMITER_OLD}
+ * to {@link com.metamatrix.modeler.core.index.IndexConstants.LIST_DELIMITER} and
also the
+ * property delimiter was changed from {@link
com.metamatrix.modeler.core.index.IndexConstants.PROP_DELIMITER_OLD}
+ * to {@link com.metamatrix.modeler.core.index.IndexConstants.PROP_DELIMITER}. Added
07/22/2004.
+ * @release 4.1.1
+ */
+ public static final int DELIMITER_INDEX_VERSION = 1;
+
+ /**
+ * The version number that is associated with the change made to add materialization
+ * property on tables. Added 08/18/2004.
+ * @release 4.2
+ */
+ public static final int TABLE_MATERIALIZATION_INDEX_VERSION = 2;
+
+ /**
+ * The version number that is associated with the change made to add native type
+ * property on columns. Added 08/24/2004.
+ * @release 4.2
+ */
+ public static final int COLUMN_NATIVE_TYPE_INDEX_VERSION = 3;
+
+ /**
+ * The version number that is associated with the change made to add an input
parameter
+ * flag on columns. The flag is used to indicate if an element for a virtual table
+ * represents an input parameter. This change was made to support the
Procedural-Relational
+ * Mapping project. Added 09/29/2004.
+ * @release 4.2
+ */
+ public static final int COLUMN_INPUT_PARAMETER_FLAG_INDEX_VERSION = 4;
+
+ /**
+ * The version number that is associated with the change made to remove property
value
+ * pairs from the annotation records any properties on annotations would now be
indexed
+ * as part of the properties index. Added 12/14/2004.
+ * @release 4.2
+ */
+ public static final int ANNOTATION_TAGS_INDEX_VERSION = 5;
+
+ /**
+ * The version number that is associated with the change made to add uuid for the
+ * transformation mapping root on the transformation records, uuids would now be
indexed
+ * as part of the transformation index. Added 1/13/2005.
+ * @release 4.2
+ */
+ public static final int TRANSFORMATION_UUID_INDEX_VERSION = 6;
+
+ /**
+ * The version number that is associated with the change made to add count of null
and
+ * distinct values for columns on the column records 7/8/2005.
+ * @release 4.2
+ */
+ public static final int COLUMN_NULL_DISTINCT_INDEX_VERSION = 7;
+
+ /**
+ * The version number that is associated with the change made to add
+ * primitive type ID on datatype records 02/28/2006.
+ * @release 5.0
+ */
+ public static final int PRIMITIVE_TYPE_ID_INDEX_VERSION = 8;
+
+ /**
+ * The version number that is associated with the change made to add
+ * an update count to physical stored and XQuery procedures 04/29/2008.
+ * @release 5.0
+ */
+ public static final int PROCEDURE_UPDATE_COUNT_VERSION = 9;
+
+ /**
+ * The version number that is encoded with all newly created index records
+ */
+ public static final int CURRENT_INDEX_VERSION = PROCEDURE_UPDATE_COUNT_VERSION;
+
+ //
==================================================================================
+ // P U B L I C M E T H O D S
+ //
==================================================================================
+
+ /**
+ * Return a collection of {@link
com.metamatrix.modeler.core.metadata.runtime.MetadataRecord}
+ * instances for the result obtained from executing
<code>queryEntriesMatching</code>
+ * method on the {@link com.metamatrix.internal.core.index.impl.Index}
+ * @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);
+ for (int i = 0; i < queryResult.length; i++) {
+ final AbstractMetadataRecord record = getMetadataRecord(queryResult[i]);
+ if (record != null) {
+ records.add(record);
+ }
+ }
+ return records;
+ }
+
+ /**
+ * Return the {@link com.metamatrix.modeler.core.metadata.runtime.MetadataRecord}
+ * instances for specified IEntryResult.
+ * @param entryResult
+ */
+ private static AbstractMetadataRecord getMetadataRecord(final char[] record) {
+ if (record == null || record.length == 0) {
+ return null;
+ }
+ switch (record[0]) {
+ case IndexConstants.RECORD_TYPE.MODEL: return createModelRecord(record);
+ case IndexConstants.RECORD_TYPE.TABLE: return createTableRecord(record);
+ case IndexConstants.RECORD_TYPE.JOIN_DESCRIPTOR: return null;
+ case IndexConstants.RECORD_TYPE.CALLABLE: return
createProcedureRecord(record);
+ case IndexConstants.RECORD_TYPE.CALLABLE_PARAMETER: return
createProcedureParameterRecord(record);
+ case IndexConstants.RECORD_TYPE.COLUMN: return createColumnRecord(record);
+ case IndexConstants.RECORD_TYPE.ACCESS_PATTERN:
+ case IndexConstants.RECORD_TYPE.INDEX:
+ case IndexConstants.RECORD_TYPE.RESULT_SET:
+ case IndexConstants.RECORD_TYPE.UNIQUE_KEY:
+ case IndexConstants.RECORD_TYPE.PRIMARY_KEY: return
createColumnSetRecord(record);
+ case IndexConstants.RECORD_TYPE.FOREIGN_KEY: return
createForeignKeyRecord(record);
+ case IndexConstants.RECORD_TYPE.DATATYPE: return
createDatatypeRecord(record);
+ case IndexConstants.RECORD_TYPE.SELECT_TRANSFORM:
+ case IndexConstants.RECORD_TYPE.INSERT_TRANSFORM:
+ case IndexConstants.RECORD_TYPE.UPDATE_TRANSFORM:
+ case IndexConstants.RECORD_TYPE.DELETE_TRANSFORM:
+ case IndexConstants.RECORD_TYPE.MAPPING_TRANSFORM:
+ case IndexConstants.RECORD_TYPE.PROC_TRANSFORM: return
createTransformationRecord(record);
+ case IndexConstants.RECORD_TYPE.ANNOTATION: return
createAnnotationRecord(record);
+ case IndexConstants.RECORD_TYPE.PROPERTY: return
createPropertyRecord(record);
+ case IndexConstants.RECORD_TYPE.FILE: return createFileRecord(record);
+ default:
+ throw new IllegalArgumentException("Invalid record type for creating
MetadataRecord "+record[0]); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Return the {@link com.metamatrix.modeler.core.metadata.runtime.MetadataRecord}
+ * instances for specified IEntryResult.
+ * @param entryResult
+ * @param container Container reference to be set on the record
+ */
+ public static AbstractMetadataRecord getMetadataRecord(final IEntryResult
queryResult) {
+ AbstractMetadataRecord record = getMetadataRecord(queryResult.getWord());
+ return record;
+ }
+
+ /**
+ * Append the specified IEntryResult[] to the IEntryResult
+ * to create a single result representing an index entry that
+ * was split across multiple index records.
+ * @param result
+ * @param continuationResults
+ * @param blockSize
+ */
+ public static IEntryResult joinEntryResults(final IEntryResult result,
+ final IEntryResult[] continuationResults,
+ final int blockSize) {
+ Assertion.isNotNull(result);
+
+ // If the IEntryResult is not continued on another record, return the original
+ char[] baseResult = result.getWord();
+ if (baseResult.length < blockSize || baseResult[blockSize-1] !=
IndexConstants.RECORD_TYPE.RECORD_CONTINUATION) {
+ return result;
+ }
+
+ // Extract the UUID string from the original result
+ String baseStr = new String(baseResult);
+ String objectID = extractUUIDString(result);
+
+ // Create and initialize a StringBuffer to store the concatenated result
+ StringBuffer sb = new StringBuffer();
+ sb.append(baseStr.substring(0,blockSize-1));
+
+ // Append the continuation results onto the original -
+ // assumes the IEntryResult[] are in ascending order of segment number
+ final IEntryResult[] sortedResults =
sortContinuationResults(objectID,continuationResults);
+ for (int i = 0; i < sortedResults.length; i++) {
+ char[] continuation = sortedResults[i].getWord();
+ int segNumber = getContinuationSegmentNumber(objectID,sortedResults[i]);
+ int beginIndex = objectID.length() + Integer.toString(segNumber).length() +
5;
+ for (int j = beginIndex; j < continuation.length; j++) {
+ if (j < blockSize-1) {
+ sb.append(continuation[j]);
+ }
+ }
+ }
+
+ return new EntryResult(sb.toString().toCharArray(),result.getFileReferences());
+ }
+
+ private static IEntryResult[] sortContinuationResults(final String objectID, final
IEntryResult[] continuationResults) {
+ // If the array length is less than 10, then we should be able to safely
+ // assume the IEntryResult[] are in ascending order of segment count
+ if (continuationResults.length < 10) {
+ return continuationResults;
+ }
+
+ // If the number of continuation records is 10 or greater then we need to sort
them
+ // by segment count since continuation records 10-19 will appear before records
1-9
+ // in the array
+ final IEntryResult[] sortedResults = new
IEntryResult[continuationResults.length];
+ for (int i = 0; i < continuationResults.length; i++) {
+ int segNumber =
getContinuationSegmentNumber(objectID,continuationResults[i]);
+ sortedResults[segNumber-1] = continuationResults[i];
+ }
+ return sortedResults;
+ }
+
+ public static int getContinuationSegmentNumber(final String objectID, final
IEntryResult continuationResult) {
+ // The header portion of the continuation record is of the form:
+ // RECORD_CONTINUATION|objectID|segmentCount|
+ char[] record = continuationResult.getWord();
+
+ int segNumber = -1;
+
+ int index = objectID.length() + 4;
+ if (record[index+1] == IndexConstants.RECORD_STRING.RECORD_DELIMITER) {
+ // segment count < 10
+ segNumber = Character.getNumericValue(record[index]);
+ } else if (record[index+2] == IndexConstants.RECORD_STRING.RECORD_DELIMITER) {
+ // 9 < segment count < 100
+ char[] temp = new char[] {record[index], record[index+1]};
+ String segCount = new String(temp);
+ segNumber = Integer.parseInt(segCount);
+ } else if (record[index+3] == IndexConstants.RECORD_STRING.RECORD_DELIMITER) {
+ // 99 < segment count < 1000
+ char[] temp = new char[] {record[index], record[index+1], record[index+2]};
+ String segCount = new String(temp);
+ segNumber = Integer.parseInt(segCount);
+ }
+ return segNumber;
+ }
+
+ /**
+ * Extract the UUID string from the IEntryResult
+ * @param result
+ */
+ public static String extractUUIDString(final IEntryResult result) {
+ Assertion.isNotNull(result);
+
+ char[] word = result.getWord();
+ String baseStr = new String(word);
+ int beginIndex = baseStr.indexOf(UUID.PROTOCOL);
+ int endIndex = word.length;
+ Assertion.assertTrue(beginIndex != -1);
+ for (int i = beginIndex; i < word.length; i++) {
+ if (word[i] == IndexConstants.RECORD_STRING.RECORD_DELIMITER) {
+ endIndex = i;
+ break;
+ }
+ }
+ Assertion.assertTrue(beginIndex < endIndex);
+ return baseStr.substring(beginIndex,endIndex);
+ }
+
+ //
==================================================================================
+ // P R O T E C T E D M E T H O D S
+ //
==================================================================================
+
+ /**
+ * Create a ModelRecord instance from the specified index record
+ */
+ public static ModelRecordImpl createModelRecord(final char[] record) {
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final ModelRecordImpl model = new ModelRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+ setRecordHeaderValues(model, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++));
+
+ // The next token is the max set size
+ model.setMaxSetSize( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the model type
+ model.setModelType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the primary metamodel Uri
+ model.setPrimaryMetamodelUri(getObjectValue((String)tokens.get(tokenIndex++)));
+
+ // 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);
+
+ return model;
+ }
+
+ /**
+ * Create a TransformationRecord instance from the specified index record
+ */
+ public static TransformationRecordImpl createTransformationRecord(final char[]
record) {
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final TransformationRecordImpl transform = new TransformationRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+
+ 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++));
+
+ // The next token is the UUID of the transformation object
+ if(includeTransformationUUID(indexVersion)) {
+ transform.setUUID(getObjectValue(((String)tokens.get(tokenIndex++))));
+ }
+
+ // The next token is the transformation definition
+ transform.setTransformation(getObjectValue((String)tokens.get(tokenIndex++)));
+
+ // The next token are the list of bindings
+ List bindings = getStrings((String)tokens.get(tokenIndex++), indexVersion);
+ transform.setBindings(bindings);
+
+ // The next token are the list of schemaPaths
+ List schemaPaths = getStrings((String)tokens.get(tokenIndex++), indexVersion);
+ transform.setSchemaPaths(schemaPaths);
+
+ // The next tokens are footer values
+ setRecordFooterValues(transform, tokens, tokenIndex);
+
+ return transform;
+ }
+
+ protected static String getTransformTypeForRecordType(final char recordType) {
+ switch (recordType) {
+ case IndexConstants.RECORD_TYPE.SELECT_TRANSFORM: return
TransformationRecordImpl.Types.SELECT;
+ case IndexConstants.RECORD_TYPE.INSERT_TRANSFORM: return
TransformationRecordImpl.Types.INSERT;
+ case IndexConstants.RECORD_TYPE.UPDATE_TRANSFORM: return
TransformationRecordImpl.Types.UPDATE;
+ case IndexConstants.RECORD_TYPE.DELETE_TRANSFORM: return
TransformationRecordImpl.Types.DELETE;
+ case IndexConstants.RECORD_TYPE.PROC_TRANSFORM: return
TransformationRecordImpl.Types.PROCEDURE;
+ case IndexConstants.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 IndexConstants.RECORD_TYPE.UNIQUE_KEY: return
MetadataConstants.KEY_TYPES.UNIQUE_KEY;
+ case IndexConstants.RECORD_TYPE.INDEX: return
MetadataConstants.KEY_TYPES.INDEX;
+ case IndexConstants.RECORD_TYPE.ACCESS_PATTERN: return
MetadataConstants.KEY_TYPES.ACCESS_PATTERN;
+ case IndexConstants.RECORD_TYPE.PRIMARY_KEY: return
MetadataConstants.KEY_TYPES.PRIMARY_KEY;
+ case IndexConstants.RECORD_TYPE.FOREIGN_KEY: return
MetadataConstants.KEY_TYPES.FOREIGN_KEY;
+ case IndexConstants.RECORD_TYPE.RESULT_SET : return -1;
+ default:
+ throw new IllegalArgumentException("Invalid record type, for
key" + recordType); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Create a TableRecord instance from the specified index record
+ */
+ public static TableRecordImpl createTableRecord(final char[] record) {
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final TableRecordImpl table = new TableRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+ setRecordHeaderValues(table, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++));
+
+ // The next token is the cardinality
+ table.setCardinality( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the tableType
+ table.setTableType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token are the supports flags
+ char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ table.setVirtual(getBooleanValue(supportFlags[0]));
+ table.setSystem(getBooleanValue(supportFlags[1]));
+ table.setSupportsUpdate(getBooleanValue(supportFlags[2]));
+ if(includeMaterializationFlag(indexVersion)) {
+ 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 is the UUID of the primary key
+ table.setPrimaryKeyID(getObjectValue((String)tokens.get(tokenIndex++)));
+
+ tokenIndex+=4; //skip reading uuids for associated records
+
+ if(includeMaterializationFlag(indexVersion)) {
+ // The next token are the UUIDs for the materialized table ID
+ table.setMaterializedTableID((String)tokens.get(tokenIndex++));
+ // The next token are the UUID for the materialized stage table ID
+ table.setMaterializedStageTableID((String)tokens.get(tokenIndex++));
+ }
+
+ // The next tokens are footer values
+ setRecordFooterValues(table, tokens, tokenIndex);
+
+ return table;
+ }
+
+ /**
+ * Create a ColumnRecord instance from the specified index record
+ */
+ public static ColumnRecordImpl createColumnRecord(final char[] record) {
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final ColumnRecordImpl column = new ColumnRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+ setRecordHeaderValues(column, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++));
+
+ // The next token are the supports flags
+ char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ column.setSelectable(getBooleanValue(supportFlags[0]));
+ column.setUpdatable(getBooleanValue(supportFlags[1]));
+ column.setAutoIncrementable(getBooleanValue(supportFlags[2]));
+ column.setCaseSensitive(getBooleanValue(supportFlags[3]));
+ 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++)) );
+
+ // The next token is the search type
+ column.setSearchType( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the length
+ column.setLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the scale
+ column.setScale( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the precision
+ column.setPrecision( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the precision
+ column.setPosition( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the charOctetLength
+ column.setCharOctetLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the radix
+ column.setRadix( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ if (includeColumnNullDistinctValues(indexVersion)) {
+ // The next token is the distinct value
+ column.setDistinctValues(Integer.parseInt((String)tokens.get(tokenIndex++))
);
+ // The next token is the null value
+ column.setNullValues(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ }
+
+ // The next token is the min value
+ column.setMinValue( getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the max value
+ column.setMaxValue( getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the format value
+ column.setFormat( getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the runtime type
+ column.setRuntimeType( getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ if(includeColumnNativeType(indexVersion)) {
+ // The next token is the native type
+ column.setNativeType( getObjectValue((String)tokens.get(tokenIndex++)) );
+ }
+
+ // The next token is the datatype ObjectID
+ column.setDatatypeUUID( getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the default value
+ column.setDefaultValue( getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next tokens are footer values
+ setRecordFooterValues(column, tokens, tokenIndex);
+
+ return column;
+ }
+
+ /**
+ * Create a ColumnSetRecord instance from the specified index record
+ */
+ public static ColumnSetRecordImpl createColumnSetRecord(final char[] record) {
+ 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);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+ setRecordHeaderValues(columnSet, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++));
+
+ // The next token are the UUIDs for the column references
+ List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ columnSet.setColumnIDs(uuids);
+
+ if (record[0] == IndexConstants.RECORD_TYPE.UNIQUE_KEY || record[0] ==
IndexConstants.RECORD_TYPE.PRIMARY_KEY) {
+ //read the values from the index to update the tokenindex, but we don't
actually use them.
+ getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ }
+ // The next tokens are footer values
+ setRecordFooterValues(columnSet, tokens, tokenIndex);
+
+ return columnSet;
+ }
+
+ /**
+ * Create a ForeignKeyRecord instance from the specified index record
+ */
+ public static ForeignKeyRecordImpl createForeignKeyRecord(final char[] record) {
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final ForeignKeyRecordImpl fkRecord = new ForeignKeyRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+ setRecordHeaderValues(fkRecord, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++));
+
+ // The next token are the UUIDs for the column references
+ List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ fkRecord.setColumnIDs(uuids);
+
+ // The next token is the UUID of the unique key
+ fkRecord.setUniqueKeyID(getObjectValue((String)tokens.get(tokenIndex++)));
+
+ // The next tokens are footer values
+ setRecordFooterValues(fkRecord, tokens, tokenIndex);
+
+ return fkRecord;
+ }
+
+ /**
+ * Create a DatatypeRecord instance from the specified index record
+ */
+ public static DatatypeRecordImpl createDatatypeRecord(final char[] record) {
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final DatatypeRecordImpl dt = new DatatypeRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+
+ // Set the record type
+ dt.setRecordType(((String)tokens.get(tokenIndex++)).toCharArray()[0]);
+
+ // Set the datatype and basetype identifiers
+ dt.setDatatypeID(getObjectValue((String)tokens.get(tokenIndex++)));
+ dt.setBasetypeID(getObjectValue((String)tokens.get(tokenIndex++)));
+
+ // Set the fullName/objectID/nameInSource
+ dt.setFullName((String)tokens.get(tokenIndex++));
+ dt.setUUID(getObjectValue((String)tokens.get(tokenIndex++)));
+ 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);
+
+ // 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++)) );
+
+ // Set the search type
+ dt.setSearchType( Short.parseShort((String)tokens.get(tokenIndex++)) );
+
+ // Set the null type
+ dt.setNullType( Short.parseShort((String)tokens.get(tokenIndex++)) );
+
+ // Set the boolean flags
+ char[] booleanValues = ((String)tokens.get(tokenIndex++)).toCharArray();
+ dt.setSigned(getBooleanValue(booleanValues[0]));
+ dt.setAutoIncrement(getBooleanValue(booleanValues[1]));
+ dt.setCaseSensitive(getBooleanValue(booleanValues[2]));
+
+ // Append the length
+ dt.setLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // Append the precision length
+ dt.setPrecisionLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // Append the scale
+ dt.setScale( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // Append the radix
+ dt.setRadix( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // Set the primitive type identifier
+ if (includePrimitiveTypeIdValue(indexVersion)) {
+ // The next token is the primitive type identifier
+ dt.setPrimitiveTypeID(getObjectValue((String)tokens.get(tokenIndex++)));
+ }
+
+ // The next tokens are footer values
+ setRecordFooterValues(dt, tokens, tokenIndex);
+
+ return dt;
+ }
+
+ /**
+ * Create a ProcedureRecord instance from the specified index record
+ */
+ public static ProcedureRecordImpl createProcedureRecord(final char[] record) {
+
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final ProcedureRecordImpl procRd = new ProcedureRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+
+ // Set the record type
+ setRecordHeaderValues(procRd, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++));
+
+ // Set the boolean flags
+ char[] booleanValues = ((String)tokens.get(tokenIndex++)).toCharArray();
+ // flag indicating if the procedure is a function
+ procRd.setFunction(getBooleanValue(booleanValues[0]));
+ // flag indicating if the procedure is virtual
+ procRd.setVirtual(getBooleanValue(booleanValues[1]));
+
+ // The next token are the UUIDs for the param references
+ List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ procRd.setParameterIDs(uuids);
+
+ // The next token is the UUID of the resultSet object
+ procRd.setResultSetID(getObjectValue((String)tokens.get(tokenIndex++)));
+
+ if (includeProcedureUpdateCount(indexVersion)) {
+ procRd.setUpdateCount(Integer.parseInt((String)tokens.get(tokenIndex++)));
+ }
+
+ // The next tokens are footer values
+ setRecordFooterValues(procRd, tokens, tokenIndex);
+
+ return procRd;
+ }
+
+ /**
+ * Create a ProcedureParameterRecord instance from the specified index record
+ *
header|defaultValue|dataType|length|radix|scale|nullType|precision|paramType|footer|
+ */
+ public static ProcedureParameterRecordImpl createProcedureParameterRecord(final
char[] record) {
+
+ final String str = new String(record);
+ final List tokens =
StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final ProcedureParameterRecordImpl paramRd = new ProcedureParameterRecordImpl();
+
+ // Extract the index version information from the record
+ int indexVersion = getIndexVersion(record);
+
+ // The tokens are the standard header values
+ int tokenIndex = 0;
+
+ // Set the record type
+ setRecordHeaderValues(paramRd, (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++),
+ (String)tokens.get(tokenIndex++),
(String)tokens.get(tokenIndex++));
+
+ // The next token is the default value of the parameter
+ paramRd.setDefaultValue(getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the runtime type
+ paramRd.setRuntimeType(getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the uuid
+ paramRd.setDatatypeUUID(getObjectValue((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the length
+ paramRd.setLength(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the radix
+ paramRd.setRadix(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the scale
+ paramRd.setScale(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the null type
+ paramRd.setNullType(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the precision
+ paramRd.setPrecision(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is the position
+ paramRd.setPosition(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+
+ // The next token is parameter type
+ paramRd.setType(Integer.parseInt((String)tokens.get(tokenIndex++)));
+
+ // The next token is flag for parameter optional prop
+ char[] flags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ paramRd.setOptional(getBooleanValue(flags[0]));
+
+ // The next tokens are footer values
+ setRecordFooterValues(paramRd, tokens, tokenIndex);
+
+ return paramRd;
+ }
+
+ /**
+ * Create a AnnotationRecord instance from the specified index record
+ */
+ public static AnnotationRecordImpl 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++));
+
+ if(includeAnnotationProperties(indexVersion)) {
+ // The next token are the properties, ignore it not going to be read any way
+ tokenIndex++;
+ }
+
+ // The next token is the description
+ annotation.setDescription((String)tokens.get(tokenIndex++));
+
+ // The next tokens are footer values
+ setRecordFooterValues(annotation, tokens, tokenIndex);
+
+ return annotation;
+ }
+
+ /**
+ * 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++));
+
+ // for newer records
+ if(!includeAnnotationProperties(indexVersion)) {
+ // The next token is extension boolean
+ tokenIndex++;
+ }
+
+ // The next tokens are footer values
+ setRecordFooterValues(property, tokens, tokenIndex);
+
+ return property;
+ }
+
+ /**
+ * 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.
+ * @param record
+ * @since 4.2
+ */
+ private static int getIndexVersion(final char[] record) {
+ Assertion.isNotNull(record);
+ int endIndex = record.length;
+ int beginIndex = (endIndex - 6 > 0 ? endIndex - 6 : 1);
+ int version = NONVERSIONED_RECORD_INDEX_VERSION;
+ for (int i = beginIndex; i < endIndex; i++) {
+ if (record[i] == IndexConstants.RECORD_STRING.INDEX_VERSION_MARKER) {
+ char versionPart1 = record[i+1];
+ char versionPart2 = record[i+2];
+ if (Character.isDigit(versionPart1) &&
Character.isDigit(versionPart2)){
+ version = Character.digit(versionPart1, 10) * 10 +
Character.digit(versionPart2, 10);
+ }
+ }
+ }
+ return version;
+ }
+
+ public static String getObjectValue(final String str) {
+ if (str != null && str.length() == 1 && str.charAt(0) ==
IndexConstants.RECORD_STRING.SPACE) {
+ return null;
+ }
+ return str;
+ }
+
+ public static boolean getBooleanValue(final char b) {
+ if (b == IndexConstants.RECORD_STRING.TRUE) {
+ return true;
+ }
+ return false;
+ }
+
+ public static List getIDs(final String values, final int indexVersionNumber) {
+ if (StringUtil.isEmpty(values)) {
+ return Collections.EMPTY_LIST;
+ }
+ if (values.length() == 1 && values.charAt(0) ==
IndexConstants.RECORD_STRING.SPACE) {
+ return Collections.EMPTY_LIST;
+ }
+ final char listDelimiter = getListDelimiter(indexVersionNumber);
+ final List tokens = StringUtil.split(values,String.valueOf(listDelimiter));
+ final List result = new ArrayList(tokens.size());
+ for (Iterator iter = tokens.iterator(); iter.hasNext();) {
+ String token = getObjectValue((String)iter.next());
+ if (token != null) {
+ result.add(token);
+ }
+ }
+ return result;
+ }
+
+ public static List getStrings(final String values, final int indexVersionNumber) {
+ if (StringUtil.isEmpty(values)) {
+ return Collections.EMPTY_LIST;
+ }
+ if (values.length() == 1 && values.charAt(0) ==
IndexConstants.RECORD_STRING.SPACE) {
+ return Collections.EMPTY_LIST;
+ }
+ final char listDelimiter = getListDelimiter(indexVersionNumber);
+ final List tokens = StringUtil.split(values,String.valueOf(listDelimiter));
+ final List result = new ArrayList(tokens.size());
+ for (Iterator iter = tokens.iterator(); iter.hasNext();) {
+ String token = (String)iter.next();
+ if (token != null) {
+ result.add(token);
+ }
+ }
+ return result;
+ }
+
+ public static char getListDelimiter(final int indexVersionNumber) {
+ if (indexVersionNumber < DELIMITER_INDEX_VERSION) {
+ return IndexConstants.RECORD_STRING.LIST_DELIMITER_OLD;
+ }
+ return IndexConstants.RECORD_STRING.LIST_DELIMITER;
+ }
+
+ public static boolean includeMaterializationFlag(final int indexVersionNumber) {
+ if (indexVersionNumber < TABLE_MATERIALIZATION_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean includeMaterializedTables(final int indexVersionNumber) {
+ if (indexVersionNumber < TABLE_MATERIALIZATION_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean includeColumnNativeType(final int indexVersionNumber) {
+ if (indexVersionNumber < COLUMN_NATIVE_TYPE_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean includeColumnNullDistinctValues(final int indexVersionNumber) {
+ if (indexVersionNumber < COLUMN_NULL_DISTINCT_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean includePrimitiveTypeIdValue(final int indexVersionNumber) {
+ if (indexVersionNumber < PRIMITIVE_TYPE_ID_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean includeInputParameterFlag(final int indexVersionNumber) {
+ if (indexVersionNumber < COLUMN_INPUT_PARAMETER_FLAG_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean includeAnnotationProperties(final int indexVersionNumber) {
+ if (indexVersionNumber < ANNOTATION_TAGS_INDEX_VERSION) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean includeTransformationUUID(final int indexVersionNumber) {
+ if (indexVersionNumber < TRANSFORMATION_UUID_INDEX_VERSION) {
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean includeProcedureUpdateCount(final int indexVersionNumber) {
+ return (indexVersionNumber >= PROCEDURE_UPDATE_COUNT_VERSION);
+ }
+
+ public static int getCurrentIndexVersionNumber() {
+ return CURRENT_INDEX_VERSION;
+ }
+
+ //
==================================================================================
+ // P R I V A T E M E T H O D S
+ //
==================================================================================
+
+ /**
+ * Set the "header" values on the specified MetadataRecord.
+ * All index file record headers are of the form:
+ * recordType|upperFullName|objectID|fullName|nameInSource|parentObjectID
+ * The order of the fields in the index file header must also
+ * be the order of the arguments in method signature.
+ */
+ private static void setRecordHeaderValues(final AbstractMetadataRecord record, final
String recordType,
+ final String upperName, final String
objectID, final String fullName,
+ 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));
+ }
+
+ /**
+ * Set the "footer" values on the specified MetadataRecord.
+ * All index file record footers are of the form:
+ * modelPath|name|indexVersion
+ * The order of the fields in the index file header must also
+ * be the order of the arguments in method signature.
+ */
+ private static void setRecordFooterValues(final AbstractMetadataRecord record, final
List tokens, int tokenIndex) {
+ if (record instanceof TransformationRecordImpl) {
+ ((TransformationRecordImpl)record).setResourcePath(getOptionalToken(tokens,
tokenIndex));
+ }
+ tokenIndex++;
+ record.setName(getOptionalToken(tokens, tokenIndex++));
+ //placeholder for index version
+ getOptionalToken(tokens, tokenIndex++);
+ }
+
+ public static String getOptionalToken( final List tokens, int tokenIndex) {
+ if(tokens.size() > tokenIndex) {
+ return (String) tokens.get(tokenIndex);
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
(rev 0)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,589 @@
+/*
+ * 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.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.core.index.IEntryResult;
+import org.teiid.internal.core.index.BlocksIndexInput;
+import org.teiid.internal.core.index.Index;
+
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.StringUtil;
+
+/**
+ * IndexUtil
+ */
+public class SimpleIndexUtil {
+
+ public static interface ProgressMonitor {
+
+ public void beginTask(String name, int totalWork);
+
+ public void worked(int work);
+ }
+
+
//############################################################################################################################
+ //# Constants
#
+
//############################################################################################################################
+
+ public static final boolean CASE_SENSITIVE_INDEX_FILE_NAMES = false;
+
+
//############################################################################################################################
+ //# Indexing Methods
#
+
//############################################################################################################################
+
+ public static String getIndexFilePath(final String indexDirectoryPath, final String
indexFileName) {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append(indexDirectoryPath);
+ if (!indexDirectoryPath.endsWith(File.separator)) {
+ sb.append(File.separator);
+ }
+ sb.append(indexFileName);
+ return sb.toString();
+ }
+
+
//############################################################################################################################
+ //# Methods to query indexes
#
+
//############################################################################################################################
+
+ /**
+ * Return all index file records that match the specified record pattern.
+ * The pattern can be constructed from any combination of characters
+ * including the multiple character wildcard '*' and single character
+ * wildcard '?'. The field delimiter is used to tokenize both the pattern
+ * and the index record so that individual fields can be matched. The method
+ * assumes that the first occurrence of the delimiter in the record alligns
+ * with the first occurrence in the pattern. Any wildcard characters in the
+ * pattern cannot represent a delimiter character.
+ * @param indexes the array of MtkIndex instances to query
+ * @param pattern
+ * @param fieldDelimiter
+ * @return results
+ * @throws QueryMetadataException
+ */
+ public static IEntryResult[] queryIndex(final Index[] indexes, final char[] pattern,
final char fieldDelimiter) throws MetaMatrixCoreException {
+ final boolean isCaseSensitive = false;
+ final List<IEntryResult> queryResult = new
ArrayList<IEntryResult>();
+
+ try {
+ for (int i = 0; i < indexes.length; i++) {
+ // Search for index records matching the specified pattern
+ IEntryResult[] partialResults =
indexes[i].queryEntriesMatching(pattern,isCaseSensitive);
+
+ // If any of these IEntryResults represent an index record that is
continued
+ // across multiple entries within the index file then we must query for
those
+ // records and build the complete IEntryResult
+ if (partialResults != null) {
+ partialResults = addContinuationRecords(indexes[i], partialResults);
+ }
+
+ if (partialResults != null) {
+ queryResult.addAll(Arrays.asList(partialResults));
+ }
+ }
+ } catch(IOException e) {
+ throw new MetaMatrixCoreException(e);
+ }
+
+ // Remove any results that do not match after tokenizing the record
+ for (int i = 0, n = queryResult.size(); i < n; i++) {
+ IEntryResult record = queryResult.get(i);
+ if ( record == null || !entryMatches(record.getWord(),pattern,fieldDelimiter)
) {
+ queryResult.remove(record);
+ }
+ }
+
+ return queryResult.toArray(new IEntryResult[queryResult.size()]);
+ }
+
+ /**
+ * Return true if the record matches the pattern after being tokenized using
+ * the specified delimiter. The method assumes that the first occurrence of
+ * the delimiter in the record alligns with the first occurrence in the pattern.
+ * Any wildcard characters in the pattern cannot represent a delimiter character.
+ * @param record
+ * @param pattern
+ * @param fieldDelimiter
+ * @return
+ */
+ private static boolean entryMatches(final char[] record, final char[] pattern, final
char fieldDelimiter) {
+ final boolean isCaseSensitive = false;
+ if (record == null)
+ return false; // null record cannot match
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+
+ String delimiter = String.valueOf(fieldDelimiter);
+ List recordTokens = StringUtil.split(new String(record),delimiter);
+ List patternTokens = StringUtil.split(new String(pattern),delimiter);
+ if (patternTokens.size() > recordTokens.size()) {
+ return false;
+ }
+
+ for (int i = 0, n = patternTokens.size(); i < n; i++) {
+ char[] patternToken = ((String)patternTokens.get(i)).toCharArray();
+ char[] recordToken = ((String)recordTokens.get(i)).toCharArray();
+ if (!CharOperation.match(patternToken,recordToken,isCaseSensitive)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return all index file records that match the specified record prefix
+ * or pattern. The pattern can be constructed from any combination of characters
+ * including the multiple character wildcard '*' and single character
+ * wildcard '?'. The prefix may be constructed from any combination of
+ * characters excluding the wildcard characters. The prefix specifies a fixed
+ * number of characters that the index record must start with.
+ * @param indexes the array of MtkIndex instances to query
+ * @param pattern
+ * @return results
+ * @throws MetamatrixCoreException
+ */
+ public static IEntryResult[] queryIndex(final Index[] indexes, final char[] pattern,
final boolean isPrefix, final boolean returnFirstMatch) throws MetaMatrixCoreException {
+ return queryIndex(null, indexes, pattern, isPrefix, true, returnFirstMatch);
+ }
+
+ /**
+ * Return all index file records that match the specified record prefix
+ * or pattern. The pattern can be constructed from any combination of characters
+ * including the multiple character wildcard '*' and single character
+ * wildcard '?'. The prefix may be constructed from any combination of
+ * characters excluding the wildcard characters. The prefix specifies a fixed
+ * number of characters that the index record must start with.
+ * @param monitor an optional ProgressMonitor
+ * @param indexes the array of MtkIndex instances to query
+ * @param pattern
+ * @return results
+ * @throws MetamatrixCoreException
+ */
+ public static IEntryResult[] queryIndex(ProgressMonitor monitor, final Index[]
indexes, final char[] pattern, final boolean isPrefix, final boolean returnFirstMatch)
throws MetaMatrixCoreException {
+ return queryIndex(monitor, indexes, pattern, isPrefix, true, returnFirstMatch);
+ }
+
+ /**
+ * Return all index file records that match the specified record prefix
+ * or pattern. The pattern can be constructed from any combination of characters
+ * including the multiple character wildcard '*' and single character
+ * wildcard '?'. The prefix may be constructed from any combination of
+ * characters excluding the wildcard characters. The prefix specifies a fixed
+ * number of characters that the index record must start with.
+ * @param monitor an optional ProgressMonitor
+ * @param indexes the array of MtkIndex instances to query
+ * @param pattern
+ * @return results
+ * @throws MetamatrixCoreException
+ */
+ public static IEntryResult[] queryIndex(ProgressMonitor monitor, final Index[]
indexes, final char[] pattern, final boolean isPrefix, final boolean isCaseSensitive,
final boolean returnFirstMatch) throws MetaMatrixCoreException {
+ final List<IEntryResult> queryResult = new
ArrayList<IEntryResult>();
+ if ( monitor != null ) {
+ monitor.beginTask( null, indexes.length );
+ }
+
+ try {
+ for (int i = 0; i < indexes.length; i++) {
+
+ if ( monitor != null ) {
+ monitor.worked( 1 );
+ }
+
+ IEntryResult[] partialResults = null;
+ if(isPrefix) {
+ // Query based on prefix. This uses a fast binary search
+ // based on matching the first n characters in the index record.
+ // The index files contain records that are sorted alphabetically
+ // by fullname such that the search algorithm can quickly determine
+ // which index block(s) contain the matching prefixes.
+ partialResults = indexes[i].queryEntries(pattern, isCaseSensitive);
+ } else {
+ // Search for index records matching the specified pattern
+ partialResults = indexes[i].queryEntriesMatching(pattern,
isCaseSensitive);
+ }
+
+ // If any of these IEntryResults represent an index record that is
continued
+ // across multiple entries within the index file then we must query for
those
+ // records and build the complete IEntryResult
+ if (partialResults != null) {
+ partialResults = addContinuationRecords(indexes[i], partialResults);
+ }
+
+ // Process these results against the specified pattern and return
+ // only the subset entries that match both criteria
+ if (partialResults != null) {
+ for (int j = 0; j < partialResults.length; j++) {
+ // filter out any continuation records, they should already
appended
+ // to index record thet is continued
+ IEntryResult result = partialResults[j];
+ if(result != null && result.getWord()[0] !=
IndexConstants.RECORD_TYPE.RECORD_CONTINUATION) {
+ queryResult.add(partialResults[j]);
+ }
+ }
+ }
+
+ if (returnFirstMatch && queryResult.size() > 0) {
+ break;
+ }
+ }
+ } catch(IOException e) {
+ throw new MetaMatrixCoreException(e);
+ }
+
+ return queryResult.toArray(new IEntryResult[queryResult.size()]);
+ }
+
+ /**
+ * Return all index file records that match the specified record prefix
+ * or pattern. The pattern can be constructed from any combination of characters
+ * including the multiple character wildcard '*' and single character
+ * wildcard '?'. The prefix may be constructed from any combination of
+ * characters excluding the wildcard characters. The prefix specifies a fixed
+ * number of characters that the index record must start with.
+ * @param monitor an optional ProgressMonitor
+ * @param indexes the array of MtkIndex instances to query
+ * @param pattern
+ * @return results
+ * @throws MetamatrixCoreException
+ */
+ public static IEntryResult[] queryIndex(ProgressMonitor monitor, final Index[]
indexes, final Collection patterns, final boolean isPrefix, final boolean isCaseSensitive,
final boolean returnFirstMatch) throws MetaMatrixCoreException {
+ final List<IEntryResult> queryResult = new
ArrayList<IEntryResult>();
+ if ( monitor != null ) {
+ monitor.beginTask( null, indexes.length );
+ }
+
+ // index file input
+ BlocksIndexInput input = null;
+
+ try {
+ for (int i = 0; i < indexes.length; i++) {
+
+ if ( monitor != null ) {
+ monitor.worked( 1 );
+ }
+ // initialize input for the index file
+ input = new BlocksIndexInput(indexes[i].getIndexFile());
+
+ IEntryResult[] partialResults = null;
+ for(final Iterator patternIter = patterns.iterator();
patternIter.hasNext();) {
+ char[] pattern = ((String) patternIter.next()).toCharArray();
+ if(isPrefix) {
+ // Query based on prefix. This uses a fast binary search
+ // based on matching the first n characters in the index record.
+ // The index files contain records that are sorted
alphabetically
+ // by fullname such that the search algorithm can quickly
determine
+ // which index block(s) contain the matching prefixes.
+ partialResults = input.queryEntriesPrefixedBy(pattern,
isCaseSensitive);
+ } else {
+ // Search for index records matching the specified pattern
+ partialResults = input.queryEntriesMatching(pattern,
isCaseSensitive);
+ }
+
+ // If any of these IEntryResults represent an index record that is
continued
+ // across multiple entries within the index file then we must query
for those
+ // records and build the complete IEntryResult
+ if (partialResults != null) {
+ partialResults = addContinuationRecords(indexes[i],
partialResults);
+ }
+
+ // Process these results against the specified pattern and return
+ // only the subset entries that match both criteria
+ if (partialResults != null) {
+ for (int j = 0; j < partialResults.length; j++) {
+ IEntryResult record = partialResults[j];
+ if(record != null) {
+ char[] recordWord = partialResults[j].getWord();
+ // filter out any continuation records, they should
already appended
+ // to index record thet is continued
+ if(recordWord[0] !=
IndexConstants.RECORD_TYPE.RECORD_CONTINUATION) {
+ if (!isPrefix) {
+ // filter results that do not match after
tokenizing the record
+
if(entryMatches(recordWord,pattern,IndexConstants.RECORD_STRING.RECORD_DELIMITER) ) {
+ queryResult.add(partialResults[j]);
+ }
+ } else {
+ queryResult.add(partialResults[j]);
+ }
+ }
+ }
+ }
+ }
+ if (returnFirstMatch && queryResult.size() > 0) {
+ break;
+ }
+
+ // close file input
+ input.close();
+ }
+ }
+ } catch(IOException e) {
+ throw new MetaMatrixCoreException(e);
+ } finally {
+ // close file input
+ try {
+ if(input != null) {
+ input.close();
+ }
+ } catch(IOException io) {}
+ }
+
+ return queryResult.toArray(new IEntryResult[queryResult.size()]);
+ }
+
+
+ private static IEntryResult[] addContinuationRecords(final Index index, final
IEntryResult[] partialResults) throws IOException {
+
+ final int blockSize = RecordFactory.INDEX_RECORD_BLOCK_SIZE;
+
+ IEntryResult[] results = partialResults;
+ for (int i = 0; i < results.length; i++) {
+ IEntryResult partialResult = results[i];
+ char[] word = partialResult.getWord();
+
+ // If this IEntryResult is not continued on another record then skip to the
next result
+ if (word.length < blockSize || word[blockSize-1] !=
IndexConstants.RECORD_TYPE.RECORD_CONTINUATION) {
+ continue;
+ }
+ // Extract the UUID from the IEntryResult to use when creating the prefix
string
+ String objectID = RecordFactory.extractUUIDString(partialResult);
+ String patternStr = "" //$NON-NLS-1$
+ + IndexConstants.RECORD_TYPE.RECORD_CONTINUATION
+ + word[0]
+ + IndexConstants.RECORD_STRING.RECORD_DELIMITER
+ + objectID
+ + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+
+ // Query the index file for any continuation records
+ IEntryResult[] continuationResults =
index.queryEntries(patternStr.toCharArray(), true);
+ // If found the continued records then join to the original result and stop
searching
+ if (continuationResults != null && continuationResults.length > 0)
{
+ results[i] = RecordFactory.joinEntryResults(partialResult,
continuationResults, blockSize);
+ }
+ }
+ return results;
+ }
+
+
//############################################################################################################################
+ //# Helper methods
#
+
//############################################################################################################################
+
+ /**
+ * Return true if the specifed index file exists on the file system
+ * otherwise return false.
+ */
+ public static boolean indexFileExists(final String indexFilePath) {
+ if (indexFilePath == null) {
+ return false;
+ }
+ String filePath = indexFilePath.replace(FileUtils.SEPARATOR,
File.separatorChar);
+ final File indexFile = new File(filePath);
+ return indexFileExists(indexFile);
+ }
+
+ /**
+ * Return true if the specifed index file exists on the file system
+ * otherwise return false.
+ */
+ public static boolean indexFileExists(final File indexFile) {
+ if ( !indexFile.isDirectory() && indexFile.exists() ) {
+ return isIndexFile(indexFile.getName());
+ }
+ return false;
+ }
+
+ /**
+ * Return true if the specifed index file represents a known index file
+ * on the file system otherwise return false.
+ */
+ public static boolean isModelIndex(final String indexFileName) {
+ if (!isIndexFile(indexFileName)) {
+ return false;
+ }
+ return !IndexConstants.INDEX_NAME.isKnownIndex(indexFileName);
+ }
+
+ /**
+ * Return true if the specifed index file represents a index file
+ * on the file system otherwise return false.
+ */
+ public static boolean isIndexFile(final String indexFileName) {
+ if (!StringUtil.isEmpty(indexFileName)) {
+ String extension = FileUtils.getExtension(indexFileName);
+ if(extension != null ) {
+ if( extension.equals(IndexConstants.INDEX_EXT) ||
extension.equals(IndexConstants.SEARCH_INDEX_EXT)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return true if the specifed index file represents a index file
+ * on the file system otherwise return false.
+ */
+ public static boolean isIndexFile(final File indexFile) {
+ if (indexFile != null && indexFile.isFile()) {
+ return isIndexFile(indexFile.getName());
+ }
+ return false;
+ }
+
+ /**
+ * Return an array of indexes given a indexName.
+ * @param indexName The shortName of the index file
+ * @param selector The indexSelector to lookup indexes
+ * @return An array of indexes, may be duplicates depending on index selector.
+ * @throws MetamatrixCoreException If there is an error looking up indexes
+ * @since 4.2
+ */
+ public static Index[] getIndexes(final String indexName, final IndexMetadataStore
selector) {
+ 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];
+ if(coreIndex != null) {
+ final String indexFileName = indexes[i].getIndexFile().getName();
+ if(indexName.equals(indexFileName)) {
+ tmp.add(coreIndex);
+ }
+ }
+ }
+ return tmp.toArray(new Index[tmp.size()]);
+ }
+
+ /**
+ * Return the name of the index file to use for the specified record type, applies
only for sever and vdb
+ * index files.
+ * @param recordType
+ * @return
+ */
+ public static String getIndexFileNameForRecordType(final char recordType) {
+ switch (recordType) {
+ case IndexConstants.RECORD_TYPE.COLUMN: return
IndexConstants.INDEX_NAME.COLUMNS_INDEX;
+ case IndexConstants.RECORD_TYPE.TABLE: return
IndexConstants.INDEX_NAME.TABLES_INDEX;
+ case IndexConstants.RECORD_TYPE.MODEL: return
IndexConstants.INDEX_NAME.MODELS_INDEX;
+ case IndexConstants.RECORD_TYPE.CALLABLE:
+ case IndexConstants.RECORD_TYPE.CALLABLE_PARAMETER:
+ case IndexConstants.RECORD_TYPE.RESULT_SET: return
IndexConstants.INDEX_NAME.PROCEDURES_INDEX;
+ case IndexConstants.RECORD_TYPE.INDEX:
+ case IndexConstants.RECORD_TYPE.ACCESS_PATTERN:
+ case IndexConstants.RECORD_TYPE.PRIMARY_KEY:
+ case IndexConstants.RECORD_TYPE.FOREIGN_KEY:
+ case IndexConstants.RECORD_TYPE.UNIQUE_KEY: return
IndexConstants.INDEX_NAME.KEYS_INDEX;
+ case IndexConstants.RECORD_TYPE.SELECT_TRANSFORM: return
IndexConstants.INDEX_NAME.SELECT_TRANSFORM_INDEX;
+ case IndexConstants.RECORD_TYPE.INSERT_TRANSFORM: return
IndexConstants.INDEX_NAME.INSERT_TRANSFORM_INDEX;
+ case IndexConstants.RECORD_TYPE.UPDATE_TRANSFORM: return
IndexConstants.INDEX_NAME.UPDATE_TRANSFORM_INDEX;
+ case IndexConstants.RECORD_TYPE.DELETE_TRANSFORM: return
IndexConstants.INDEX_NAME.DELETE_TRANSFORM_INDEX;
+ case IndexConstants.RECORD_TYPE.PROC_TRANSFORM: return
IndexConstants.INDEX_NAME.PROC_TRANSFORM_INDEX;
+ case IndexConstants.RECORD_TYPE.MAPPING_TRANSFORM: return
IndexConstants.INDEX_NAME.MAPPING_TRANSFORM_INDEX;
+ case IndexConstants.RECORD_TYPE.DATATYPE: return
IndexConstants.INDEX_NAME.DATATYPES_INDEX;
+ //case IndexConstants.RECORD_TYPE.DATATYPE_ELEMENT:
+ //case IndexConstants.RECORD_TYPE.DATATYPE_FACET:
+ case IndexConstants.RECORD_TYPE.VDB_ARCHIVE: return
IndexConstants.INDEX_NAME.VDBS_INDEX;
+ case IndexConstants.RECORD_TYPE.ANNOTATION: return
IndexConstants.INDEX_NAME.ANNOTATION_INDEX;
+ case IndexConstants.RECORD_TYPE.PROPERTY: return
IndexConstants.INDEX_NAME.PROPERTIES_INDEX;
+ //case IndexConstants.RECORD_TYPE.JOIN_DESCRIPTOR: return null;
+ case IndexConstants.RECORD_TYPE.FILE: return IndexConstants.INDEX_NAME.FILES_INDEX;
+ }
+ throw new IllegalArgumentException("Unkown record type " +
recordType);
+ }
+
+ /**
+ * Return the name of the index file to use for the specified record type, applies
only for sever and vdb
+ * index files.
+ * @param recordType
+ * @return
+ */
+ public static String getRecordTypeForIndexFileName(final String indexName) {
+ char recordType;
+ if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.COLUMNS_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.COLUMN;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.TABLES_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.TABLE;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MODELS_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.MODEL;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.DATATYPES_INDEX))
{
+ recordType = IndexConstants.RECORD_TYPE.DATATYPE;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.VDBS_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.VDB_ARCHIVE;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.ANNOTATION_INDEX))
{
+ recordType = IndexConstants.RECORD_TYPE.ANNOTATION;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROPERTIES_INDEX))
{
+ recordType = IndexConstants.RECORD_TYPE.PROPERTY;
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.SELECT_TRANSFORM_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.SELECT_TRANSFORM;
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.INSERT_TRANSFORM_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.INSERT_TRANSFORM;
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.UPDATE_TRANSFORM_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.UPDATE_TRANSFORM;
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.DELETE_TRANSFORM_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.DELETE_TRANSFORM;
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROC_TRANSFORM_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.PROC_TRANSFORM;
+ } else
if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MAPPING_TRANSFORM_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.MAPPING_TRANSFORM;
+ } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.FILES_INDEX)) {
+ recordType = IndexConstants.RECORD_TYPE.FILE;
+ } else {
+ return null;
+ }
+ return StringUtil.Constants.EMPTY_STRING + recordType;
+ }
+
+
+ /**
+ * 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|name|
+ * @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|
+ */
+ public static String getPrefixPattern(final char recordType, final String uuid) {
+
+ // construct the pattern string
+ String patternStr = "" //$NON-NLS-1$
+ + recordType
+ + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+ if(uuid != null && !uuid.equals(StringUtil.Constants.EMPTY_STRING)) {
+ patternStr = patternStr + uuid.trim() +
IndexConstants.RECORD_STRING.RECORD_DELIMITER;
+ }
+
+ return patternStr;
+ }
+
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java
(rev 0)
+++
trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,84 @@
+/*
+ * 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.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+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.metadata.runtime.api.MetadataSource;
+import com.metamatrix.query.metadata.MetadataStore;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+
+public class VDBMetadataFactory {
+
+ public static QueryMetadataInterface getVDBMetadata(String vdbFile) {
+ MetadataSource source;
+ try {
+ source = new VDBArchive(new FileInputStream(vdbFile));
+ } 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 {
+ MetadataSource source = new VDBArchive(vdbURL.openStream());
+ IndexMetadataStore selector = new IndexMetadataStore(source);
+ return new TransformationMetadata(new
CompositeMetadataStore(Arrays.asList(selector), source));
+ }
+
+ public static QueryMetadataInterface getVDBMetadata(String[] vdbFile) {
+
+ List<MetadataStore> selectors = new ArrayList<MetadataStore>();
+ MetadataSource source = null;
+ for (int i = 0; i < vdbFile.length; i++){
+ try {
+ MetadataSource tempSource = new VDBArchive(new File(vdbFile[i]));
+ if (i == 0) {
+ source = tempSource;
+ }
+ selectors.add(new IndexMetadataStore(tempSource));
+ } catch (IOException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+
+ return new TransformationMetadata(new CompositeMetadataStore(selectors,
source));
+ }
+}
Property changes on:
trunk/metadata/src/main/java/org/teiid/metadata/index/VDBMetadataFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/metadata/src/main/resources/org (from rev 1098,
trunk/metadata/src/main/resources/com)
Property changes on: trunk/metadata/src/main/resources/org
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/resources/org/teiid (from rev 1098,
trunk/metadata/src/main/resources/com/metamatrix)
Property changes on: trunk/metadata/src/main/resources/org/teiid
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/metadata/src/main/resources/org/teiid/metadata/i18n.properties (from rev
1098, trunk/metadata/src/main/resources/com/metamatrix/metadata/runtime/i18n.properties)
===================================================================
--- trunk/metadata/src/main/resources/org/teiid/metadata/i18n.properties
(rev 0)
+++ trunk/metadata/src/main/resources/org/teiid/metadata/i18n.properties 2009-07-08
04:55:17 UTC (rev 1107)
@@ -0,0 +1,1124 @@
+#
+# 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.
+#
+
+#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# Note: All new messages should have been looked up before being logged! DON'T use
I18nLogManager!
+#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+# ==========================================
+# Error Messages for the Metadata Package (008)
+# ==========================================
+#
+# example ERR.008.001.0001=Test Error Message for Metadata Package
+
+# ================== GENERIC METADATA MESSAGES ==================
+# generic (000)
+ERR.008.000.0001 = Error closing connection
+ERR.008.000.0002 = Error processing event
+ERR.008.000.0003 = Error loading configuration.
+ERR.008.000.0004 = Error creating unique id
+ERR.008.000.0005 = Attempt to compare null
+ERR.008.000.0006 = Error rolling back.
+ERR.008.000.0007 = Error executing query: {0}
+ERR.008.000.0008 = Error closing statement
+ERR.008.000.0009 = Error preparing statement: {0}
+ERR.008.000.0010 = Unable to commit transaction
+ERR.008.000.0011 = Unable to rollback transaction
+ERR.008.000.0012 = Unable to close transaction
+
+# ================== METADATA RUNTIME MESSAGES ==================
+# runtime (001)
+ERR.008.001.0001 = VDB name can not be null.
+ERR.008.001.0002 = Error obtaining active VDB ID for {0}
+ERR.008.001.0003 = There is no available virtual database with name: {0} and version:
{1}
+ERR.008.001.0004 = RuntimeMetadata: failed setVDBStatus for vdb {0}
+ERR.008.001.0005 = Error obtaining active VDB
+ERR.008.001.0006 = Error obtaining VDB {0}
+ERR.008.001.0007 = Error obtaining active VDB IDs.
+ERR.008.001.0008 = Error obtaining MetaBase info.
+ERR.008.001.0009 = Error obtaining Models for VDB {0}
+ERR.008.001.0010 = Can not find modelID with name: {0} in VDB {1}
+ERR.008.001.0011 = Error obtaining runtime types.
+ERR.008.001.0012 = Error obtaining all data types.
+ERR.008.001.0013 = Error adding listener. Creating NoOpMessageBus.
+ERR.008.001.0014 = Unable to load the MetadataSupplier class "{0}". No dynamic
runtime metadata loading will be available.
+ERR.008.001.0015 = Unable to instantiate the MetadataSupplier class "{0}". No
dynamic runtime metadata loading will be available.
+ERR.008.001.0016 = Unable to access the MetadataSupplier class "{0}". No
dynamic runtime metadata loading will be available.
+ERR.008.001.0017 = Error initializing transaction manager.
+ERR.008.001.0018 = The model name string may not be null
+ERR.008.001.0019 = The VirtualDatabaseID reference may not be null
+ERR.008.001.0020 = The model name string may not be zero-length
+ERR.008.001.0021 = The ModelID reference may not be null
+ERR.008.001.0022 = The VirtualDatabaseLoader reference may not be null
+ERR.008.001.0023 = The group name string may not be null
+ERR.008.001.0024 = The group name string may not be zero-length
+ERR.008.001.0025 = A model with name "{0}" cannot be found in the VDB
"{1}"
+ERR.008.001.0026 = deleteVDBMarkedForDelete: Unable to delete VDB: {0}
+ERR.008.001.0027 = deleteVDBsMarkedForDelete(sessionID<{0}>) no sessions logged in:
Unable to delete VDB: {1}
+ERR.008.001.0028 = Error getting sessions logged in to VDB version: {0} {1}
+ERR.008.001.0029 = Can''t delete Entitlements for VDB {0} version {1}
+ERR.008.001.0030 = Can''t delete the {0} Entitlements for VDB {1} version {2}
+ERR.008.001.0031 = Model is null in VDBMetadata, ID <{0}>
+ERR.008.001.0032 = GroupID is null in VDBMetadata, ID <{0}> under Model:
<{1}>
+ERR.008.001.0033 = Resource {0} could not be found or loaded in order to know what type
of model classes to entitle.
+
+# runtime.api (002)
+
+# runtime.event (003)
+
+# runtime.exception (004)
+
+# runtime.model (005)
+ERR.008.005.0001 = Invalid element full name.
+ERR.008.005.0002 = Invalid group full name.
+ERR.008.005.0003 = Invalid key full name.
+ERR.008.005.0004 = Unable to create an ID object with a null full name.
+ERR.008.005.0005 = Unable to create an ID object with a zero-length name.
+# ERR.008.005.0006 = Attempt to compare null
+ERR.008.005.0007 = Unable to create a basic object with a null ID
+ERR.008.005.0008 = Class Cast : Attempt to compare {0} to {1}
+ERR.008.005.0009 = Cannot clone this immutable object.
+ERR.008.005.0010 = The list of group names may not be null
+ERR.008.005.0011 = The list of group names may not be empty
+ERR.008.005.0012 = The list of group name may not be null
+ERR.008.005.0013 = The String builder method reference may not be null
+ERR.008.005.0014 = The VirtualDatabaseID reference may not be null
+ERR.008.005.0015 = The ModelID reference may not be null
+ERR.008.005.0016 = Invalid model full name {0}
+ERR.008.005.0017 = Invalid procedure full name.
+ERR.008.005.0018 = The fullnameWithinModel String may not be null
+ERR.008.005.0019 = The fullnameWithinModel String may not be zero-length
+ERR.008.005.0020 = The GroupID reference may not be null
+ERR.008.005.0021 = The name String may not be null
+ERR.008.005.0022 = The name dataTypeName may not be null
+ERR.008.005.0023 = The name String may not be zero-length
+ERR.008.005.0024 = The name dataTypeName may not be zero-length
+ERR.008.005.0025 = The DataType reference may not be null
+ERR.008.005.0026 = The Key reference may not be null
+ERR.008.005.0027 = The Element[] reference may not be null
+ERR.008.005.0028 = The Group reference may not be null
+ERR.008.005.0029 = The Element reference may not be null
+ERR.008.005.0030 = The Group reference must be an instance of BasicGroup
+ERR.008.005.0031 = The Element reference must be an instance of BasicElement
+ERR.008.005.0032 = Group {0} not found in the RuntimeMetadata.
+ERR.008.005.0033 = Key {0} not found in the RuntimeMetadata.
+ERR.008.005.0034 = Element {0} not found in the RuntimeMetadata.
+ERR.008.005.0035 = Model {0} not found in the RuntimeMetadata.
+ERR.008.005.0036 = Procedure {0} not found in the RuntimeMetadata.
+ERR.008.005.0037 = UnsupportedOperation : getMetaBaseInfo is not supported in
MetadataCache
+ERR.008.005.0038 = UnsupportedOperation : getVirtualDatabaseID is not supported in
MetadataCache
+ERR.008.005.0039 = Error obtaining elements in key.
+ERR.008.005.0040 = Error obtaining procedures.
+ERR.008.005.0041 = Error obtaining key.
+ERR.008.005.0042 = Error obtaining keys in model.
+ERR.008.005.0043 = Error obtaining keys in group.
+ERR.008.005.0044 = UnsupportedOperation : getVirtualDatabases is not supported in
MetadataCache
+ERR.008.005.0045 = Can not find VDB with ID {0} and UUID {1}
+ERR.008.005.0046 = Can not find VDB {0}
+ERR.008.005.0047 = Error obtaining data types.
+ERR.008.005.0048 = Incomplete group name "{0}"
+ERR.008.005.0049 = Error creating KeyID for {0}
+ERR.008.005.0050 = Error creating ElementID for {0}
+ERR.008.005.0051 = Error creating ModelID for {0}
+ERR.008.005.0052 = Error creating ProcedureID for {0}
+ERR.008.005.0053 = Error obtaining properties.
+ERR.008.005.0054 = Error obtaining groupIDs for model.
+ERR.008.005.0055 = Error obtaining loaded groupIDs for model.
+ERR.008.005.0056 = Error obtaining groupIDs with the pattern {0}
+ERR.008.005.0057 = UnsupportedOperation : loadGroups is not supported in MetadataCache
+ERR.008.005.0058 = Error obtaining groupIDs that end with {0}
+ERR.008.005.0059 = Error obtaining XML Schema for {0}
+ERR.008.005.0060 = Error obtaining group.
+ERR.008.005.0061 = Error obtaining VDB.
+ERR.008.005.0062 = Error obtaining models.
+ERR.008.005.0063 = Error initializing object cache.
+ERR.008.005.0064 = Error loading built-in types.
+ERR.008.005.0065 = Error loading xml file: {0}
+ERR.008.005.0066 = Failed loading xml files into Runtime Metadata for VDB {0}
+ERR.008.005.0067 = There are unresolved references. See error log.
+ERR.008.005.0068 = Error inserting objects.
+ERR.008.005.0069 = Error creating VDB: {0}
+ERR.008.005.0070 = The virtual database is not fully created yet.
+ERR.008.005.0071 = Error setting VDB status.
+ERR.008.005.0072 = Error setting VDB: {0} active.
+ERR.008.005.0073 = Error broadcasting VDB changes.
+ERR.008.005.0074 = Virtual Database: {0} can not be deleted because it is not marked for
deletion.
+ERR.008.005.0075 = Error deleting VDB.
+ERR.008.005.0076 = Error deleting VDB: {0}
+ERR.008.005.0077 = Error obtaining RT connector binding name.
+ERR.008.005.0078 = Error setting connector binding names.
+ERR.008.005.0079 = Error setting status.
+ERR.008.005.0080 = Error obtaining RT visibility levels.
+ERR.008.005.0081 = Error setting visibility levels.
+ERR.008.005.0082 = Error setting visibility levels updating system models
+ERR.008.005.0083 = Error adding Schemas
+ERR.008.005.0084 = Unable to resolve connection for Schema Insert.
+ERR.008.005.0085 = Error inserting Schema
+ERR.008.005.0086 = Error obtaining all model IDs.
+ERR.008.005.0087 = The VirtualDatabaseID reference may not be null
+ERR.008.005.0088 = The MetadataCache reference may not be null
+ERR.008.005.0089 = The MetadataSupplier reference may not be null
+ERR.008.005.0090 = Incomplete group name "{0}"
+ERR.008.005.0091 = The valid fullname string may not be null
+ERR.008.005.0092 = The test fullname string may not be null
+ERR.008.005.0093 = The ModelID reference may not be null
+ERR.008.005.0094 = The UpdateController reference may not be null
+ERR.008.005.0095 = The MetadataSupplier reference may not be null
+ERR.008.005.0096 = The VirtualDatabaseID reference may not be null
+ERR.008.005.0097 = The BasicModel reference may not be null
+ERR.008.005.0098 = Virtual Database already contains model "{0}"
+ERR.008.005.0099 = Unable to obtain connection to add relational model to VDB {0}
+ERR.008.005.0100 = Error adding relational model to VDB {0}
+ERR.008.005.0101 = The UpdateController reference may not be null
+ERR.008.005.0102 = The VirtualDatabaseID reference may not be null
+ERR.008.005.0103 = The ModelID reference may not be null
+ERR.008.005.0104 = Unable to obtain connection to add relational objects to VDB {0}
+ERR.008.005.0105 = Unable to obtain connection to delete relational objects from VDB
+ERR.008.005.0106 = Error updating the status of {0} for VDB {1}
+ERR.008.005.0107 = Error reading the status of {0} for VDB {1}
+ERR.008.005.0108 = Model {0} in virtual database {1} has a status of "{2}" and
cannot be accessed at this time.
+ERR.008.005.0109 = Unable to obtain connection to delete relational objects from VDB {0}
+ERR.008.005.0110 = The model name string may not be null
+ERR.008.005.0111 = The model name string may not be zero-length
+ERR.008.005.0112 = The VirtualDatabaseLoader reference may not be null
+ERR.008.005.0113 = No VirtualDatabaseLoaderProperties returned for model {0}
+ERR.008.005.0114 = The group name string may not be null
+ERR.008.005.0115 = The group name string may not be zero-length
+ERR.008.005.0116 = The VirtualDatabaseMetadata must be an instance of
BasicVirtualDatabaseMetadata
+ERR.008.005.0117 = The KeyID reference may not be null
+ERR.008.005.0118 = The List reference may not be null
+ERR.008.005.0119 = A model with the name, "{0}", does not exist for VDB,
"{1}"
+ERR.008.005.0120 = Cannot create a ModelID with the name, "{0}". A model by
that name already exists for VDB, "{1}"
+ERR.008.005.0121 = Cannot create a GroupID with the name, "{0}". A group by
that name already exists for VDB, "{1}"
+ERR.008.005.0122 = The specified name, "{0}", is invalid: {1}
+
+
+# runtime.spi (006)
+ERR.008.006.0001 = Error obtaining connection for {0}
+ERR.008.006.0002 = The connection is not the appropriate type ("{0}")
+ERR.008.006.0003 = JDBC error while processing query: {0}
+ERR.008.006.0004 = Error processing results for query: {0}
+ERR.008.006.0005 = Error getting query plan for procedure using:{0}
+ERR.008.006.0006 = Unexpected Error getting Procedures
+ERR.008.006.0007 = The specified status, "{0}", is not one of the allowable
values.
+ERR.008.006.0008 = The virtual database: {0} is already marked for deletion. It can not
be set to other status.
+ERR.008.006.0009 = Error inserting models
+ERR.008.006.0010 = Error inserting groups
+ERR.008.006.0011 = Element: {0} does not have data type
+ERR.008.006.0012 = Unable to find a valid DataType with name "{0}"
+ERR.008.006.0013 = Error inserting elements
+ERR.008.006.0014 = Error inserting models
+ERR.008.006.0015 = Error inserting procedures
+ERR.008.006.0016 = Error inserting key elements
+ERR.008.006.0017 = Parameter: {0} does not have data type
+ERR.008.006.0018 = Error inserting parameters
+ERR.008.006.0019 = Error inserting properties
+ERR.008.006.0020 = Runtime type for type: {0} is not defined.
+ERR.008.006.0021 = Error inserting data types
+ERR.008.006.0022 = Error inserting data type elements
+ERR.008.006.0023 = Error inserting database: {0}
+ERR.008.006.0024 = Error deleting model : {0}
+ERR.008.006.0025 = Error deleting group : {0}
+ERR.008.006.0026 = Error deleting properties
+ERR.008.006.0027 = UnsupportedOperation : loadGroups is not supported for JDBCConnector
+ERR.008.006.0028 = Error inserting query plan: {0}
+ERR.008.006.0029 = Error processing document schema: Schema may not be null
+ERR.008.006.0030 = Error processing document schema: IDs may not be null {0} - {1}
+ERR.008.006.0031 = Error inserting schema: {0}
+ERR.008.006.0032 = Current system vdb is not active.
+ERR.008.006.0033 = Error obtaining all required models in order to update system models.
+ERR.008.006.0034 = Can not resolve RuntimeType for
+ERR.008.006.0035 = Error processing query: {0}
+ERR.008.006.0036 = There is no XML Schema in runtime metadata for {0}
+ERR.008.006.0037 = Referenced key {0} is not resolved.
+ERR.008.006.0038 = Error setting state to {0} for virtual database: {1}
+ERR.008.006.0039 = Error updating connector binding names for VDB {0}
+ERR.008.006.0040 = Error setting visibility levels for VDB {0}
+ERR.008.006.0041 = Error updating VDB {0}
+ERR.008.006.0042 = Error updating VDB models for vdb {0}
+ERR.008.006.0043 = Error updating VDB version for VDB {0}
+ERR.008.006.0044 = Error inserting VDB models for vdb {0}
+ERR.008.006.0045 = Error converting String to Date.
+ERR.008.006.0046 = Error parsing multiplicity: {0}
+ERR.008.006.0047 = Can not find dataType with uid {0} for element {1}
+ERR.008.006.0048 = Error creating objects.
+ERR.008.006.0049 = SearchType: {0} is not supported.
+ERR.008.006.0050 = Error obtaining multiplicity: {0}
+ERR.008.006.0051 = DataTypeType: {0} is not supported.
+ERR.008.006.0052 = NullType: {0} is not supported.
+ERR.008.006.0053 = Can not resolve runtime type {0}
+ERR.008.006.0054 = Error creating properties.
+ERR.008.006.0055 = Property value {0} not an instance of Boolean or String
+ERR.008.006.0056 = Unresolved dataType reference: {0}
+ERR.008.006.0057 = Unresolved element reference in key: {0}
+ERR.008.006.0058 = Unresolved foreign key reference in primary key: {0}
+ERR.008.006.0059 = Unresolved query reference in group: {0}
+ERR.008.006.0060 = Unresolved mapping reference in document element: {0}
+ERR.008.006.0061 = Error getting all data types.
+ERR.008.006.0062 = Error getting runtime type for {0}
+ERR.008.006.0063 = Can not get built-in type for {0}
+ERR.008.006.0064 = Error updating the model name for ModelID "{0}" with UID
{1}
+ERR.008.006.0065 = Error updating the group path for GroupID "{0}" with UID
{1}
+
+# runtime.util (007)
+ERR.008.007.0001 = One or more files are not found.
+ERR.008.007.0002 = Error saving input stream to file for key {0}
+ERR.008.007.0003 = Error saving input stream from file for key {0}
+
+# ================== METADATA SEARCHBASE MESSAGES ==================
+# searchbase (008)
+ERR.008.008.0001 = Searchbase Error processing element : {0}
+ERR.008.008.0002 = Error adding data type model for target {0}
+ERR.008.008.0003 = Searchbase Error establishing sb_publish connection pool
+ERR.008.008.0004 = Unable to get connection, target {0} is invalid and not known to the
searchbase.
+
+# searchbase.api (009)
+
+# searchbase.apiimpl (010)
+
+# searchbase.command (011)
+
+# searchbase.exception (012)
+
+# searchbase.jdbc (013)
+
+# searchbase.processor (014)
+
+# searchbase.tool (015)
+
+# searchbase.transform (016)
+
+# searchbase.transform.xml (017)
+
+# searchbase.util (018)
+
+# searchbase.xmi (019)
+# ================== METADATA SERVER MESSAGES ==================
+# server.api (020)
+ERR.008.020.0001 = The entryUUIDs may not be null
+ERR.008.020.0002 = The entryUUID may not be null
+ERR.008.020.0003 = The UUID string may not be zero-length
+ERR.008.020.0004 = The version may not be null
+ERR.008.020.0005 = The getInfoCriteriaType may not be null, see GetInfoCriteria
+ERR.008.020.0006 = The getInfoCriteriaType string may not be zero-length, see
GetInfoCriteria
+ERR.008.020.0007 = The searchCriteriaStatement may not be null
+ERR.008.020.0008 = The searchCriteriaStatement string may not be zero-length
+ERR.008.020.0009 = Search type {0} is not supported.
+ERR.008.020.0010 = The criteria may not be null, call getInfo to first obtain a criteria
object.
+ERR.008.020.0011 = The version may not be null
+ERR.008.020.0012 = VersionLabel is not supported, must use a VersionRule or VersionName
to specify the version.
+ERR.008.020.0013 = The from VersionIdentifier may not be null
+ERR.008.020.0014 = The to VersionIdentifier may not be null
+ERR.008.020.0015 = The from Date may not be null
+ERR.008.020.0016 = The to Date may not be null
+ERR.008.020.0017 = The dtcUUID may not be null
+ERR.008.020.0018 = The dtcUUID string may not be zero-length
+ERR.008.020.0019 = The parentUUID may not be null
+ERR.008.020.0020 = The parentUUID string may not be zero-length
+ERR.008.020.0021 = The userName may not be null
+ERR.008.020.0022 = The userName string may not be zero-length
+ERR.008.020.0023 = The projectUUID may not be null
+ERR.008.020.0024 = The projectUUID string may not be zero-length
+ERR.008.020.0025 = The map of primaryModelUUID and Versions may not be null
+ERR.008.020.0026 = The fileName string may not be null
+ERR.008.020.0027 = The fileName string may not be zero-length
+ERR.008.020.0028 = The creationDate string may not be null
+ERR.008.020.0029 = The content may not be null
+ERR.008.020.0030 = The fileType string may not be null
+ERR.008.020.0031 = The fileType string may not be zero-length
+ERR.008.020.0032 = Cannot name a file a reserved word.
+ERR.008.020.0033 = The lastModifiedDate string may not be null
+ERR.008.020.0034 = The folderName string may not be null
+ERR.008.020.0035 = The folderName string may not be zero-length
+ERR.008.020.0036 = The versionRollbackTo string may not be null
+ERR.008.020.0037 = The versionRollbackTo string may not be zero-length
+ERR.008.020.0038 = The newParentUUID string may not be null
+ERR.008.020.0039 = The newParentUUID string may not be zero-length
+ERR.008.020.0040 = The copy operation is not supported in the Toolkit
+ERR.008.020.0041 = The entry may not be null
+ERR.008.020.0042 = he updatedProperties may not be null
+ERR.008.020.0043 = The label string may not be null
+ERR.008.020.0044 = The label string may not be zero-length
+ERR.008.020.0045 = The UUID version list may not be null
+ERR.008.020.0046 = The resourceNames may not be null
+ERR.008.020.0047 = The first EntryInfo reference may not be null
+ERR.008.020.0048 = The second EntryInfo reference may not be null
+ERR.008.020.0049 = The name of the first EntryInfo reference may not be null
+ERR.008.020.0050 = The name of the second EntryInfo reference may not be null
+ERR.008.020.0051 = The entry UUID String reference may not be null.
+ERR.008.020.0052 = The entry UUID String reference may not be zero-length.
+ERR.008.020.0053 = The from VersionIdentifier may not be null
+ERR.008.020.0054 = The to VersionIdentifier may not be null
+ERR.008.020.0055 = The from Date may not be null
+ERR.008.020.0056 = The to Date may not be null
+ERR.008.020.0057 = Connection parameters cannot be null
+ERR.008.020.0058 = Method not implemented
+ERR.008.020.0059 = The label String reference may not be null.
+ERR.008.020.0060 = The label String reference may not be zero-length.
+ERR.008.020.0061 = The name String reference may not be null.
+ERR.008.020.0062 = The name String reference may not be zero-length.
+ERR.008.020.0063 = The rule String reference may not be null.
+ERR.008.020.0064 = The rule String reference may not be zero-length.
+
+# server.api.dtc (021)
+ERR.008.021.0001 = The root Document reference may not be null
+ERR.008.021.0002 = The InputStream reference may not be null
+ERR.008.021.0003 = Error loading the XMI document from the specified stream
+ERR.008.021.0004 = The dtcUUID may not be null
+ERR.008.021.0005 = The dtcUUID may not be zero length
+ERR.008.021.0006 = The dtcName may not be null
+ERR.008.021.0007 = The dtcName may not be zero length
+ERR.008.021.0008 = The projectUUID may not be null
+ERR.008.021.0009 = The projectUUID may not be zero length
+ERR.008.021.0010 = The entryInfos may not be null
+
+# server.api.event (022)
+
+# server.api.exception (023)
+ERR.008.023.0001 = Entry "{0}" is currently locked by user "{1}".
+ERR.008.023.0002 = Entry "{0}" is not currently locked.
+ERR.008.023.0003 = No version was found in the directory for entry "{0}".
+ERR.008.023.0004 = Entry "{0}" is currently locked by the current user.
+ERR.008.023.0005 = Folder copy is not supported.
+ERR.008.023.0006 = Need to recover entry "{0}" before it can be checked out.
+ERR.008.023.0007 = Entry "{0}" already exist with uuid "{1}".
+ERR.008.023.0008 = Entry does not exist for UUID "{0}" .
+ERR.008.023.0009 = A RuntimeMetadata Configuration In Progress does not exist for UUID
"{0}" .
+ERR.008.023.0010 = There already exist a file or folder in this location with the name
"{0}".
+ERR.008.023.0011 = The model "{0}" cannot be deleted, it is involved in making
deployable configuration "{1}".
+ERR.008.023.0012 = Label "{0}" already exist for entry "{1}".
+ERR.008.023.0013 = The user "{0}" is not authorized to perform "{1}"
on entry "{2}".
+ERR.008.023.0014 = The license prevents additional physical models from being added to
the repository. No entry or entries added.
+
+# server.apiimpl (024)
+ERR.008.024.0001 = The name may not be null.
+ERR.008.024.0002 = The name may not be zero-length.
+ERR.008.024.0003 = The UUID may not be null.
+ERR.008.024.0004 = The UUID may not be zero-length.
+ERR.008.024.0005 = The file type may not be null.
+ERR.008.024.0006 = The file type may not be zero-length.
+ERR.008.024.0007 = The version may not be null.
+ERR.008.024.0008 = The version may not be zero-length.
+ERR.008.024.0009 = Context properties were not found in the sessions properties for
initializaing MetadataServerAPI.
+ERR.008.024.0010 = {0} session exception
+ERR.008.024.0011 = {0} remote exception
+ERR.008.024.0012 = {0} naming exception
+ERR.008.024.0013 = {0} create exception
+ERR.008.024.0014 = Error in MetadataServer add message bus listener for class event {0}
+ERR.008.024.0015 = Illegal Argument in MetadataServerConnectionImpl add Event Listener:
listener cannot be null
+ERR.008.024.0016 = The MetadataServerConnection is closed and may not be used.
+ERR.008.024.0017 = Invalid session when trying to submit request.
+ERR.008.024.0018 = Unable to complete directory request.
+ERR.008.024.0019 = Invalid Component when trying to submit request.
+ERR.008.024.0020 = Invalid session when trying to submit request.
+ERR.008.024.0021 = Exception occured when trying to submit request.
+ERR.008.024.0022 = Invalid Session
+ERR.008.024.0023 = The EventBroker reference may not be null
+ERR.008.024.0024 = The listener reference may not be null
+ERR.008.024.0025 = Unable to find EventObjectListener for {0}
+ERR.008.024.0026 = EntryAddCriteria may not be null
+ERR.008.024.0027 = The number of spaces to indent must be positive
+ERR.008.024.0028 = The request ID may not be null
+ERR.008.024.0029 = The session token may not be null
+ERR.008.024.0030 = The session token may not be zero-length
+ERR.008.024.0031 = This builder already has an unclosed document
+ERR.008.024.0032 = The username may not be null
+ERR.008.024.0033 = The username may not be zero-length
+ERR.008.024.0034 = Criteria object of type {0} is not supported.
+ERR.008.024.0035 = The criteria may not be null
+ERR.008.024.0036 = Unable to create inputstream for the file {0}
+ERR.008.024.0037 = Unable to load inputstream into byte array for entry {0}
+ERR.008.024.0038 = The history criteria may not be null
+ERR.008.024.0039 = The entry UUID list may not be null
+ERR.008.024.0040 = The UUID string may not be null
+ERR.008.024.0041 = The UUID string may not be zero-length
+ERR.008.024.0042 = The version string may not be null
+ERR.008.024.0043 = The version string may not be zero-length
+ERR.008.024.0044 = The content List may not be null
+ERR.008.024.0045 = The content InputStream may not be null
+ERR.008.024.0046 = The fileName string may not be null
+ERR.008.024.0047 = The fileName string may not be zero-length
+ERR.008.024.0048 = The fileType string may not be null
+ERR.008.024.0049 = The fileType string may not be zero-length
+ERR.008.024.0050 = RequestBuilder Error: Cannot use addFile method for the file type {0}
+ERR.008.024.0051 = Invalid criteria, no method was defined for this criteria.
+ERR.008.024.0052 = The Action string may not be null
+ERR.008.024.0053 = The Target string may not be null
+ERR.008.024.0054 = The new location string may not be null
+ERR.008.024.0055 = The folderName string may not be null
+ERR.008.024.0056 = The folderName string may not be zero-length
+ERR.008.024.0057 = The entry may not be null
+ERR.008.024.0058 = The new entry UUID string may not be null
+ERR.008.024.0059 = The new entry UUID string may not be zero-length
+ERR.008.024.0060 = The new parent UUID string may not be null
+ERR.008.024.0061 = The new parent UUID string may not be zero-length
+ERR.008.024.0062 = The version identifier may not be null
+ERR.008.024.0063 = Unable to convert XML to string for the request message.
+ERR.008.024.0064 = Unable to parse the response message.
+ERR.008.024.0065 = Unable to convert the response content InputStream into a byte array.
+ERR.008.024.0066 = Object type {0} is not supported for content.
+
+# server.apiimpl.dtc (025)
+ERR.008.025.0001 = The ObjectDefinition reference may not be null
+ERR.008.025.0002 = The DirectoryServiceProxy may not be null
+ERR.008.025.0003 = The DTCEditorImpl reference may not be null
+ERR.008.025.0004 = The TreeNode reference may not be null
+ERR.008.025.0005 = The referenced object is not a BasicTreeNode
+ERR.008.025.0006 = The PropertiedObject reference may not be null
+ERR.008.025.0007 = The referenced object is not a TreeNode
+ERR.008.025.0008 = The referenced object is not of type DTCDefinition
+ERR.008.025.0009 = The referenced object is not of type FolderDefinition
+
+# server.directory.api.exception (026)
+# server.directory.api.service (027)
+# server.directory.dtc (028)
+ERR.008.028.0001 = The dtcUUID may not be null
+ERR.008.028.0002 = The dtcUUID may not be zero length
+ERR.008.028.0003 = The dtcName may not be null
+ERR.008.028.0004 = The dtcName may not be zero length
+ERR.008.028.0005 = The projectUUID may not be null
+ERR.008.028.0006 = The projectUUID may not be zero length
+ERR.008.028.0007 = The entryInfos may not be null
+ERR.008.028.0008 = DTC In Progress has not completed, the content that manages the list
of models has not been saved.
+ERR.008.028.0009 = No project file found in the repository for UUID: {0} version: {1}
+ERR.008.028.0010 = Project Model Content Error, project model {0} in the repository does
not contain any content to determine model imports.
+ERR.008.028.0011 = Project Model Import Error, project model {0} in the repository does
not contain any model imports.
+ERR.008.028.0012 = Connection is closed, cannot validate DTC {0}
+ERR.008.028.0013 = Unable to complete DTC Validation
+ERR.008.028.0014 = Unable to update the DTC from "Validating" to
"InValid" status.
+ERR.008.028.0015 = Unable to notify of DTC validation
+ERR.008.028.0016 = Configuration Validation Error, unable to obtain models for
validation.
+ERR.008.028.0017 = Configuration Validation Error, no models were found in the repository
based on the request.
+ERR.008.028.0018 = Configuration Validation Error, unable to obtain model UUID {0} for
validation.
+ERR.008.028.0019 = Configuration Validation Error, model {0} in the repository does not
contain any content.
+ERR.008.028.0020 = Error obtaining model dependencies for validation.
+ERR.008.028.0021 = Configuration Validation Error, unable to load XMIDocument models for
validation.
+ERR.008.028.0022 = Error obtaining dependent model for validation.
+ERR.008.028.0023 = Configuration Validation Error, model {0} has been included more than
once in the validation. Check the internal model names for duplicates.
+ERR.008.028.0024 = Configuration Validation Error, problem obtaining file for uuid {0}.
+ERR.008.028.0025 = Configuration Validation Error, problem obtaining file {0}, the
content is empty.
+ERR.008.028.0026 = Configuration Validation Error, unable to obtain model from repository
for uuid {0}
+ERR.008.028.0027 = The MessageList reference may not be null.
+ERR.008.028.0028 = Exception during validation: {0}
+ERR.008.028.0029 = Aborted creation of Runtime Metadata Configuration due to validation
errors.
+ERR.008.028.0030 = Configuration Validation Error, unable to create the Runtime Metadata
Configuration Document.
+ERR.008.028.0031 = Validation Error Message: {0} {1}
+ERR.008.028.0032 = Cannot validate a null object.
+ERR.008.028.0033 = Error when attempting to perform validation process on object: {0}
+ERR.008.028.0034 = Unable to create the object ID for entry " + name + " using
uuid
+ERR.008.028.0035 = Method not implemented
+
+# server.directory.service (029)
+ERR.008.029.0001 = Error initializing service for {0}
+ERR.008.029.0002 = Resource property "{0}" for Resource Name "{1}" is
null.
+ERR.008.029.0003 = This DirectoryService is closed and cannot be used any longer
+ERR.008.029.0004 = The message reference may not be null
+ERR.008.029.0005 = Error submitting message {0}
+ERR.008.029.0006 = Error adding listener to message bus.
+ERR.008.029.0007 = Unable to get proxy for Authorization service.
+ERR.008.029.0008 = Invalid message request, {0} is not a valid method request.
+ERR.008.029.0009 = Error executing transaction {0}
+ERR.008.029.0010 = Error rolling back transaction for request {0}
+ERR.008.029.0011 = Invalid object passed for notify changes : Class {0} is invalid.
+ERR.008.029.0012 = Sending "CREATE" event for target: {0}
+ERR.008.029.0013 = Sending "DELETE" event for target: {0}
+ERR.008.029.0014 = Sending "CHANGE" event for target: {0}
+ERR.008.029.0015 = Error publishing changes.
+ERR.008.029.0016 = Unable to get user authorization for resources. The user principal
"{0}" is not valid.
+ERR.008.029.0017 = Error getting user authorization for resources.
+ERR.008.029.0018 = Unable to filter directory response for {0} access. The user session
"{1}" is not valid.
+ERR.008.029.0019 = Error filtering directory response for {0} access.
+ERR.008.029.0020 = Unable to check directory access. The user session "{0}" is
not valid.
+ERR.008.029.0021 = Error checking directory access.
+ERR.008.029.0022 = getEntryInfo got fault: {0}
+
+# server.directory.spi (030)
+ERR.008.030.0001 = Unable to parse the requested document.
+ERR.008.030.0002 = The number of request in a request message body must be one, the
number in the current body is {0}
+ERR.008.030.0003 = Invalid request node {0}
+ERR.008.030.0004 = Error building request message.
+ERR.008.030.0005 = Error building response message.
+
+# server.directory.spi.jdbc (031)
+ERR.008.031.0001 = The connection is not the appropriate type ("{0}")
+ERR.008.031.0002 = Installation Error - No Root Entry exist in the Directory
+ERR.008.031.0003 = No entry is found at location {0} to filter from.
+ERR.008.031.0004 = Request DTC in Progress {0} does not exist in order to delete.
+ERR.008.031.0005 = Request for DTC in Progress does not contain either a DTC uuid or
Parent UUID
+ERR.008.031.0006 = Error inserting lock for entry {0} and version {1}
+ERR.008.031.0007 = No parent entry was found for the specified UUID {0}
+ERR.008.031.0008 = Parent location was not specified.
+ERR.008.031.0009 = UUID for the destination entry was not specified.
+ERR.008.031.0010 = Unable to add Dependency for entry {1}
+ERR.008.031.0011 = Parent entry may not be null when adding dependencies
+ERR.008.031.0012 = Unable to add dependencies. No child entry found for UUID {0} and
version {1}
+ERR.008.031.0013 = Error reading basic entry information.
+ERR.008.031.0014 = No file content for UUID {0} version {1}
+ERR.008.031.0015 = Failed to execute the query "{0}"
+ERR.008.031.0016 = Unable to execute the query ("{0}") and/or process the
results
+ERR.008.031.0017 = No Entry Found for UUID: {0}
+ERR.008.031.0018 = No Entry Found for UUID: {0} when checking isDeleted flag.
+ERR.008.031.0019 = Installation Problem, no type found for: {0} using SQL: {1}
+ERR.008.031.0020 = Unable to close the statement for query {0}
+ERR.008.031.0021 = Unable to insert new entry {0} for user {1}
+ERR.008.031.0022 = Unable to insert directory lock on UUID {0} for user {1}
+ERR.008.031.0023 = Unable to insert new version for entry {0} for user {1}
+ERR.008.031.0024 = Unable to insert label UUID {0} for user {1}
+ERR.008.031.0025 = Error inserting file data.
+ERR.008.031.0026 = Failed to execute the query {0}
+ERR.008.031.0027 = Programming Error: Inserting file data for platform {0} is not
supported.
+ERR.008.031.0028 = No file found for version id {0}
+ERR.008.031.0029 = Error inserting file into directory using SQL statement: {0}
+ERR.008.031.0030 = JDBC error while inserting file data: {0}
+ERR.008.031.0031 = Unable to insert file dependencies for {0}
+ERR.008.031.0032 = Unable to insert orphaned dependencies for parent uuid {0} and child
{1}
+ERR.008.031.0033 = JDBC error while inserting file data:
+ERR.008.031.0034 = Unable to remove lock for entry {0} for user {1}
+ERR.008.031.0035 = Unable to remove entry {0}
+ERR.008.031.0036 = Unable to remove versions for entry ID {0}
+ERR.008.031.0037 = Error deleting versions for entryID {0}
+ERR.008.031.0038 = Error deleting label {0} for UUID {1}
+ERR.008.031.0039 = Error deleting labels for UUID {0}
+ERR.008.031.0040 = Error deleting file for {0}
+ERR.008.031.0041 = Unable to remove DTC in progress {0}
+ERR.008.031.0042 = Unable to remove Orphaned Dependencies for uuid: {0}
+ERR.008.031.0043 = Unable to move Orphaned Dependencies for uuid: {0}
+ERR.008.031.0044 = Unable to set state for DTC in progress {0}
+ERR.008.031.0045 = No file found for uuid {0}
+ERR.008.031.0046 = Unable to update DTC in progress {0}
+ERR.008.031.0047 = Error rollback for {0}
+ERR.008.031.0048 = Error deleting entry {0}
+
+# server.resource (032)
+ERR.008.032.0001 = The parent of uuid {0} had fault: {1}
+ERR.008.032.0002 = Error submitting request
+ERR.008.032.0003 = Error creating DirectoryServiceProxy, {0}
+ERR.008.032.0004 = Failed to create MetaBase AuthorizationPermission for uuid: {0} at
path: {1}
+ERR.008.032.0005 = Failed to delete MetaBase AuthorizationPermission for uuid: {0} at
path: {1}
+ERR.008.032.0006 = Unable to parse the request message.
+ERR.008.032.0007 = The number of request in a request message body must be one, the
number in the current body is {0}
+ERR.008.032.0008 = Invalid request node {0}
+ERR.008.032.0009 = Error building request message.
+ERR.008.032.0010 = Error building response message.
+ERR.008.032.0011 = Invalid message request, {0} is not a valid method request.
+ERR.008.032.0012 = Error obtaining resource information.
+
+# server.searchbase.api.service (033)
+
+# server.searchbase.service (034)
+ERR.008.034.0001 = Error initializing service for {0}
+ERR.008.034.0002 = The message reference may not be null
+ERR.008.034.0003 = Error submitting message {0}
+ERR.008.034.0004 = SearchbaseService error parsing for Searchbase commands.
+ERR.008.034.0005 = Error building target response message in Searchbase Service.
+
+# server.serverapi (035)
+ERR.008.035.0001 = invalid status: {0}
+
+# server.serverapi.beans (036)
+ERR.008.036.0001 = Error creating MetadataServerAPIBean, Exception: {0}
+ERR.008.036.0002 = License violation: Max number of {0} connections exceded, license only
allows {1} connections.
+ERR.008.036.0003 = Error validating licenses for {0}
+ERR.008.036.0004 = Could not connect to a SessionService.
+ERR.008.036.0005 = SessionService error: Could not connectToProduct for {0}
+ERR.008.036.0006 = Metadata Server API Bean error parsing for Searchbase commands
+ERR.008.036.0007 = Can not find a handler to hanle the request.
+ERR.008.036.0008 = DirectoryServiceProxy couldn''t be instantiated.
+ERR.008.036.0009 = SearchbaseServiceProxy couldn''t be instantiated.
+ERR.008.036.0010 = Session "{0}" is not valid
+ERR.008.036.0011 = Unable to find a valid Session Service
+ERR.008.036.0012 = Unknown Session Service exception.
+
+# server.serverapi.beans.metadataserverapi (037)
+# server.serverapi.exception (038)
+# server.service (039)
+# server.util (040)
+ERR.008.040.0001 = The project name String may not be null.
+ERR.008.040.0002 = The project version String may not be null.
+ERR.008.040.0003 = The username String may not be null.
+ERR.008.040.0004 = The dtcName String may not be null.
+ERR.008.040.0005 = Object type {0} not supported for object conversion.
+ERR.008.040.0006 = File {0} is not found
+
+# ================== METADATA TRANSFORM MESSAGES ==================
+# transform (041)
+ERR.008.041.0007 = There was an error creating a Templates object from the XSLT source:
{0}
+ERR.008.041.0008 = Unable to create an XSLT TransformerFactory instance.
+
+# ==========================================
+# LOG Messages for the Metadata Package (008)
+# ==========================================
+#
+# example: MSG.008.001.0001=Test Message for Metadata Package
+
+# ================== GENERIC METADATA MESSAGES ==================
+# generic (000)
+MSG.008.000.0001 = Properties successfully loaded.
+
+# ================== METADATA RUNTIME MESSAGES ==================
+# runtime (001)
+MSG.008.001.0001 = Transaction Mgr successfully initialized.
+MSG.008.001.0002 = Messagebus successfully initialized.
+MSG.008.001.0003 = Update controller successfully initialized.
+
+# runtime.api (002)
+
+# runtime.event (003)
+
+# runtime.exception (004)
+
+# runtime.model (005)
+MSG.008.005.0001 = Cache successfully initialized.
+MSG.008.005.0002 = creating vdb: {0}
+MSG.008.005.0003 = created vdb: {0}
+MSG.008.005.0004 = Can not find schema "{0}"
+MSG.008.005.0005 = WrappedCache successfully initialized.
+
+# runtime.spi (006)
+MSG.008.006.0001 = Deleted DaLogManager.logTracetaType with DBID {0}
+MSG.008.006.0002 = There is only one system virtual database, or the other one is
incomplete. Nothing is done.
+MSG.008.006.0003 = Unable to resolve parent datatype for {0}
+MSG.008.006.0004 = Getting VDB: {0} with version: {1} and uid: {2}
+MSG.008.006.0005 = Got VDB ID: {0} with version: {1} and uid: {2}
+MSG.008.006.0006 = No VDB ID could be found for {0}
+
+# runtime.util (007)
+
+# ================== METADATA SEARCHBASE MESSAGES ==================
+# searchbase (008)
+MSG.008.008.0001 = Unable to add Command due to missing target ({0}) {1}
+MSG.008.008.0002 = Adding Connection Pool for target : {0}
+MSG.008.008.0003 = SearchbaseManager : Begin Lazy Init for Public SB Targets
+MSG.008.008.0004 = Config External SearchBase {0}
+MSG.008.008.0005 = Config External SearchBase {0} is a valid target and already defined
+MSG.008.008.0006 = SearchbaseManager created connection pool for target : {0}
+MSG.008.008.0007 = SearchbaseManager getConnection for target {0}
+MSG.008.008.0008 = SearchbaseManager : Invalid Connection Property. NULL value for {0}
+
+# searchbase.api (009)
+
+# searchbase.apiimpl (010)
+
+# searchbase.command (011)
+
+# searchbase.exception (012)
+
+# searchbase.jdbc (013)
+
+# searchbase.processor (014)
+
+# searchbase.tool (015)
+
+# searchbase.transform (016)
+
+# searchbase.transform.xml (017)
+
+# searchbase.util (018)
+
+# searchbase.xmi (019)
+
+# ================== METADATA SERVER MESSAGES ==================
+# server.api (020)
+# server.api.dtc (021)
+# server.api.event (022)
+# server.api.exception (023)
+# server.apiimpl (024)
+MSG.008.024.0001 = Searchbase found no public targets.
+MSG.008.024.0002 = GetResponses from response message: \n {0}
+MSG.008.024.0003 = GetResponse from response message: \n {0}
+
+# server.apiimpl.dtc (025)
+# server.directory.api.exception (026)
+# server.directory.api.service (027)
+MSG.008.027.0001 = RMI Error in DirectoryServiceProxy.
+
+# server.directory.dtc (028)
+MSG.008.028.0001 = Inserting DTC In Progress for UUID {0} and name {1}
+MSG.008.028.0002 = DTC Validation Project {0} uuid: {1}
+MSG.008.028.0003 = Starting DTC Validation
+MSG.008.028.0004 = ***** Validation succeeded
+MSG.008.028.0005 = ***** Validation failed
+MSG.008.028.0006 = Model Count to be Validated
+MSG.008.028.0007 = \tNumber of primary models: {0}
+MSG.008.028.0008 = \tNumber of secondary models: {0}
+MSG.008.028.0009 = \t --------
+MSG.008.028.0010 = \tTotal Number of Models: {0}\n
+MSG.008.028.0011 = Models are valid and will be auto deployed.
+MSG.008.028.0012 = Models are VALID, but WILL NOT be auto deployed.
+MSG.008.028.0013 = Models are INVALID and will not be deployed.
+MSG.008.028.0014 = Found {0} models requested in DTC for validation.
+MSG.008.028.0015 = DTC Validation found {0} models to make up the DTC.
+MSG.008.028.0016 = Completed Validating DTC and is DTC valid:
+MSG.008.028.0017 = Exception during validation
+MSG.008.028.0018 = Validating model {0}
+
+# server.directory.service (029)
+# MSG.008.029.0001 = Initialized directory service for {0}
+# MSG.008.029.0002 = Resource property "{0}" for Resource Name "{1}"
is null.
+# MSG.008.029.0003 = {0} : closing
+# MSG.008.029.0004 = {0} : closed
+# MSG.008.029.0005 = Submitting message request {0}
+# MSG.008.029.0006 = Unable to add physical model(s) because maximum in license would be
exceeded
+# MSG.008.029.0007 = Filtering {0} access by {1} to: {2}
+# MSG.008.029.0008 = Allowed {0} access by {1} to entries: {2}
+# MSG.008.029.0009 = Dissalowed {0} access by {1} to entries: {2}
+# MSG.008.029.0010 = UUID: {0} Path: {1} Requested Actions: {2}
+# MSG.008.029.0011 = assembleFullPath for entryInfo: {0}
+# MSG.008.029.0012 = assembleFullPath for: {0} : {1}
+# MSG.008.029.0013 = checkAuthAdd: Searching: {0} - {1}
+# MSG.008.029.0014 = checkAuthAdd: FOUND: {0} - {1}
+
+
+# server.resource (032)
+MSG.008.032.0001 = Unable to initialize DirectoryResourceResolverEnvironment:
Couldn''t get proxy for Directory service. Will attempt again on demand.
+MSG.008.032.0002 = Error registering MetaBaseResourceResolver for Directory service
events. Will attempt again on demand.
+MSG.008.032.0003 = Unable to get the children of "{0}" from Directory service:
Couldn''t get proxy. Will attempt again on demand.
+MSG.008.032.0004 = Unable to get the children of <root> from Directory service:
Couldn''t get proxy. Will attempt again on demand.
+MSG.008.032.0005 = Unable to get the parent info for "{0}" from Directory
service: Couldn''t submit request. Will attempt again on demand.
+MSG.008.032.0006 = Unable to get the parent info for <root> from Directory service:
Couldn''t submit request. Will attempt again on demand.
+MSG.008.032.0007 = Got back null for parent of uuid: {0}
+MSG.008.032.0008 = Got back same uuid: {0} for parent of uuid: {1}
+MSG.008.032.0009 = Unable to get the children info for "{0}" from Directory
service: Couldn''t submit request. Will attempt again on demand.
+MSG.008.032.0010 = Unable to get the children info for <root> from Directory
service: Couldn''t submit request. Will attempt again on demand.
+MSG.008.032.0011 = Unable to get the path for "{0}" from Directory service:
Couldn''t get proxy. Will attempt again on demand.
+MSG.008.032.0012 = Unable to get the path for <root> from Directory service:
Couldn''t get proxy. Will attempt again on demand.
+
+
+UpdateController.VDB_File_already_exist_in_extension_modules_25=VDB File {0} already
exist in extension modules
+UpdateController.VDB_File_does_not_exist_in_extension_modules_1=VDB File {0} does not
exist in extension modules
+
+#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# Note: All new messages should have been looked up before being logged! DON'T use
I18nLogManager!
+#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+VDBDefinition.Model_is_at_a_nondeployable_severity_state=Model {0} is at a nondeployable
severity state of {1}
+VDBDefinition.Problem_closing_context_editor=Problem closing VDB context editor when
processing vdb {0}
+
+MetadataCache.Model_is_at_a_nondeployable_severity_state=Model {0} is at a nondeployable
severity state of {1}
+MetadataCache.VDB_is_at_a_nondeployable_severity_state=VDB {0} is at a nondeployable
severity state of {1}
+
+RuntimeMetadataCatalog.Error_adding_listener=Unable to add listener for runtimemetadata
events
+RuntimeMetadataCatalog.No_connector_binding_found=Connector Binding with routing ID {0}
was not found in the configuration.
+RuntimeMetadataCatalog.System_cache_initialized=System vdb cache is initialized.
+RuntimeMetadataCatalog.VDB_cache_initialized=VDB cache is initialized for {0}.
+
+VDBDefXMLHelper.Unexpected_header_element=The element {0} is not the header element.
+
+
+VDBDefnFactory.VDBDefn_file_doesnt_exist= VDBDefn file {0} does not exist.
+VDBDefnFactory.VDBDefn_file_not_readable=VDBDefn file {0} can not be read.
+VDBDefnFactory.Unable_to_read_file=Unable to read the Document from file {0}
inputStream.
+VDBDefnFactory.VDB_version_not_found=VDB: {0}, version: {1} was not found.
+VDBDefnFactory.Load_vdb_models=Loading Models for VDB {0}
+VDBDefnFactory.No_connector_binding_found=Error Exporting: Connector binding {0} not
found.
+VDBDefnFactory.Unable_to_defn_file=Unable to read the VDB Definition file.
+VDBDefnFactory.Model_not_found=The model ''{0}'' was not found in the
selected VDB. You must use ''New VDB Version...'' to interactively deploy
a new version.
+
+VDBDeleteUtility.1=VDB {0} has been deleted.
+VDBDeleteUtility.2=Authorization polices have been deleted for VDB name= {0} and version=
{1}.
+
+
+VDBDefnImportExport.Invalid_properties=Properties must not be null.
+VDBDefnImportExport.Invalid_property={0} property must be specified to export a VDB.
+
+VDBDefnImportExport.0=The # of VMs are {0} and they are: {1}
+VDBDefnImportExport.1=No VMs specified for binding deployment
+VDBDefnImportExport.2=Error: VDB {0} was imported, but unable to migrate entitlements due
to no MetaMatrix server is running.
+VDBDefnImportExport.Exporting_vdb_version=Exporting VDB {0} Version {1}
+VDBDefnImportExport.Exporting_vdb=Exporting VDB {0} Version Not Specified
+VDBDefnImportExport.3= Error migrating entitlements.
+
+VDBCreation.0=VM {0} is not deployed and will not have the connector deployed to it.
+VDBCreation.2=Deploy existing binding {0} to VM {1} for PSC {2}
+VDBCreation.3=Deploy created binding {0} to VM {1} for PSC {2}
+VDBCreation.4=No VM deployed and therefore no bindngs can be deployed
+VDBCreation.5=Deploying binding {0} to VM {1} in list
+VDBCreation.7=ConnectorBinding {0} will be updated.
+VDBCreation.11=Creating PSC {0} to deploy binding {1}
+VDBDefnImport.Failed_license_check=Failed to add source. You have reached the limit of
sources per VDB defined in your MetaMatrix license. Number of sources in VDB: {0}.
+
+VDBCreation.Invalid_VDB_name=VDB Name must be specified.
+VDBCreation.Does_connectorbinding_exist=Does ConnectorBinding ''{0}''
exist?
+VDBCreation.Connectorbinding_exist=ConnectorBinding ''{0}'' already
exist.
+VDBCreation.Connectorbinding_will_be_added=ConnectorBinding ''{0}'' will
be added.
+VDBCreation.Invalid_VDB_model=The VDBModel definition must not be null.
+VDBCreation.Invalid_VDB_defintion=The VDB definition must not be null.
+VDBCreation.No_name_defined=No {0} is defined in properties.
+VDBCreation.No_model_found_in_VDB=Model {0} NOT found in the VDB inputstream.
+VDBCreation.Error_importing_vdbfile= Error importing vdb file {0}
+VDBCreation.Error_deploying_binding=Error deploying connectorbinding {0}, it was not
deployed after deploying the psc {1}
+VDBCreation.Connectorbinding_created=ConnectorBinding ''{0}'' was
created.
+VDBCreation.Warning_binding_does_not_exist=<** Warning **> ConnectorBinding {0}
does not exist in the configuration and may not have been created.
+VDBCreation.No_type_passed_and_bindingtype_not_found=There was no connector type passed
for binding {0} and the referenced type {1} was not found.
+
+RuntimeMetadataAdminAPIImpl.Can_t_delete_VDB_in_state_{0}=Can''t delete a VDB
that''s in state:
+RuntimeMetadataAdminAPIImpl.Unable_to_set_connector_bindings.=Unable to set connector
bindings.
+RuntimeMetadataAdminAPIImpl.Can__t_set_VDB_state_from_{0}_to_{1}=Can''t set VDB
state from: {0} to: {1}
+RuntimeMetadataAdminAPIImpl.The_resource_for_this_permission_does_not_exist_in_the_target_VDB.=The
resource for this permission does not exist in the target VDB.
+RuntimeMetadataAdminAPIImpl.Migrated=Migrated
+RuntimeMetadataAdminAPIImpl.VDB_null=VDB may not be null.
+RuntimeMetadataAdminAPIImpl.This_resource_exists_in_the_target_VDB_but_not_in_the_source_VDB.=This
resource exists in the target VDB but not in the source VDB.
+RuntimeMetadataAdminAPIImpl.Error_getting_VDBDefn_for_{0}=Error getting VDBDefn for {0}
+RuntimeMetadataAdminAPIImpl.materializationUserName_null=materializationUserName may not
be null or empty.
+RuntimeMetadataAdminAPIImpl.VDB_has_no_materialziation=Unable to create materialization
scripts. VDB has no materialization model.
+RuntimeMetadataAdminAPIImpl.materializationUserPwd_null=materializationUserPwd may not be
null or empty.
+RuntimeMetadataAdminAPIImpl.Expected_integer_for_port {0}=Expected integer for port in
serverVMs argument, got {0}.
+RuntimeMetadataAdminAPIImpl.metamatrixUserName_null=metamatrixUserName may not be null or
empty.
+RuntimeMetadataAdminAPIImpl.DirectoryService_is_not_available=DirectoryService is not
available, unable to ping.
+RuntimeMetadataAdminAPIImpl.Failed_migration=Failed
+RuntimeMetadataAdminAPIImpl.Succeeded_migration=Succeeded
+RuntimeMetadataAdminAPIImpl.metamatrixPwd_null=metamatrixPwd may not be null or empty.
+RuntimeMetadataAdminAPIImpl.Connector_has_no_URL=Unable to create materializatin scripts.
Connector has no URL property.
+RuntimeMetadataAdminAPIImpl.MetaMatrix_host_null=The MetaMatrix host name may not be
null.
+RuntimeMetadataAdminAPIImpl.Unable_to_encrypt_pwd=Unable to encrypt connection property
passwords for VDB {0}
+RuntimeMetadataAdminAPIImpl.Migrated_entitlement_policy_with_no_permissions=Migrated
entitlement policy with no permissions on any resources.
+RuntimeMetadataAdminAPIImpl.Error_creating_DirectoryServiceProxy:_{0}=Failed to create
Directory Service for Session id =\"{0}\"
+RuntimeMetadataAdminAPIImpl.Unable_to_determine_ssl_mode=Error trying to determine ssl
mode for server.
+
+# runtime metadata admin helper
+ERR.018.001.0003 = Cannot get VDB Definition from MetadataDirectory.
+ERR.018.001.0004 = Error retrieving policies for Realm <{0}>: {1}.
+ERR.018.001.0005 = Error getting permission iterator from sourcePolicy.
+ERR.018.001.0006 = Error migrating entitlements.
+ERR.018.001.0008 = Error importing VDB Definition {0}.
+ERR.018.001.0010 = Error obtaining all VDB Definitions to build directory tree.
+ERR.018.001.0013 = Error submitting request.
+ERR.018.001.0051 = Cannot get VDB metadata for VDB ID <{0}>
+ERR.018.001.0052 = Cannot get all data node paths for VDB ID <{0}>
+ERR.018.001.0053 = Cannot get Models for VDB ID <{0}>
+ERR.018.001.0054 = Cannot get VDB ID for VDB name <{0}> and version <{1}>
+ERR.018.001.0055 = An error occured in the Authorization service.
+ERR.018.001.0063 = Unable to convert uuid string to object: <{0}>
+
+TransformationMetadata.Unknown_support_constant___12=Unknown support constant:
+TransformationMetadata.error_intialize_selector=Error trying to initialize the index
selector.
+TransformationMetadata.Error_trying_to_obtain_index_file_using_IndexSelector_1=Error
trying to obtain index file using IndexSelector {0}
+TransformationMetadata.Model_name_ambiguous,more_than_one_model_exist_with_the_name__2=Model
name ambiguous, more than one model exists with the name
+TransformationMetadata.The_metadataID_passed_does_not_match_a_index_record._1=The
metadataID passed does not match an index record
+TransformationMetadata.Expected_id_of_the_type_key_record_as_the_argument_2=Expected ID
of the type key record as the argument
+TransformationMetadata.Expected_id_of_the_type_accesspattern_record_as_the_argument_3=Expected
ID of the type accesspattern record as the argument
+TransformationMetadata.No_known_index_file_type_associated_with_the_recordType_1=No known
index file type associated with the recordType
+InputSetUmlAspect.Invalid_show_mask_for_getSignature=Invalid show mask for getSignature
+InputSetUmlAspect.Signature_set=Signature set to
+InputParameterUmlAspect.Invalid_show_mask_for_getSignature=Invalid show mask for
getSignature
+InputParameterUmlAspect.Signature_set=Signature set to
+MappingClassUmlAspect.Invalid_show_mask_for_getSignature=Invalid show mask for
getSignature
+MappingClassUmlAspect.Signature_set=Signature set to
+MappingClassColumnUmlAspect.Invalid_show_mask_for_getSignature=Invalid show mask for
getSignature
+MappingClassTransformationRule.Non-Query_NonUnion_transformation=The transformation
defining a mapping class ''{0}'' can only be of type QUERY, UNION,
INTERSECT or EXCEPT
+MappingClassTransformationRule.No_INPUT_Parameters_In_Criteria=Query defining the mapping
class {0} does not use INPUT parameters in its criteria.
+
+MappingClassTransformationRule.Mapping_Class_Is_Null_For_{0}_0=Recursion root mapping
class not found for {0} class
+MappingClassTransformationRule.Mismatch_Number_Of_Column_{0}_AND_{1}_1=Mismatch number of
columns between mapping class {0} and {1}
+MappingClassTransformationRule.Mismatch_Number_Column_Name_{0}_AND_{1}_2=Mismatch column
name between mapping class {0} and {1}
+MappingClassTransformationRule.Mismatch_Column_Type_{0}_AND_{1}_3=Column type mismatch
between recursion root mapping class {0} and recursion child mapping class {1}
+
+MappingClassColumnUmlAspect.Signature_set=Signature set to
+TransformationMappingValidationRule.Sql_transformation_in_the_model__1=Sql transformation
in the model
+TransformationMappingValidationRule._does_not_have_targets_mapped_for_source_element/s__2=\
does not have targets mapped for source element/s
+TransformationMappingValidationRule.Sql_transformation_in_the_model__3=Sql transformation
in the model
+TransformationMappingValidationRule._does_not_have_target_elements._4=\ does not have
target elements.
+TransformationMappingValidationRule.Sql_transformation_in_the_model__5=Sql transformation
in the model
+TransformationMappingValidationRule._cannot_have_multiple_targets_mapped_for_source_element/s__6=\
cannot have multiple targets mapped for source element/s
+TransformationMappingValidationRule.Sql_transformation_in_the_model__7=Sql transformation
in the model
+TransformationMappingValidationRule._cannot_have_multiple_target_elements._8=\ cannot
have multiple target elements.
+TransformationMetadata.GroupID_ambiguous_there_are_multiple_virtual_plans_available_for_this_groupID__1=GroupID
ambiguous, there are multiple virtual plans available for this groupID
+TransformationMetadata.GroupID_ambiguous_there_are_multiple_insert_plans_available_for_this_groupID__2=GroupID
ambiguous, there are multiple insert plans available for this groupID
+TransformationMetadata.GroupID_ambiguous_there_are_multiple_update_plans_available_for_this_groupID__3=GroupID
ambiguous, there are multiple update plans available for this groupID
+TransformationMetadata.GroupID_ambiguous_there_are_multiple_delete_plans_available_for_this_groupID__4=GroupID
ambiguous, there are multiple delete plans available for this groupID
+MappingClassSetSqlAspect.MappingClasses_sql_name=MappingClasses
+TransformationMetadata.Failed_to_create_index_files_for_non-indexed_model_resources__1=Failed
to create index files for non-indexed model resources :
+TransformationMetadata.Procedure_ambiguous_there_are_multiple_procedure_plans_available_for_this_name___4=Procedure
ambiguous, there are multiple procedure plans available for this name:
+SqlTransformationMappingRootValidationRule.Join_type_mismatch_in_crit=Implicit runtime
type conversion in join criteria ''{0}'': left type is
''{1}'', right type is ''{2}''.
+TransformationPlugin.noFunctionDefinitionFileMessage=Unable to find the Function
Definition file at {0}
+
+#-----------------TransformationHelper-----------------
+TransformationHelper.changeSelectSqlTxnDescription=Change SQL SELECT for transformation
{0}
+TransformationHelper.changeInsertSqlTxnDescription=Change SQL INSERT for transformation
{0}
+TransformationHelper.changeUpdateSqlTxnDescription=Change SQL UPDATE for transformation
{0}
+TransformationHelper.changeDeleteSqlTxnDescription=Change SQL DELETE for transformation
{0}
+TransformationHelper.removeTargetAttributesError=Error Removing attribute from Target
{0}
+
+TransformationHelper.addSrcTxnDescription=Add transformation source for transformation
{0}
+TransformationHelper.addSrcAliasTxnDescription=Add transformation source alias for source
{0}
+TransformationHelper.removeSrcTxnDescription=Remove transformation source for
transformation {0}
+TransformationHelper.removeSrcAliasTxnDescription=Remove transformation source alias for
source {0}
+
+TransformationHelper.getTransformationError=Error getting Transformation for target
virtual group {0}
+TransformationHelper.createTransformationError=Error creating Transformation for target
virtual group {0}
+TransformationHelper.addTransSourceError=Error adding Transformation Source for
transformation mapping root {0}
+TransformationHelper.removeTransSourceError=Error removing Transformation Source for
transformation mapping root {0}
+TransformationHelper.addTransSourceAliasError=Error adding Transformation Source Alias
for transformation mapping root {0}
+TransformationHelper.removeTransSourceAliasError=Error removing Transformation Source
Alias for transformation mapping root {0}
+TransformationHelper.sqlColumnRenameError=Error renaming SqlColumn {0}
+TransformationHelper.createProcResultSetError=Error creating ResultSet for Procedure {0}
+TransformationHelper.getProcResultSetDescriptorError=Error getting ResultSet Descriptor
for Procedure {0}
+TreeMappingRootSqlAspect.could_not_get_resource_for_xmldoc=Could not get resource for
{0}
+
+#-----------------TransformationMappingHelper-----------------
+TransformationMappingHelper.addAttributesTransactionDescription=Add attributes to Target
{0}
+TransformationMappingHelper.addAttributesBeginTransactionError=Error starting transaction
to Add attributes to Target {0}
+TransformationMappingHelper.addAttributesCommitTransactionError=Error committing
transaction to Add attributes to Target {0}
+TransformationMappingHelper.reconcileMappingsTransactionDescription=Reconcile mappings
for Target {0}
+TransformationMappingHelper.reconcileMappingsBeginTransactionError=Error starting
transaction to Reconcile mappings for Target {0}
+TransformationMappingHelper.reconcileMappingsCommitTransactionError=Error committing
transaction to Reconcile mappings for Target {0}
+TransformationMappingHelper.createNewAttrError=Error creating new attribute for group
{0}
+TransformationMappingHelper.moveTargetAttrError=Error moving attribute for group {0}
+TransformationMappingHelper.containerNotFoundError=Error getting Container from
ModelerCore
+TransformationMappingHelper.getChildDescriptorError=Error getting Child descriptors for
{0}
+TransformationMappingHelper.errorCreatingAttribute=Error creating new attribute with name
{0}
+TransformationMappingHelper.errorDeletingAttribute=Error deleting attribute {0}
+TransformationMappingHelper.errorDeletingAttributes=Error deleting attribute(s)
+
+#-----------------AttributeMappingHelper-----------------
+AttributeMappingHelper.removeAttrMappingError=Error removing attribute mapping {0}
+
+#-----------------TransformationSqlHelper-----------------
+TransformationSqlHelper.elementIDNotFoundError=Error finding the element ID for {0}
+TransformationSqlHelper.groupIDNotFoundError=Error finding the group ID for {0}
+
+#-----------------TransformationValidator-----------------
+TransformationValidator.getProcExternalMetadataError=Error getting External Metadata Map
for target virtual group {0}
+TransformationValidator.errorTargetIsSourceMsg= Error: Invalid source table -
{0}.\nReason: Target cannot be a source to itself.
+TransformationValidator.QMI_of_unexpected_type=Expected the QueryMetadataInterface
instance to be of type TransformationMetadataFacade or VdbMetadata
+
+TransformationMetadata.Could_not_find_query_plan_for_the_group__5=Could not find query
plan for the group
+TransformationMetadata.QueryPlan_could_not_be_found_for_physical_group__6=QueryPlan could
not be found for physical group
+TransformationMetadata.InsertPlan_could_not_be_found_for_physical_group__8=InsertPlan
could not be found for physical group
+TransformationMetadata.InsertPlan_could_not_be_found_for_physical_group__10=InsertPlan
could not be found for physical group
+TransformationMetadata.DeletePlan_could_not_be_found_for_physical_group__12=DeletePlan
could not be found for physical group
+TransformationMappingValidationRule.Sql_transformation_in_the_model_contains_the_unresolved_reference_1=Sql
transformation in the model {0} contains the unresolved reference {1}
+TransformationValidator.Error_in_the_Sql_tranformation_for_1=No Sql Transformation
defined for {0}
+SqlTransformationMappingRootValidationRule.Virtual_stored_procedures_should_always_return_a_resultSet._1=Virtual
stored procedures should always return a ResultSet.
+SqlTransformationMappingRootValidationRule.A_virtual_stored_procedure_can_only_define_IN_parameters._2=A
virtual stored procedure can only define IN parameters.
+SqlTransformationMappingRootValidationRule.Virtual_stored_procedures_transformation_definition_cannot_be_an_updateProcedure._3=The
transformation for a virtual stored procedures cannot be an update procedure.
+SqlTransformationMappingRootValidationRule.Virtual_stored_procedures_defined_by_an_Insert,_Update_or_Delete_statement_must_define_return_a_resultSet_with_one_column_of_type_int._4=Virtual
stored procedures defined by an Insert, Update or Delete statement must define return a
resultSet with one column of type int.
+TransformationHelper.Error_adding_model_import_to_{0}_1=Error adding model import to {0}
+TransformationHelper.Error_removing_Model_Import_from_{0}_1=Error removing Model Import
from {0}
+TransformationMetadata.Could_not_find_transformation_record_for_the_group__1=Could not
find transformation record for the group
+XmlDocumentValidationRule.Error_trying_to_collect_XmlElements_in_an_XmlDocument__1=Error
trying to collect XmlElements in an XmlDocument
+XmlDocumentValidationRule.Error_trying_to_collect_XmlElements_in_an_XmlDocument__2=Error
trying to collect XmlElements in an XmlDocument
+XmlDocumentValidationRule.The_option_of_a_Choice_must_either_have_the_criteria_defined,_or_be_the_default._3=The
option of a Choice must either have the criteria defined or be the default.
+XmlDocumentValidationRule.Error_trying_validate_choice_criteria__14=Error trying validate
choice criteria
+XmlDocumentValidationRule.Recursion_not_allowed_on_compositor=Mapping classes bound to an
xml element of type sequence, choice, or all cannot be marked for recursion
+XmlDocumentValidationRule.__15=\
+XmlDocumentValidationRule.0=The group ''{0}'' referenced in the choice
criteria on the ''{1}'' is not among the mapping classes in the context of
the choice.
+XmlDocumentValidationRule.Column_and_element_types_possibly_not_compatible=The mapping
column ''{0}'' of type ''{1}'' and the document element
''{2}'' of type ''{3}'' are potentially incompatible.
+XmlDocumentValidationRule.Column_and_element_types_not_compatible=The mapping column
''{0}'' of type ''{1}'' and the document element
''{2}'' of type ''{3}'' are not compatible.
+TransformationMetadata.Error_trying_to_read_schemas_for_the_document/table____1=Error
trying to read schemas for the document/table :
+SqlTransformationMappingRootValidationRule.Translate/Has_Criteria_on_an_insert_procedure_would_always_evaluate_to_false._3=Translate/Has
Criteria on an insert procedure would always evaluate to false.
+TransformationValidator.The_transformation_contains_Reference_Symbols_(_),_which_is_not_allowed,_replace___with_a_constant,_element,_or_parameter_name._1=The
transformation contains Reference Symbols (?), which is not allowed. Replace ? with a
constant, element, or parameter name.
+SqlTransformationMappingRootValidationRule.Sql_Transform_defining_the_virtual_procedure_{0}_does_not_use_any_of_the_parameters_defined_on_the_procedure._1=The
SQL defining the virtual procedure {0} does not use any of the parameters defined on the
procedure.
+TransformationMetadata.Multiple_transformation_records_found_for_the_group___1=Multiple
transformation records found for the group:
+InputParameterSqlAspect.Length_cannot_be_set_on_an_InputParameter_1=Length cannot be set
on an InputParameter
+InputParameterSqlAspect.NullType_cannot_be_set_on_an_InputParameter_2=NullType cannot be
set on an InputParameter
+MappingClassColumnSqlAspect.Length_cannot_be_set_on_a_MappingClassColumn_1=Length cannot
be set on a MappingClassColumn
+MappingClassColumnSqlAspect.NullType_cannot_be_set_on_a_MappingClassColumn_2=NullType
cannot be set on a MappingClassColumn
+TransformationValidator.Only_update_procedures_are_allowed_in_the_INSERT/UPDATE/DELETE_tabs._1=Only
update procedures are allowed in the Insert/Update/Delete tabs.
+TransformationValidator.Query_defining_a_virtual_group_can_only_be_of_type_Select_or_Exec._1=The
query defining a virtual group can only be of type Select or Exec.
+TransformationValidator.Query_defining_a_virtual_procedure_can_only_be_of_type_Virtual_procedure._2=The
query defining a virtual procedure can only be of type Virtual procedure.
+TransformationValidator.Query_defining_an_operation_can_only_be_of_type_Virtual_procedure._1=The
query defining an operation can only be of type Virtual procedure.
+SqlTransformationMappingRootValidationRule.The_transformation_on_the_updatable_virtual_group_{0},_allows_Insert/Update/Delete_but_does_not_define_the_necessary_transformation._1=The
transformation on the updatable virtual group {0} allows Insert/Update/Delete but does not
define the necessary transformation(s).
+XmlDocumentValidationRule.This_entity_{0}_is_fixed_or_default_and_should_not_have_a_mapping_attribute_defined_in_MappingClasses_1="{0}"
has a fixed or default value and should not be mapped.
+XmlDocumentValidationRule.The_entity_{0}_has_been_selected_to_be_excluded_from_the_Document,_but_has_a_mapping_attribute_defined_in_MappingClasses_2="{0}"
is excluded from the Document, but is still mapped.
+XmlDocumentValidationRule.The_entity_{0}_has_a_min_occurs_of_zero,_but_has_a_mapping_attribute_defined_in_MappingClasses_3="{0}"
references an XML Schema component that has a min occurs of zero, and may not appear in a
result document.
+XmlDocumentValidationRule.The_element_{0}_has_a_max_occurs_of_one,_but_is_mapped_to_a_MappingClass="{0}"
references an XML Schema component that has a max occurs of one, but may occur more than
once in a result document.
+XmlDocumentValidationRule.The_entity_{0}__s_schema_component_reference_is_nullable,_but_has_a_mapping_attribute_defined_in_MappingClasses._5="{0}"
references an XML Schema component that is nullable and is mapped.
+XmlDocumentValidationRule.The_entity_{0}_having_element/attribute_children_may_not_have_a_mapping_attribute_defined_in_MappingClasses._6="{0}"
has element/attribute children that may not be mapped with a MappingClass.
+XmlDocumentValidationRule.The_attribute_{0}_references_a_prohibited_schema_attribute._7=The
attribute "{0}" references a prohibited schema attribute.
+XmlDocumentValidationRule.The_entity_{0}_has_been_selected_to_be_excluded_from_the_Document,_but_the_neither_the_entity_nor_its_parent_are_optional._9="{0}"
is excluded from the Document, but the neither the entity nor its parent are optional.
+XmlDocumentValidationRule.The_document_element/attribute_{0}_doesn__t_reference_a_schema_component._10="{0}"
does not reference a schema component.
+XmlDocumentValidationRule.The_entity_{0},_may_be_violating_maxOccurs_specified_by_the_schema._1="{0}"
may cause a result document to violate the referenced XML Schema component's
maxOccurs.
+SqlTransformationMappingRootValidationRule.Sql_transformation_in_the_model_{0},_has_no_target_tables/groups._1=The
SQL transformation (in model {0}) has no target tables/groups.
+SqlTransformationMappingRootValidationRule.there_are_source_parameters_that_are_not_mapped_to_a_virtual_column=There
are {0} in/in-out parameters from source procedures that are not mapped to a virtual group
attribute
+SqlTransformationMappingRootValidationRule.Sql_transformation_in_the_model_{0},_cannot_not_have_multiple_target_tables/groups._2=The
SQL transformation (in model {0}) cannot not have multiple target tables/groups.
+SqlTransformationMappingRootValidationRule.The_transformation_defining_an_updatable_virtual_group_should_be_include_atleast_one_updatable_source_group._1=The
transformation defining an updatable virtual group should include at least one updatable
source.
+SqlTransformationMappingRootValidationRule.The_number_of_columns/elements_in_{0}_are_less_than_the_number_defined_in_the_sql_transformation._1=The
number of columns/elements in {0} are less than the number defined in the SQL
transformation.
+SqlTransformationMappingRootValidationRule.The_number_of_columns/elements_in_{0}_are_greater_than_the_number_defined_in_the_sql_transformation._2=The
number of columns/elements in {0} are greater than the number defined in the SQL
transformation.
+SqlTransformationMappingRootValidationRule.The_target_attribute_matches_no_symbol_in_the_query_{0}._1=The
target attribute {0} does not match the corresponding symbol name in the query.
+SqlTransformationMappingRootValidationRule.parameter_in_procedure_is_not_mapped_to_a_virtual_column=The
IN/IN_OUT parameter {0} in procedure {1} is not mapped to a column in {2}
+SqlTransformationMappingRootValidationRule.InputParam_In_Mapping_Class_Transform=INPUT
parameters cannot be used in the SELECT clause of the transformation defining the mapping
class ''{0}''
+SqlTransformationMappingRootValidationRule.invalid_source_for_target=''{0}''
is not a valid transformation source for ''{1}''.
+SqlTransformationMappingRootValidationRule.invalid_target_for_source=''{0}''
is not a valid transformation target for ''{1}''.
+SqlTransformationMappingRootSqlAspect.EObject_has_not_resourceset_reference=The EObject
{0} has no resource set reference
+SqlTransformationMappingRootValidationRule.The_datatype_type_of_the_column_{0}_does_not_match_the_source_column_type._1=The
column ''{0}'' with runtime type ''{1}'' does not match
the runtime type ''{2}'' from the query transformation.
+SqlTransformationMappingRootValidationRule.The_datatype_type_of_the_column_{0}_is_not_set_or_cannot_be_resolved_in_the_workspace._1=The
datatype type of the column ''{0}'' is not set or cannot be resolved in
the workspace.
+SqlTransformationMappingRootValidationRule.all_virtual_group_attributes_for_parameters_must_be_in_an_access_pattern=All
virtual group attributes mapped to source procedure input parameters must be specified in
a single virtual access pattern
+SqlTransformationMappingRootValidationRule.The_Nullable_value_of_virtual_group_attribute_{0}_doesn____t_match_that_of_the_attribute_it_mapps_to_in_query_transform._1=The
Nullable value of virtual group attribute {0} doesn\'\'t match that of the
attribute it maps to in the SQL query transform.
+SqlTransformationMappingRootValidationRule.The_insert_procedure_for_the_virtualGroup_{0}_does____not_execute_an_insert._1=The
insert procedure for the virtualGroup {0} does not execute an insert.
+SqlTransformationMappingRootValidationRule.The_update_procedure_for_the_virtualGroup_{0}_does____not_execute_an_update._2=The
update procedure for the virtualGroup {0} does not execute an update.
+SqlTransformationMappingRootValidationRule.The_delete_procedure_for_the_virtualGroup_{0}_does____not_execute_an_delete._3=The
delete procedure for the virtualGroup {0} does not execute a delete.
+SqlTransformationMappingRootValidationRule.The_virtual_group_{0}_cannot_be_involved_as_an_input_to_the_transformation_defining_it._1=The
virtual group {0} cannot use itself as a source.
+SqlTransformationMappingRootValidationRule.The_insert_procedure_for_the_virtualGroup_{0},_is_trying_to_execute_an_insert_against_itself._1=The
insert procedure for {0} is trying to execute an insert against itself.
+SqlTransformationMappingRootValidationRule.The_update_procedure_for_the_virtualGroup_{0},_is_trying_to_execute_an_update_against_itself._2=The
update procedure for {0} is trying to execute an update against itself.
+SqlTransformationMappingRootValidationRule.The_delete_procedure_for_the_virtualGroup_{0},_is_trying_to_execute_an_delete_against_itself._3=The
delete procedure for {0} is trying to execute an delete against itself.
+InputParameterValidationRule.The_inputParameter_{0}_on_the_inputSet_of_the_MappingClass_{1}_is_not_bound_to_any_mappingClass_column._1=The
input parameter {0} in the input set of the MappingClass {1} is not bound to a mapping
class column.
+InputParameterValidationRule.Invalid_binding=The input parameter {0} in the input set of
the MappingClass {1} is bound to an invalid mapping class column.
+TransformationMetadata.Multiple_annotation_records_found_for_the_entity_{0}_1=Multiple
annotation records found for the entity {0}
+TransformationMetadata.No_metadata_info_available_for_the_index_with_UUID_{0}._1=No
metadata info available for the index with UUID {0}.
+TransformationMetadata.Ambigous_index_with_UUID_{0},_found_multiple_indexes_with_the_given_UUID._2=Ambigous
index with UUID {0}, found multiple indexes with the given UUID.
+TransformationValidator.Invalid_transformation_type,_only_allowed_transformations_are_select,_insert,_update,_delete_transforms._1=Invalid
transformation type, only allowed transformations are select, insert, update, delete
transforms.
+SqlTransformationMappingRootValidationRule.A_circular_dependency_exists_between_this_tranformation_and_the_source_group_0_1=A
circular dependency exists between this transformation and virtual group {0}
+ModelerMetadata.Resolving_entity_{0}_using_index_files_1=Resolving entity {0} using index
files
+ModelerMetadata.Resolving_entity_{0}_by_navigating_the_workspace_1=Resolving entity {0}
by navigating the workspace
+ModelerMetadata.Found_{0}_records_for_the_entity_{1}_1=Found {0} records for the entity
{1}
+TransformationMetadata.does_not_exist._1=does not exist.
+TransformationMetadata.0={0} ambiguous, more than one entity matching the same name
+TransformationMetadata.Group(0}_does_not_have_elements=Group ''{0}'' does
not have any elements.
+TransformationMetadata.Error_trying_to_read_virtual_document_{0},_with_body__n{1}_1=Error
trying to read virtual document {0}, with body \n{1}
+TransformationValidator.Found_problems_validating_transformation_defining_{0},_re-validate_in_the_transformation_editor._1=Found
problems validating transformation defining {0}, re-validate in the transformation
editor.
+SqlTransformationMappingRootValidationRule.0=Group name ''{0}'' used in
the OPTION MAKEDEP/MAKENOTDEP clause is not a fully qualified group, check if it is an
alias name.
+SqlTransformationMappingRootValidationRule.1=Cannot use Virtual Group
''{0}'' in the OPTION MAKEDEP/MAKENOTDEP clause.
+SqlTransformationMappingRootValidationRule.10=Transformation query has an empty OPTION
NOCACHE clause, no materialized virtual groups found among the groups in the FROM clause.
+SqlTransformationMappingRootValidationRule.2=Group name ''{0}'' used in
the OPTION MAKEDEP/MAKENOTDEP clause could not be found in any dependent transformations.
+SqlTransformationMappingRootValidationRule.3=Group name ''{0}'' used in
the OPTION NOCACHE clause is not a fully qualified group, check if it is an alias name.
+SqlTransformationMappingRootValidationRule.4=Cannot use Virtual Group
''{0}'' in the OPTION NOCACHE clause.
+SqlTransformationMappingRootValidationRule.5=Group name ''{0}'' used in
the OPTION NOCACHE clause could not be found in any dependent transformations.
+SqlTransformationMappingRootValidationRule.6=Possible cross-join: Group/s
''{0}'' are not joined either directly or transitively to other groups
through a join criteria. Check all queries in the transformation.
+SqlTransformationMappingRootValidationRule.7=Group name ''{0}'' in the
OPTION NOCACHE clause ambiguous, matches short name of more than one group in the FROM
clause of the query.
+SqlTransformationMappingRootValidationRule.8=Group name ''{0}'' in the
OPTION NOCACHE clause ambiguous, matches alias name of more than one group in the FROM
clause of the query.
+SqlTransformationMappingRootValidationRule.9=Group name ''{0}'' in the
OPTION NOCACHE clause does not match any materialized virtual group name or alias in the
FROM clause of the query.
+SqlTransformationMappingRootValidationRule.11=Group name ''{0}'' in the
OPTION NOCACHE clause ambiguous, matches partial name of more than one group in the FROM
clause of the query.
+SqlTransformationMappingRootValidationRule.no_valid_target=The sql transformation does
not have a valid target.
+SqlTransformationMappingRootValidationRule.no_valid_source=The sql transformation does
not have a valid source.
+SqlTransformationMappingRootValidationRule.xml_doc_mapped_at_root_for_web_service=The XML
document source may return multiple documents. That is not supported by web service per
the WS-I profile.
+SqlTransformationMappingRootSqlAspect.0=The transformation mapping root {0} does not have
a target table.
+SqlTransformationMappingRootSqlAspect.EObject_has_no_resource_reference=The EObject {0}
has no resource reference
+TreeMappingRootSqlAspect.0=The tree mapping root {0} does not have a target document.
+TransformationMetadata.Invalid_type=Invalid type: {0}.
+ServerRuntimeMetadata.invalid_selector=The metadata instace is using an invalid index
selector.
+MappingDocumentFormatter.Unable_to_determine_schema_in_the_workspace_for_XsdComponent_{0}_when_deriving_Namespace_Prefix_1=Unable
to determine schema in the workspace for XsdComponent {0} when deriving Namespace Prefix
+_UI_InputParameter_type = Input Parameter
+_UI_InputSet_type = Input Set
+_UI_MappingClass_type = Mapping Class
+_UI_MappingClassColumn_type = Mapping Class Column
+_UI_StagingTable_type = Staging Table
+TransformationMetadata.Unable_to_determine_fullname_for_element__1=Unable to determine
fullname for element
+ProcedureParameterValidationHelper.Additional_Assignment=View parameter
''{0}'' has more than 1 valid assignment: ''{1}''.
+ProcedureParameterValidationHelper.Required_view_parameter=Required view parameter
''{0}'' does not have a valid assignment.
+ProcedureParameterValidationHelper.Required_procedure_parameter=Required procedure
parameter ''{0}'' does not have a valid assignment.
+ProcedureParameterValidationHelper.Invalid_Assignment=Parameter ''{0}''
has an invalid assignment: ''{1}''.
+ProcedureParameterValidationHelper.Non-selectable_column=Non-selectable column
''{0}'' must have a Default Value, be set to Nullable, or set as Auto
Incremented.
+ProcedureParameterValidationHelper.No_default_for_mapping_class_parameter=The mapping
class column ''{0}'' is non-selectable, but does not have a default value.
A null value will be used if the column is used as a procedure parameter.
+SqlTransformationMappingRootValidationRule.STRING_BASED_FUNCTION_ONE_BASED =In 5.0 SP1,
the SUBSTRING, LOCATE, and INSERT functions changed from 0-based to 1-based to match the
JDBC and ODBC specifications. Please verify they are used correctly in the
transformation.
+XQueryTransformationMappingRootSqlAspect.0=The transformation mapping root {0} does not
have a target.
+
Property changes on: trunk/metadata/src/main/resources/org/teiid/metadata/i18n.properties
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/TestPropertyFileObjectSource.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/TestPropertyFileObjectSource.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/TestPropertyFileObjectSource.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,6 +25,9 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+
+import org.teiid.connector.metadata.PropertyFileObjectSource;
+
import junit.framework.TestCase;
import com.metamatrix.core.MetaMatrixRuntimeException;
Modified:
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestIndexCriteriaBuilder.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestIndexCriteriaBuilder.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestIndexCriteriaBuilder.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,13 +25,15 @@
import java.util.HashMap;
import java.util.Map;
+import org.teiid.connector.metadata.IndexCriteriaBuilder;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
import org.teiid.connector.metadata.runtime.PropertyRecordImpl;
+import org.teiid.metadata.index.IndexConstants;
import junit.framework.TestCase;
-import com.metamatrix.modeler.internal.core.index.IndexConstants;
/**
Modified:
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataConnectorMetadata.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataConnectorMetadata.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataConnectorMetadata.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -28,20 +28,23 @@
import java.util.HashMap;
import java.util.Map;
+import org.teiid.connector.metadata.FileRecordImpl;
+import org.teiid.connector.metadata.MetadataConnectorMetadata;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
+import org.teiid.connector.metadata.RuntimeVdbRecord;
+import org.teiid.connector.metadata.VdbMetadataContext;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.ModelRecordImpl;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.index.IndexConstants;
+import org.teiid.metadata.index.IndexMetadataStore;
import junit.framework.TestCase;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.connector.metadata.FileRecordImpl;
-import com.metamatrix.connector.metadata.RuntimeVdbRecord;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.service.metadata.CompositeMetadataStore;
import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.modeler.internal.core.index.IndexConstants;
-import com.metamatrix.modeler.internal.core.index.IndexMetadataStore;
/**
Modified:
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataResultsPostProcessor.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataResultsPostProcessor.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/index/TestMetadataResultsPostProcessor.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,6 +25,9 @@
import java.util.HashMap;
import java.util.Map;
+import org.teiid.connector.metadata.MetadataLiteralCriteria;
+import org.teiid.connector.metadata.MetadataResultsPostProcessor;
+import org.teiid.connector.metadata.VdbMetadataContext;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
import org.teiid.connector.metadata.runtime.ModelRecordImpl;
Modified: trunk/metadata/src/test/java/com/metamatrix/core/util/TestCharOperation.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/core/util/TestCharOperation.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/core/util/TestCharOperation.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,6 +22,8 @@
package com.metamatrix.core.util;
+import org.teiid.metadata.index.CharOperation;
+
import junit.framework.TestCase;
Modified:
trunk/metadata/src/test/java/com/metamatrix/internal/core/index/TestGammaCompressedIndexBlock.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/internal/core/index/TestGammaCompressedIndexBlock.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/internal/core/index/TestGammaCompressedIndexBlock.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,6 +22,11 @@
package com.metamatrix.internal.core.index;
+import org.teiid.internal.core.index.GammaCompressedIndexBlock;
+import org.teiid.internal.core.index.IIndexConstants;
+import org.teiid.internal.core.index.IndexBlock;
+import org.teiid.internal.core.index.WordEntry;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
Modified:
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -28,7 +28,14 @@
import java.util.Map;
import java.util.Properties;
+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.DatatypeRecordImpl;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.index.IndexMetadataStore;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationEnvironment;
@@ -36,18 +43,11 @@
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.connector.metadata.IndexFile;
-import com.metamatrix.connector.metadata.MetadataConnectorConstants;
-import com.metamatrix.connector.metadata.MultiObjectSource;
-import com.metamatrix.connector.metadata.PropertyFileObjectSource;
import com.metamatrix.connector.metadata.internal.IObjectSource;
import com.metamatrix.core.util.TempDirectoryMonitor;
import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.metadata.CompositeMetadataStore;
-import com.metamatrix.dqp.service.metadata.TransformationMetadata;
import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.modeler.internal.core.index.IndexMetadataStore;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified:
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeQueryMetadata.java
===================================================================
---
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeQueryMetadata.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeQueryMetadata.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,7 +22,8 @@
package com.metamatrix.metadata.runtime;
-import com.metamatrix.modeler.internal.core.index.IndexConstants;
+import org.teiid.metadata.index.IndexConstants;
+
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.unittest.QueryMetadataInterfaceBuilder;
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -70,7 +70,7 @@
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabaseID;
import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
import com.metamatrix.platform.admin.apiimpl.RuntimeStateAdminAPIHelper;
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -117,8 +117,8 @@
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.vdb.defn.VDBCreation;
import com.metamatrix.metadata.runtime.vdb.defn.VDBDefnFactory;
import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -90,7 +90,7 @@
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.ZipFileUtil;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.platform.admin.api.runtime.HostData;
import com.metamatrix.platform.admin.api.runtime.ProcessData;
import com.metamatrix.platform.admin.api.runtime.SystemState;
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -60,8 +60,8 @@
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
import com.metamatrix.metadata.runtime.RuntimeVDBDeleteUtility;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabaseID;
import com.metamatrix.platform.admin.api.runtime.HostData;
import com.metamatrix.platform.admin.api.runtime.ProcessData;
Modified:
trunk/server/src/main/java/com/metamatrix/dqp/service/metadata/IndexMetadataService.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/dqp/service/metadata/IndexMetadataService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/dqp/service/metadata/IndexMetadataService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -26,6 +26,7 @@
import java.util.Properties;
import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.metadata.QueryMetadataCache;
import com.google.inject.Inject;
import com.metamatrix.api.exception.MetaMatrixComponentException;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -26,13 +26,15 @@
import java.util.Collections;
import java.util.Iterator;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.util.LogRuntimeMetadataConstants;
import com.metamatrix.metadata.util.ErrorMessageKeys;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataCatalog.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataCatalog.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeMetadataCatalog.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -33,6 +33,9 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.metadata.QueryMetadataCache;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
@@ -49,19 +52,18 @@
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.event.EventObjectListener;
import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.dqp.service.metadata.QueryMetadataCache;
import com.metamatrix.metadata.runtime.api.MetadataSourceAPI;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.RuntimeMetadataPropertyNames;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseMetadata;
import com.metamatrix.metadata.runtime.event.RuntimeMetadataEvent;
import com.metamatrix.metadata.runtime.event.RuntimeMetadataListener;
import com.metamatrix.metadata.runtime.exception.InvalidStateException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabaseMetadata;
import com.metamatrix.metadata.runtime.model.MetadataCache;
import com.metamatrix.metadata.runtime.model.UpdateController;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeVDBDeleteUtility.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeVDBDeleteUtility.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/RuntimeVDBDeleteUtility.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,6 +25,8 @@
import java.util.Collection;
import java.util.Iterator;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
Modified: trunk/server/src/main/java/com/metamatrix/metadata/runtime/VDBTreeUtility.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/VDBTreeUtility.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/VDBTreeUtility.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -31,6 +31,8 @@
import java.util.List;
import java.util.Map;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.tree.basic.BasicTreeNode;
import com.metamatrix.core.id.ObjectID;
@@ -43,8 +45,8 @@
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.Procedure;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseMetadata;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.util.LogRuntimeMetadataConstants;
import com.metamatrix.metadata.util.ErrorMessageKeys;
import com.metamatrix.platform.admin.api.PermissionDataNodeDefinition;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceAPI.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceAPI.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceAPI.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,8 +25,6 @@
import java.util.Collection;
import java.util.List;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
/**
* The DataAccessAPI is the common interface to access runtime metadata.
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseMetadata.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseMetadata.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseMetadata.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.List;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
/**
* A VirtualDatabaseMetadata represent a virtual database in the repository.
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/exception/InvalidStateException.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/exception/InvalidStateException.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/exception/InvalidStateException.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,6 +22,8 @@
package com.metamatrix.metadata.runtime.exception;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
+
/**
* Thrown when an update is requested on the VirtualDatabase and the VirtualDatabase is
not in the proper state to allow it.
*/
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicElementID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicElementID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicElementID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,9 +22,10 @@
package com.metamatrix.metadata.runtime.model;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.ElementID;
import com.metamatrix.metadata.runtime.api.GroupID;
import com.metamatrix.metadata.runtime.api.ModelID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicGroupID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicGroupID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicGroupID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,9 +22,10 @@
package com.metamatrix.metadata.runtime.model;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.GroupID;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.util.LogRuntimeMetadataConstants;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicKeyID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicKeyID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicKeyID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,9 +22,10 @@
package com.metamatrix.metadata.runtime.model;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.GroupID;
import com.metamatrix.metadata.runtime.api.KeyID;
import com.metamatrix.metadata.runtime.api.ModelID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -28,11 +28,11 @@
import java.util.List;
import org.teiid.connector.metadata.runtime.MetadataConstants;
+import org.teiid.metadata.RuntimeMetadataPlugin;
import com.metamatrix.common.namedobject.IDVerifier;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.ElementID;
import com.metamatrix.metadata.runtime.api.KeyID;
import com.metamatrix.metadata.runtime.api.MetadataID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataObject.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataObject.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicMetadataObject.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,12 +25,13 @@
import java.io.Serializable;
import java.util.Properties;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.MetadataID;
import com.metamatrix.metadata.runtime.api.MetadataObject;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.util.ErrorMessageKeys;
/**
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicModelID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicModelID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicModelID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,9 +22,10 @@
package com.metamatrix.metadata.runtime.model;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.util.LogRuntimeMetadataConstants;
import com.metamatrix.metadata.util.ErrorMessageKeys;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicProcedureID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicProcedureID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicProcedureID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,9 +22,10 @@
package com.metamatrix.metadata.runtime.model;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.ProcedureID;
import com.metamatrix.metadata.runtime.util.LogRuntimeMetadataConstants;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseID.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseID.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseID.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -22,8 +22,9 @@
package com.metamatrix.metadata.runtime.model;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.util.ErrorMessageKeys;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseMetadata.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseMetadata.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/BasicVirtualDatabaseMetadata.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -35,9 +35,9 @@
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.Procedure;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseMetadata;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
public class BasicVirtualDatabaseMetadata implements VirtualDatabaseMetadata{
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/MetadataCache.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/MetadataCache.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/MetadataCache.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -35,28 +35,28 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.metadata.IObjectQuery;
+import org.teiid.connector.metadata.ObjectQueryProcessor;
import org.teiid.connector.metadata.runtime.MetadataConstants;
+import org.teiid.metadata.RuntimeMetadataPlugin;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.connector.metadata.internal.IObjectQuery;
-import com.metamatrix.connector.metadata.internal.MetadataException;
-import com.metamatrix.connector.metadata.internal.ObjectQueryProcessor;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.vdb.ModelType;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.GroupID;
import com.metamatrix.metadata.runtime.api.MetadataSourceAPI;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.vdb.runtime.BasicModelInfo;
/**
@@ -88,11 +88,11 @@
return columnNames;
}
- public Map getCriteria() throws MetadataException {
+ public Map getCriteria() throws ConnectorException {
return criteria;
}
- public String getTableNameInSource() throws MetadataException {
+ public String getTableNameInSource() throws ConnectorException {
return tableNameInSource;
}
}
@@ -251,7 +251,7 @@
buildGroupObjects(getObjectQueryProcessor().process(new MetadataQuery(GROUP_COLUMNS,
GROUPS_NAME_IN_SOURCE)));
buildColumnObjects(getObjectQueryProcessor().process(new
MetadataQuery(ELEMENT_COLUMNS, COLUMNS_NAME_IN_SOURCE)));
buildProcedureObjects(getObjectQueryProcessor().process(new
MetadataQuery(PROCEDURE_COLUMNS, PROCEDURES_NAME_IN_SOURCE)));
- } catch (MetadataException e) {
+ } catch (ConnectorException e) {
throw new VirtualDatabaseException(e);
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/UpdateController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/UpdateController.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/model/UpdateController.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -32,6 +32,8 @@
import java.util.List;
import java.util.Map;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.connection.TransactionMgr;
@@ -51,13 +53,12 @@
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.vdb.VDBStatus;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.exception.InvalidStateException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.spi.MetaBaseConnector;
import com.metamatrix.metadata.runtime.util.LogRuntimeMetadataConstants;
import com.metamatrix.metadata.util.ErrorMessageKeys;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -29,6 +29,8 @@
import java.util.Iterator;
import java.util.Map;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.connection.BaseTransaction;
import com.metamatrix.common.connection.ManagedConnection;
import com.metamatrix.common.connection.ManagedConnectionException;
@@ -38,13 +40,12 @@
import com.metamatrix.core.util.DateUtil;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.exception.InvalidStateException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicModel;
import com.metamatrix.metadata.runtime.model.BasicModelID;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabaseID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -35,16 +35,17 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.CorePlugin;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.MetadataConstants;
import com.metamatrix.metadata.runtime.api.MetadataID;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicMetadataID;
import com.metamatrix.metadata.runtime.model.BasicModelID;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabaseID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataWriter.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataWriter.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataWriter.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -32,18 +32,19 @@
import java.util.List;
import java.util.Map;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.jdbc.JDBCReservedWords;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.core.util.DateUtil;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.ModelID;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.exception.InvalidStateException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicModelID;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabase;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabaseID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -31,12 +31,13 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.common.jdbc.JDBCReservedWords;
import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.DateUtil;
import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.MetadataID;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.ModelID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -34,6 +34,8 @@
import java.util.Properties;
import java.util.Set;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.actions.ObjectEditor;
import com.metamatrix.common.config.CurrentConfiguration;
@@ -58,7 +60,6 @@
import com.metamatrix.common.vdb.api.VDBDefn;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.RuntimeMetadataPropertyNames;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBDefnFactory.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBDefnFactory.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBDefnFactory.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -27,6 +27,8 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.metadata.RuntimeMetadataPlugin;
+
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ComponentType;
@@ -36,7 +38,6 @@
import com.metamatrix.common.vdb.api.VDBStreamImpl;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -51,9 +51,9 @@
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
Modified:
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -35,6 +35,7 @@
import java.util.Set;
import org.teiid.adminapi.AdminRoles;
+import org.teiid.metadata.RuntimeMetadataPlugin;
import org.teiid.transport.SSLConfiguration;
import com.metamatrix.admin.RolesAllowed;
@@ -53,12 +54,11 @@
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.vdb.VDBStatus;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.RuntimeVDBDeleteUtility;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.vdb.defn.VDBCreation;
import com.metamatrix.metadata.runtime.vdb.defn.VDBDefnFactory;
import com.metamatrix.metadata.util.ErrorMessageKeys;
Modified:
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -34,6 +34,7 @@
import java.util.Set;
import org.teiid.adminapi.AdminOptions;
+import org.teiid.metadata.RuntimeMetadataPlugin;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
@@ -49,14 +50,13 @@
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.core.vdb.VDBStatus;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.RuntimeMetadataPlugin;
import com.metamatrix.metadata.runtime.VDBTreeUtility;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseMetadata;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.util.ErrorMessageKeys;
import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
import com.metamatrix.platform.admin.api.PermissionDataNode;
Modified:
trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/server/dqp/config/PlatformConfigSource.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -27,6 +27,7 @@
import java.util.Properties;
import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.metadata.QueryMetadataCache;
import com.google.inject.Binder;
import com.google.inject.name.Names;
@@ -37,9 +38,8 @@
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.metadata.IndexMetadataService;
-import com.metamatrix.dqp.service.metadata.QueryMetadataCache;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
import com.metamatrix.platform.util.PlatformProxyHelper;
import com.metamatrix.server.Configuration;
Modified:
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformVDBService.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformVDBService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformVDBService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -52,11 +52,11 @@
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
import com.metamatrix.metadata.runtime.api.Model;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.metadata.runtime.event.RuntimeMetadataEvent;
import com.metamatrix.metadata.runtime.event.RuntimeMetadataListener;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.server.ServerPlugin;
import com.metamatrix.server.util.LogConstants;
import com.metamatrix.vdb.runtime.VDBKey;
Modified:
trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeMetadataCatalog.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeMetadataCatalog.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeMetadataCatalog.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -29,8 +29,8 @@
import java.util.Map;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.model.BasicModel;
import com.metamatrix.metadata.runtime.model.BasicModelID;
import com.metamatrix.metadata.runtime.model.BasicVirtualDatabase;
Modified:
trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerConfigAdminImpl.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerConfigAdminImpl.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerConfigAdminImpl.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,8 +25,8 @@
import java.util.Collection;
import java.util.Map;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.platform.registry.ClusteredRegistryState;
/**
Modified:
trunk/server/src/test/java/com/metamatrix/dqp/service/metadata/TestIndexMetadataService.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/dqp/service/metadata/TestIndexMetadataService.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/test/java/com/metamatrix/dqp/service/metadata/TestIndexMetadataService.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -30,6 +30,7 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
+import org.teiid.metadata.QueryMetadataCache;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.vdb.api.VDBArchive;
Modified:
trunk/server/src/test/java/com/metamatrix/server/admin/apiimpl/TestRuntimeMetadataHelper.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/server/admin/apiimpl/TestRuntimeMetadataHelper.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/server/src/test/java/com/metamatrix/server/admin/apiimpl/TestRuntimeMetadataHelper.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -45,7 +45,7 @@
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.core.vdb.ModelType;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
-import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.server.admin.api.MaterializationLoadScripts;
import com.metamatrix.vdb.materialization.DatabaseDialect;
import com.metamatrix.vdb.materialization.ScriptType;
Modified:
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
---
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -44,11 +44,11 @@
import org.teiid.dqp.internal.datamgr.language.TestSelectImpl;
import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
+import org.teiid.metadata.index.VDBMetadataFactory;
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.rewriter.QueryRewriter;
Modified:
trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java
===================================================================
---
trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,13 +25,14 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.metadata.index.VDBMetadataFactory;
+
import junit.framework.TestCase;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.QueryOptimizer;
Modified:
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModel.java
===================================================================
---
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModel.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModel.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -30,13 +30,13 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.metadata.index.VDBMetadataFactory;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.connector.metadata.IndexConnector;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.metadata.runtime.FakeMetadataService;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
public class TestSystemPhysicalModel {
static FakeMetadataService metadataService = null;
Modified:
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModelSelf.java
===================================================================
---
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModelSelf.java 2009-07-08
03:42:18 UTC (rev 1106)
+++
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestSystemPhysicalModelSelf.java 2009-07-08
04:55:17 UTC (rev 1107)
@@ -25,6 +25,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.teiid.metadata.index.VDBMetadataFactory;
+
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -36,7 +38,6 @@
import com.metamatrix.connector.metadata.IndexConnector;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.metadata.runtime.FakeMetadataService;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
public class TestSystemPhysicalModelSelf extends TestCase {