teiid SVN: r1916 - in trunk/engine: src/main/java/com/metamatrix and 82 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-05 09:26:51 -0500 (Fri, 05 Mar 2010)
New Revision: 1916
Added:
trunk/engine/src/main/java/com/metamatrix/api/
trunk/engine/src/main/java/com/metamatrix/api/exception/
trunk/engine/src/main/java/com/metamatrix/api/exception/security/
trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java
trunk/engine/src/main/java/com/metamatrix/common/queue/
trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java
trunk/engine/src/main/java/org/teiid/cache/
trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/
trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
trunk/engine/src/test/java/com/metamatrix/common/queue/
trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
Removed:
trunk/engine/src/main/java/com/metamatrix/api/exception/
trunk/engine/src/main/java/com/metamatrix/api/exception/security/
trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java
trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java
trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java
trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java
trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java
trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java
trunk/engine/src/main/java/com/metamatrix/common/comm/
trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java
trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/
trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java
Modified:
trunk/engine/
trunk/engine/pom.xml
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java
trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java
trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java
trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java
trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java
trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java
trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
Log:
TEIID-833 committing JCA merge
Property changes on: trunk/engine
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/pom.xml 2010-03-05 14:26:51 UTC (rev 1916)
@@ -50,11 +50,13 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-connector-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -64,20 +66,25 @@
</dependency>
<dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- </dependency>
-
- <dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
- </dependency>
+ <scope>provided</scope>
+ </dependency>
<dependency>
- <groupId>com.google.code.guice</groupId>
- <artifactId>guice</artifactId>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
+
+
</project>
\ No newline at end of file
Copied: trunk/engine/src/main/java/com/metamatrix/api (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api)
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception)
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security)
Deleted: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,81 +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.api.exception.security;
-
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-
-public class AuthorizationException extends MetaMatrixSecurityException {
- /**
- * No-Arg Constructor
- */
- public AuthorizationException( ) {
- super( );
- }
- /**
- * Constructs an instance of the exception with the specified detail message. A detail
- * message is a String that describes this particular exception.
- * @param the detail message
- */
- public AuthorizationException(String message) {
- super(message);
- }
- /**
- * Constructs an instance of the exception with no detail message but with a
- * single exception.
- * @param e the exception that is encapsulated by this exception
- */
- public AuthorizationException(Throwable e) {
- super(e);
- }
- /**
- * Constructs an instance of the exception with the specified detail message
- * and a single exception. A detail message is a String that describes this
- * particular exception.
- * @param message the detail message
- * @param e the exception that is encapsulated by this exception
- */
- public AuthorizationException( Throwable e, String message ) {
- super(e, message);
- }
- /**
- * Construct an instance with an error code and message specified.
- *
- * @param message The error message
- * @param code The error code
- */
- public AuthorizationException( String code, String message ) {
- super( code, message );
- }
- /**
- * Construct an instance with a linked exception, and an error code and
- * message, specified.
- *
- * @param e An exception to chain to this exception
- * @param message The error message
- * @param code The error code
- */
- public AuthorizationException( Throwable e, String code, String message ) {
- super(e, code, message );
- }
-}
-
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,81 @@
+/*
+ * 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.api.exception.security;
+
+import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
+
+public class AuthorizationException extends MetaMatrixSecurityException {
+ /**
+ * No-Arg Constructor
+ */
+ public AuthorizationException( ) {
+ super( );
+ }
+ /**
+ * Constructs an instance of the exception with the specified detail message. A detail
+ * message is a String that describes this particular exception.
+ * @param the detail message
+ */
+ public AuthorizationException(String message) {
+ super(message);
+ }
+ /**
+ * Constructs an instance of the exception with no detail message but with a
+ * single exception.
+ * @param e the exception that is encapsulated by this exception
+ */
+ public AuthorizationException(Throwable e) {
+ super(e);
+ }
+ /**
+ * Constructs an instance of the exception with the specified detail message
+ * and a single exception. A detail message is a String that describes this
+ * particular exception.
+ * @param message the detail message
+ * @param e the exception that is encapsulated by this exception
+ */
+ public AuthorizationException( Throwable e, String message ) {
+ super(e, message);
+ }
+ /**
+ * Construct an instance with an error code and message specified.
+ *
+ * @param message The error message
+ * @param code The error code
+ */
+ public AuthorizationException( String code, String message ) {
+ super( code, message );
+ }
+ /**
+ * Construct an instance with a linked exception, and an error code and
+ * message, specified.
+ *
+ * @param e An exception to chain to this exception
+ * @param message The error message
+ * @param code The error code
+ */
+ public AuthorizationException( Throwable e, String code, String message ) {
+ super(e, code, message );
+ }
+}
+
Deleted: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,87 +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.api.exception.security;
-
-public class AuthorizationMgmtException extends AuthorizationException {
-
- /**
- * No-Arg Constructor
- */
- public AuthorizationMgmtException( ) {
- super( );
- }
- /**
- * Constructs an instance of the exception with the specified detail
- * message. A detail message is a String that describes this particular
- * exception.
- * @param the detail message
- */
- public AuthorizationMgmtException(String message) {
- super(message);
- }
-
- /**
- * Constructs an instance of the exception with no detail message but with a
- * single exception.
- * @param e the exception that is encapsulated by this exception
- */
- public AuthorizationMgmtException(Throwable e) {
- super(e);
- }
-
- /**
- * Constructs an instance of the exception with the specified detail message
- * and a single exception. A detail message is a String that describes this
- * particular exception.
- * @param e the exception that is encapsulated by this exception
- * @param message the detail message
- */
- public AuthorizationMgmtException(Throwable e, String message) {
- super(e,message);
- }
-
- /**
- * Construct an instance with an error code and message specified.
- *
- * @param message The error message
- * @param code The error code
- */
- public AuthorizationMgmtException( String code, String message ) {
- super( code, message );
- }
-
- /**
- * Construct an instance with a linked exception, and an error code and
- * message, specified.
- *
- * @param e An exception to chain to this exception
- * @param message The error message
- * @param code The error code
- */
- public AuthorizationMgmtException( Throwable e, String code, String message ) {
- super( e, code, message );
- }
-
-}
-
-
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,87 @@
+/*
+ * 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.api.exception.security;
+
+public class AuthorizationMgmtException extends AuthorizationException {
+
+ /**
+ * No-Arg Constructor
+ */
+ public AuthorizationMgmtException( ) {
+ super( );
+ }
+ /**
+ * Constructs an instance of the exception with the specified detail
+ * message. A detail message is a String that describes this particular
+ * exception.
+ * @param the detail message
+ */
+ public AuthorizationMgmtException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs an instance of the exception with no detail message but with a
+ * single exception.
+ * @param e the exception that is encapsulated by this exception
+ */
+ public AuthorizationMgmtException(Throwable e) {
+ super(e);
+ }
+
+ /**
+ * Constructs an instance of the exception with the specified detail message
+ * and a single exception. A detail message is a String that describes this
+ * particular exception.
+ * @param e the exception that is encapsulated by this exception
+ * @param message the detail message
+ */
+ public AuthorizationMgmtException(Throwable e, String message) {
+ super(e,message);
+ }
+
+ /**
+ * Construct an instance with an error code and message specified.
+ *
+ * @param message The error message
+ * @param code The error code
+ */
+ public AuthorizationMgmtException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance with a linked exception, and an error code and
+ * message, specified.
+ *
+ * @param e An exception to chain to this exception
+ * @param message The error message
+ * @param code The error code
+ */
+ public AuthorizationMgmtException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+
+}
+
+
Deleted: trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,80 +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.api.exception.security;
-
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-
-public class SessionServiceException extends MetaMatrixSecurityException {
- /**
- * No-Arg Constructor
- */
- public SessionServiceException( ) {
- super( );
- }
- /**
- * Constructs an instance of the exception with the specified detail message. A detail
- * message is a String that describes this particular exception.
- * @param the detail message
- */
- public SessionServiceException(String message) {
- super(message);
- }
- /**
- * Constructs an instance of the exception with no detail message but with a
- * single exception.
- * @param e the exception that is encapsulated by this exception
- */
- public SessionServiceException(Throwable e) {
- super(e);
- }
- /**
- * Constructs an instance of the exception with the specified detail message
- * and a single exception. A detail message is a String that describes this
- * particular exception.
- * @param message the detail message
- * @param e the exception that is encapsulated by this exception
- */
- public SessionServiceException( Throwable e, String message ) {
- super(e, message);
- }
- /**
- * Construct an instance with an error code and message specified.
- *
- * @param message The error message
- * @param code The error code
- */
- public SessionServiceException( String code, String message ) {
- super( code, message );
- }
- /**
- * Construct an instance with a linked exception, and an error code and
- * message, specified.
- *
- * @param e An exception to chain to this exception
- * @param message The error message
- * @param code The error code
- */
- public SessionServiceException( Throwable e, String code, String message ) {
- super( e, code, message );
- }
-}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,80 @@
+/*
+ * 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.api.exception.security;
+
+import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
+
+public class SessionServiceException extends MetaMatrixSecurityException {
+ /**
+ * No-Arg Constructor
+ */
+ public SessionServiceException( ) {
+ super( );
+ }
+ /**
+ * Constructs an instance of the exception with the specified detail message. A detail
+ * message is a String that describes this particular exception.
+ * @param the detail message
+ */
+ public SessionServiceException(String message) {
+ super(message);
+ }
+ /**
+ * Constructs an instance of the exception with no detail message but with a
+ * single exception.
+ * @param e the exception that is encapsulated by this exception
+ */
+ public SessionServiceException(Throwable e) {
+ super(e);
+ }
+ /**
+ * Constructs an instance of the exception with the specified detail message
+ * and a single exception. A detail message is a String that describes this
+ * particular exception.
+ * @param message the detail message
+ * @param e the exception that is encapsulated by this exception
+ */
+ public SessionServiceException( Throwable e, String message ) {
+ super(e, message);
+ }
+ /**
+ * Construct an instance with an error code and message specified.
+ *
+ * @param message The error message
+ * @param code The error code
+ */
+ public SessionServiceException( String code, String message ) {
+ super( code, message );
+ }
+ /**
+ * Construct an instance with a linked exception, and an error code and
+ * message, specified.
+ *
+ * @param e An exception to chain to this exception
+ * @param message The error message
+ * @param code The error code
+ */
+ public SessionServiceException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,118 +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.common.application;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
-import com.metamatrix.common.classloader.URLFilteringClassLoader;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.dqp.util.LogConstants;
-
-public abstract class AbstractClassLoaderManager implements ClassLoaderManager {
-
- private ClassLoader parentClassLoader;
- private URLFilteringClassLoader commonExtensionClassloader;
- private Map<String, PostDelegatingClassLoader> postdelegationClassLoaderCache = new HashMap<String, PostDelegatingClassLoader>();
- private boolean usePostDelegationCache;
- private MetaMatrixURLStreamHandlerFactory factory;
- private Object lock = new Object();
-
- public AbstractClassLoaderManager(ClassLoader parentClassLoader, boolean usePostDelegationCache, boolean useStreamHandler) {
- this.usePostDelegationCache = usePostDelegationCache;
- this.parentClassLoader = parentClassLoader;
- if (useStreamHandler) {
- factory = new MetaMatrixURLStreamHandlerFactory();
- }
- }
-
- public ClassLoader getCommonClassLoader(String urls) {
- synchronized (lock) {
- if (this.commonExtensionClassloader == null) {
- // since we are using the extensions, get the common extension path
- this.commonExtensionClassloader = new URLFilteringClassLoader(parseURLs(getCommonExtensionClassPath()), parentClassLoader, factory);
- }
- if (urls != null && urls.trim().length() > 0) {
- for (URL url : parseURLs(urls)) {
- this.commonExtensionClassloader.addURL(url);
- }
- }
- return this.commonExtensionClassloader;
- }
- }
-
- public ClassLoader getPostDelegationClassLoader(String urls) {
- synchronized (lock) {
- PostDelegatingClassLoader cl = this.postdelegationClassLoaderCache.get(urls);
- if (cl == null) {
- if (urls != null && urls.trim().length() > 0) {
- cl = new PostDelegatingClassLoader(parseURLs(urls), getCommonClassLoader(null), factory);
- if (usePostDelegationCache) {
- this.postdelegationClassLoaderCache.put(urls, cl);
- }
- }
- if (cl == null) {
- return getCommonClassLoader(null);
- }
- }
- return cl;
- }
- }
-
- public void clearCache() {
- synchronized (lock) {
- this.commonExtensionClassloader = null;
- this.postdelegationClassLoaderCache.clear();
- }
- }
-
- public URL[] parseURLs(String delimitedUrls) {
- StringTokenizer toke = new StringTokenizer(delimitedUrls, ";"); //$NON-NLS-1$
- List<URL> urls = new ArrayList<URL>(toke.countTokens());
- while (toke.hasMoreElements()) {
- String urlString = toke.nextToken();
- try {
- URL url = parseURL(urlString);
- if (url != null) {
- urls.add(url);
- }
- } catch (MalformedURLException e) {
- LogManager.logError(LogConstants.CTX_EXTENSION_SOURCE, "Invalid extension classpath entry " + urlString); //$NON-NLS-1$
- }
- }
-
- return urls.toArray(new URL[urls.size()]);
- }
-
- public abstract URL parseURL(String url) throws MalformedURLException;
-
- public abstract String getCommonExtensionClassPath();
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,93 +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.common.application;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
-/**
- * The environment is available internally to the application as a means
- * of finding application services of a particular type or to retrieve
- * other information about the application itself.
- */
-public class ApplicationEnvironment {
-
- private LinkedHashMap<String, ApplicationService> services = new LinkedHashMap<String, ApplicationService>();
-
- private CacheFactory cache;
-
- public ApplicationEnvironment() {
-
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationEnvironment#bindService(java.lang.String, com.metamatrix.common.application.ApplicationService)
- */
- public void bindService(String type, ApplicationService service) {
- this.services.put(type, service);
- }
-
- public ApplicationService findService(String type) {
- return this.services.get(type);
- }
-
- public CacheFactory getCacheFactory() {
- return cache;
- }
-
- public void setCacheFactory(CacheFactory cache) {
- this.cache = cache;
- }
-
- /*
- * @see com.metamatrix.common.application.Application#installService(com.metamatrix.common.application.ApplicationService)
- */
- public final void installService(String type, ApplicationService service) throws ApplicationInitializationException {
- if(service == null) {
- return;
- }
-
- try {
- service.start(this);
- this.bindService(type, service);
- } catch(ApplicationLifecycleException e) {
- throw new ApplicationInitializationException(e, CommonPlugin.Util.getString("BasicApplication.Failed_while_installing_service_of_type__1") + type); //$NON-NLS-1$
- }
- }
-
- /**
- * @see com.metamatrix.common.application.Application#stop()
- */
- public void stop() throws ApplicationLifecycleException {
- for (Map.Entry<String, ApplicationService> entry : services.entrySet()) {
- entry.getValue().stop();
- }
- services.clear();
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,63 +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.common.application;
-
-import java.util.Properties;
-
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
-/**
- * This defines the basic interface for an application service. The lifecycle
- * of a service is generally as follows:
- * <ul>
- * <li>Initialize - configure the service</li>
- * <li>Start - performed by application prior to start the service running in an environment</li>
- * <li>Stop - performed by application after the service is unbound from the environment</li>
- * </ul>
- */
-public interface ApplicationService {
-
- /**
- * Initialize the service with the specified properties.
- * @param props Initialialization properties
- * @throws ApplicationInitializationException If an error occurs during initialization
- */
- public void initialize(Properties props) throws ApplicationInitializationException;
-
- /**
- * Start the service with the specified environment. The environment can
- * be used to find other services or resources.
- * @param environment Environment
- * @throws ApplicationLifecycleException If an error occurs while starting
- */
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException;
-
- /**
- * Stop the service.
- * @throws ApplicationLifecycleException If an error occurs while starting
- */
- public void stop() throws ApplicationLifecycleException;
-
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,41 +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.common.application;
-
-public interface ClassLoaderManager {
-
- /**
- * Return the common class loader with the given urls appended
- * @param urls
- * @return
- */
- ClassLoader getCommonClassLoader(String urls);
-
- /**
- * Return a distinct post delgation class loader - which may be cached.
- * @param urls
- * @return
- */
- ClassLoader getPostDelegationClassLoader(String urls);
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,35 +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.common.application;
-
-import java.util.Properties;
-
-/**
- * This interface represents a source of DQP configuration information.
- */
-public interface DQPConfigSource {
-
- public Properties getProperties();
-
- public ApplicationService getServiceInstance(Class<? extends ApplicationService> type);
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,35 +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.common.application;
-
-/**
- * Used as an entry mechanism for the Designer to extend service classes
- * without depending upon embedded.
- */
-public class ServiceLoader {
-
- public ApplicationService loadService(String serviceType, ApplicationService service) {
- return service;
- }
-
-}
Copied: trunk/engine/src/main/java/com/metamatrix/common/queue (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/common/queue)
Deleted: trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,288 +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.common.queue;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.resource.spi.work.ExecutionContext;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
-import javax.resource.spi.work.WorkRejectedException;
-
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.NamedThreadFactory;
-
-/**
- * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to
- * capture statistics and implement an unbounded queue of work.
- */
-public class StatsCapturingWorkManager {
-
- private static class WorkContext {
- ExecutionContext context;
- long startTimeout;
- long submitted = System.currentTimeMillis();
-
- public WorkContext(ExecutionContext context, long startTimeout) {
- this.context = context;
- this.startTimeout = startTimeout;
- }
-
- long getStartTimeout() {
- if (startTimeout == 0) {
- return 0;
- }
- return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
- }
-
- }
-
- private final class WorkWrapper implements Work {
- private final WorkManager delegate;
- private final Work work;
- private final WorkContext workContext;
-
- private WorkWrapper(WorkManager delegate, Work work, WorkContext workContext) {
- this.delegate = delegate;
- this.work = work;
- this.workContext = workContext;
- }
-
- @Override
- public void run() {
- Thread t = Thread.currentThread();
- synchronized (poolLock) {
- threads.add(t);
- }
- String name = t.getName();
- t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
- LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
- }
- boolean success = false;
- try {
- work.run();
- success = true;
- } finally {
- synchronized (poolLock) {
- WorkWrapper next = null;
- if (success) {
- completedCount++;
- next = queue.poll();
- }
- threads.remove(t);
- if (next == null) {
- activeCount--;
- if (activeCount == 0 && terminated) {
- poolLock.notifyAll();
- }
- } else {
- try {
- if (next.workContext == null) {
- delegate.scheduleWork(next);
- } else {
- delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
- }
- } catch (WorkException e) {
- handleException(next.work, e);
- }
- }
- }
- t.setName(name);
- }
- }
-
- @Override
- public void release() {
- this.work.release();
- }
- }
-
- private static void handleException(Work work, WorkException e) {
- if (work instanceof WorkListener) {
- ((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
- } else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_POOLING, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$
- }
- }
-
- private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
-
- private volatile int activeCount;
- private volatile int highestActiveCount;
- private volatile int highestQueueSize;
- private volatile boolean terminated;
- private volatile int submittedCount;
- private volatile int completedCount;
- private Object poolLock = new Object();
- private AtomicInteger threadCounter = new AtomicInteger();
- private String poolName;
- private int maximumPoolSize;
- private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
- private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
- private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
- private int idCounter;
-
- public StatsCapturingWorkManager(String name, int maximumPoolSize) {
- this.maximumPoolSize = maximumPoolSize;
- this.poolName = name;
- }
-
- public void scheduleWork(final WorkManager delegate, final Work arg0) throws WorkException {
- scheduleWork(delegate, arg0, (WorkContext)null);
- }
-
- private void scheduleWork(final WorkManager delegate, final Work work, WorkContext workContext)
- throws WorkRejectedException, WorkException {
- boolean atMaxThreads = false;
- boolean newMaxQueueSize = false;
- synchronized (poolLock) {
- checkForTermination();
- submittedCount++;
- atMaxThreads = activeCount == maximumPoolSize;
- if (atMaxThreads) {
- queue.add(new WorkWrapper(delegate, work, workContext));
- int queueSize = queue.size();
- if (queueSize > highestQueueSize) {
- newMaxQueueSize = true;
- highestQueueSize = queueSize;
- }
- } else {
- activeCount++;
- highestActiveCount = Math.max(activeCount, highestActiveCount);
- }
- }
- if (atMaxThreads) {
- if (newMaxQueueSize && maximumPoolSize > 1) {
- LogManager.logWarning(LogConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
- }
- return;
- }
- if (workContext == null) {
- delegate.scheduleWork(new WorkWrapper(delegate, work, null));
- } else {
- delegate.scheduleWork(new WorkWrapper(delegate, work, null), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
- }
- }
-
- public void scheduleWork(final WorkManager delegate, final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
- if (delay < 1) {
- scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
- } else {
- synchronized (futures) {
- final int id = idCounter++;
- ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
-
- @Override
- public void run() {
- try {
- futures.remove(id);
- scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
- } catch (WorkException e) {
- handleException(arg0, e);
- }
- }
- }, delay, TimeUnit.MILLISECONDS);
- this.futures.put(id, sf);
- }
- }
- }
-
- private void checkForTermination() throws WorkRejectedException {
- if (terminated) {
- throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
- }
- }
-
- public WorkerPoolStatisticsMetadata getStats() {
- WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
- stats.setName(poolName);
- stats.setQueued(queue.size());
- stats.setHighestQueued(highestQueueSize);
- stats.setActiveThreads(this.activeCount);
- stats.setMaxThreads(this.maximumPoolSize);
- stats.setTotalSubmitted(this.submittedCount);
- stats.setHighestActiveThreads(this.highestActiveCount);
- stats.setTotalCompleted(this.completedCount);
- return stats;
- }
-
- public void shutdown() {
- this.terminated = true;
- }
-
- public void shutdownNow() {
- this.shutdown();
- synchronized (poolLock) {
- for (Thread t : threads) {
- t.interrupt();
- }
- queue.clear();
- }
- synchronized (futures) {
- for (ScheduledFuture<?> future : futures.values()) {
- future.cancel(true);
- }
- futures.clear();
- }
- }
-
- public boolean isTerminated() {
- return terminated;
- }
-
- public boolean awaitTermination(long timeout, TimeUnit unit)
- throws InterruptedException {
- long timeoutMillis = unit.toMillis(timeout);
- long finalMillis = System.currentTimeMillis() + timeoutMillis;
- synchronized (poolLock) {
- while (this.activeCount > 0 || !terminated) {
- if (timeoutMillis < 1) {
- return false;
- }
- poolLock.wait(timeoutMillis);
- timeoutMillis = finalMillis - System.currentTimeMillis();
- }
- }
- return true;
- }
-
-}
Copied: trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,288 @@
+/*
+ * 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.common.queue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+import com.metamatrix.common.CommonPlugin;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.NamedThreadFactory;
+
+/**
+ * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to
+ * capture statistics and implement an unbounded queue of work.
+ */
+public class StatsCapturingWorkManager {
+
+ private static class WorkContext {
+ ExecutionContext context;
+ long startTimeout;
+ long submitted = System.currentTimeMillis();
+
+ public WorkContext(ExecutionContext context, long startTimeout) {
+ this.context = context;
+ this.startTimeout = startTimeout;
+ }
+
+ long getStartTimeout() {
+ if (startTimeout == 0) {
+ return 0;
+ }
+ return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
+ }
+
+ }
+
+ private final class WorkWrapper implements Work {
+ private final WorkManager delegate;
+ private final Work work;
+ private final WorkContext workContext;
+
+ private WorkWrapper(WorkManager delegate, Work work, WorkContext workContext) {
+ this.delegate = delegate;
+ this.work = work;
+ this.workContext = workContext;
+ }
+
+ @Override
+ public void run() {
+ Thread t = Thread.currentThread();
+ synchronized (poolLock) {
+ threads.add(t);
+ }
+ String name = t.getName();
+ t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
+ }
+ boolean success = false;
+ try {
+ work.run();
+ success = true;
+ } finally {
+ synchronized (poolLock) {
+ WorkWrapper next = null;
+ if (success) {
+ completedCount++;
+ next = queue.poll();
+ }
+ threads.remove(t);
+ if (next == null) {
+ activeCount--;
+ if (activeCount == 0 && terminated) {
+ poolLock.notifyAll();
+ }
+ } else {
+ try {
+ if (next.workContext == null) {
+ delegate.scheduleWork(next);
+ } else {
+ delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
+ }
+ } catch (WorkException e) {
+ handleException(next.work, e);
+ }
+ }
+ }
+ t.setName(name);
+ }
+ }
+
+ @Override
+ public void release() {
+ this.work.release();
+ }
+ }
+
+ private static void handleException(Work work, WorkException e) {
+ if (work instanceof WorkListener) {
+ ((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
+ } else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_POOLING, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$
+ }
+ }
+
+ private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
+
+ private volatile int activeCount;
+ private volatile int highestActiveCount;
+ private volatile int highestQueueSize;
+ private volatile boolean terminated;
+ private volatile int submittedCount;
+ private volatile int completedCount;
+ private Object poolLock = new Object();
+ private AtomicInteger threadCounter = new AtomicInteger();
+ private String poolName;
+ private int maximumPoolSize;
+ private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
+ private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
+ private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
+ private int idCounter;
+
+ public StatsCapturingWorkManager(String name, int maximumPoolSize) {
+ this.maximumPoolSize = maximumPoolSize;
+ this.poolName = name;
+ }
+
+ public void scheduleWork(final WorkManager delegate, final Work arg0) throws WorkException {
+ scheduleWork(delegate, arg0, (WorkContext)null);
+ }
+
+ private void scheduleWork(final WorkManager delegate, final Work work, WorkContext workContext)
+ throws WorkRejectedException, WorkException {
+ boolean atMaxThreads = false;
+ boolean newMaxQueueSize = false;
+ synchronized (poolLock) {
+ checkForTermination();
+ submittedCount++;
+ atMaxThreads = activeCount == maximumPoolSize;
+ if (atMaxThreads) {
+ queue.add(new WorkWrapper(delegate, work, workContext));
+ int queueSize = queue.size();
+ if (queueSize > highestQueueSize) {
+ newMaxQueueSize = true;
+ highestQueueSize = queueSize;
+ }
+ } else {
+ activeCount++;
+ highestActiveCount = Math.max(activeCount, highestActiveCount);
+ }
+ }
+ if (atMaxThreads) {
+ if (newMaxQueueSize && maximumPoolSize > 1) {
+ LogManager.logWarning(LogConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
+ }
+ return;
+ }
+ if (workContext == null) {
+ delegate.scheduleWork(new WorkWrapper(delegate, work, null));
+ } else {
+ delegate.scheduleWork(new WorkWrapper(delegate, work, null), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
+ }
+ }
+
+ public void scheduleWork(final WorkManager delegate, final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
+ if (delay < 1) {
+ scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
+ } else {
+ synchronized (futures) {
+ final int id = idCounter++;
+ ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ futures.remove(id);
+ scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
+ } catch (WorkException e) {
+ handleException(arg0, e);
+ }
+ }
+ }, delay, TimeUnit.MILLISECONDS);
+ this.futures.put(id, sf);
+ }
+ }
+ }
+
+ private void checkForTermination() throws WorkRejectedException {
+ if (terminated) {
+ throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
+ }
+ }
+
+ public WorkerPoolStatisticsMetadata getStats() {
+ WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+ stats.setName(poolName);
+ stats.setQueued(queue.size());
+ stats.setHighestQueued(highestQueueSize);
+ stats.setActiveThreads(this.activeCount);
+ stats.setMaxThreads(this.maximumPoolSize);
+ stats.setTotalSubmitted(this.submittedCount);
+ stats.setHighestActiveThreads(this.highestActiveCount);
+ stats.setTotalCompleted(this.completedCount);
+ return stats;
+ }
+
+ public void shutdown() {
+ this.terminated = true;
+ }
+
+ public void shutdownNow() {
+ this.shutdown();
+ synchronized (poolLock) {
+ for (Thread t : threads) {
+ t.interrupt();
+ }
+ queue.clear();
+ }
+ synchronized (futures) {
+ for (ScheduledFuture<?> future : futures.values()) {
+ future.cancel(true);
+ }
+ futures.clear();
+ }
+ }
+
+ public boolean isTerminated() {
+ return terminated;
+ }
+
+ public boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ long timeoutMillis = unit.toMillis(timeout);
+ long finalMillis = System.currentTimeMillis() + timeoutMillis;
+ synchronized (poolLock) {
+ while (this.activeCount > 0 || !terminated) {
+ if (timeoutMillis < 1) {
+ return false;
+ }
+ poolLock.wait(timeoutMillis);
+ timeoutMillis = finalMillis - System.currentTimeMillis();
+ }
+ }
+ return true;
+ }
+
+}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,14 +25,12 @@
package com.metamatrix.dqp.message;
import java.io.Serializable;
-import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
-import org.teiid.connector.xa.api.TransactionContext;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.query.sql.lang.Command;
/**
@@ -54,19 +52,13 @@
* The connectorBindingID that identifies the connector needed for this
* query.
*/
- private String connectorBindingID;
+ private String connectorName;
/**
* Name of model where the connector is bound to
*/
private String modelName;
- /**
- * For cancel and update operations, the id of the data connector which
- * originally handled the request.
- */
- private ConnectorID connectorID;
-
// Transaction context for the current request
private TransactionContext txnContext;
@@ -76,11 +68,8 @@
// results fetch size
private int fetchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
- // The time when the command was created by the client
- private Date submittedTimestamp;
-
// The time when command begins processing on the server.
- private Date processingTimestamp;
+ private long processingTimestamp = System.currentTimeMillis();
// whether to use ResultSet cache if there is one
private boolean useResultSetCache;
@@ -107,22 +96,14 @@
return this.atomicRequestId;
}
- public String getConnectorBindingID() {
- return connectorBindingID;
+ public String getConnectorName() {
+ return connectorName;
}
- public ConnectorID getConnectorID() {
- return connectorID;
+ public void setConnectorName(String string) {
+ connectorName = string;
}
-
- public void setConnectorID(ConnectorID connectorID) {
- this.connectorID = connectorID;
- }
- public void setConnectorBindingID(String string) {
- connectorBindingID = string;
- }
-
public String getModelName() {
return this.modelName;
}
@@ -140,7 +121,7 @@
}
public boolean isTransactional(){
- return this.txnContext != null && this.txnContext.isInTransaction();
+ return this.txnContext != null && this.txnContext.getXid() != null;
}
public Command getCommand() {
@@ -163,54 +144,13 @@
}
/**
- * Get time that the time when the command was created by the client.
- * @return timestamp in millis
- */
- public Date getSubmittedTimestamp() {
- return submittedTimestamp;
- }
-
- /**
- * Set time that the time when the command was created by the client.
- * NOTE: By default, this gets set to the current time by the constructor.
- * @param submittedTimestamp Time submitted to server.
- */
- public void setSubmittedTimestamp(Date submittedTimestamp) {
- this.submittedTimestamp = submittedTimestamp;
- }
-
- /**
- * Start the clock on submission start - this should be called when the request is originally created.
- */
- public void markSubmissionStart() {
- setSubmittedTimestamp(new Date());
- }
-
-
- /**
* Get time that the request was assigned a unique ID by the server.
* @return timestamp in millis
*/
- public Date getProcessingTimestamp() {
+ public long getProcessingTimestamp() {
return processingTimestamp;
}
- /**
- * Set time that the request is submitted on the server.
- * @param processingTimestamp Time submitted to server.
- */
- public void setProcessingTimestamp(Date processingTimestamp) {
- this.processingTimestamp = processingTimestamp;
- }
-
- /**
- * Start the clock on processing times - this should be called when the query
- * hits the QueryService or SubscriptionService.
- */
- public void markProcessingStart() {
- setProcessingTimestamp(new Date());
- }
-
public boolean useResultSetCache() {
//not use caching when there is a txn
return useResultSetCache
Copied: trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,175 @@
+/*
+ * 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.dqp.message;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * <p>This class represents an identifier for a request. However, there are some
+ * differences in what constitutes "uniqueness" for a given RequestID that
+ * is based on context (where the id is used). The RequestID has 2 parts:
+ * connectionID, and executionIDFor the purposes of the RequestID, the combined
+ * representation is "connectionID.executionID" - this implies a scoping
+ * for the name parts. The connectionID specifies a particular connection that
+ * is making requests. Each connection generates a unique executionID for each
+ * request execution, so the executionID is only unique in the context of a
+ * connectionID. </p>
+ *
+ * <p>When this class is used between client and server, the connectionID is implied
+ * and thus only the executionID part will be used. The server will qualify the
+ * executionID with a connectionID when it reaches the server. </p>
+ *
+ * <p>RequestIDs are immutable so no setters exist. This allows hashcodes to be
+ * pre-computed for faster comparison in equals.</p>
+ */
+public class RequestID implements Externalizable {
+
+ static final long serialVersionUID = -2888539138291776071L;
+
+ public static final String NO_CONNECTION_STR = "C"; //$NON-NLS-1$
+ private static final String SEPARATOR = "."; //$NON-NLS-1$
+
+ // Basic state
+ private String connectionID;
+ private long executionID;
+
+ // Derived state
+ private String combinedID;
+ private int hash;
+
+ /**
+ * Necessary for implementing Externalizable
+ */
+ public RequestID() {
+ }
+
+ /**
+ * Create a RequestID using all of the ID parts.
+ * @param connectionID Identifies a connection, may be null
+ * @param executionID Identifies an execution, cannot be null
+ */
+ public RequestID(String connectionID, long executionID) {
+ this.connectionID = connectionID;
+ this.executionID = executionID;
+
+ createCombinedID();
+ computeHashCode();
+ }
+
+ public RequestID(long connectionID, long executionID) {
+ this.connectionID = String.valueOf(connectionID);
+ this.executionID = executionID;
+
+ createCombinedID();
+ computeHashCode();
+ }
+
+ /**
+ * Create a RequestID for an execution where the connection is
+ * not specified.
+ * @param executionID Identifies an execution, cannot be null
+ */
+ public RequestID(long executionID) {
+ this(null, executionID);
+ }
+
+
+ /**
+ * Return connectionID, may be null if connection has not been specified.
+ * @return Connection ID, may be null
+ */
+ public String getConnectionID() {
+ return this.connectionID;
+ }
+
+ /**
+ * Return executionID, which identifies a per-connection execution.
+ * @return Execution ID
+ */
+ public long getExecutionID() {
+ return this.executionID;
+ }
+
+ /**
+ * Create a unique combined ID string from the RequestID parts.
+ */
+ private void createCombinedID() {
+ StringBuffer combinedStr = new StringBuffer();
+ if(this.connectionID != null) {
+ combinedStr.append(this.connectionID);
+ } else {
+ combinedStr.append(NO_CONNECTION_STR);
+ }
+ combinedStr.append(SEPARATOR);
+ combinedStr.append(this.executionID);
+
+ this.combinedID = combinedStr.toString();
+ }
+
+ private void computeHashCode() {
+ this.hash = combinedID.hashCode();
+ }
+
+ public int hashCode() {
+ return this.hash;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this) {
+ return true;
+ } else if(obj == null || !(obj instanceof RequestID) || obj.hashCode() != this.hashCode()) {
+ return false;
+ } else {
+ return this.toString().equals(obj.toString());
+ }
+ }
+
+ /**
+ * Return a combined string for the ID.
+ */
+ public String toString() {
+ return this.combinedID;
+ }
+
+ /**
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ connectionID = (String)in.readObject();
+ executionID = in.readLong();
+
+ createCombinedID();
+ computeHashCode();
+ }
+
+ /**
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(connectionID);
+ out.writeLong(executionID);
+ }
+}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,24 +24,18 @@
import java.util.Collection;
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
-import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.platform.security.api.AuthorizationPolicy;
import com.metamatrix.platform.security.api.AuthorizationRealm;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.eval.SecurityFunctionEvaluator;
/**
* This service provides a means to check whether a connection is authorized to access
* various data resources.
*/
-public interface AuthorizationService extends ApplicationService, SecurityFunctionEvaluator {
+public interface AuthorizationService extends SecurityFunctionEvaluator {
public static final int ACTION_READ = 0;
public static final int ACTION_CREATE = 1;
@@ -60,14 +54,13 @@
/**
* Determine which of a set of resources a connection does not have permission to
* perform the specified action.
- * @param connectionID Connection ID identifying the connection (and thus the user credentials)
* @param action Action connection wishes to perform
* @param resources Resources the connection wishes to perform the action on, Collection of String
* @param context Auditing context
* @return Collection Subset of resources
* @throws MetaMatrixComponentException If an error occurs in the service while checking resources
*/
- Collection getInaccessibleResources(String connectionID, int action, Collection resources, int context) throws MetaMatrixComponentException;
+ Collection getInaccessibleResources(int action, Collection resources, int context) throws MetaMatrixComponentException;
/**
* Determine whether entitlements checking is enabled on the server.
@@ -75,24 +68,9 @@
*/
boolean checkingEntitlements();
- boolean isCallerInRole(SessionToken session, String roleName ) throws AuthorizationMgmtException;
+ boolean isCallerInRole(String roleName ) throws AuthorizationMgmtException;
-
/**
- * Returns a Collection of String names of MetaMatrix roles to which the
- * given principal is assigned.
- * @param caller the session token of the principal that is attempting to access the roles.
- * @param principal <code>MetaMatrixPrincipalName</code> for which roles are sought
- * @return The <code>Collection</code> of role names the principal is assigned.
- * @throws InvalidSessionException if the administrative session is invalid
- * @throws MetaMatrixSecurityException if there is a problem internally with the MembershipService
- * @throws AuthorizationException if administrator does not have the authority to see the requested information
- * @throws ComponentNotFoundException if a component required by this method could not be found within the server
- */
- Collection<String> getRoleNamesForPrincipal(MetaMatrixPrincipalName principal)
- throws InvalidSessionException, AuthorizationException, AuthorizationMgmtException;
-
- /**
* Returns a <code>Collection</code> of <code>AuthorizationPolicy</code>s
* that have <code>AuthorizationPermission</code>s in the given <code>AuthorizationRealm</code>.<br>
* <strong>NOTE:</strong> It is the responsibility of the caller to determine
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,15 +24,17 @@
import org.teiid.dqp.internal.cache.DQPContextCache;
-import com.metamatrix.common.application.ApplicationService;
+import com.metamatrix.cache.CacheFactory;
import com.metamatrix.common.buffer.BufferManager;
/**
*/
-public interface BufferService extends ApplicationService {
+public interface BufferService {
BufferManager getBufferManager();
DQPContextCache getContextCache();
+
+ CacheFactory getCacheFactory();
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -61,7 +61,7 @@
String applicationName;
String principal;
String vdbName;
- String vdbVersion;
+ int vdbVersion;
// RequestInfo
String requestID;
@@ -82,7 +82,7 @@
String applicationName,
String principal,
String vdbName,
- String vdbVersion,
+ int vdbVersion,
String sql) {
// userCommandStart
this.type = USER_COMMAND_START;
@@ -102,7 +102,7 @@
String sessionID,
String principal,
String vdbName,
- String vdbVersion,
+ int vdbVersion,
int finalRowCount,
boolean isCancelled,
boolean errorOccurred) {
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,392 +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.dqp.service;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-import java.util.Properties;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.ClassLoaderManager;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.config.api.ExtensionModule;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.platform.security.api.service.SessionListener;
-
-
-
-/**
- * Configuration Service, this is responsible for all the configuration
- * for other services and also DQP configuration.
- * @since 4.3
- */
-public interface ConfigurationService extends ApplicationService, ClassLoaderManager {
- public static final String NEXT_VDB_VERSION = "NEXT_VDB_VERSION"; //$NON-NLS-1$
- public static final String USER_DEFINED_FUNCTION_MODEL = "FunctionDefinitions.xmi"; //$NON-NLS-1$
- /**
- * Get the VDB contents for the "System.VDB"
- * @return URL - URL to System.vdb file; null if one not found
- */
- public URL getSystemVdb();
-
- public File getWorkDir();
-
- /**
- * Get DQP properties
- * @return Properties - properties
- * @throws MetaMatrixComponentException
- */
- public Properties getSystemProperties();
-
- /**
- * Set System property (Contents of ServerConfig.xml file)
- * @param key
- * @param value
- * @throws MetaMatrixComponentException
- */
- public void setSystemProperty(String key, String value) throws MetaMatrixComponentException;
-
- /**
- * Set several System properties (Contents of ServerConfig.xml file).
- * Any properties not specified will remain unchanged.
- *
- * @param properties The properties to set.
- * @throws MetaMatrixComponentException
- */
- public void updateSystemProperties(Properties properties) throws MetaMatrixComponentException;
-
-
-
- /**
- * Get the system Configuration object loaded from the configuration object, this is currently
- * only needed to support the exportConfiguration admin call.
- * @return
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public ConfigurationModelContainer getSystemConfiguration() throws MetaMatrixComponentException;
-
-
- /**
- * Get the user defined functions file name
- * @return URL - URL to the User defined file; null if one not defined
- */
- public URL getUDFFile();
-
- /**
- * Save the given vdb file into underlying persistent mechanism used by
- * this configuration service
- * @param vdb - VDB to be saved
- * @param version - Version to be saved as; when used text "NEXT_VDB_VERSION" as version
- * save as the next available version.
- * @return
- * @throws MetaMatrixComponentException
- */
- public void saveVDB(VDBArchive vdb, String version) throws MetaMatrixComponentException;
-
- /**
- * Add the VDB to the configuration
- * @param vdb - vdb to be added
- * @param replaceBindings - flag which specifies action to be taken in case there are conflicts in
- * connector bindings.
- * @return - added VDB instance.
- * @throws MetaMatrixComponentException
- */
- public VDBArchive addVDB(VDBArchive vdb, boolean replaceBindings) throws MetaMatrixComponentException;
-
- /**
- * Delete the VDB from the underlying persistent mechanism used by this
- * configuration service
- * @param vdbName - Name of the VDB
- * @param vdbVersion - VDB version
- * @throws MetaMatrixComponentException
- */
- public void deleteVDB(VDBArchive vdb) throws MetaMatrixComponentException;
-
- /**
- * Assign a connector binding to the Model
- * @param vdbName - Name of the VDB
- * @param version - version of the VDB
- * @param modelName - Model Name
- * @param bindings - bindings to be assigned
- * @return modified VDB
- */
- public void assignConnectorBinding(String vdbName, String version, String modelName, ConnectorBinding[] bindings) throws MetaMatrixComponentException;
-
- /**
- * Get the list of VDB files available with the Configuration Service, this includes
- * all status (active, inactive)
- * @param vdbName - Name of the VDB
- * @param vdbVersio - VDB version.
- * @return VDBArchive
- * @throws MetaMatrixComponentException
- */
- public VDBArchive getVDB(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-
- /**
- * Get a list of available VDBS from the configuration
- * @return list of {@link com.metamatrix.common.vdb.api.VDBArchive}
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public List<VDBArchive> getVDBs() throws MetaMatrixComponentException;
-
- /**
- * Add the connector binding to the persistent store
- * @param connectorBindingName - Connector Binding Name
- * @param binding - Connector binding to Add
- * @param replace - flag to replace in case a duplicate found.
- */
- public ConnectorBinding addConnectorBinding(String connectorBindingName, ConnectorBinding binding, boolean replace)
- throws MetaMatrixComponentException;
-
- /**
- * Delete the connector binding from the persistent store
- * @param connectorBindingName - Connector Binding Name
- */
- public void deleteConnectorBinding(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * get the connector binding from the persistent store
- * @param connectorBindingName - Connector Binding Name
- * @return Connector binding by the name given.
- */
- public ConnectorBinding getConnectorBinding(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * Get the default properties for the Connector type
- * @param type
- * @return properties
- */
- public Properties getDefaultProperties(ConnectorBindingType type);
-
- /**
- * Update the Connector Binding, the assumption here that we kept the name same
- * @param binding - Connector Binding to be modified
- * @return modified connector; usually same referenced object.
- */
- public ConnectorBinding updateConnectorBinding(ConnectorBinding binding)
- throws MetaMatrixComponentException;
-
- /**
- * Get the list of connector bindings available in the configuration.
- * @return list of {@link com.metamatrix.common.config.api.ConnectorBinding}
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public List<ConnectorBinding> getConnectorBindings() throws MetaMatrixComponentException;
-
-
- /**
- * Get Component type for the given id
- * @param id
- * @return
- * @throws MetaMatrixComponentException
- */
- public ConnectorBindingType getConnectorType(String connectorType)
- throws MetaMatrixComponentException;
-
- /**
- * Add the Given component type to the persistent store
- * @param type
- * @throws MetaMatrixComponentException
- */
- public void saveConnectorType(ConnectorBindingType type)
- throws MetaMatrixComponentException;
-
- /**
- * Delete the Given component type to the persistent store
- * @param connectorType - Name of the connector Type
- * @throws MetaMatrixComponentException
- */
- public void deleteConnectorType(String connectorType)
- throws MetaMatrixComponentException;
-
- /**
- * Get list of all the connector types available in the System.
- * @return list of {@link com.metamatrix.common.config.api.ComponentType}
- * @throws MetaMatrixComponentException
- */
- public List<ComponentType> getConnectorTypes()
- throws MetaMatrixComponentException;
-
- /**
- * Retun the context class path to be used by all the extension modules
- * to use. if one not specified a default must be supplied. Usally this
- * is directory where all the extension jars are stored or a URL
- * @return String URL - url to extension path; null if extensions are not used
- * @since 4.3
- */
- public URL[] getExtensionPath();
-
- /**
- * Get the list of extension modules available in the store
- * @return list of Extension Modules {@link com.metamatrix.common.config.api.ExtensionModule}
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public List<ExtensionModule> getExtensionModules() throws MetaMatrixComponentException;
-
- /**
- * Get the extension module by the given identifier
- * @param extModuleName - Module name
- * @return ExtensionModule; null if not found
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public ExtensionModule getExtensionModule(String extModuleName)
- throws MetaMatrixComponentException;
-
- /**
- * Save the given extension module
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public void saveExtensionModule(ExtensionModule extModule) throws MetaMatrixComponentException;
-
- /**
- * Delete the extension module from the configuration with name supplied
- * @param extModuleName - extension module name
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public void deleteExtensionModule(String extModuleName)
- throws MetaMatrixComponentException;
-
- /**
- * Client Connection Listener object for the service; This will get notifications
- * about the connections currently available to DQP.
- * @throws MetaMatrixComponentException
- * @since 4.3.2
- */
- public SessionListener getSessionListener();
-
-
- /**
- * Register a listener for the VDB life cycle events, and get notified for
- * when vdb is loded and unloaded
- * @param listener - lister object
- */
- public void register(VDBLifeCycleListener listener);
-
- public void unregister(VDBLifeCycleListener listener);
-
- /**
- * Register a listener for the connector binding life cycle events, and get notified for
- * when connector binding is loded and unloaded
- * @param listener - lister object
- */
- public void register(ConnectorBindingLifeCycleListener listener);
-
- public void unregister(ConnectorBindingLifeCycleListener listener);
-
- /**
- * Gets the reference URL to the Configuration File for the DQP.
- * @return URL to configuration file; null otherwise
- * @since 4.4
- */
- public URL getConfigFile();
-
-
- /**
- * Use the extension classpath defined in the connector bindins and load jars in
- * different class loader or in the same class loader as calling code
- * @return true - to load different class loader, false otherwise
- */
- public boolean useExtensionClasspath();
-
-
- /**
- * Get path(s) for VDB(s) that are availble from the configuration to the DQP
- * engine.
- * @return URLs to the resources.
- */
- public URL[] getVDBLocations();
-
-
- /**
- * Use disk for buffering for result set management during the processing
- * @return true if yes to use buffering; false otherwise
- */
- public boolean useDiskBuffering();
-
- /**
- * Get the directory to use for the disk buffering
- * @return must a return a location
- */
- public File getDiskBufferDirectory();
-
-
- /**
- * Size of Memory in MB allocated to be used by the Resultset Management before
- * disk buffering kicks in.
- * @return must a return a location
- */
- public String getBufferMemorySize();
-
- /**
- * Return some identifier which uniquely identifies the DQP. Usually this
- * is name given to this process
- * @return unique number for DQP in a given JVM
- */
- public String getProcessName();
-
-
- /**
- * Gets the processor batch size
- * @return
- * @since 4.3
- */
- String getProcessorBatchSize();
- /**
- * Gets the connector batch size
- * @return
- * @since 4.3
- */
- String getConnectorBatchSize();
-
- /**
- * Unload the User defined functions file.
- * @throws MetaMatrixComponentException
- */
- void unloadUDF() throws MetaMatrixComponentException;
-
- /**
- * Load the UDF function model
- * @throws MetaMatrixComponentException
- */
- void loadUDF() throws MetaMatrixComponentException;
-
- void clearClassLoaderCache() throws MetaMatrixComponentException;
-
- boolean isFullyConfiguredVDB(VDBArchive vdb) throws MetaMatrixComponentException;
-
- String getClusterName();
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,101 +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.dqp.service;
-
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
-import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-
-
-/**
- * Defines constants used for naming DQP services.
- */
-public interface DQPServiceNames {
-
- /** Buffer service - provides access to buffer management */
- public static final String BUFFER_SERVICE = "dqp.buffer"; //$NON-NLS-1$
-
- /** Metadata service - provides acecss to runtime metadata */
- public static final String METADATA_SERVICE = "dqp.metadata"; //$NON-NLS-1$
-
- /** Data service - provides access to data via connectors */
- public static final String DATA_SERVICE = "dqp.data"; //$NON-NLS-1$
-
- /** Authorization service - provides access to entitlements info */
- public static final String AUTHORIZATION_SERVICE = "dqp.authorization"; //$NON-NLS-1$
-
- /** VDB service - provides access to vdb information */
- public static final String VDB_SERVICE = "dqp.vdb"; //$NON-NLS-1$
-
- /** Transaction service - provides access to MMTtransactionManager */
- public static final String TRANSACTION_SERVICE = "dqp.transaction"; //$NON-NLS-1$
-
- /** Configuration Service - provides access to Configuration*/
- public static final String CONFIGURATION_SERVICE = "dqp.configuration"; //$NON-NLS-1$
-
- public static final String REGISTRY_SERVICE = "platform.registry"; //$NON-NLS-1$
-
- public static final String SESSION_SERVICE = "dqp.session"; //$NON-NLS-1$
-
- public static final String MEMBERSHIP_SERVICE = "dqp.membership"; //$NON-NLS-1$
-
-
- /**
- * Array of all services a DQP may use.
- */
- public static final String[] ALL_SERVICES = new String[] {
- CONFIGURATION_SERVICE,
- BUFFER_SERVICE,
- AUTHORIZATION_SERVICE,
- TRANSACTION_SERVICE,
- VDB_SERVICE,
- METADATA_SERVICE,
- DATA_SERVICE,
- SESSION_SERVICE,
- MEMBERSHIP_SERVICE
- };
-
- public static final Class[] ALL_SERVICE_CLASSES = new Class[] {
- ConfigurationService.class,
- BufferService.class,
- AuthorizationService.class,
- TransactionService.class,
- VDBService.class,
- MetadataService.class,
- DataService.class,
- SessionServiceInterface.class,
- MembershipServiceInterface.class
- };
-
- public static final String[] SERVICE_LOGGING_CONTEXT = new String[] {
- null,
- null,
- null,
- LogConstants.CTX_TXN_LOG,
- null,
- null,
- null,
- null,
- null
- };
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,171 +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.dqp.service;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-
-import org.teiid.adminapi.ConnectionPool;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- * Defines interface for management of the Data Services, i.e Connectors with
- * which all the physical data is accessed.
- *
- */
-public interface DataService extends ApplicationService {
-
- /**
- * Select a connector to use for the given connector binding.
- * @param connectorBindingName Connector binding identifier
- * @return ConnectorID identifying a connector instance
- */
- ConnectorID selectConnector(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * Execute the given request on a <code>Connector</code>.
- * @param request
- * @return
- */
- void executeRequest(AtomicRequestMessage request, ConnectorID connector, ResultsReceiver<AtomicResultsMessage> resultListener)
- throws MetaMatrixComponentException;
-
- void cancelRequest(AtomicRequestID request, ConnectorID connectorId) throws MetaMatrixComponentException;
-
- void closeRequest(AtomicRequestID request, ConnectorID connectorId) throws MetaMatrixComponentException;
-
- void requestBatch(AtomicRequestID request, ConnectorID connectorId) throws MetaMatrixComponentException;
-
- /**
- * Find the capabilities of this source.
- * @param request Original request message, used to extract security information
- * @param connector Connector to retrieve capabilities from
- * @return All capability information as key-value pairs
- */
- SourceCapabilities getCapabilities(RequestMessage request, DQPWorkContext dqpWorkContext, String modelName)
- throws MetaMatrixComponentException;
-
- /**
- * Return the metadata for a given connector
- * @param vdbName
- * @param vdbVersion
- * @param modelName
- * @param importProperties
- * @return
- * @throws MetaMatrixComponentException
- */
- MetadataStore getConnectorMetadata(String vdbName, String vdbVersion, String modelName, Properties importProperties) throws MetaMatrixComponentException;
-
- /**
- * Start the Connector Binding by the name given, if it is already added and not srarted.
- * @param connectorBindingName
- * @throws ApplicationLifecycleException
- * @throws ComponentNotFoundException
- * @since 4.3
- */
- void startConnectorBinding(String connectorBindingName)
- throws ApplicationLifecycleException, MetaMatrixComponentException;
-
- /**
- * Stop the Connector Binding by the given name
- * @param connectorBindingName
- * @throws ApplicationLifecycleException
- * @throws ComponentNotFoundException
- * @since 4.3
- */
- void stopConnectorBinding(String connectorBindingName)
- throws ApplicationLifecycleException, MetaMatrixComponentException;
-
- /**
- * Get the list of connector bindings deployed in the system.
- * @return list {@link com.metamatrix.common.config.api.ConnectorBinding}
- * @throws ComponentNotFoundException
- * @since 4.3
- */
- List getConnectorBindings() throws MetaMatrixComponentException;
-
-
- /**
- * Get the connector binding specifed the name
- * @return ConnectorBinding
- * @throws ComponentNotFoundException
- * @since 4.3
- */
- ConnectorBinding getConnectorBinding(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * Get the State of the connector binding name
- * @return {@link ConnectorStatus}
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- ConnectorStatus getConnectorBindingState(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * Get connector bindings queue statistics
- * @param connectorBindingName - Name of the connector binding
- * @return a list of {@link com.metamatrix.common.queue.WorkerPoolStats}
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- Collection getConnectorBindingStatistics(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * Clear any caches for the connector binding. Incase of the JDBC Connector
- * clear the result set cache.
- * @param connectorBindingName
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- void clearConnectorBindingCache(String connectorBindingName)
- throws MetaMatrixComponentException;
-
- /**
- * Get connection pool statistics for connector binding
- * @param connectorBindingName - Name of the connector binding
- * @return a list of {@link com.metamatrix.admin.objects.ConnectionPoolStatsImpl}
- * @throws MetaMatrixComponentException
- * @since 6.1
- */
- Collection<? extends ConnectionPool> getConnectionPoolStatistics(String connectorBindingName)
- throws MetaMatrixComponentException;
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.dqp.service;
-
-import java.util.Map;
-
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.metadata.CompositeMetadataStore;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-/**
- */
-public interface MetadataService extends ApplicationService {
-
- QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-
- CompositeMetadataStore getMetadataObjectSource(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-
- Map<String, Datatype> getBuiltinDatatypes() throws MetaMatrixComponentException;
-
-}
Copied: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,117 @@
+/*
+ * 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.dqp.service;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.ExecutionContext;
+
+public class TransactionContext extends ExecutionContext implements Serializable{
+
+ private static final long serialVersionUID = -8689401273499649058L;
+
+ public enum Scope {
+ BLOCK,
+ GLOBAL,
+ LOCAL,
+ NONE,
+ REQUEST
+ }
+
+ private String threadId;
+ private Scope transactionType = Scope.NONE;
+ private long creationTime;
+ private boolean rollback = false;
+ private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
+ private Map<String, AtomicInteger> txnSources = Collections.synchronizedMap(new HashMap<String, AtomicInteger>());
+
+ public boolean isInTransaction() {
+ return (getXid() != null && this.txnSources.size() > 0);
+ }
+
+ public long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(long time) {
+ this.creationTime = time;
+ }
+
+ public void setTransactionType(Scope transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public Scope getTransactionType() {
+ return transactionType;
+ }
+
+ public void setThreadId(String threadId) {
+ this.threadId = threadId;
+ }
+
+ public String getThreadId() {
+ return threadId;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ this.buildString(sb);
+ return sb.toString();
+ }
+
+ private void buildString(StringBuffer sb) {
+ sb.append("xid: ").append(getXid()); //$NON-NLS-1$
+ }
+
+ public void setRollbackOnly() {
+ this.rollback = true;
+ }
+
+ public boolean shouldRollback() {
+ return this.rollback;
+ }
+
+ public Set<String> getSuspendedBy() {
+ return this.suspendedBy;
+ }
+
+ public void incrementPartcipatingSourceCount(String source) {
+ AtomicInteger count = txnSources.get(source);
+ if (count == null) {
+ txnSources.put(source, new AtomicInteger(1));
+ }
+ else {
+ count.incrementAndGet();
+ }
+ }
+
+ public boolean isOnePhase() {
+ return this.txnSources.size() == 1;
+ }
+}
\ No newline at end of file
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,95 +26,53 @@
import java.util.Collection;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.Transaction;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
-import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
/**
*/
-public interface TransactionService extends ApplicationService {
- public static final String TRANSACTIONS_ENABLED = "xa.enabled"; //$NON-NLS-1$
- public static final String MAX_TIMEOUT = "xa.max_timeout"; //$NON-NLS-1$
- public static final String TXN_STORE_DIR = "xa.txnstore_dir"; //$NON-NLS-1$
- public static final String TXN_STATUS_PORT = "xa.txnstatus_port"; //$NON-NLS-1$
- public static final String TXN_ENABLE_RECOVERY = "xa.enable_recovery"; //$NON-NLS-1$
+public interface TransactionService {
- public static final String PROCESSNAME = DQPEmbeddedProperties.PROCESSNAME;
-
- public static final String DEFAULT_TXN_MGR_LOG_DIR = "txnlog"; //$NON-NLS-1$
- public static final String DEFAULT_TXN_TIMEOUT = "120"; //$NON-NLS-1$ //2 mins
- public static final String DEFAULT_TXN_STATUS_PORT = "0"; //$NON-NLS-1$
-
- TransactionManager getTransactionManager();
-
// processor level methods
- TransactionContext start(TransactionContext context) throws XATransactionException, SystemException;
+ TransactionContext start(TransactionContext context) throws XATransactionException;
- TransactionContext commit(TransactionContext context) throws XATransactionException, SystemException;
+ TransactionContext commit(TransactionContext context) throws XATransactionException;
- TransactionContext rollback(TransactionContext context) throws XATransactionException, SystemException;
+ TransactionContext rollback(TransactionContext context) throws XATransactionException;
TransactionContext getOrCreateTransactionContext(String threadId);
// local transaction methods
- TransactionContext begin(String threadId) throws XATransactionException, SystemException;
+ TransactionContext begin(String threadId) throws XATransactionException;
- void commit(String threadId) throws XATransactionException, SystemException;
+ void commit(String threadId) throws XATransactionException;
- void rollback(String threadId) throws XATransactionException, SystemException;
+ void rollback(String threadId) throws XATransactionException;
- void cancelTransactions(String threadId, boolean requestOnly) throws InvalidTransactionException, SystemException;
+ void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException;
// global transaction methods
- int prepare(final String threadId,
- MMXid xid) throws XATransactionException;
+ int prepare(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException;
- void commit(final String threadId,
- MMXid xid,
- boolean onePhase) throws XATransactionException;
+ void commit(final String threadId, MMXid xid, boolean onePhase, boolean singleTM) throws XATransactionException;
- void rollback(final String threadId,
- MMXid xid) throws XATransactionException;
+ void rollback(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException;
- Xid[] recover(int flag) throws XATransactionException;
+ Xid[] recover(int flag, boolean singleTM) throws XATransactionException;
- void forget(final String threadId,
- MMXid xid) throws XATransactionException;
+ void forget(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException;
- void start(final String threadId,
- MMXid xid,
- int flags,
- int timeout) throws XATransactionException;
+ void start(final String threadId, MMXid xid, int flags, int timeout, boolean singleTM) throws XATransactionException;
- void end(final String threadId,
- MMXid xid,
- int flags) throws XATransactionException;
+ void end(final String threadId, MMXid xid, int flags, boolean singleTM) throws XATransactionException;
// management methods
Collection<Transaction> getTransactions();
- void terminateTransaction(Xid transactionId) throws AdminException;
-
- void terminateTransaction(String transactionId, String sessionId) throws AdminException;
-
- // Teiid managed XA
- TransactionContext enlist(TransactionContext context,
- XAResource resource) throws XATransactionException;
-
- void registerRecoverySource(String name, XAConnectionSource resource);
-
- void removeRecoverySource(String name);
-
+ void terminateTransaction(String transactionId) throws AdminException;
}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,111 +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.dqp.service;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.vdb.api.VDBArchive;
-
-/**
- * This interface defines methods which are specific to dealing with VDBs
- * and their management in a server/dqp.
- */
-public interface VDBService extends ApplicationService {
-
- /**
- * Get connector bindings for a particular vdb model. For most models, there will be exactly one. For
- * multi-source models, there may be more than one. The {@link VDBConfiguration#getMultiSourceModels(String, String)}
- * method can be used to determine which models are multi-source models.
- * @param vdbName VDB name
- * @param vdbVersion VDB version
- * @param modelName Model name
- * @return list of {@link java.lang.String} names of connectors
- */
- public List<String> getConnectorBindingNames(String vdbName, String vdbVersion, String modelName)
- throws MetaMatrixComponentException;
-
-
- /**
- * Get model visibility
- * @param vdbName VDB name
- * @param vdbVersion VDB version
- * @param modelName The name of the model
- * @return Visibility constant, as defined in this class
- */
- public int getModelVisibility(String vdbName, String vdbVersion, String modelName)
- throws MetaMatrixComponentException;
-
- /**
- * Get visibility of the file at the given path in the vdb.
- * @param vdbName VDB name
- * @param vdbVersion VDB version
- * @param pathInVDB The path to the model in the VDB
- * @return Visibility constant, as defined in this class
- */
- public int getFileVisibility(String vdbName, String vdbVersion, String pathInVDB)
- throws MetaMatrixComponentException;
-
- /**
- * Get all multi-source model names (models that can be bound to multiple connector bindings) for this VDB
- * name and version.
- * @param vdbName VDB name
- * @param vdbVersion VDB version
- * @return List<String> of model names that are multi-source models.
- * @since 4.2
- */
- public List getMultiSourceModels(String vdbName, String vdbVersion)
- throws MetaMatrixComponentException;
-
- /**
- * Get the list of VDBs available from the service
- * @return List of {@link com.metamatrix.metadata.runtime.admin.vdb.VDBDefn}
- * @since 4.3
- */
- public List<VDBArchive> getAvailableVDBs()
- throws MetaMatrixComponentException;
-
- /**
- * Change the status of the VDB
- * @param vdbName - Name of the VDB
- * @param vdbVersion - Version of the VDB
- * @param status -
- * @since 4.3
- */
- public void changeVDBStatus(String vdbName, String vdbVersion, int status)
- throws ApplicationLifecycleException, MetaMatrixComponentException;
-
- // to be removed later..
- public String getConnectorName(String connectorBindingID) throws MetaMatrixComponentException;
-
- /**
- *
- * @param vdbName
- * @param vdbVersion may be null to indicate latest/default
- * @return
- * @throws MetaMatrixComponentException
- */
- public VDBArchive getVDB(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,12 @@
package com.metamatrix.dqp.util;
+import org.teiid.connector.basic.DefaultConnectorLogger;
+
public interface LogConstants {
// add the new contexts to the Log4JUtil.java class, for configuration purpose
public static final String CTX_DQP = "DQP"; //$NON-NLS-1$
- public static final String CTX_CONNECTOR = "CONNECTOR"; //$NON-NLS-1$
+ public static final String CTX_CONNECTOR = DefaultConnectorLogger.CTX_CONNECTOR;
public static final String CTX_BUFFER_MGR = "BUFFER_MGR"; //$NON-NLS-1$
public static final String CTX_STORAGE_MGR = "STORAGE_MGR"; //$NON-NLS-1$
public static final String CTX_TXN_LOG = "TXN_LOG"; //$NON-NLS-1$
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,156 +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.platform.security.api;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * This class represents an immutable informational object describing
- * the attributes of a unique MetaMatrix session within a given MetaMatrix System.
- */
-public class MetaMatrixSessionInfo implements Serializable, Cloneable {
-
- public final static long serialVersionUID = -9120197553960136239L;
-
- private SessionToken sessionToken; // immutable
- private long lastPingTime;
- private long timeCreated;
- private String applicationName;
- private Properties productInfo;
- private String clientIp;
- private String clientHostname;
- private Serializable trustedToken;
-
- /**
- * Master constructor, allows a MetaMatrixSessionInfo to be created with
- * any state and any timestamps.
- */
- public MetaMatrixSessionInfo(MetaMatrixSessionID sessionID, String userName, long timeCreated, String applicationName, Properties productInfo, String clientIp, String clientHostname){
- this.timeCreated = timeCreated;
- this.lastPingTime = timeCreated;
- this.applicationName = applicationName;
- this.sessionToken = new SessionToken(sessionID, userName);
- this.productInfo = productInfo;
- this.clientIp = clientIp;
- this.clientHostname = clientHostname;
- }
-
- public MetaMatrixSessionID getSessionID() {
- return this.sessionToken.getSessionID();
- }
-
- public String getUserName() {
- return this.sessionToken.getUsername();
- }
-
- public String getApplicationName() {
- return this.applicationName;
- }
-
- public long getTimeCreated() {
- return this.timeCreated;
- }
-
- /**
- * Get the time the server was last pinged by this session.
- * Note that the session's "last ping time" will only be acurate
- * if the session is in the ACTIVE state.
- * @return The time the server was last pinged by this session.
- */
- public long getLastPingTime() {
- return lastPingTime;
- }
-
- /**
- * Used <i><b>ONLY</b></i> by the session service to set the
- * time this session last initiated a server ping.
- * @param lastPingTime The last time this session pinged the server.
- */
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
- public SessionToken getSessionToken(){
- return this.sessionToken;
- }
-
- /**
- * Return a cloned instance of this object.
- * @return the object that is the clone of this instance.
- */
- public Object clone() {
- try {
- // Everything is immutable, so bit-wise copy (of references) is okay!
- return super.clone();
- } catch ( CloneNotSupportedException e ) {
- }
- return null;
- }
-
- /**
- * Returns a string representing the current state of the object.
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append("MetaMatrixSessionInfo[ "); //$NON-NLS-1$
- s.append(this.sessionToken.toString());
- s.append(", "); //$NON-NLS-1$
- s.append("application:"); //$NON-NLS-1$
- s.append(this.applicationName);
- s.append(", created:"); //$NON-NLS-1$
- s.append(this.timeCreated);
- s.append(", last pinged server:"); //$NON-NLS-1$
- s.append(this.lastPingTime);
- s.append("]"); //$NON-NLS-1$
- return s.toString();
- }
-
- /**
- * @return Returns the productInfo.
- * @since 4.3
- */
- public String getProductInfo(String key) {
- return this.productInfo.getProperty(key);
- }
-
- public Properties getProductInfo() {
- return this.productInfo;
- }
-
- public String getClientIp() {
- return clientIp;
- }
-
- public String getClientHostname() {
- return clientHostname;
- }
-
- public void setTrustedToken(Serializable trustedToken) {
- this.trustedToken = trustedToken;
- }
-
- public Serializable getTrustedToken() {
- return trustedToken;
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,63 +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.
- */
-
-/*
- * Date: Feb 11, 2004
- * Time: 9:33:14 AM
- */
-package com.metamatrix.platform.security.api.service;
-
-import java.io.Serializable;
-
-/**
- * Interface AuthenticationToken.
- *
- * <p></p>
- */
-public interface AuthenticationToken extends Serializable {
-
- /**
- * Get the payload token that has been successfully authentcated by a
- * membership domain.
- * @return The successfully authenticated token unmodified.
- */
- Serializable getPayload();
-
- /**
- * Get the <b>exact</b> username of the authenticated user as it
- * is known to the authenticating membership domain.
- * <br>Will be <code>null</code> if the user was <b>not</b>
- * authenticated.
- * @return The username (including case) of this authenticated
- * user exactly as it is known by the authenticating memebership domain.
- * @since 5.0
- */
- String getUserName();
-
- /**
- * Find out whether or not the user was authenticated.
- * @return <code>true</code> iff the membership domain was able
- * to authenticate this user.
- * @since 5.0
- */
- boolean isAuthenticated();
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,81 +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.
- */
-
-/*
- * Date: Dec 1, 2003
- * Time: 1:26:57 PM
- */
-package com.metamatrix.platform.security.api.service;
-
-import java.io.Serializable;
-
-/**
- * FailedAuthenticationToken
- *
- * <p>Marker indicating failed authentication attempt. Membership SPI
- * domain implementations should wrap the <code>Serializable</code> payload
- * in an instance of this class to signify to the Membgership service that
- * the domian failed to authenticate the given payload token.</p>
- *
- * <p>This wrapper class will not be exposed outside of the Mebership framework.</p>
- */
-public final class FailedAuthenticationToken implements AuthenticationToken {
-
- /**
- * FailedAuthenticationToken
- *
- * @param payload The failed authentication token - may be null.
- */
- public FailedAuthenticationToken() {
- }
-
- /**
- * Get the payload token that failed to authentcation by a
- * membership domain.
- *
- * @return The failed authentication token unmodified - may be null.
- */
- public Serializable getPayload() {
- return null;
- }
-
- /**
- * Get the <b>exact</b> username of the authenticated user as it
- * is known to the authenticating membership domain.
- * <p><b>Will be <code>null</code> if the user was <b>not</b>
- * authenticated. </b></p>
- * @return The username (including case) of this authenticated
- * user exactly as it is known by the authenticating memebership domain.
- * @since 5.0
- */
- public String getUserName() {
- return null;
- }
-
- /**
- * The attempt to authenticate the given payload failed.
- * @return <code>false</code> - always.
- */
- public boolean isAuthenticated() {
- return false;
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,117 +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.platform.security.api.service;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Set;
-
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.api.exception.security.InvalidPrincipalException;
-import com.metamatrix.api.exception.security.MembershipServiceException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-
-/**
- * This interface represents the API to the MemberShip Service,
- * and it defines the functionality that is accessible to clients.
- */
-public interface MembershipServiceInterface extends ApplicationService {
- public static String NAME = "MembershipService"; //$NON-NLS-1$
-
- /**
- * The environment property describing both the domain names and their required
- * order of search. Domain names are assumed to be in preferred search order
- * and in the form "A,X,...,D" where A, X and D are domain names.
- * This property is required (there is no default).
- */
- public static final String DOMAIN_ORDER = "membership.DomainOrder"; //$NON-NLS-1$
- /**
- * The environment property name for the class that is to be used for the names of the domains.
- * This property is required (there is no default).
- */
- public static final String DOMAIN_NAME = "domainName"; //$NON-NLS-1$
-
- public static final String DEFAULT_ADMIN_USERNAME = "admin"; //$NON-NLS-1$
-
- public static final String ADMIN_PASSWORD = "membership.superUserPassword"; //$NON-NLS-1$
- public static final String ADMIN_USERNAME = "membership.superUser"; //$NON-NLS-1$
- public static final String DOMAIN_ACTIVE = "activate"; //$NON-NLS-1$
- public static final String ADMIN_HOSTS = "membership.allowedHosts"; //$NON-NLS-1$
- public static final String SECURITY_ENABLED = "membership.enabled"; //$NON-NLS-1$
-
- public static final String DOMAIN_PROPERTIES = "propertiesFile"; //$NON-NLS-1$
-
- public static final String AT = "@"; //$NON-NLS-1$
-
- /**
- * Authenticate a user with the specified username and credential
- * for use with the specified application. The application name may also
- * be used by the Membership Service to determine the appropriate authentication
- * mechanism.
- * @param username the username that is to be authenticated
- * @param credential the credential provided by the user that is to be used
- * to authenticate the user for the principal name
- * @param trustePayload
- * @param applicationName the name of the application for which the user
- * is authenticating
- * @return true if the specified credentials properly authenticates for
- * the application the user with the specified username and application
- * @throws MetaMatrixSecurityException if there is an error within this
- * service or during communicating with the underlying service provider
- */
- AuthenticationToken authenticateUser(String username, Credentials credential, Serializable trustePayload, String applicationName)
- throws MembershipServiceException;
-
- /**
- * Obtain the principal object that is representative of the user with the specified username.
- *
- * all names should be domain qualified.
- */
- MetaMatrixPrincipal getPrincipal(MetaMatrixPrincipalName principal)
- throws MembershipServiceException, InvalidPrincipalException;
-
- /**
- * Obtain the collection of groups to which this user belongs
- *
- * The username should be fully qualified
- */
- Set<String> getGroupsForUser(String username)
- throws MembershipServiceException, InvalidPrincipalException;
-
- /**
- * Obtain the collection of group names.
- */
- Set<String> getGroupNames() throws MembershipServiceException;
-
- List<String> getDomainNames() throws MembershipServiceException;
-
- Set<String> getGroupsForDomain(String domainName) throws MembershipServiceException;
-
- boolean isSuperUser(String username) throws MembershipServiceException;
-
- boolean isSecurityEnabled() throws MembershipServiceException;
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,32 +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.platform.security.api.service;
-
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
-public interface SessionListener {
-
- void sessionCreated(MetaMatrixSessionInfo info);
-
- void sessionClosed(MetaMatrixSessionInfo info);
-}
Copied: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,148 @@
+/*
+ * 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.platform.security.api.service;
+
+import java.util.Collection;
+import java.util.Properties;
+
+import javax.security.auth.login.LoginException;
+
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.dqp.internal.process.DQPCore;
+
+import com.metamatrix.admin.api.exception.security.InvalidSessionException;
+import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.platform.security.api.Credentials;
+
+/**
+ * <p>
+ * The session service deals with managing sessions; this involves creating
+ * sessions, closing sessions, terminating sessions, and updating session
+ * state.
+ * </p>
+ * <p>
+ * A session has a timestamp, information about the principal owning the
+ * session, and a "state" indicating whether it is actively in use, in use
+ * but passivated, or has been rendered invalid by being closed or terminated,
+ * or by expiring.
+ * </p>
+ * <p>
+ * Note that this service does <i>not</i> deal with authentication explicitly,
+ * but may use a membership service provider to authenticate some
+ * requests.
+ * </p>
+ */
+public interface SessionService {
+ public static String NAME = "SessionService"; //$NON-NLS-1$
+
+ public static final long DEFAULT_MAX_SESSIONS = 5000;
+ public static final long DEFAULT_SESSION_EXPIRATION = 0;
+
+ public static final String MAX_SESSIONS = "session.maxSessions"; //$NON-NLS-1$
+ public static final String SESSION_EXPIRATION = "session.expirationTimeInMilli"; //$NON-NLS-1$
+
+ /**
+ * Create a session for the given user authenticating against the given <code>Credentials</code>.
+ */
+ public SessionMetadata createSession(String userName,
+ Credentials credentials,
+ String applicationName,
+ Properties properties, boolean admin)
+ throws LoginException, SessionServiceException;
+
+ /**
+ * Closes the specified session.
+ *
+ * @param sessionID The MetaMatrixSessionID identifying user's session
+ * to be closed
+ * @throws InvalidSessionException If sessionID identifies an invalid
+ * session
+ * @throws SessionServiceException
+ */
+ void closeSession(long sessionID) throws InvalidSessionException;
+
+ /**
+ * Terminates the specified session. This is an administrative action.
+ *
+ * @param terminatedSessionID The MetaMatrixSessionID identifying user's session
+ * to be terminated
+ * @param adminSessionID The session id identifying session of administrator
+ * @throws InvalidSessionException If terminatedSessionID identifies an invalid
+ * session
+ * @throws AuthorizationException if the caller denoted by <code>adminSessionID</code>
+ * does not have authority to terminate the <code>terminatedSessionID</code> session
+ * @throws SessionServiceException
+ */
+ boolean terminateSession(long terminatedSessionID, long adminSessionID);
+
+ /**
+ * Get the collection of active user sessions on the system.
+ * @return The collection of MetaMatrixSessionInfo objects of active users on
+ * the system - possibly empty, never null.
+ */
+ Collection<SessionMetadata> getActiveSessions() throws SessionServiceException;
+
+ /**
+ * Get the number of active user sessions on the system.
+ * @return int
+ */
+ int getActiveSessionsCount() throws SessionServiceException;
+
+ /**
+ * This method is intended to verify that the session is valid, and, if
+ * need be, set the session in an active state, ready to be used.
+ * @param sessionID MetaMatrixSessionID representing the session
+ * @return SessionToken object identifying the session
+ * @throws InvalidSessionException If sessionID identifies an invalid
+ * session
+ * @throws SessionServiceException
+ */
+ SessionMetadata validateSession(long sessionID)
+ throws InvalidSessionException, SessionServiceException;
+
+ /**
+ * Get all <code>MetaMatrixSessionID</code>s that are in the ACTIVE state
+ * and currently logged in to a VDB.
+ * @param VDBName The name of the VDB.
+ * @param VDBVersion The version of the VDB.
+ * @throws SessionServiceException when transaction with database fails or unexpected exception happens
+ */
+ Collection<SessionMetadata> getSessionsLoggedInToVDB(String VDBName, int VDBVersion)
+ throws SessionServiceException;
+
+ /**
+ * Periodically called by the client to indicate the client is still alive.
+ *
+ * @param sessionID - identifies the client
+ */
+ public void pingServer(long sessionID) throws InvalidSessionException;
+
+
+ public void setLocalSession(long sessionID);
+
+ SessionMetadata getActiveSession(long sessionID);
+
+ void setDqp(DQPCore dqp);
+
+}
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,161 +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.platform.security.api.service;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Properties;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.MetaMatrixAuthenticationException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
-/**
- * <p>
- * The session service deals with managing sessions; this involves creating
- * sessions, closing sessions, terminating sessions, and updating session
- * state.
- * </p>
- * <p>
- * A session has a timestamp, information about the principal owning the
- * session, and a "state" indicating whether it is actively in use, in use
- * but passivated, or has been rendered invalid by being closed or terminated,
- * or by expiring.
- * </p>
- * <p>
- * Note that this service does <i>not</i> deal with authentication explicitly,
- * but may use a membership service provider to authenticate some
- * requests.
- * </p>
- */
-public interface SessionServiceInterface extends ApplicationService {
- public static String NAME = "SessionService"; //$NON-NLS-1$
-
- public static final String DEFAULT_MAX_SESSIONS = "5000"; //$NON-NLS-1$
- public static final String DEFAULT_SESSION_EXPIRATION = "0"; //$NON-NLS-1$
-
- public static final String MAX_SESSIONS = "session.maxSessions"; //$NON-NLS-1$
- public static final String SESSION_EXPIRATION = "session.expirationTimeInMilli"; //$NON-NLS-1$
-
- /**
- * Create a session for the given user authenticating against the given <code>Credentials</code>.
- */
- public MetaMatrixSessionInfo createSession(String userName,
- Credentials credentials,
- Serializable trustedToken,
- String applicationName,
- Properties properties)
- throws MetaMatrixAuthenticationException, SessionServiceException;
-
- /**
- * Closes the specified session.
- *
- * @param sessionID The MetaMatrixSessionID identifying user's session
- * to be closed
- * @throws InvalidSessionException If sessionID identifies an invalid
- * session
- * @throws SessionServiceException
- */
- void closeSession(MetaMatrixSessionID sessionID) throws InvalidSessionException;
-
- /**
- * Terminates the specified session. This is an administrative action.
- *
- * @param terminatedSessionID The MetaMatrixSessionID identifying user's session
- * to be terminated
- * @param adminSessionID The session id identifying session of administrator
- * @throws InvalidSessionException If terminatedSessionID identifies an invalid
- * session
- * @throws AuthorizationException if the caller denoted by <code>adminSessionID</code>
- * does not have authority to terminate the <code>terminatedSessionID</code> session
- * @throws SessionServiceException
- */
- boolean terminateSession(MetaMatrixSessionID terminatedSessionID, MetaMatrixSessionID adminSessionID);
-
- /**
- * Get the collection of active user sessions on the system.
- * @return The collection of MetaMatrixSessionInfo objects of active users on
- * the system - possibly empty, never null.
- */
- Collection<MetaMatrixSessionInfo> getActiveSessions() throws SessionServiceException;
-
- /**
- * Get the number of active user sessions on the system.
- * @return int
- */
- int getActiveSessionsCount() throws SessionServiceException;
-
- /**
- * Returns a MetaMatrixPrincipal object describing the owner (user) of the
- * indicated session.
- * @param sessionID MetaMatrixSessionID representing the session
- * @return MetaMatrixPrincipal object describing the owner of the
- * indicated session.
- */
- MetaMatrixPrincipal getPrincipal(MetaMatrixSessionID sessionID)
- throws InvalidSessionException, SessionServiceException;
-
- /**
- * This method is intended to verify that the session is valid, and, if
- * need be, set the session in an active state, ready to be used.
- * @param sessionID MetaMatrixSessionID representing the session
- * @return SessionToken object identifying the session
- * @throws InvalidSessionException If sessionID identifies an invalid
- * session
- * @throws SessionServiceException
- */
- MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
- throws InvalidSessionException, SessionServiceException;
-
- /**
- * Get all <code>MetaMatrixSessionID</code>s that are in the ACTIVE state
- * and currently logged in to a VDB.
- * @param VDBName The name of the VDB.
- * @param VDBVersion The version of the VDB.
- * @throws SessionServiceException when transaction with database fails or unexpected exception happens
- */
- Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName, String VDBVersion)
- throws SessionServiceException;
-
- /**
- * Periodically called by the client to indicate the client is still alive.
- *
- * @param sessionID - identifies the client
- */
- public void pingServer(MetaMatrixSessionID sessionID) throws InvalidSessionException;
-
- /**
- * Register a session listener
- * @param listener
- */
- public void register(SessionListener listener);
-
- public void setLocalSession(MetaMatrixSessionID sessionID);
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,116 +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.
- */
-
-/*
- * Date: Dec 1, 2003
- * Time: 1:26:57 PM
- */
-package com.metamatrix.platform.security.api.service;
-
-import java.io.Serializable;
-
-import com.metamatrix.platform.security.api.SecurityMessagesKeys;
-import com.metamatrix.platform.security.api.SecurityPlugin;
-
-/**
- * SuccessfulAuthenticationToken.
- *
- * <p>Marker indicating successful authentication attempt. Membership SPI
- * domain implementations should wrap the <code>Serializable</code> payload
- * in an instance of this class to signify to the Membgership service that
- * the domian successfully authenticated the given payload token.</p>
- *
- * <p>As well as providing a holder for the <code>Serializable</code> payload,
- * which may have been augmented or replaced by the authenticating membership
- * domain, this class provides a holder for the user name of the authenticated
- * user that may be used in the MetaMatrix system for such things as session
- * tracking and authorization policies.</p>
- *
- * <p>This wrapper class will not be exposed outside of the Membership framework.</p>
- */
-public final class SuccessfulAuthenticationToken implements AuthenticationToken {
- private Serializable payload;
- private String username;
- private String domainName;
-
- /**
- * SuccessfulAuthenticationToken
- *
- * <p>Indicate that successful user authentication has occurred.</p>
- *
- * <p>MetaMatrix must know the user name of every user connected to the system.
- * In particular, when MetaMatrix authorization policies (entitlements) are
- * created, the users and groups that are assigned to these policies come from
- * the membership domain.</p>
- *
- * @param payload The successfully authenticated token. May be <code>null</code>.
- * @param username The username of the <i>authenticated</i> user
- * exactly as it is known by the authenticating membership domain. May <b>not</b>
- * be <code>null</code>.
- */
- public SuccessfulAuthenticationToken(final Serializable payload, final String username) {
- if (username == null || username.trim().length() == 0) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0061));
- }
- this.payload = payload;
- this.username = username;
- }
-
- /**
- * Get the payload token that has been successfully authenticated by a
- * membership domain.
- * @return The successfully authenticated token unmodified.
- */
- public Serializable getPayload() {
- return payload;
- }
-
- /**
- * Get the <b>exact</b> username of the authenticated user as it
- * is known to the authenticating membership domain.
- * <p><b>Will be <code>null</code> if the user was <b>not</b>
- * authenticated. </b></p>
- * @return The username (including case) of this authenticated
- * user exactly as it is known by the authenticating membership domain.
- * @since 5.0
- */
- public String getUserName() {
- return username;
- }
-
- /**
- * The attempt to authenticate the given payload was successful.
- *
- * @return <code>true</code> - always.
- */
- public boolean isAuthenticated() {
- return true;
- }
-
- public String getDomainName() {
- return domainName;
- }
-
- public void setDomainName(String domainName) {
- this.domainName = domainName;
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -44,7 +44,6 @@
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.function.metadata.FunctionMethod;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.LanguageObject;
@@ -640,8 +639,7 @@
}
// Execute function
- FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
- Object result = library.invokeFunction(fd, values);
+ Object result = fd.invokeFunction(values);
return result;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,6 +29,6 @@
public static final String ADMIN_ROLE = "admin"; //$NON-NLS-1$
public static final String DATA_ROLE = "data"; //$NON-NLS-1$
- boolean hasRole(String connectionID, String roleType, String roleName) throws MetaMatrixComponentException;
+ boolean hasRole(String roleType, String roleName) throws MetaMatrixComponentException;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,11 +23,21 @@
package com.metamatrix.query.function;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Arrays;
+import com.metamatrix.api.exception.query.FunctionExecutionException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.core.util.Assertion;
+import com.metamatrix.query.QueryPlugin;
+import com.metamatrix.query.function.metadata.FunctionMethod;
+import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.util.ErrorMessageKeys;
/**
* The FunctionDescriptor describes a particular function instance enough
@@ -36,6 +46,8 @@
*/
public class FunctionDescriptor implements Serializable, Cloneable {
+ private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
+
private String name;
private int pushdown;
private Class[] types;
@@ -199,4 +211,68 @@
this.returnType = returnType;
}
+
+ /**
+ * Invoke the function described in the function descriptor, using the
+ * values provided. Return the result of the function.
+ * @param fd Function descriptor describing the name and types of the arguments
+ * @param values Values that should match 1-to-1 with the types described in the
+ * function descriptor
+ * @return Result of invoking the function
+ */
+ public Object invokeFunction(Object[] values) throws FunctionExecutionException {
+
+ if (!isNullDependent()) {
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] == null) {
+ return null;
+ }
+ }
+ }
+
+ // If descriptor is missing invokable method, find this VM's descriptor
+ // give name and types from fd
+ Method method = getInvocationMethod();
+ if(method == null) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, getName()));
+ }
+
+ if (getDeterministic() >= FunctionMethod.SESSION_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
+ CommandContext cc = (CommandContext)values[0];
+ cc.setSessionFunctionEvaluated(true);
+ }
+
+ // Invoke the method and return the result
+ try {
+ if (method.isVarArgs()) {
+ int i = method.getParameterTypes().length;
+ Object[] newValues = Arrays.copyOf(values, i);
+ newValues[i - 1] = Arrays.copyOfRange(values, i - 1, values.length);
+ values = newValues;
+ }
+ Object result = method.invoke(null, values);
+ if (!ALLOW_NAN_INFINITY) {
+ if (result instanceof Double) {
+ Double floatVal = (Double)result;
+ if (Double.isInfinite(floatVal) || Double.isNaN(floatVal)) {
+ throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName())); //$NON-NLS-1$
+ }
+ } else if (result instanceof Float) {
+ Float floatVal = (Float)result;
+ if (Float.isInfinite(floatVal) || Float.isNaN(floatVal)) {
+ throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName())); //$NON-NLS-1$
+ }
+ }
+ }
+ result = DataTypeManager.convertToRuntimeType(result);
+ result = DataTypeManager.transformValue(result, getReturnType());
+ return result;
+ } catch(InvocationTargetException e) {
+ throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName()));
+ } catch(IllegalAccessException e) {
+ throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0004, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0004, method.toString()));
+ } catch (TransformationException e) {
+ throw new FunctionExecutionException(e, e.getMessage());
+ }
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,9 +24,11 @@
import java.io.Serializable;
import java.util.*;
+
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.function.metadata.*;
/**
@@ -169,7 +171,7 @@
str.append(", "); //$NON-NLS-1$
} else {
str.append(" "); //$NON-NLS-1$
- str.append(ReservedWords.AS);
+ str.append(SQLReservedWords.AS);
str.append(" "); //$NON-NLS-1$
}
str.append(inputParamNames.get(1));
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -46,10 +46,8 @@
* functions are available, resolve function signatures, and invoke system
* and user-defined functions.
*/
-public class FunctionLibrary {
-
- private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
-
+public class FunctionLibrary {
+
// Special type conversion functions
public static final String CONVERT = "convert"; //$NON-NLS-1$
public static final String CAST = "cast"; //$NON-NLS-1$
@@ -98,17 +96,16 @@
// Function tree for system functions (never reloaded)
private FunctionTree systemFunctions;
- // Function tree for user-defined functions (reloadable)
+ // Function tree for user-defined functions
private FunctionTree userFunctions;
/**
* Construct the function library. This should be called only once by the
* FunctionLibraryManager.
*/
- FunctionLibrary() {
- // Put empty trees here to avoid null checks throughout the class
- systemFunctions = new FunctionTree(Collections.EMPTY_LIST);
- userFunctions = new FunctionTree(Collections.EMPTY_LIST);
+ public FunctionLibrary(FunctionTree systemFuncs, FunctionTree userFuncs) {
+ systemFunctions = systemFuncs;
+ userFunctions = userFuncs;
}
/**
@@ -156,33 +153,6 @@
return form;
}
- /**
- * Add the system functions to the library. This should be done
- * exactly once by the FunctionLibraryManager.
- * @param source System metadata source
- */
- void setSystemFunctions(FunctionMetadataSource source) {
- this.systemFunctions = new FunctionTree(source);
- }
-
- /**
- * Replace the existing set of reloadable functions with a new set. This
- * is called by the FunctionLibraryManager every time it reloads the
- * reloadable sources.
- * @param sources Collection of {@link FunctionMetadataSource} objects
- */
- void replaceReloadableFunctions(Collection sources) {
- // Build new function tree
- FunctionTree reloadedFunctions = new FunctionTree(sources);
-
- // Switch to new user-defined functions - this is not synchronized
- // because it is merely an object reference change. There is no
- // way for other code to get part of the old tree and part of the new
- // tree - they will get either one or the other. The old tree is
- // dropped.
- this.userFunctions = reloadedFunctions;
- }
-
/**
* Find a function descriptor given a name and the types of the arguments.
* This method matches based on case-insensitive function name and
@@ -344,84 +314,6 @@
}
/**
- * Invoke the function described in the function descriptor, using the
- * values provided. Return the result of the function.
- * @param fd Function descriptor describing the name and types of the arguments
- * @param values Values that should match 1-to-1 with the types described in the
- * function descriptor
- * @return Result of invoking the function
- */
- public Object invokeFunction(FunctionDescriptor fd, Object[] values)
- throws InvalidFunctionException, FunctionExecutionException {
-
- if(fd == null) {
- throw new InvalidFunctionException(ErrorMessageKeys.FUNCTION_0001, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0001, fd));
- }
-
- if (!fd.isNullDependent()) {
- for (int i = 0; i < values.length; i++) {
- if (values[i] == null) {
- return null;
- }
- }
- }
-
- // If descriptor is missing invokable method, find this VM's descriptor
- // give name and types from fd
- Method method = fd.getInvocationMethod();
- if(method == null) {
- FunctionDescriptor localDescriptor = findFunction(fd.getName(), fd.getTypes());
- if(localDescriptor == null) {
- throw new InvalidFunctionException(ErrorMessageKeys.FUNCTION_0001, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0001, fd));
- }
-
- // Get local invocation method, which should never be null
- method = localDescriptor.getInvocationMethod();
- if (method == null){
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, localDescriptor.getName()));
- }
- }
-
- if (fd.getDeterministic() >= FunctionMethod.SESSION_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
- CommandContext cc = (CommandContext)values[0];
- cc.setSessionFunctionEvaluated(true);
- }
-
- // Invoke the method and return the result
- try {
- if (method.isVarArgs()) {
- int i = method.getParameterTypes().length;
- Object[] newValues = Arrays.copyOf(values, i);
- newValues[i - 1] = Arrays.copyOfRange(values, i - 1, values.length);
- values = newValues;
- }
- Object result = method.invoke(null, values);
- if (!ALLOW_NAN_INFINITY) {
- if (result instanceof Double) {
- Double floatVal = (Double)result;
- if (Double.isInfinite(floatVal) || Double.isNaN(floatVal)) {
- throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, fd.getName())); //$NON-NLS-1$
- }
- } else if (result instanceof Float) {
- Float floatVal = (Float)result;
- if (Float.isInfinite(floatVal) || Float.isNaN(floatVal)) {
- throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, fd.getName())); //$NON-NLS-1$
- }
- }
- }
- result = DataTypeManager.convertToRuntimeType(result);
- result = DataTypeManager.transformValue(result, fd.getReturnType());
- return result;
- } catch(InvocationTargetException e) {
- throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, fd.getName()));
- } catch(IllegalAccessException e) {
- throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0004, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0004, method.toString()));
- } catch (TransformationException e) {
- throw new FunctionExecutionException(e, e.getMessage());
- }
- }
-
- /**
* Return a copy of the given FunctionDescriptor with the sepcified return type.
* @param fd FunctionDescriptor to be copied.
* @param returnType The return type to apply to the copied FunctionDescriptor.
Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,152 +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.query.function;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.metadata.FunctionMetadataValidator;
-import com.metamatrix.query.function.source.SystemSource;
-import com.metamatrix.query.report.ActivityReport;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-/**
- * Factory to obtain the local FunctionLibrary and register sources of function metadata.
- */
-public class FunctionLibraryManager {
-
- // Reference to singleton FunctionLibrary
- private static FunctionLibrary LIB;
-
- // List of reloadable (user-defined) sources of metadata
- private static List RELOADABLE_SOURCES;
-
- // Static initializer
- static {
- // Create the function library instance
- LIB = new FunctionLibrary();
-
- // Create the system source and add it to the source list
- FunctionMetadataSource systemSource = new SystemSource();
-
- // Load the system source
- LIB.setSystemFunctions(systemSource);
-
- // Validate the system source - should never fail
- ActivityReport report = new ActivityReport("Function Validation"); //$NON-NLS-1$
- validateSource(systemSource, report);
- if(report.hasItems()) {
- // Should never happen as SystemSource doesn't change
- System.err.println(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0005, report));
- }
-
- // Initialize the reloadable sources
- RELOADABLE_SOURCES = new ArrayList();
-
- }
-
- /**
- * Can't construct - just a factory
- */
- private FunctionLibraryManager() {}
-
- /**
- * Factory method to obtain a reference to a function.
- * @return Function library to find and invoke functions
- */
- public static FunctionLibrary getFunctionLibrary() {
- return LIB;
- }
-
- /**
- * Register a new source of function metadata. The method
- * {@link #reloadSources} will be called as a result.
- * @param source A new source of function metadata
- * @return Report of any invalid FunctionMethod objects
- */
- public static synchronized ActivityReport registerSource(FunctionMetadataSource source) {
- // Add the reloadable source
- RELOADABLE_SOURCES.add(source);
-
- // Reload
- return reloadSources();
- }
-
- /**
- * Register a new source of function metadata. The method
- * {@link #reloadSources} will be called as a result.
- * @param source A new source of function metadata
- * @return Report of any invalid FunctionMethod objects
- */
- public static synchronized ActivityReport deregisterSource(FunctionMetadataSource source) {
- // Add the reloadable source
- RELOADABLE_SOURCES.remove(source);
-
- // Reload
- return reloadSources();
- }
-
- /**
- * Reload all sources. All valid functions in the registered function sources
- * are reloaded. Any invalid functions are noted in the report.
- * @return Report of any invalid FunctionMethod objects.
- */
- public static synchronized ActivityReport reloadSources() {
- // Create activity report
- ActivityReport report = new ActivityReport("Function Validation"); //$NON-NLS-1$
-
- // Reload and re-validate all metadata sources
- Iterator iter = RELOADABLE_SOURCES.iterator();
- while(iter.hasNext()) {
- FunctionMetadataSource source = (FunctionMetadataSource) iter.next();
-
- // Reload - even though it is reload it is never called
- // other than the register methods, so it may of no use.
- // if need it we will get this back.
- //source.reloadMethods();
-
- // Validate
- validateSource(source, report);
- }
-
- // Upload all new reloadable functions into function library in bulk
- LIB.replaceReloadableFunctions(RELOADABLE_SOURCES);
-
- // Return report of failures during reload
- return report;
- }
-
- /**
- * Validate all function metadata in the source with the FunctionMetadataValidator. Add
- * any problems to the specified report.
- * @param source Source of function metadata
- * @param report Report to update with any problems
- */
- private static void validateSource(FunctionMetadataSource source, ActivityReport report) {
- Collection functionMethods = source.getFunctionMethods();
- FunctionMetadataValidator.validateFunctionMethods(functionMethods,report);
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,10 @@
package com.metamatrix.query.function;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.Collection;
+import com.metamatrix.query.function.metadata.FunctionMethod;
+
/**
* A FunctionMetadataSource represents a source of function metadata for
* the function library. A FunctionMetadataSource needs to know how to
@@ -42,7 +42,7 @@
* always return the newest information available.
* @return Collection of FunctionMethod objects
*/
- Collection getFunctionMethods();
+ Collection<FunctionMethod> getFunctionMethods();
/**
* This method determines where the invocation classes specified in the
@@ -52,7 +52,4 @@
* @throws ClassNotFoundException If class could not be found
*/
Class getInvocationClass(String className) throws ClassNotFoundException;
-
-
- void loadFunctions(InputStream source) throws IOException;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -36,13 +36,14 @@
import java.util.Properties;
import java.util.TimeZone;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.FunctionExecutionException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -449,7 +450,7 @@
cal.setTime(timestamp);
// case of interval = 1, fractional seconds (nanos), don't go to branches of addField()
- if (intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+ if (intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
int countValue = count.intValue();
nanos += countValue;
@@ -487,23 +488,23 @@
private static void addField(String interval, Integer count, Calendar cal) {
int countValue = count.intValue();
- if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+ if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
//nano seconds - should never get into this branch
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_SECOND)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
cal.add(Calendar.SECOND, countValue);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_MINUTE)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
cal.add(Calendar.MINUTE, countValue);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_HOUR)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
cal.add(Calendar.HOUR_OF_DAY, countValue);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_DAY)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
cal.add(Calendar.DAY_OF_YEAR, countValue);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_WEEK)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
cal.add(Calendar.WEEK_OF_YEAR, countValue);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_MONTH)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
cal.add(Calendar.MONTH, countValue);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_QUARTER)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
cal.add(Calendar.MONTH, countValue*3);
- } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_YEAR)) {
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
cal.add(Calendar.YEAR, countValue);
}
}
@@ -525,25 +526,25 @@
long tsDiff = ts2 - ts1;
long count = 0;
- if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+ if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
count = tsDiff;
} else {
tsDiff = tsDiff / 1000000; //convert to milliseconds
- if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_SECOND)) {
+ if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
count = tsDiff / 1000;
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MINUTE)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
count = (tsDiff / 1000) / 60;
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_HOUR)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
count = (tsDiff / 1000) / (60*60);
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_DAY)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
count = (tsDiff / 1000) / (60*60*24);
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_WEEK)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
count = (tsDiff / 1000) / (60*60*24*7);
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MONTH)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
count = (tsDiff / 1000) / (60*60*24*30);
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_QUARTER)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
count = (tsDiff / 1000) / (60*60*24*91);
- } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_YEAR)) {
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
count = (tsDiff / 1000) / (60*60*24*365);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -57,7 +57,7 @@
* are concerned with function metadata EXCEPT {@link #getFunction} which is used to find a function
* for execution.
*/
-class FunctionTree {
+public class FunctionTree {
// Constant used to look up the special descriptor key in a node map
private static final Integer DESCRIPTOR_KEY = new Integer(-1);
@@ -83,7 +83,7 @@
* Construct a new tree with the given source of function metadata.
* @param source The metadata source
*/
- FunctionTree(FunctionMetadataSource source) {
+ public FunctionTree(FunctionMetadataSource source) {
// Load data structures
addSource(source);
}
Copied: trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,71 @@
+/*
+ * 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.query.function;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import com.metamatrix.query.QueryPlugin;
+import com.metamatrix.query.function.metadata.FunctionMetadataValidator;
+import com.metamatrix.query.function.source.SystemSource;
+import com.metamatrix.query.report.ActivityReport;
+import com.metamatrix.query.util.ErrorMessageKeys;
+
+public class SystemFunctionManager {
+
+ private static FunctionTree systemFunctionTree;
+
+ static {
+ // Create the system source and add it to the source list
+ SystemSource systemSource = new SystemSource();
+
+ // Validate the system source - should never fail
+ ActivityReport report = new ActivityReport("Function Validation"); //$NON-NLS-1$
+ validateSource(systemSource, report);
+ if(report.hasItems()) {
+ // Should never happen as SystemSource doesn't change
+ System.err.println(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0005, report));
+ }
+
+ systemFunctionTree = new FunctionTree(systemSource);
+ }
+
+
+ public static FunctionTree getSystemFunctions() {
+ return systemFunctionTree;
+ }
+
+ public static FunctionLibrary getSystemFunctionLibrary() {
+ return new FunctionLibrary(systemFunctionTree, new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
+ }
+
+ /**
+ * Validate all function metadata in the source with the FunctionMetadataValidator. Add
+ * any problems to the specified report.
+ * @param source Source of function metadata
+ * @param report Report to update with any problems
+ */
+ private static void validateSource(FunctionMetadataSource source, ActivityReport report) {
+ Collection functionMethods = source.getFunctionMethods();
+ FunctionMetadataValidator.validateFunctionMethods(functionMethods,report);
+ }
+}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,63 +22,24 @@
package com.metamatrix.query.function;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
import java.util.Collection;
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.query.function.metadata.FunctionMetadataReader;
import com.metamatrix.query.function.metadata.FunctionMethod;
public class UDFSource implements FunctionMetadataSource {
- private URL[] classpath = null;
- private ClassLoader classLoader = null;
private Collection <FunctionMethod> methods = null;
- public UDFSource(URL url) throws IOException {
- loadFunctions(url.openStream());
+ public UDFSource(Collection <FunctionMethod> methods) {
+ this.methods = methods;
}
- public UDFSource(URL url, URL[] classpath) throws IOException{
- this.classpath = classpath;
- loadFunctions(url.openStream());
- }
-
- public UDFSource(InputStream udfStream, URL[] classpath) throws IOException {
- this.classpath = classpath;
- loadFunctions(udfStream);
- }
-
- public UDFSource(InputStream udfStream, ClassLoader classloader) throws IOException {
- this.classLoader = classloader;
- loadFunctions(udfStream);
- }
-
-
public Collection getFunctionMethods() {
return this.methods;
}
public Class getInvocationClass(String className) throws ClassNotFoundException {
- // If no classpath is specified then use the default classpath
- if (this.classLoader == null && (classpath == null || classpath.length == 0)) {
- return Class.forName(className);
- }
-
- // If the class loader is not created for the UDF functions then create
- // one and cache it.
- if (classLoader == null) {
- classLoader = new PostDelegatingClassLoader(this.classpath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
- }
-
- return classLoader.loadClass(className);
+ return Class.forName(className);
}
-
- public void loadFunctions(InputStream in) throws IOException{
- methods = FunctionMetadataReader.loadFunctionMethods(in);
- }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -32,8 +32,6 @@
public static boolean hasRole(CommandContext context, Object roleType, Object roleName) throws FunctionExecutionException {
- String connectionId = context.getConnectionID();
-
SecurityFunctionEvaluator eval = context.getSecurityFunctionEvaluator();
if (eval == null) {
@@ -41,7 +39,7 @@
}
try {
- return eval.hasRole(connectionId, (String)roleType, (String)roleName);
+ return eval.hasRole((String)roleType, (String)roleName);
} catch (MetaMatrixComponentException err) {
throw new FunctionExecutionException(err, err.getMessage());
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -952,12 +952,4 @@
public Class getInvocationClass(String className) throws ClassNotFoundException {
return Class.forName(className);
}
-
- /**
- * Never need to reload - do nothing.
- */
- public void loadFunctions(InputStream source) throws IOException{
- }
-
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,6 +29,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingNode;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -514,5 +515,10 @@
throws MetaMatrixComponentException, QueryMetadataException {
return false;
}
+
+ @Override
+ public FunctionLibrary getFunctionLibrary() {
+ return null;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingNode;
@@ -362,4 +363,9 @@
return actualMetadata.isScalarGroup(groupID);
}
+ @Override
+ public FunctionLibrary getFunctionLibrary() {
+ return actualMetadata.getFunctionLibrary();
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,13 @@
package com.metamatrix.query.metadata;
-import java.util.*;
import java.util.Collection;
import java.util.List;
+import java.util.Properties;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingNode;
@@ -675,4 +676,5 @@
boolean isScalarGroup(Object groupID)
throws MetaMatrixComponentException, QueryMetadataException;
+ FunctionLibrary getFunctionLibrary();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -169,7 +169,7 @@
Object modelID = metadata.getModelID(groupID);
String modelName = metadata.getFullName(modelID);
if (metadata.isVirtualGroup(groupID)) {
- InsertPlanExecutionNode ipen = new InsertPlanExecutionNode(getID());
+ InsertPlanExecutionNode ipen = new InsertPlanExecutionNode(getID(), metadata);
ipen.setProcessorPlan((ProcessorPlan)node.getFirstChild().getProperty(Info.PROCESSOR_PLAN));
ipen.setReferences(insert.getValues());
processNode = ipen;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,7 @@
import java.util.List;
import org.teiid.connector.api.ConnectorCapabilities.SupportedJoinCriteria;
+import org.teiid.connector.language.SQLReservedWords;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -38,7 +39,6 @@
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -145,7 +145,7 @@
// Check particular function
String func = aggregate.getAggregateFunction();
- if(func.equals(ReservedWords.COUNT)) {
+ if(func.equals(SQLReservedWords.COUNT)) {
if(aggregate.getExpression() == null) {
if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_COUNT_STAR)) {
return false;
@@ -155,19 +155,19 @@
return false;
}
}
- } else if(func.equals(ReservedWords.SUM)) {
+ } else if(func.equals(SQLReservedWords.SUM)) {
if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_SUM)) {
return false;
}
- } else if(func.equals(ReservedWords.AVG)) {
+ } else if(func.equals(SQLReservedWords.AVG)) {
if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_AVG)) {
return false;
}
- } else if(func.equals(ReservedWords.MIN)) {
+ } else if(func.equals(SQLReservedWords.MIN)) {
if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_MIN)) {
return false;
}
- } else if(func.equals(ReservedWords.MAX)) {
+ } else if(func.equals(SQLReservedWords.MAX)) {
if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_MAX)) {
return false;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -78,7 +78,7 @@
while(current != endNode) {
// Make translations as defined in node in each current node
- convertNode(current, oldGroup, newGroups, symbolMap);
+ convertNode(current, oldGroup, newGroups, symbolMap, metadata);
PlanNode parent = current.getParent();
@@ -159,7 +159,7 @@
// symbols. In that case, some additional work can be done because we can assume
// that an oldElement isn't being replaced by an expression using elements from
// multiple new groups.
- static void convertNode(PlanNode node, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap)
+ static void convertNode(PlanNode node, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata)
throws QueryPlannerException {
// Update groups for current node
@@ -202,7 +202,7 @@
if(type == NodeConstants.Types.SELECT) {
Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- crit = convertCriteria(crit, symbolMap);
+ crit = convertCriteria(crit, symbolMap, metadata);
node.setProperty(NodeConstants.Info.SELECT_CRITERIA, crit);
if (!singleMapping) {
@@ -222,7 +222,7 @@
List<Criteria> joinCrits = (List<Criteria>) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
if(joinCrits != null && !joinCrits.isEmpty()) {
Criteria crit = new CompoundCriteria(joinCrits);
- crit = convertCriteria(crit, symbolMap);
+ crit = convertCriteria(crit, symbolMap, metadata);
if (crit instanceof CompoundCriteria) {
node.setProperty(NodeConstants.Info.JOIN_CRITERIA, ((CompoundCriteria)crit).getCriteria());
} else {
@@ -274,14 +274,14 @@
return expression;
}
- static Criteria convertCriteria(Criteria criteria, final Map symbolMap)
+ static Criteria convertCriteria(Criteria criteria, final Map symbolMap, QueryMetadataInterface metadata)
throws QueryPlannerException {
ExpressionMappingVisitor.mapExpressions(criteria, symbolMap);
// Simplify criteria if possible
try {
- return QueryRewriter.rewriteCriteria(criteria, null, null, null);
+ return QueryRewriter.rewriteCriteria(criteria, null, null, metadata);
} catch(QueryValidatorException e) {
throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0023, criteria));
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -194,7 +194,7 @@
}
PlanNode limit = NodeEditor.findNodePreOrder(node, NodeConstants.Types.TUPLE_LIMIT, NodeConstants.Types.SET_OP);
if (limit != null) {
- processLimit(limit, unionCommand);
+ processLimit(limit, unionCommand, metadata);
}
int count = 0;
for (PlanNode child : setOpNode.getChildren()) {
@@ -219,7 +219,7 @@
query.setFrom(new From());
buildQuery(accessRoot, node, query, metadata, capFinder);
if (query.getCriteria() instanceof CompoundCriteria) {
- query.setCriteria(QueryRewriter.optimizeCriteria((CompoundCriteria)query.getCriteria()));
+ query.setCriteria(QueryRewriter.optimizeCriteria((CompoundCriteria)query.getCriteria(), metadata));
}
if (!CapabilitiesUtil.useAnsiJoin(RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), metadata, capFinder)) {
simplifyFromClause(query);
@@ -334,7 +334,7 @@
}
case NodeConstants.Types.TUPLE_LIMIT:
{
- processLimit(node, query);
+ processLimit(node, query, metadata);
break;
}
}
@@ -371,7 +371,7 @@
}
private void processLimit(PlanNode node,
- QueryCommand query) {
+ QueryCommand query, QueryMetadataInterface metadata) {
Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
if (limit != null) {
if (query.getLimit() != null) {
@@ -385,7 +385,7 @@
if (offset != null) {
if (query.getLimit() != null) {
Expression oldoffset = query.getLimit().getOffset();
- query.getLimit().setOffset(RulePushLimit.getSum(offset, oldoffset));
+ query.getLimit().setOffset(RulePushLimit.getSum(offset, oldoffset, metadata.getFunctionLibrary()));
} else {
query.setLimit(new Limit(offset, null));
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -93,7 +93,7 @@
return plan;
}
- if (tryToCopy(plan, new Set[2])) {
+ if (tryToCopy(plan, new Set[2], metadata)) {
//Push any newly created criteria nodes and try to copy them afterwards
rules.push(RuleConstants.COPY_CRITERIA);
rules.push(RuleConstants.PUSH_NON_JOIN_CRITERIA);
@@ -123,13 +123,14 @@
Map tgtMap,
List joinCriteria,
Set combinedCriteria,
- boolean checkForGroupReduction) {
+ boolean checkForGroupReduction,
+ QueryMetadataInterface metadata) {
int startGroups = GroupsUsedByElementsVisitor.getGroups(crit).size();
Criteria tgtCrit = (Criteria) crit.clone();
try {
- tgtCrit = FrameUtil.convertCriteria(tgtCrit, tgtMap);
+ tgtCrit = FrameUtil.convertCriteria(tgtCrit, tgtMap, metadata);
} catch (QueryPlannerException err) {
LogManager.logDetail(LogConstants.CTX_QUERY_PLANNER, err, "Could not remap target criteria in RuleCopyCriteria"); //$NON-NLS-1$
return false;
@@ -164,7 +165,7 @@
* @param node
* @return true if criteria has been created
*/
- private boolean tryToCopy(PlanNode node, Set[] criteriaInfo) {
+ private boolean tryToCopy(PlanNode node, Set[] criteriaInfo, QueryMetadataInterface metadata) {
boolean changedTree = false;
if (node == null) {
@@ -176,14 +177,14 @@
JoinType jt = (JoinType)node.getProperty(NodeConstants.Info.JOIN_TYPE);
if (jt == JoinType.JOIN_FULL_OUTER) {
- return visitChildern(node, criteriaInfo, changedTree);
+ return visitChildern(node, criteriaInfo, changedTree, metadata);
}
Set[] leftChildCriteria = new Set[2];
Set[] rightChildCriteria = new Set[2];
- changedTree |= tryToCopy(node.getFirstChild(), leftChildCriteria);
- changedTree |= tryToCopy(node.getLastChild(), rightChildCriteria);
+ changedTree |= tryToCopy(node.getFirstChild(), leftChildCriteria, metadata);
+ changedTree |= tryToCopy(node.getLastChild(), rightChildCriteria, metadata);
List joinCrits = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
Set combinedCriteria = null;
@@ -214,11 +215,11 @@
List newJoinCrits = new LinkedList();
- changedTree = createCriteriaFromSelectCriteria(changedTree, combinedCriteria, toCopy, srcToTgt, newJoinCrits);
+ changedTree = createCriteriaFromSelectCriteria(changedTree, combinedCriteria, toCopy, srcToTgt, newJoinCrits, metadata);
srcToTgt = buildElementMap(allCriteria);
- changedTree = createCriteriaFromJoinCriteria(changedTree, joinCrits, combinedCriteria, srcToTgt, newJoinCrits);
+ changedTree = createCriteriaFromJoinCriteria(changedTree, joinCrits, combinedCriteria, srcToTgt, newJoinCrits, metadata);
joinCrits.addAll(newJoinCrits);
}
@@ -235,7 +236,7 @@
return changedTree;
}
- changedTree = visitChildern(node, criteriaInfo, changedTree);
+ changedTree = visitChildern(node, criteriaInfo, changedTree, metadata);
//visit select nodes on the way back up
switch (node.getType()) {
@@ -281,7 +282,8 @@
List joinCrits,
Set combinedCriteria,
Map srcToTgt,
- List newJoinCrits) {
+ List newJoinCrits,
+ QueryMetadataInterface metadata) {
if (srcToTgt.size() == 0) {
return changedTree;
}
@@ -289,7 +291,7 @@
while (i.hasNext()) {
Criteria crit = (Criteria)i.next();
- if (copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, true)) {
+ if (copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, true, metadata)) {
changedTree = true;
if (crit instanceof CompareCriteria) {
CompareCriteria cc = (CompareCriteria)crit;
@@ -317,14 +319,15 @@
Set combinedCriteria,
Set toCopy,
Map srcToTgt,
- List newJoinCrits) {
+ List newJoinCrits,
+ QueryMetadataInterface metadata) {
if (srcToTgt.size() == 0) {
return changedTree;
}
Iterator i = toCopy.iterator();
while (i.hasNext()) {
Criteria crit = (Criteria)i.next();
- changedTree |= copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, false);
+ changedTree |= copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, false, metadata);
}
return changedTree;
}
@@ -352,12 +355,13 @@
private boolean visitChildern(PlanNode node,
Set[] criteriaInfo,
- boolean changedTree) {
+ boolean changedTree,
+ QueryMetadataInterface metadata) {
if (node.getChildCount() > 0) {
List children = node.getChildren();
for (int i = 0; i < children.size(); i++) {
PlanNode childNode = (PlanNode)children.get(i);
- changedTree |= tryToCopy(childNode, i==0?criteriaInfo:new Set[2]);
+ changedTree |= tryToCopy(childNode, i==0?criteriaInfo:new Set[2], metadata);
}
}
return changedTree;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -58,7 +58,7 @@
// Merge chains
for (PlanNode critNode : criteriaChains) {
- mergeChain(critNode);
+ mergeChain(critNode, metadata);
}
return plan;
@@ -93,7 +93,7 @@
}
}
- static void mergeChain(PlanNode chainRoot) {
+ static void mergeChain(PlanNode chainRoot, QueryMetadataInterface metadata) {
// Remove all of chain except root, collect crit from each
CompoundCriteria critParts = new CompoundCriteria();
@@ -115,7 +115,7 @@
}
- Criteria combinedCrit = QueryRewriter.optimizeCriteria(critParts);
+ Criteria combinedCrit = QueryRewriter.optimizeCriteria(critParts, metadata);
if (isDependentSet) {
chainRoot.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -35,6 +35,8 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryPlannerException;
@@ -57,7 +59,6 @@
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.LanguageObject.Util;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Criteria;
@@ -235,7 +236,7 @@
for (Expression expr : aggMap.values()) {
ExpressionMappingVisitor.mapExpressions(expr, projectedMap);
}
- mapExpressions(groupNode.getParent(), aggMap);
+ mapExpressions(groupNode.getParent(), aggMap, metadata);
}
private boolean canPushGroupByToUnionChild(QueryMetadataInterface metadata,
@@ -350,14 +351,14 @@
if (pushdown) {
projectedViewSymbols.add(agg);
} else {
- if (agg.getAggregateFunction().equals(ReservedWords.COUNT)) {
+ if (agg.getAggregateFunction().equals(SQLReservedWords.COUNT)) {
SearchedCaseExpression count = new SearchedCaseExpression(Arrays.asList(new IsNullCriteria(agg.getExpression())), Arrays.asList(new Constant(Integer.valueOf(0))));
count.setElseExpression(new Constant(Integer.valueOf(1)));
count.setType(DataTypeManager.DefaultDataClasses.INTEGER);
projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", count)); //$NON-NLS-1$
} else { //min, max, sum
Expression ex = agg.getExpression();
- ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()));
+ ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata);
projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", ex)); //$NON-NLS-1$
}
}
@@ -500,7 +501,7 @@
} else {
// if the source has no rows we need to insert a select node with criteria count(*)>0
PlanNode selectNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
- AggregateSymbol count = new AggregateSymbol("stagedAgg", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol count = new AggregateSymbol("stagedAgg", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
aggregates.add(count); //consider the count aggregate for the push down call below
selectNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, new CompareCriteria(count, CompareCriteria.GT,
new Constant(new Integer(0))));
@@ -536,7 +537,7 @@
try {
Set<AggregateSymbol> newAggs = new HashSet<AggregateSymbol>();
Map<AggregateSymbol, Expression> aggMap = buildAggregateMap(aggregates, metadata, newAggs);
- mapExpressions(groupNode.getParent(), aggMap);
+ mapExpressions(groupNode.getParent(), aggMap, metadata);
aggregates.clear();
aggregates.addAll(newAggs);
} catch (QueryResolverException err) {
@@ -668,27 +669,25 @@
Expression newExpression = null;
String aggFunction = partitionAgg.getAggregateFunction();
- if (aggFunction.equals(ReservedWords.COUNT)) {
+ if (aggFunction.equals(SQLReservedWords.COUNT)) {
//COUNT(x) -> CONVERT(SUM(COUNT(x)), INTEGER)
- AggregateSymbol newAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, partitionAgg); //$NON-NLS-1$
+ AggregateSymbol newAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, partitionAgg); //$NON-NLS-1$
// Build conversion function to convert SUM (which returns LONG) back to INTEGER
Constant convertTargetType = new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()),
DataTypeManager.DefaultDataClasses.STRING);
- Function convertFunc = new Function(FunctionLibrary.CONVERT, new Expression[] {
- newAgg, convertTargetType
- });
+ Function convertFunc = new Function(FunctionLibrary.CONVERT, new Expression[] {newAgg, convertTargetType});
ResolverVisitor.resolveLanguageObject(convertFunc, metadata);
newExpression = convertFunc;
nestedAggregates.add(partitionAgg);
- } else if (aggFunction.equals(ReservedWords.AVG)) {
+ } else if (aggFunction.equals(SQLReservedWords.AVG)) {
//AVG(x) -> SUM(SUM(x)) / SUM(COUNT(x))
- AggregateSymbol countAgg = new AggregateSymbol("stagedAgg", ReservedWords.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
- AggregateSymbol sumAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
+ AggregateSymbol countAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
+ AggregateSymbol sumAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
- AggregateSymbol sumSumAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, sumAgg); //$NON-NLS-1$
- AggregateSymbol sumCountAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, countAgg); //$NON-NLS-1$
+ AggregateSymbol sumSumAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, sumAgg); //$NON-NLS-1$
+ AggregateSymbol sumCountAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, countAgg); //$NON-NLS-1$
Function divideFunc = new Function("/", new Expression[] {sumSumAgg, sumCountAgg}); //$NON-NLS-1$
ResolverVisitor.resolveLanguageObject(divideFunc, metadata);
@@ -707,11 +706,11 @@
return aggMap;
}
- static void mapExpressions(PlanNode node, Map<? extends Expression, ? extends Expression> exprMap)
+ static void mapExpressions(PlanNode node, Map<? extends Expression, ? extends Expression> exprMap, QueryMetadataInterface metadata)
throws QueryPlannerException {
while (node != null) {
- FrameUtil.convertNode(node, null, null, exprMap);
+ FrameUtil.convertNode(node, null, null, exprMap, metadata);
switch (node.getType()) {
case NodeConstants.Types.SOURCE:
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,7 +31,7 @@
import com.metamatrix.api.exception.query.QueryPlannerException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
import com.metamatrix.query.optimizer.relational.OptimizerRule;
@@ -120,7 +120,7 @@
{
//combine the limits
Expression minLimit = getMinValue((Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT), (Expression)child.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT));
- Expression offSet = getSum((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)child.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT));
+ Expression offSet = getSum((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)child.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), metadata.getFunctionLibrary());
NodeEditor.removeChildNode(limitNode, child);
@@ -142,7 +142,7 @@
PlanNode newLimit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
Expression limit = (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
Expression offset = (Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
- newLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset));
+ newLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset, metadata.getFunctionLibrary()));
grandChild.addAsParent(newLimit);
limitNodes.add(newLimit);
}
@@ -205,7 +205,7 @@
// since we're pushing underneath the offset, we want enough rows to satisfy both the limit and the row offset
- pushedLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset));
+ pushedLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset, metadata.getFunctionLibrary()));
if (accessNode.getChildCount() == 0) {
accessNode.addFirstChild(pushedLimit);
@@ -224,7 +224,7 @@
* @param limitNode
* @param child
*/
- static Expression getSum(Expression expr1, Expression expr2) {
+ static Expression getSum(Expression expr1, Expression expr2, FunctionLibrary functionLibrary) {
if (expr1 == null) {
return expr2;
}
@@ -233,7 +233,7 @@
}
Function newExpr = new Function("+", new Expression[] {expr1, expr2}); //$NON-NLS-1$
- newExpr.setFunctionDescriptor(FunctionLibraryManager.getFunctionLibrary().findFunction("+", new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER})); //$NON-NLS-1$
+ newExpr.setFunctionDescriptor(functionLibrary.findFunction("+", new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER})); //$NON-NLS-1$
newExpr.setType(newExpr.getFunctionDescriptor().getReturnType());
return newExpr;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -112,7 +112,7 @@
switch (sourceNode.getType()) {
case NodeConstants.Types.SOURCE:
{
- moved = pushAcrossFrame(sourceNode, critNode);
+ moved = pushAcrossFrame(sourceNode, critNode, metadata);
break;
}
case NodeConstants.Types.JOIN:
@@ -255,7 +255,7 @@
NodeEditor.removeChildNode(critNode.getParent(), critNode);
destination.addAsParent(critNode);
if (groupSelects && destination == sourceNode) {
- RuleMergeCriteria.mergeChain(critNode);
+ RuleMergeCriteria.mergeChain(critNode, metadata);
}
}
@@ -331,7 +331,7 @@
return sourceNode;
}
- boolean pushAcrossFrame(PlanNode sourceNode, PlanNode critNode)
+ boolean pushAcrossFrame(PlanNode sourceNode, PlanNode critNode, QueryMetadataInterface metadata)
throws QueryPlannerException {
//ensure that the criteria can be pushed further
@@ -347,7 +347,7 @@
//only allow criteria without subqueires - node cloning doesn't allow for the proper creation of
//multiple nodes with the same subqueries
if (child == sourceNode.getFirstChild() && critNode.getSubqueryContainers().isEmpty()) {
- return pushAcrossSetOp(critNode, child);
+ return pushAcrossSetOp(critNode, child, metadata);
}
//this could be an access node in the middle of the source and set op,
//it is an odd case that is not supported for now
@@ -356,7 +356,7 @@
}
// See if we can move it towards the SOURCE node
- return moveNodeAcrossFrame(critNode, sourceNode);
+ return moveNodeAcrossFrame(critNode, sourceNode, metadata);
}
/**
@@ -376,7 +376,7 @@
return true;
}
- boolean moveNodeAcrossFrame(PlanNode critNode, PlanNode sourceNode)
+ boolean moveNodeAcrossFrame(PlanNode critNode, PlanNode sourceNode, QueryMetadataInterface metadata)
throws QueryPlannerException {
Assertion.isNotNull(critNode.getParent());
@@ -393,7 +393,7 @@
SymbolMap symbolMap = (SymbolMap) sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
- if (!createConvertedSelectNode(critNode, sourceNode.getGroups().iterator().next(), projectNode, symbolMap)) {
+ if (!createConvertedSelectNode(critNode, sourceNode.getGroups().iterator().next(), projectNode, symbolMap, metadata)) {
return false;
}
@@ -479,7 +479,7 @@
return copyNode;
}
- boolean pushAcrossSetOp(PlanNode critNode, PlanNode setOp)
+ boolean pushAcrossSetOp(PlanNode critNode, PlanNode setOp, QueryMetadataInterface metadata)
throws QueryPlannerException {
// Find source node above union and grab the symbol map
@@ -505,7 +505,7 @@
}
// Move the node
- if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap)) {
+ if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap, metadata)) {
movedCount++;
}
@@ -535,7 +535,8 @@
private boolean createConvertedSelectNode(PlanNode critNode,
GroupSymbol sourceGroup,
PlanNode projectNode,
- SymbolMap symbolMap) throws QueryPlannerException {
+ SymbolMap symbolMap,
+ QueryMetadataInterface metadata) throws QueryPlannerException {
// If projectNode has children, then it is from a SELECT without a FROM and the criteria should not be pushed
if(projectNode.getChildCount() == 0) {
return false;
@@ -560,7 +561,7 @@
copyNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
}
- FrameUtil.convertNode(copyNode, sourceGroup, null, symbolMap.asMap());
+ FrameUtil.convertNode(copyNode, sourceGroup, null, symbolMap.asMap(), metadata);
PlanNode intermediateParent = NodeEditor.findParent(projectNode, NodeConstants.Types.ACCESS, NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
if (intermediateParent != null) {
intermediateParent.addAsParent(copyNode);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Set;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryPlannerException;
@@ -42,7 +44,6 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.OrderBy;
@@ -276,8 +277,8 @@
static boolean areAggregatesCardinalityDependent(Set<AggregateSymbol> aggs) {
for (AggregateSymbol aggregateSymbol : aggs) {
- if (aggregateSymbol.getAggregateFunction().equalsIgnoreCase(ReservedWords.COUNT) ||
- aggregateSymbol.getAggregateFunction().equalsIgnoreCase(ReservedWords.AVG)) {
+ if (aggregateSymbol.getAggregateFunction().equalsIgnoreCase(SQLReservedWords.COUNT) ||
+ aggregateSymbol.getAggregateFunction().equalsIgnoreCase(SQLReservedWords.AVG)) {
return true;
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,10 +24,11 @@
import java.io.StringReader;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.Option;
@@ -126,7 +127,7 @@
// Check for OPTION
Option option = null;
int closeBracket = sql.lastIndexOf(XML_CLOSE_BRACKET);
- int optionIndex = sql.toUpperCase().lastIndexOf(ReservedWords.OPTION);
+ int optionIndex = sql.toUpperCase().lastIndexOf(SQLReservedWords.OPTION);
if (optionIndex != -1 && optionIndex > closeBracket){
String optionSQL = sql.substring(optionIndex);
option = getOption(optionSQL, parseInfo);
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,10 +27,11 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.FromClause;
import com.metamatrix.query.sql.lang.JoinType;
@@ -201,17 +202,17 @@
return JoinType.JOIN_INNER;
}
String joinType = joinTypeToken.image;
- if(joinType.equalsIgnoreCase(ReservedWords.INNER)) {
+ if(joinType.equalsIgnoreCase(SQLReservedWords.INNER)) {
return JoinType.JOIN_INNER;
- } else if(joinType.equalsIgnoreCase(ReservedWords.CROSS)) {
+ } else if(joinType.equalsIgnoreCase(SQLReservedWords.CROSS)) {
return JoinType.JOIN_CROSS;
- } else if(joinType.equalsIgnoreCase(ReservedWords.LEFT)) {
+ } else if(joinType.equalsIgnoreCase(SQLReservedWords.LEFT)) {
return JoinType.JOIN_LEFT_OUTER;
- } else if(joinType.equalsIgnoreCase(ReservedWords.RIGHT)) {
+ } else if(joinType.equalsIgnoreCase(SQLReservedWords.RIGHT)) {
return JoinType.JOIN_RIGHT_OUTER;
- } else if(joinType.equalsIgnoreCase(ReservedWords.FULL)) {
+ } else if(joinType.equalsIgnoreCase(SQLReservedWords.FULL)) {
return JoinType.JOIN_FULL_OUTER;
- } else if(joinType.equalsIgnoreCase(ReservedWords.UNION)) {
+ } else if(joinType.equalsIgnoreCase(SQLReservedWords.UNION)) {
return JoinType.JOIN_UNION;
} else {
Object[] params = new Object[] { joinType };
@@ -230,23 +231,23 @@
int num = info.anonExprCount++;
return "expr" + (num == 0 ? "" : ""+num); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if(functionType.equals(ReservedWords.COUNT)) {
+ } else if(functionType.equals(SQLReservedWords.COUNT)) {
int num = info.anonCountCount++;
return "count" + (num == 0 ? "" : ""+num);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if(functionType.equals(ReservedWords.SUM)) {
+ } else if(functionType.equals(SQLReservedWords.SUM)) {
int num = info.anonSumCount++;
return "sum" + (num == 0 ? "" : ""+num);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if(functionType.equals(ReservedWords.AVG)) {
+ } else if(functionType.equals(SQLReservedWords.AVG)) {
int num = info.anonAvgCount++;
return "avg" + (num == 0 ? "" : ""+num);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if(functionType.equals(ReservedWords.MIN)) {
+ } else if(functionType.equals(SQLReservedWords.MIN)) {
int num = info.anonMinCount++;
return "min" + (num == 0 ? "" : ""+num);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if(functionType.equals(ReservedWords.MAX)) {
+ } else if(functionType.equals(SQLReservedWords.MAX)) {
int num = info.anonMaxCount++;
return "max" + (num == 0 ? "" : ""+num);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -30,6 +30,8 @@
import java.util.List;
import java.util.Map;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.QueryProcessingException;
@@ -157,10 +159,14 @@
if (dynamicCommand.getUsing() != null
&& !dynamicCommand.getUsing().isEmpty()) {
- metadataStore.addTempGroup(ProcedureReservedWords.USING, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
- GroupSymbol using = new GroupSymbol(ProcedureReservedWords.USING);
- using.setMetadataID(metadataStore.getTempGroupID(ProcedureReservedWords.USING));
+ metadataStore.addTempGroup(SQLReservedWords.USING, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
+ GroupSymbol using = new GroupSymbol(SQLReservedWords.USING);
+ using.setMetadataID(metadataStore.getTempGroupID(SQLReservedWords.USING));
command.addExternalGroupToContext(using);
+ metadataStore.addTempGroup(ProcedureReservedWords.DVARS, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
+ using = new GroupSymbol(ProcedureReservedWords.DVARS);
+ using.setMetadataID(metadataStore.getTempGroupID(ProcedureReservedWords.DVARS));
+ command.addExternalGroupToContext(using);
}
// Resolve any groups
@@ -233,8 +239,8 @@
LogManager.logTrace(LogConstants.CTX_DQP,
new Object[] { this, " The using variable ", //$NON-NLS-1$
setClause.getSymbol(), " has value :", assignment }); //$NON-NLS-1$
- localContext.setValue(setClause.getSymbol(),
- assignment);
+ localContext.setValue(setClause.getSymbol(), assignment);
+ localContext.setValue(new ElementSymbol(SQLReservedWords.USING + ElementSymbol.SEPARATOR + setClause.getSymbol().getShortName()), assignment);
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -35,6 +35,7 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.util.CommandContext;
@@ -107,15 +108,15 @@
}
protected boolean prepareNextCommand(Command atomicCommand) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- return prepareCommand(atomicCommand, this, this.getContext());
+ return prepareCommand(atomicCommand, this, this.getContext(), this.getContext().getMetadata());
}
- static boolean prepareCommand(Command atomicCommand, RelationalNode node, CommandContext context)
+ static boolean prepareCommand(Command atomicCommand, RelationalNode node, CommandContext context, QueryMetadataInterface metadata)
throws ExpressionEvaluationException, MetaMatrixComponentException,
MetaMatrixProcessingException, CriteriaEvaluationException {
try {
// Defect 16059 - Rewrite the command once the references have been replaced with values.
- QueryRewriter.evaluateAndRewrite(atomicCommand, node.getDataManager(), context);
+ QueryRewriter.evaluateAndRewrite(atomicCommand, node.getDataManager(), context, metadata);
} catch (QueryValidatorException e) {
throw new MetaMatrixProcessingException(e, QueryExecPlugin.Util.getString("AccessNode.rewrite_failed", atomicCommand)); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -97,7 +97,7 @@
boolean needProcessing = false;
if(shouldEvaluate != null && shouldEvaluate.get(i)) {
updateCommand = (Command) updateCommand.clone();
- needProcessing = AccessNode.prepareCommand(updateCommand, this, context);
+ needProcessing = AccessNode.prepareCommand(updateCommand, this, context, context.getMetadata());
} else {
needProcessing = RelationalNodeUtil.shouldExecute(updateCommand, true);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Map;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
@@ -47,7 +49,6 @@
import com.metamatrix.query.function.aggregate.Sum;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Expression;
@@ -163,19 +164,19 @@
}
aggProjectionIndexes[i] = index;
String function = aggSymbol.getAggregateFunction();
- if(function.equals(ReservedWords.COUNT)) {
+ if(function.equals(SQLReservedWords.COUNT)) {
functions[i] = new Count();
- } else if(function.equals(ReservedWords.SUM)) {
+ } else if(function.equals(SQLReservedWords.SUM)) {
functions[i] = new Sum();
- } else if(function.equals(ReservedWords.AVG)) {
+ } else if(function.equals(SQLReservedWords.AVG)) {
functions[i] = new Avg();
- } else if(function.equals(ReservedWords.MIN)) {
+ } else if(function.equals(SQLReservedWords.MIN)) {
functions[i] = new Min();
} else {
functions[i] = new Max();
}
- if(aggSymbol.isDistinct() && !function.equals(ReservedWords.MIN) && !function.equals(ReservedWords.MAX)) {
+ if(aggSymbol.isDistinct() && !function.equals(SQLReservedWords.MIN) && !function.equals(SQLReservedWords.MAX)) {
functions[i] = new DuplicateFilter(functions[i], getBufferManager(), getConnectionID());
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,6 +31,7 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.symbol.Reference;
public class InsertPlanExecutionNode extends PlanExecutionNode {
@@ -40,9 +41,11 @@
private int batchRow = 1;
private int insertCount = 0;
private TupleBatch currentBatch;
+ private QueryMetadataInterface metadata;
- public InsertPlanExecutionNode(int nodeID) {
+ public InsertPlanExecutionNode(int nodeID, QueryMetadataInterface metadata) {
super(nodeID);
+ this.metadata = metadata;
}
public void setReferences(List<Reference> references) {
@@ -82,13 +85,13 @@
return false;
}
//assign the reference values.
- PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext());
+ PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata);
this.batchRow++;
return true;
}
public Object clone(){
- InsertPlanExecutionNode clonedNode = new InsertPlanExecutionNode(super.getID());
+ InsertPlanExecutionNode clonedNode = new InsertPlanExecutionNode(super.getID(), this.metadata);
copy(this, clonedNode);
return clonedNode;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -106,7 +106,7 @@
TempMetadataStore childMetadata = new TempMetadataStore();
QueryMetadataInterface resolveMetadata = new TempMetadataAdapter(metadata, childMetadata);
- GroupContext externalGroups = findChildCommandMetadata(procCommand, subCommand, childMetadata, resolveMetadata);
+ GroupContext externalGroups = findChildCommandMetadata(procCommand, childMetadata, resolveMetadata);
QueryResolver.setChildMetadata(subCommand, childMetadata.getData(), externalGroups);
@@ -132,20 +132,27 @@
* Find all metadata defined by this command for it's children. This metadata should be collected
* in the childMetadata object. Typical uses of this are for stored queries that define parameter
* variables valid in subcommands. only used for inserts, updates, and deletes
+ * @param metadata Metadata access
* @param command The command to find metadata on
- * @param metadata Metadata access
* @param childMetadata The store to collect child metadata in
* @throws QueryMetadataException If there is a metadata problem
* @throws QueryResolverException If the query cannot be resolved
* @throws MetaMatrixComponentException If there is an internal error
*/
- public GroupContext findChildCommandMetadata(ProcedureContainer container, Command subCommand, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
+ public GroupContext findChildCommandMetadata(ProcedureContainer container, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
// get the group on the delete statement
GroupSymbol group = container.getGroup();
// proceed further if it is a virtual group
- GroupContext externalGroups = new GroupContext();
+ return createChildMetadata(discoveredMetadata, metadata, group);
+ }
+
+ static GroupContext createChildMetadata(
+ TempMetadataStore discoveredMetadata,
+ QueryMetadataInterface metadata, GroupSymbol group)
+ throws QueryMetadataException, MetaMatrixComponentException {
+ GroupContext externalGroups = new GroupContext();
//Look up elements for the virtual group
List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, metadata);
@@ -159,6 +166,7 @@
}
addScalarGroup(ProcedureReservedWords.INPUT, discoveredMetadata, externalGroups, inputElments);
+ addScalarGroup(ProcedureReservedWords.INPUTS, discoveredMetadata, externalGroups, inputElments);
// Switch type to be boolean for all CHANGING variables
List<ElementSymbol> changingElements = new ArrayList<ElementSymbol>(elements.size());
@@ -170,10 +178,9 @@
}
addScalarGroup(ProcedureReservedWords.CHANGING, discoveredMetadata, externalGroups, changingElements);
+ return externalGroups;
+ }
- return externalGroups;
- }
-
/**
* @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -75,8 +75,7 @@
@Override
public GroupContext findChildCommandMetadata(ProcedureContainer container,
- Command subCommand, TempMetadataStore discoveredMetadata,
- QueryMetadataInterface metadata) throws QueryMetadataException,
+ TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata) throws QueryMetadataException,
QueryResolverException, MetaMatrixComponentException {
//defect 16451: don't expose input and changing variables to delete procedures
return null;
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,30 +22,30 @@
package com.metamatrix.query.resolver.command;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.query.QueryPlugin;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataID;
+import com.metamatrix.query.resolver.CommandResolver;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.resolver.util.ResolverVisitor;
+import com.metamatrix.query.sql.ProcedureReservedWords;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.DynamicCommand;
+import com.metamatrix.query.sql.lang.SetClause;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
public class DynamicCommandResolver implements CommandResolver {
/**
@@ -85,8 +85,8 @@
if (dynamicCmd.getUsing() != null && !dynamicCmd.getUsing().isEmpty()) {
for (SetClause clause : dynamicCmd.getUsing().getClauses()) {
ElementSymbol id = clause.getSymbol();
- id.setName(ProcedureReservedWords.USING + SingleElementSymbol.SEPARATOR + id.getShortName());
- id.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.USING));
+ id.setName(ProcedureReservedWords.DVARS + SingleElementSymbol.SEPARATOR + id.getShortName());
+ id.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.DVARS));
id.setType(clause.getValue().getType());
id.setMetadataID(new TempMetadataID(id.getCanonicalName(), id.getType()));
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -209,8 +209,7 @@
@Override
public GroupContext findChildCommandMetadata(ProcedureContainer container,
- Command subCommand, TempMetadataStore discoveredMetadata,
- QueryMetadataInterface metadata) throws QueryMetadataException,
+ TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata) throws QueryMetadataException,
QueryResolverException, MetaMatrixComponentException {
StoredProcedure storedProcedureCommand = (StoredProcedure) container;
@@ -276,7 +275,7 @@
Expression result = null;
try {
- result = ResolverUtil.convertExpression(expr, tgtType);
+ result = ResolverUtil.convertExpression(expr, tgtType, metadata);
} catch (QueryResolverException e) {
throw new QueryResolverException(e, QueryPlugin.Util.getString("ExecResolver.Param_convert_fail", new Object[] { srcType, tgtType})); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -102,7 +102,7 @@
resolveVariables(metadata, insert, groups);
}
- resolveTypes(insert);
+ resolveTypes(insert, metadata);
if (!insert.getGroup().isResolved()) { //define the implicit temp group
if(insert.getQueryExpression() != null) {
@@ -113,7 +113,7 @@
resolveVariables(metadata, insert, groups);
//ensure that the types match
- resolveTypes(insert);
+ resolveTypes(insert, metadata);
}
if (insert.getQueryExpression() != null && metadata.isVirtualGroup(insert.getGroup().getMetadataID())) {
@@ -151,7 +151,7 @@
* @param insert
* @throws QueryResolverException
*/
- public void resolveTypes(Insert insert) throws QueryResolverException {
+ public void resolveTypes(Insert insert, TempMetadataAdapter metadata) throws QueryResolverException {
boolean usingQuery = insert.getQueryExpression() != null;
@@ -183,7 +183,7 @@
if(element.getType() != null && expression.getType() != null) {
String elementTypeName = DataTypeManager.getDataTypeName(element.getType());
if (!usingQuery) {
- newValues.add(ResolverUtil.convertExpression(expression, elementTypeName));
+ newValues.add(ResolverUtil.convertExpression(expression, elementTypeName, metadata));
} else if (element.getType() != expression.getType()
&& !DataTypeManager.isImplicitConversion(DataTypeManager.getDataTypeName(expression.getType()),
DataTypeManager.getDataTypeName(element.getType()))) {
@@ -249,9 +249,11 @@
String varName = varSymbol.getShortCanonicalName();
String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
String inputKey = ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + varName;
-
+ String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
result.put(changingKey, new Constant(Boolean.TRUE));
- result.put(inputKey, valIter.next());
+ Object value = valIter.next();
+ result.put(inputKey, value);
+ result.put(inputsKey, value);
}
Collection insertElmnts = ResolverUtil.resolveElementsInGroup(insert.getGroup(), metadata);
@@ -267,9 +269,10 @@
String varName = varSymbol.getShortCanonicalName();
String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
String inputKey = ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + varName;
-
+ String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
result.put(changingKey, new Constant(Boolean.FALSE));
result.put(inputKey, value);
+ result.put(inputsKey, value);
}
return result;
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -34,6 +34,7 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.resolver.CommandResolver;
@@ -89,7 +90,7 @@
}
}
- setQuery.setProjectedTypes(firstProjectTypes);
+ setQuery.setProjectedTypes(firstProjectTypes, metadata.getMetadata());
// ORDER BY clause
if(setQuery.getOrderBy() != null) {
@@ -97,7 +98,7 @@
ResolverUtil.resolveOrderBy(setQuery.getOrderBy(), setQuery, metadata);
}
- setProjectedTypes(setQuery, firstProjectTypes);
+ setProjectedTypes(setQuery, firstProjectTypes, metadata.getMetadata());
if (setQuery.getLimit() != null) {
ResolverUtil.resolveLimit(setQuery.getLimit());
@@ -107,7 +108,7 @@
}
private void setProjectedTypes(SetQuery setQuery,
- List firstProjectTypes) throws QueryResolverException {
+ List firstProjectTypes, QueryMetadataInterface metadata) throws QueryResolverException {
for (QueryCommand subCommand : setQuery.getQueryCommands()) {
if (!(subCommand instanceof SetQuery)) {
continue;
@@ -126,8 +127,8 @@
}
}
}
- child.setProjectedTypes(firstProjectTypes);
- setProjectedTypes(child, firstProjectTypes);
+ child.setProjectedTypes(firstProjectTypes, metadata);
+ setProjectedTypes(child, firstProjectTypes, metadata);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -92,6 +92,7 @@
GroupSymbol groupSymbol = (GroupSymbol) groupIter.next();
String groupName = groupSymbol.getName();
if(!groupName.equalsIgnoreCase(ProcedureReservedWords.INPUT) &&
+ !groupName.equalsIgnoreCase(ProcedureReservedWords.INPUTS) &&
!groupName.equalsIgnoreCase(ProcedureReservedWords.CHANGING) ) {
// set the groupSymbol on the procedure
ResolverUtil.resolveGroup(groupSymbol, metadata);
@@ -277,7 +278,7 @@
throw new QueryResolverException(QueryPlugin.Util.getString("ResolveVariablesVisitor.datatype_for_the_expression_not_resolvable")); //$NON-NLS-1$
}
String varTypeName = DataTypeManager.getDataTypeName(varType);
- assStmt.setExpression(ResolverUtil.convertExpression(expr, varTypeName));
+ assStmt.setExpression(ResolverUtil.convertExpression(expr, varTypeName, metadata));
}
break;
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -102,10 +102,10 @@
String varName = leftSymbol.getShortCanonicalName();
String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
String inputKey = ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + varName;
-
+ String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
result.put(changingKey, new Constant(Boolean.TRUE));
result.put(inputKey, entry.getValue());
-
+ result.put(inputsKey, entry.getValue());
updateVars.add(leftSymbol);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -43,7 +43,6 @@
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.metadata.GroupInfo;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.StoredProcedureInfo;
@@ -187,10 +186,10 @@
* @return
* @throws QueryResolverException
*/
- public static Expression convertExpression(Expression sourceExpression, String targetTypeName) throws QueryResolverException {
+ public static Expression convertExpression(Expression sourceExpression, String targetTypeName, QueryMetadataInterface metadata) throws QueryResolverException {
return convertExpression(sourceExpression,
DataTypeManager.getDataTypeName(sourceExpression.getType()),
- targetTypeName);
+ targetTypeName, metadata);
}
/**
@@ -203,14 +202,14 @@
* @return
* @throws QueryResolverException
*/
- public static Expression convertExpression(Expression sourceExpression, String sourceTypeName, String targetTypeName) throws QueryResolverException {
+ public static Expression convertExpression(Expression sourceExpression, String sourceTypeName, String targetTypeName, QueryMetadataInterface metadata) throws QueryResolverException {
if (sourceTypeName.equals(targetTypeName)) {
return sourceExpression;
}
if(canImplicitlyConvert(sourceTypeName, targetTypeName)
|| (sourceExpression instanceof Constant && convertConstant(sourceTypeName, targetTypeName, (Constant)sourceExpression) != null)) {
- return getConversion(sourceExpression, sourceTypeName, targetTypeName, true);
+ return getConversion(sourceExpression, sourceTypeName, targetTypeName, true, metadata.getFunctionLibrary());
}
//Expression is wrong type and can't convert
@@ -258,10 +257,9 @@
public static Function getConversion(Expression sourceExpression,
String sourceTypeName,
String targetTypeName,
- boolean implicit) {
+ boolean implicit, FunctionLibrary library) {
Class<?> srcType = DataTypeManager.getDataTypeClass(sourceTypeName);
- FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
FunctionDescriptor fd = library.findTypedConversionFunction(srcType, DataTypeManager.getDataTypeClass(targetTypeName));
Function conversion = new Function(fd.getName(), new Expression[] { sourceExpression, new Constant(targetTypeName) });
@@ -777,7 +775,7 @@
* @throws QueryResolverException if a conversion is necessary but none can
* be found
*/
- static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit)
+ static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit, QueryMetadataInterface metadata)
throws QueryResolverException {
// Check that type of the expression is same as the type of the
@@ -796,7 +794,7 @@
String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
Expression result = null;
try {
- result = convertExpression(expression, exprTypeName, subqueryTypeName);
+ result = convertExpression(expression, exprTypeName, subqueryTypeName, metadata);
} catch (QueryResolverException qre) {
throw new QueryResolverException(qre, ErrorMessageKeys.RESOLVER_0033, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0033, crit));
}
@@ -841,7 +839,7 @@
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
}
result.setKeyElement(keyElement);
- args[3] = convertExpression(args[3], DataTypeManager.getDataTypeName(keyElement.getType()));
+ args[3] = convertExpression(args[3], DataTypeManager.getDataTypeName(keyElement.getType()), metadata);
return result;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -44,11 +44,11 @@
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionForm;
import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.metadata.GroupInfo;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.ProcedureReservedWords;
import com.metamatrix.query.sql.lang.BetweenCriteria;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.GroupContext;
@@ -206,6 +206,13 @@
//copy the match information
ElementSymbol resolvedSymbol = match.element;
+ if (isExternal //convert input to inputs
+ && metadata.isScalarGroup(resolvedSymbol.getGroupSymbol().getMetadataID())
+ && ProcedureReservedWords.INPUT.equals(groupContext)) {
+ resolvedSymbol = new ElementSymbol(ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + elementShortName);
+ resolveElementSymbol(resolvedSymbol);
+ elementSymbol.setOutputName(resolvedSymbol.getOutputName());
+ }
elementSymbol.setIsExternalReference(isExternal);
elementSymbol.setType(resolvedSymbol.getType());
elementSymbol.setMetadataID(resolvedSymbol.getMetadataID());
@@ -264,7 +271,7 @@
public void visit(SubqueryCompareCriteria obj) {
try {
- obj.setLeftExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj));
+ obj.setLeftExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj, metadata));
} catch(QueryResolverException e) {
handleException(e);
}
@@ -273,7 +280,7 @@
public void visit(SubquerySetCriteria obj) {
try {
- obj.setExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj));
+ obj.setExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj, metadata));
} catch(QueryResolverException e) {
handleException(e);
}
@@ -289,7 +296,7 @@
public void visit(Function obj) {
try {
- resolveFunction(obj);
+ resolveFunction(obj, this.metadata.getFunctionLibrary());
} catch(QueryResolverException e) {
if (unresolvedFunctions == null) {
unresolvedFunctions = new LinkedHashMap<Function, QueryResolverException>();
@@ -320,7 +327,7 @@
String type = DataTypeManager.getDataTypeName(obj.getSymbol().getType());
try {
setDesiredType(obj.getValue(), obj.getSymbol().getType(), obj);
- obj.setValue(ResolverUtil.convertExpression(obj.getValue(), type));
+ obj.setValue(ResolverUtil.convertExpression(obj.getValue(), type, metadata));
} catch(QueryResolverException e) {
handleException(new QueryResolverException(e, QueryPlugin.Util.getString("SetClause.resolvingError", new Object[] {obj.getValue(), obj.getSymbol(), type}))); //$NON-NLS-1$
}
@@ -367,7 +374,7 @@
/**
* Resolve function such that all functions are resolved and type-safe.
*/
- void resolveFunction(Function function)
+ void resolveFunction(Function function, FunctionLibrary library)
throws QueryResolverException, MetaMatrixComponentException {
// Check whether this function is already resolved
@@ -388,8 +395,6 @@
hasArgWithoutType = true;
}
}
-
- FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
//special case handling for convert of an untyped reference
if (FunctionLibrary.isConvert(function) && hasArgWithoutType) {
@@ -543,9 +548,9 @@
String commonType = ResolverUtil.getCommonType(new String[] {expTypeName, lowerTypeName, upperTypeName});
if (commonType != null) {
- criteria.setExpression(ResolverUtil.convertExpression(exp, expTypeName, commonType));
- criteria.setLowerExpression(ResolverUtil.convertExpression(lower, lowerTypeName, commonType));
- criteria.setUpperExpression(ResolverUtil.convertExpression(upper, upperTypeName, commonType));
+ criteria.setExpression(ResolverUtil.convertExpression(exp, expTypeName, commonType, metadata));
+ criteria.setLowerExpression(ResolverUtil.convertExpression(lower, lowerTypeName, commonType, metadata));
+ criteria.setUpperExpression(ResolverUtil.convertExpression(upper, upperTypeName, commonType, metadata));
} else {
// Couldn't find a common type to implicitly convert to
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0027, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0027, expTypeName, lowerTypeName, criteria));
@@ -575,7 +580,7 @@
if(rightExpression instanceof Constant) {
// Auto-convert constant string on right to expected type on left
try {
- ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName));
+ ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName, metadata));
return;
} catch (QueryResolverException qre) {
//ignore
@@ -586,7 +591,7 @@
if(leftExpression instanceof Constant) {
// Auto-convert constant string on left to expected type on right
try {
- ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName));
+ ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName, metadata));
return;
} catch (QueryResolverException qre) {
//ignore
@@ -596,12 +601,12 @@
// Try to apply a conversion generically
if(ResolverUtil.canImplicitlyConvert(leftTypeName, rightTypeName)) {
- ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName) );
+ ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName, metadata) );
return;
}
if(ResolverUtil.canImplicitlyConvert(rightTypeName, leftTypeName)) {
- ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName) );
+ ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName, metadata) );
return;
}
@@ -611,8 +616,8 @@
// Neither are aggs, but types can't be reconciled
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0027, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0027, new Object[] { leftTypeName, rightTypeName, ccrit }));
}
- ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, commonType) );
- ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, commonType) );
+ ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, commonType, metadata) );
+ ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, commonType, metadata) );
}
void resolveMatchCriteria(MatchCriteria mcrit)
@@ -644,12 +649,12 @@
if(!(expr instanceof AggregateSymbol) &&
ResolverUtil.canImplicitlyConvert(type, DataTypeManager.DefaultDataTypes.STRING)) {
- result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.STRING);
+ result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.STRING, metadata);
} else if (!(expr instanceof AggregateSymbol) &&
ResolverUtil.canImplicitlyConvert(type, DataTypeManager.DefaultDataTypes.CLOB)){
- result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.CLOB);
+ result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.CLOB, metadata);
} else {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0029, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0029, mcrit));
@@ -687,7 +692,7 @@
String valTypeName = DataTypeManager.getDataTypeName(value.getType());
if(ResolverUtil.canImplicitlyConvert(valTypeName, exprTypeName)) {
// Apply cast and replace current value
- newVals.add(ResolverUtil.convertExpression(value, valTypeName, exprTypeName) );
+ newVals.add(ResolverUtil.convertExpression(value, valTypeName, exprTypeName, metadata) );
changed = true;
} else {
convertLeft = true;
@@ -716,7 +721,7 @@
}
// Convert left expression to type of values in the set
- scrit.setExpression(ResolverUtil.convertExpression(scrit.getExpression(), exprTypeName, setTypeName ));
+ scrit.setExpression(ResolverUtil.convertExpression(scrit.getExpression(), exprTypeName, setTypeName, metadata));
} else {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0031, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0031, scrit));
@@ -799,16 +804,16 @@
if (thenTypeName == null) {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0068, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0068, "THEN/ELSE", obj)); //$NON-NLS-1$
}
- obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), whenTypeName));
+ obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), whenTypeName, metadata));
ArrayList whens = new ArrayList(whenCount);
ArrayList thens = new ArrayList(whenCount);
for (int i = 0; i < whenCount; i++) {
- whens.add(ResolverUtil.convertExpression(obj.getWhenExpression(i), whenTypeName));
- thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName));
+ whens.add(ResolverUtil.convertExpression(obj.getWhenExpression(i), whenTypeName, metadata));
+ thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName, metadata));
}
obj.setWhen(whens, thens);
if (elseExpr != null) {
- obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName));
+ obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName, metadata));
}
// Set this CASE expression's type to the common THEN type, and we're done.
obj.setType(DataTypeManager.getDataTypeClass(thenTypeName));
@@ -887,11 +892,11 @@
}
ArrayList thens = new ArrayList(whenCount);
for (int i = 0; i < whenCount; i++) {
- thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName));
+ thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName, metadata));
}
obj.setWhen(obj.getWhen(), thens);
if (elseExpr != null) {
- obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName));
+ obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName, metadata));
}
// Set this CASE expression's type to the common THEN type, and we're done.
obj.setType(DataTypeManager.getDataTypeClass(thenTypeName));
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -42,6 +42,7 @@
import java.util.StringTokenizer;
import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.SQLReservedWords;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
@@ -49,7 +50,6 @@
import com.metamatrix.api.exception.query.CriteriaEvaluationException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.InvalidFunctionException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
@@ -61,7 +61,6 @@
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.function.FunctionMethods;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -73,7 +72,6 @@
import com.metamatrix.query.resolver.util.ResolverVisitor;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.LanguageObject.Util;
import com.metamatrix.query.sql.lang.AbstractSetCriteria;
import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
@@ -190,8 +188,8 @@
this.procCommand = procCommand;
}
- public static Command evaluateAndRewrite(Command command, ProcessorDataManager dataMgr, CommandContext context) throws MetaMatrixProcessingException, MetaMatrixComponentException {
- QueryRewriter queryRewriter = new QueryRewriter(null, context, null);
+ public static Command evaluateAndRewrite(Command command, ProcessorDataManager dataMgr, CommandContext context, QueryMetadataInterface metadata) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ QueryRewriter queryRewriter = new QueryRewriter(metadata, context, null);
queryRewriter.dataMgr = dataMgr;
queryRewriter.rewriteSubcommands = true;
try {
@@ -917,7 +915,7 @@
List symbols = query.getSelect().getProjectedSymbols();
- List newSymbols = SetQuery.getTypedProjectedSymbols(symbols, actualSymbolTypes);
+ List newSymbols = SetQuery.getTypedProjectedSymbols(symbols, actualSymbolTypes, this.metadata);
query.getSelect().setSymbols(newSymbols);
}
@@ -932,7 +930,7 @@
}
correctProjectedTypes(setQuery.getProjectedTypes(), (Query)command);
}
- setQuery.setProjectedTypes(null);
+ setQuery.setProjectedTypes(null, null);
}
setQuery.setLeftQuery((QueryCommand)rewriteCommand(setQuery.getLeftQuery(), true));
@@ -1075,9 +1073,9 @@
* @param criteria
* @return
*/
- public static Criteria optimizeCriteria(CompoundCriteria criteria) {
+ public static Criteria optimizeCriteria(CompoundCriteria criteria, QueryMetadataInterface metadata) {
try {
- return new QueryRewriter(null, null, null).rewriteCriteria(criteria, false);
+ return new QueryRewriter(metadata, null, null).rewriteCriteria(criteria, false);
} catch (QueryValidatorException err) {
//shouldn't happen
return criteria;
@@ -1362,7 +1360,7 @@
// Create a function of the two constants and evaluate it
Expression combinedConst = null;
- FunctionLibrary funcLib = FunctionLibraryManager.getFunctionLibrary();
+ FunctionLibrary funcLib = this.metadata.getFunctionLibrary();
FunctionDescriptor descriptor = funcLib.findFunction(oppFunc, new Class[] { rightExpr.getType(), const1.getType() });
if (descriptor == null){
//See defect 9380 - this can be caused by const2 being a null Constant, for example (? + 1) < null
@@ -1373,13 +1371,10 @@
if (rightExpr instanceof Constant) {
Constant const2 = (Constant)rightExpr;
try {
- Object result = funcLib.invokeFunction(
- descriptor, new Object[] { const2.getValue(), const1.getValue() } );
+ Object result = descriptor.invokeFunction(new Object[] { const2.getValue(), const1.getValue() } );
combinedConst = new Constant(result, descriptor.getReturnType());
- } catch(InvalidFunctionException e) {
+ } catch(FunctionExecutionException e) {
throw new QueryValidatorException(e, ErrorMessageKeys.REWRITER_0003, QueryExecPlugin.Util.getString(ErrorMessageKeys.REWRITER_0003, e.getMessage()));
- } catch(FunctionExecutionException e) {
- throw new QueryValidatorException(e, ErrorMessageKeys.REWRITER_0003, QueryExecPlugin.Util.getString(ErrorMessageKeys.REWRITER_0003, e.getMessage()));
}
} else {
Function conversion = new Function(descriptor.getName(), new Expression[] { rightExpr, const1 });
@@ -1601,21 +1596,18 @@
return crit;
}
String format = (String)((Constant)formatExpr).getValue();
- FunctionLibrary funcLib = FunctionLibraryManager.getFunctionLibrary();
+ FunctionLibrary funcLib = this.metadata.getFunctionLibrary();
FunctionDescriptor descriptor = funcLib.findFunction(inverseFunction, new Class[] { rightExpr.getType(), formatExpr.getType() });
if(descriptor == null){
return crit;
}
Object value = ((Constant)rightExpr).getValue();
try {
- Object result = funcLib.invokeFunction(descriptor, new Object[] {((Constant)rightExpr).getValue(), format});
- result = funcLib.invokeFunction(leftFunction.getFunctionDescriptor(), new Object[] { result, format } );
+ Object result = descriptor.invokeFunction(new Object[] {((Constant)rightExpr).getValue(), format});
+ result = leftFunction.getFunctionDescriptor().invokeFunction(new Object[] { result, format } );
if (((Comparable)value).compareTo(result) != 0) {
return getSimpliedCriteria(crit, leftExpr, crit.getOperator() != CompareCriteria.EQ, true);
}
- } catch(InvalidFunctionException e) {
- String errorMsg = QueryExecPlugin.Util.getString("QueryRewriter.criteriaError", crit); //$NON-NLS-1$
- throw new QueryValidatorException(e, errorMsg);
} catch(FunctionExecutionException e) {
//Not all numeric formats are invertable, so just return the criteria as it may still be valid
return crit;
@@ -1900,7 +1892,7 @@
Expression value = (Expression)variables.get(es.getCanonicalName());
if (value == null) {
- if (grpName.equals(ProcedureReservedWords.INPUT)) {
+ if ((grpName.equals(ProcedureReservedWords.INPUT) || grpName.equals(ProcedureReservedWords.INPUTS))) {
return new Constant(null, es.getType());
}
if (grpName.equals(ProcedureReservedWords.CHANGING)) {
@@ -1952,12 +1944,12 @@
}
private Expression rewriteExpression(AggregateSymbol expression) {
- if (!expression.getAggregateFunction().equals(ReservedWords.COUNT)
- && !expression.getAggregateFunction().equals(ReservedWords.SUM)
+ if (!expression.getAggregateFunction().equals(SQLReservedWords.COUNT)
+ && !expression.getAggregateFunction().equals(SQLReservedWords.SUM)
&& EvaluatableVisitor.willBecomeConstant(expression.getExpression())) {
try {
return new ExpressionSymbol(expression.getName(), ResolverUtil
- .convertExpression(expression.getExpression(),DataTypeManager.getDataTypeName(expression.getType())));
+ .convertExpression(expression.getExpression(),DataTypeManager.getDataTypeName(expression.getType()), metadata));
} catch (QueryResolverException e) {
//should not happen, so throw as a runtime
throw new MetaMatrixRuntimeException(e);
@@ -1989,6 +1981,7 @@
function.setName(actualName);
}
+ FunctionLibrary funcLibrary = this.metadata.getFunctionLibrary();
Integer code = FUNCTION_MAP.get(functionLowerName);
if (code != null) {
switch (code) {
@@ -1997,7 +1990,7 @@
new Expression[] {new Constant(" "), function.getArg(0)}); //$NON-NLS-1$
//resolve the function
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.REPEAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER});
+ funcLibrary.findFunction(SourceSystemFunctions.REPEAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER});
result.setFunctionDescriptor(descriptor);
result.setType(DataTypeManager.DefaultDataClasses.STRING);
function = result;
@@ -2005,10 +1998,10 @@
}
case 1: {//from_unixtime(a) => timestampadd(SQL_TSI_SECOND, a, new Timestamp(0))
Function result = new Function(FunctionLibrary.TIMESTAMPADD,
- new Expression[] {new Constant(ReservedWords.SQL_TSI_SECOND), function.getArg(0), new Constant(new Timestamp(0)) });
+ new Expression[] {new Constant(SQLReservedWords.SQL_TSI_SECOND), function.getArg(0), new Constant(new Timestamp(0)) });
//resolve the function
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(FunctionLibrary.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
+ funcLibrary.findFunction(FunctionLibrary.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
result.setFunctionDescriptor(descriptor);
result.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
function = result;
@@ -2030,7 +2023,7 @@
new Expression[] {function.getArg(0), function.getArg(1) });
//resolve the function
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { function.getType(), function.getType() });
+ funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { function.getType(), function.getType() });
result.setFunctionDescriptor(descriptor);
result.setType(function.getType());
function = result;
@@ -2046,14 +2039,14 @@
newArgs[i].setType(args[i].getType());
Assertion.assertTrue(args[i].getType() == DataTypeManager.DefaultDataClasses.STRING);
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
+ funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
newArgs[i].setFunctionDescriptor(descriptor);
}
Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
concat.setType(DataTypeManager.DefaultDataClasses.STRING);
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
+ funcLibrary.findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
concat.setFunctionDescriptor(descriptor);
List when = Arrays.asList(new Criteria[] {new CompoundCriteria(CompoundCriteria.AND, new IsNullCriteria(args[0]), new IsNullCriteria(args[1]))});
@@ -2067,33 +2060,33 @@
case 5: {
if (function.getType() != DataTypeManager.DefaultDataClasses.TIMESTAMP) {
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
+ funcLibrary.findFunction(SourceSystemFunctions.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
function.setFunctionDescriptor(descriptor);
Class<?> type = function.getType();
function.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
- function.getArgs()[2] = ResolverUtil.getConversion(function.getArg(2), DataTypeManager.getDataTypeName(type), DataTypeManager.DefaultDataTypes.TIMESTAMP, false);
- function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false);
+ function.getArgs()[2] = ResolverUtil.getConversion(function.getArg(2), DataTypeManager.getDataTypeName(type), DataTypeManager.DefaultDataTypes.TIMESTAMP, false, funcLibrary);
+ function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false, funcLibrary);
}
break;
}
case 6:
case 7: {
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.PARSETIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
+ funcLibrary.findFunction(SourceSystemFunctions.PARSETIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
function.setName(SourceSystemFunctions.PARSETIMESTAMP);
function.setFunctionDescriptor(descriptor);
Class<?> type = function.getType();
function.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
- function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false);
+ function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false, funcLibrary);
break;
}
case 8:
case 9: {
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.FORMATTIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, DataTypeManager.DefaultDataClasses.STRING });
+ funcLibrary.findFunction(SourceSystemFunctions.FORMATTIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, DataTypeManager.DefaultDataClasses.STRING });
function.setName(SourceSystemFunctions.FORMATTIMESTAMP);
function.setFunctionDescriptor(descriptor);
- function.getArgs()[0] = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.TIMESTAMP, false);
+ function.getArgs()[0] = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.TIMESTAMP, false, funcLibrary);
break;
}
}
@@ -2366,7 +2359,7 @@
for (SingleElementSymbol ses : actualSymbols) {
actualTypes.add(ses.getType());
}
- List<SingleElementSymbol> selectSymbols = SetQuery.getTypedProjectedSymbols(ResolverUtil.resolveElementsInGroup(inlineGroup, tma), actualTypes);
+ List<SingleElementSymbol> selectSymbols = SetQuery.getTypedProjectedSymbols(ResolverUtil.resolveElementsInGroup(inlineGroup, tma), actualTypes, tma);
Iterator<SingleElementSymbol> iter = actualSymbols.iterator();
for (SingleElementSymbol ses : selectSymbols) {
ses = (SingleElementSymbol)ses.clone();
@@ -2471,7 +2464,7 @@
Boolean result = null;
for (ElementSymbol var : ElementCollectorVisitor.getElements(expr, false)) {
String grpName = var.getGroupSymbol().getName();
- if (var.isExternalReference() && grpName.equals(ProcedureReservedWords.INPUT)) {
+ if (var.isExternalReference() && (grpName.equalsIgnoreCase(ProcedureReservedWords.INPUT) || grpName.equalsIgnoreCase(ProcedureReservedWords.INPUTS))) {
String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + var.getShortCanonicalName();
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,21 @@
package com.metamatrix.query.sql;
+import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
+import org.teiid.connector.language.SQLReservedWords;
+
/**
* Special variable names in stored procedure language.
*/
public class ProcedureReservedWords {
- public static final String INPUT = "INPUT"; //$NON-NLS-1$
+ @Deprecated
+ public static final String INPUT = SQLReservedWords.INPUT;
+
+ public static final String INPUTS = "INPUTS"; //$NON-NLS-1$
public static final String ROWS_UPDATED = "ROWS_UPDATED"; //$NON-NLS-1$
@@ -38,29 +44,25 @@
public static final String VARIABLES = "VARIABLES"; //$NON-NLS-1$
- public static final String USING = "USING"; //$NON-NLS-1$
-
- public static final String[] ALL_WORDS = new String[] {
- INPUT,
- ROWS_UPDATED,
- CHANGING,
- VARIABLES,
- USING
- };
-
+ public static final String DVARS = "DVARS"; //$NON-NLS-1$
+
/**
- * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
- */
- private static final Set PROCEDURE_RESERVED_WORDS = new HashSet();
+ * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
+ */
+ private static final Set<String> RESERVED_WORDS = new HashSet<String>();
- // Initialize PROCEDURE_RESERVED_WORDS set
- static {
- // Iterate through the reserved words and capitalize all of them
- for ( int i=0; i!=ProcedureReservedWords.ALL_WORDS.length; ++i ) {
- String reservedWord = ProcedureReservedWords.ALL_WORDS[i];
- ProcedureReservedWords.PROCEDURE_RESERVED_WORDS.add( reservedWord.toUpperCase() );
- }
- }
+ // Initialize RESERVED_WORDS set - This is a poor man's enum. To much legacy code expects the constants to be Strings.
+ static {
+ Field[] fields = SQLReservedWords.class.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getType() == String.class) {
+ try {
+ RESERVED_WORDS.add((String)field.get(null));
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
/** Can't construct */
private ProcedureReservedWords() {}
@@ -74,6 +76,6 @@
if (str == null) {
return false;
}
- return PROCEDURE_RESERVED_WORDS.contains(str.toUpperCase());
+ return RESERVED_WORDS.contains(str.toUpperCase());
}
}
Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,296 +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.query.sql;
-
-import java.util.Set;
-import java.util.HashSet;
-
-public class ReservedWords {
-
- public static final String ANY = "ANY"; //$NON-NLS-1$
- public static final String ALL = "ALL"; //$NON-NLS-1$
- public static final String ALL_COLS = "*"; //$NON-NLS-1$
- public static final String AND = "AND"; //$NON-NLS-1$
- public static final String AS = "AS"; //$NON-NLS-1$
- public static final String ASC = "ASC"; //$NON-NLS-1$
- public static final String AVG = "AVG"; //$NON-NLS-1$
- public static final String BEGIN = "BEGIN"; //$NON-NLS-1$
- public static final String BETWEEN = "BETWEEN"; //$NON-NLS-1$
- public static final String BIGDECIMAL = "BIGDECIMAL"; //$NON-NLS-1$
- public static final String BIGINTEGER = "BIGINTEGER"; //$NON-NLS-1$
- public static final String BLOB = "BLOB"; //$NON-NLS-1$
- public static final String BREAK = "BREAK"; //$NON-NLS-1$
- public static final String BY = "BY"; //$NON-NLS-1$
- public static final String BYTE = "BYTE"; //$NON-NLS-1$
- public static final String CASE = "CASE"; //$NON-NLS-1$
- public static final String CAST = "CAST"; //$NON-NLS-1$
- public static final String CHAR = "CHAR"; //$NON-NLS-1$
- public static final String CLOB = "CLOB"; //$NON-NLS-1$
- public static final String CONVERT = "CONVERT"; //$NON-NLS-1$
- public static final String CONTINUE = "CONTINUE"; //$NON-NLS-1$
- public static final String COUNT = "COUNT"; //$NON-NLS-1$
- public static final String CRITERIA = "CRITERIA"; //$NON-NLS-1$
- public static final String CREATE = "CREATE"; //$NON-NLS-1$
- public static final String CROSS = "CROSS"; //$NON-NLS-1$
- public static final String DATE = "DATE"; //$NON-NLS-1$
- public static final String DEBUG = "DEBUG"; //$NON-NLS-1$
- public static final String DECLARE = "DECLARE"; //$NON-NLS-1$
- public static final String DELETE = "DELETE"; //$NON-NLS-1$
- public static final String DESC = "DESC"; //$NON-NLS-1$
- public static final String DISTINCT = "DISTINCT"; //$NON-NLS-1$
- public static final String DOUBLE = "DOUBLE"; //$NON-NLS-1$
- public static final String DROP = "DROP"; //$NON-NLS-1$
- public static final String ELSE = "ELSE"; //$NON-NLS-1$
- public static final String END = "END"; //$NON-NLS-1$
- public static final String ERROR = "ERROR"; //$NON-NLS-1$
- public static final String ESCAPE = "ESCAPE"; //$NON-NLS-1$
- public static final String EXCEPT = "EXCEPT"; //$NON-NLS-1$
- public static final String EXEC = "EXEC"; //$NON-NLS-1$
- public static final String EXECUTE = "EXECUTE"; //$NON-NLS-1$
- public static final String EXISTS = "EXISTS"; //$NON-NLS-1$
- public static final String FALSE = "FALSE"; //$NON-NLS-1$
- public static final String FLOAT = "FLOAT"; //$NON-NLS-1$
- public static final String FOR = "FOR"; //$NON-NLS-1$
- public static final String FROM = "FROM"; //$NON-NLS-1$
- public static final String FULL = "FULL"; //$NON-NLS-1$
- public static final String GROUP = "GROUP"; //$NON-NLS-1$
- public static final String HAS = "HAS"; //$NON-NLS-1$
- public static final String HAVING = "HAVING"; //$NON-NLS-1$
- public static final String IF = "IF"; //$NON-NLS-1$
- public static final String IN = "IN"; //$NON-NLS-1$
- public static final String INNER = "INNER"; //$NON-NLS-1$
- public static final String INSERT = "INSERT"; //$NON-NLS-1$
- public static final String INTEGER = "INTEGER"; //$NON-NLS-1$
- public static final String INTERSECT = "INTERSECT"; //$NON-NLS-1$
- public static final String INTO = "INTO"; //$NON-NLS-1$
- public static final String IS = "IS"; //$NON-NLS-1$
- public static final String JOIN = "JOIN"; //$NON-NLS-1$
- public static final String LEFT = "LEFT"; //$NON-NLS-1$
- public static final String LIKE = "LIKE"; //$NON-NLS-1$
- public static final String LIMIT = "LIMIT"; //$NON-NLS-1$
- public static final String LOCAL = "LOCAL"; //$NON-NLS-1$
- public static final String LONG = "LONG"; //$NON-NLS-1$
- public static final String LOOP = "LOOP"; //$NON-NLS-1$
- public static final String MAKEDEP = "MAKEDEP"; //$NON-NLS-1$
- public static final String MAKENOTDEP = "MAKENOTDEP"; //$NON-NLS-1$
- public static final String MIN = "MIN"; //$NON-NLS-1$
- public static final String MAX = "MAX"; //$NON-NLS-1$
- public static final String NOCACHE = "NOCACHE"; //$NON-NLS-1$
- public static final String NOT = "NOT"; //$NON-NLS-1$
- public static final String NULL = "NULL"; //$NON-NLS-1$
- public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
- public static final String ON = "ON"; //$NON-NLS-1$
- public static final String OR = "OR"; //$NON-NLS-1$
- public static final String ORDER = "ORDER"; //$NON-NLS-1$
- public static final String OPTION = "OPTION"; //$NON-NLS-1$
- public static final String OUTER = "OUTER"; //$NON-NLS-1$
- public static final String PROCEDURE = "PROCEDURE"; //$NON-NLS-1$
- public static final String PLANONLY = "PLANONLY"; //$NON-NLS-1$
- public static final String RIGHT = "RIGHT"; //$NON-NLS-1$
- public static final String SELECT = "SELECT"; //$NON-NLS-1$
- public static final String SET = "SET"; //$NON-NLS-1$
- public static final String SHORT = "SHORT"; //$NON-NLS-1$
- public static final String SHOWPLAN = "SHOWPLAN"; //$NON-NLS-1$
- public static final String SOME = "SOME"; //$NON-NLS-1$
- public static final String SQL_TSI_FRAC_SECOND = "SQL_TSI_FRAC_SECOND"; //$NON-NLS-1$
- public static final String SQL_TSI_SECOND = "SQL_TSI_SECOND"; //$NON-NLS-1$
- public static final String SQL_TSI_MINUTE = "SQL_TSI_MINUTE"; //$NON-NLS-1$
- public static final String SQL_TSI_HOUR = "SQL_TSI_HOUR"; //$NON-NLS-1$
- public static final String SQL_TSI_DAY = "SQL_TSI_DAY"; //$NON-NLS-1$
- public static final String SQL_TSI_WEEK = "SQL_TSI_WEEK"; //$NON-NLS-1$
- public static final String SQL_TSI_MONTH = "SQL_TSI_MONTH"; //$NON-NLS-1$
- public static final String SQL_TSI_QUARTER = "SQL_TSI_QUARTER"; //$NON-NLS-1$
- public static final String SQL_TSI_YEAR = "SQL_TSI_YEAR"; //$NON-NLS-1$
- public static final String STRING = "STRING"; //$NON-NLS-1$
- public static final String SUM = "SUM"; //$NON-NLS-1$
- public static final String TABLE = "TABLE"; //$NON-NLS-1$
- public static final String TEMPORARY = "TEMPORARY"; //$NON-NLS-1$
- public static final String THEN = "THEN"; //$NON-NLS-1$
- public static final String TIME = "TIME"; //$NON-NLS-1$
- public static final String TIMESTAMP = "TIMESTAMP"; //$NON-NLS-1$
- public static final String TIMESTAMPADD = "TIMESTAMPADD"; //$NON-NLS-1$
- public static final String TIMESTAMPDIFF = "TIMESTAMPDIFF"; //$NON-NLS-1$
- public static final String TRANSLATE = "TRANSLATE"; //$NON-NLS-1$
- public static final String TRUE = "TRUE"; //$NON-NLS-1$
- public static final String UNION = "UNION"; //$NON-NLS-1$
- public static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
- public static final String UPDATE = "UPDATE"; //$NON-NLS-1$
- public static final String USING = "USING"; //$NON-NLS-1$
- public static final String VALUES = "VALUES"; //$NON-NLS-1$
- public static final String VIRTUAL = "VIRTUAL"; //$NON-NLS-1$
- public static final String VIRTUAL_DEP_JOIN = "VIRTUALDEP"; //$NON-NLS-1$
- public static final String WHEN = "WHEN"; //$NON-NLS-1$
- public static final String WITH = "WITH"; //$NON-NLS-1$
- public static final String WHERE = "WHERE"; //$NON-NLS-1$
- public static final String WHILE = "WHILE"; //$NON-NLS-1$
- public static final String XML = "XML"; //$NON-NLS-1$
-
- public static final String[] ALL_WORDS = new String[] {
- ALL,
- ALL_COLS,
- AND,
- ANY,
- AS,
- ASC,
- AVG,
- BEGIN,
- BETWEEN,
- BIGINTEGER,
- BIGDECIMAL,
- BLOB,
- BREAK,
- BY,
- BYTE,
- CASE,
- CAST,
- CHAR,
- CLOB,
- CONVERT,
- CONTINUE,
- COUNT,
- CREATE,
- CRITERIA,
- CROSS,
- DATE,
- DEBUG,
- DECLARE,
- DELETE,
- DESC,
- DISTINCT,
- DOUBLE,
- DROP,
- ELSE,
- END,
- ERROR,
- ESCAPE,
- EXCEPT,
- EXEC,
- EXECUTE,
- EXISTS,
- FALSE,
- FLOAT,
- FOR,
- FROM,
- FULL,
- GROUP,
- HAS,
- HAVING,
- IF,
- IN,
- INNER,
- INSERT,
- INTEGER,
- INTERSECT,
- INTO,
- IS,
- JOIN,
- LEFT,
- LIKE,
- LIMIT,
- LOCAL,
- LONG,
- LOOP,
- MAKEDEP,
- MAKENOTDEP,
- MIN,
- MAX,
- NOCACHE,
- NOT,
- NULL,
- OBJECT,
- ON,
- OR,
- ORDER,
- OPTION,
- OUTER,
- PLANONLY,
- PROCEDURE,
- RIGHT,
- SELECT,
- SET,
- SHORT,
- SHOWPLAN,
- SOME,
- SQL_TSI_FRAC_SECOND,
- SQL_TSI_SECOND,
- SQL_TSI_MINUTE,
- SQL_TSI_HOUR,
- SQL_TSI_DAY,
- SQL_TSI_WEEK,
- SQL_TSI_MONTH,
- SQL_TSI_QUARTER,
- SQL_TSI_YEAR,
- STRING,
- SUM,
- TABLE,
- TEMPORARY,
- THEN,
- TIME,
- TIMESTAMP,
- TIMESTAMPADD,
- TIMESTAMPDIFF,
- TRANSLATE,
- TRUE,
- UNION,
- UNKNOWN,
- UPDATE,
- USING,
- VALUES,
- VIRTUAL,
- VIRTUAL_DEP_JOIN,
- WHEN,
- WITH,
- WHERE,
- WHILE,
- XML,
- };
-
- /**
- * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
- */
- private static final Set RESERVED_WORDS = new HashSet();
-
- // Initialize RESERVED_WORDS set
- static {
- // Iterate through the reserved words and capitalize all of them
- for ( int i=0; i!=ReservedWords.ALL_WORDS.length; ++i ) {
- String reservedWord = ReservedWords.ALL_WORDS[i];
- ReservedWords.RESERVED_WORDS.add( reservedWord.toUpperCase() );
- }
- }
-
- /** Can't construct */
- private ReservedWords() {}
-
- /**
- * Check whether a string is a reserved word.
- * @param str String to check
- * @return True if reserved word, false if not or null
- */
- public static final boolean isReservedWord(String str) {
- if(str == null) {
- return false;
- }
- return RESERVED_WORDS.contains(str.toUpperCase());
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -239,6 +239,9 @@
ElementSymbol symbol = (ElementSymbol)((ElementSymbol)variables.get( j )).clone();
symbol.setName(ProcedureReservedWords.INPUT + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
map.put(symbol, values.get( j ) );
+ symbol = (ElementSymbol)((ElementSymbol)variables.get( j )).clone();
+ symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
+ map.put(symbol, values.get( j ) );
} // for
return map;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,6 +24,8 @@
import java.util.*;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.core.util.HashCodeUtil;
import com.metamatrix.query.sql.*;
import com.metamatrix.core.util.EquivalenceUtil;
@@ -36,8 +38,8 @@
*/
public class Option implements LanguageObject {
- public final static String MAKEDEP = ReservedWords.MAKEDEP;
- public final static String MAKENOTDEP = ReservedWords.MAKENOTDEP;
+ public final static String MAKEDEP = SQLReservedWords.MAKEDEP;
+ public final static String MAKENOTDEP = SQLReservedWords.MAKENOTDEP;
public final static String OPTIONAL = "optional"; //$NON-NLS-1$
private boolean showPlan = false;
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -179,23 +179,6 @@
}
/**
- * This is a helper method to get the value of this parameter when the expression
- * is a constant. It may throw IllegalStateException if used when the expression
- * is not a Constant.
- * @return Value of this parameter
- */
- public Object getValue() {
- if(this.expression == null) {
- return null;
- }
- try {
- return Evaluator.evaluate(this.expression);
- } catch (MetaMatrixException err) {
- throw new MetaMatrixRuntimeException(err);
- }
- }
-
- /**
* Set the positional index of this parameter
* @param index The positional index of this parameter
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -62,6 +62,7 @@
private QueryCommand rightQuery;
private List<Class<?>> projectedTypes = null; //set during resolving
+ private QueryMetadataInterface metadata = null; // set during resolving
/**
* Construct query with operation type
@@ -123,12 +124,12 @@
Query query = getProjectedQuery();
List projectedSymbols = query.getProjectedSymbols();
if (projectedTypes != null) {
- return getTypedProjectedSymbols(projectedSymbols, projectedTypes);
+ return getTypedProjectedSymbols(projectedSymbols, projectedTypes, metadata);
}
return projectedSymbols;
}
- public static List getTypedProjectedSymbols(List acutal, List projectedTypes) {
+ public static List getTypedProjectedSymbols(List acutal, List projectedTypes, QueryMetadataInterface metadata) {
List newProject = new ArrayList();
for (int i = 0; i < acutal.size(); i++) {
SingleElementSymbol originalSymbol = (SingleElementSymbol)acutal.get(i);
@@ -145,7 +146,7 @@
}
try {
- symbol = new ExpressionSymbol(originalSymbol.getShortName(), ResolverUtil.convertExpression(expr, DataTypeManager.getDataTypeName(type)));
+ symbol = new ExpressionSymbol(originalSymbol.getShortName(), ResolverUtil.convertExpression(expr, DataTypeManager.getDataTypeName(type), metadata));
} catch (QueryResolverException err) {
throw new MetaMatrixRuntimeException(err);
}
@@ -182,7 +183,7 @@
}
if (this.projectedTypes != null) {
- copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes));
+ copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata);
}
return copy;
@@ -252,8 +253,9 @@
/**
* @param projectedSymbols The projectedSymbols to set.
*/
- public void setProjectedTypes(List<Class<?>> projectedTypes) {
+ public void setProjectedTypes(List<Class<?>> projectedTypes, QueryMetadataInterface metadata) {
this.projectedTypes = projectedTypes;
+ this.metadata = metadata;
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -267,7 +267,9 @@
ElementSymbol symbol = (ElementSymbol)(setClause.getSymbol()).clone();
symbol.setName(ProcedureReservedWords.INPUT + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
map.put( symbol, setClause.getValue() );
-
+ symbol = (ElementSymbol)(setClause.getSymbol()).clone();
+ symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
+ map.put( symbol, setClause.getValue() );
} // for
return map;
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package com.metamatrix.query.sql.proc;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -57,10 +58,10 @@
* matter that it has an invalid ID or GroupSymbol. Setting the type to
* String allows for the expression to be converted to String as necessary.
*/
- ElementSymbol result = new ElementSymbol(ReservedWords.ERROR);
- result.setMetadataID(ReservedWords.ERROR);
+ ElementSymbol result = new ElementSymbol(SQLReservedWords.ERROR);
+ result.setMetadataID(SQLReservedWords.ERROR);
result.setType(String.class);
- result.setGroupSymbol(new GroupSymbol(ReservedWords.ERROR));
+ result.setGroupSymbol(new GroupSymbol(SQLReservedWords.ERROR));
return result;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,12 +27,13 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.util.ErrorMessageKeys;
/**
@@ -66,11 +67,11 @@
static {
AGGREGATE_FUNCTIONS = new HashSet();
- AGGREGATE_FUNCTIONS.add(ReservedWords.COUNT);
- AGGREGATE_FUNCTIONS.add(ReservedWords.SUM);
- AGGREGATE_FUNCTIONS.add(ReservedWords.AVG);
- AGGREGATE_FUNCTIONS.add(ReservedWords.MIN);
- AGGREGATE_FUNCTIONS.add(ReservedWords.MAX);
+ AGGREGATE_FUNCTIONS.add(SQLReservedWords.COUNT);
+ AGGREGATE_FUNCTIONS.add(SQLReservedWords.SUM);
+ AGGREGATE_FUNCTIONS.add(SQLReservedWords.AVG);
+ AGGREGATE_FUNCTIONS.add(SQLReservedWords.MIN);
+ AGGREGATE_FUNCTIONS.add(SQLReservedWords.MAX);
SUM_TYPES = new HashMap();
SUM_TYPES.put(DataTypeManager.DefaultDataClasses.BYTE, DataTypeManager.DefaultDataClasses.LONG);
@@ -109,7 +110,7 @@
/**
* Construct an aggregate symbol with all given data.
* @param name Name of the function
- * @param aggregateFunction Aggregate function type ({@link com.metamatrix.query.sql.ReservedWords#COUNT}, etc)
+ * @param aggregateFunction Aggregate function type ({@link org.teiid.connector.language.SQLReservedWords#COUNT}, etc)
* @param isDistinct True if DISTINCT flag is set
* @param expression Contained expression
*/
@@ -119,16 +120,16 @@
setAggregateFunction(aggregateFunction);
this.distinct = isDistinct;
}
-
+
/**
* Set the aggregate function. If the aggregate function is an invalid value, an
* IllegalArgumentException is thrown.
* @param aggregateFunction Aggregate function type
- * @see com.metamatrix.query.sql.ReservedWords#COUNT
- * @see com.metamatrix.query.sql.ReservedWords#SUM
- * @see com.metamatrix.query.sql.ReservedWords#AVG
- * @see com.metamatrix.query.sql.ReservedWords#MIN
- * @see com.metamatrix.query.sql.ReservedWords#MAX
+ * @see org.teiid.connector.language.SQLReservedWords#COUNT
+ * @see org.teiid.connector.language.SQLReservedWords#SUM
+ * @see org.teiid.connector.language.SQLReservedWords#AVG
+ * @see org.teiid.connector.language.SQLReservedWords#MIN
+ * @see org.teiid.connector.language.SQLReservedWords#MAX
*/
private void setAggregateFunction(String aggregateFunction) {
// Validate aggregate
@@ -142,11 +143,11 @@
* Get the aggregate function type - this will map to one of the reserved words
* for the aggregate functions.
* @return Aggregate function type
- * @see com.metamatrix.query.sql.ReservedWords#COUNT
- * @see com.metamatrix.query.sql.ReservedWords#SUM
- * @see com.metamatrix.query.sql.ReservedWords#AVG
- * @see com.metamatrix.query.sql.ReservedWords#MIN
- * @see com.metamatrix.query.sql.ReservedWords#MAX
+ * @see org.teiid.connector.language.SQLReservedWords#COUNT
+ * @see org.teiid.connector.language.SQLReservedWords#SUM
+ * @see org.teiid.connector.language.SQLReservedWords#AVG
+ * @see org.teiid.connector.language.SQLReservedWords#MIN
+ * @see org.teiid.connector.language.SQLReservedWords#MAX
*/
public String getAggregateFunction() {
return this.aggregate;
@@ -167,12 +168,12 @@
* @return Type of the symbol
*/
public Class getType() {
- if(this.aggregate.equals(ReservedWords.COUNT)) {
+ if(this.aggregate.equals(SQLReservedWords.COUNT)) {
return COUNT_TYPE;
- } else if(this.aggregate.equals(ReservedWords.SUM) ) {
+ } else if(this.aggregate.equals(SQLReservedWords.SUM) ) {
Class expressionType = this.getExpression().getType();
return (Class) SUM_TYPES.get(expressionType);
- } else if (this.aggregate.equals(ReservedWords.AVG)) {
+ } else if (this.aggregate.equals(SQLReservedWords.AVG)) {
Class expressionType = this.getExpression().getType();
return (Class) AVG_TYPES.get(expressionType);
} else {
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -186,7 +186,7 @@
// Construct properly named INPUT variable based on short name of virtual element
String virtualElementName = metadata.getFullName(virtualElements.get(i));
String virtualElementShortName = metadata.getShortElementName(virtualElementName);
- ElementSymbol inputElement = new ElementSymbol(ProcedureReservedWords.INPUT + "." + virtualElementShortName); //$NON-NLS-1$
+ ElementSymbol inputElement = new ElementSymbol(ProcedureReservedWords.INPUTS + "." + virtualElementShortName); //$NON-NLS-1$
values.add(inputElement);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,11 +29,13 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.connector.language.SQLReservedWords.Tokens;
+
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.BetweenCriteria;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -177,43 +179,43 @@
parts.add(SPACE);
if (obj.isNegated()) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(SPACE);
}
- parts.add(ReservedWords.BETWEEN);
+ parts.add(SQLReservedWords.BETWEEN);
parts.add(SPACE);
parts.add(registerNode(obj.getLowerExpression()));
parts.add(SPACE);
- parts.add(ReservedWords.AND);
+ parts.add(SQLReservedWords.AND);
parts.add(SPACE);
parts.add(registerNode(obj.getUpperExpression()));
}
public void visit(CaseExpression obj) {
- parts.add(ReservedWords.CASE);
+ parts.add(SQLReservedWords.CASE);
parts.add(SPACE);
parts.add(registerNode(obj.getExpression()) );
parts.add(SPACE);
for (int i = 0; i < obj.getWhenCount(); i++) {
- parts.add(ReservedWords.WHEN);
+ parts.add(SQLReservedWords.WHEN);
parts.add(SPACE);
parts.add(registerNode(obj.getWhenExpression(i)) );
parts.add(SPACE);
- parts.add(ReservedWords.THEN);
+ parts.add(SQLReservedWords.THEN);
parts.add(SPACE);
parts.add(registerNode(obj.getThenExpression(i)));
parts.add(SPACE);
}
if (obj.getElseExpression() != null) {
- parts.add(ReservedWords.ELSE);
+ parts.add(SQLReservedWords.ELSE);
parts.add(SPACE);
parts.add(registerNode(obj.getElseExpression()));
parts.add(SPACE);
}
- parts.add(ReservedWords.END);
+ parts.add(SQLReservedWords.END);
}
public void visit(CompareCriteria obj) {
@@ -233,9 +235,9 @@
int operator = obj.getOperator();
String operatorStr = ""; //$NON-NLS-1$
if(operator == CompoundCriteria.AND) {
- operatorStr = ReservedWords.AND;
+ operatorStr = SQLReservedWords.AND;
} else if(operator == CompoundCriteria.OR) {
- operatorStr = ReservedWords.OR;
+ operatorStr = SQLReservedWords.OR;
}
// Get criteria
@@ -283,17 +285,17 @@
public void visit(Delete obj) {
//add delete clause
- parts.add(ReservedWords.DELETE);
+ parts.add(SQLReservedWords.DELETE);
parts.add(SPACE);
//add from clause
- parts.add(ReservedWords.FROM);
+ parts.add(SQLReservedWords.FROM);
parts.add(SPACE);
parts.add(registerNode(obj.getGroup()));
//add where clause
if(obj.getCriteria() != null) {
parts.add(SPACE);
- parts.add(ReservedWords.WHERE);
+ parts.add(SQLReservedWords.WHERE);
parts.add(SPACE);
parts.add(registerNode(obj.getCriteria()));
}
@@ -311,10 +313,10 @@
// operator and beginning of list
parts.add(SPACE);
if (obj.isNegated()) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(SPACE);
}
- parts.add(ReservedWords.IN);
+ parts.add(SQLReservedWords.IN);
parts.add(" (<dependent values>)"); //$NON-NLS-1$
}
@@ -323,13 +325,13 @@
List clauses = obj.getClauses();
if(clauses.size() == 1) {
replaceStringParts(new Object[] {
- ReservedWords.FROM, SPACE,
+ SQLReservedWords.FROM, SPACE,
registerNode( (FromClause) clauses.get(0) ) });
} else if(clauses.size() > 1) {
parts = new Object[2 + clauses.size() + (clauses.size()-1)];
// Add first clause
- parts[0] = ReservedWords.FROM;
+ parts[0] = SQLReservedWords.FROM;
parts[1] = SPACE;
Iterator clauseIter = clauses.iterator();
parts[2] = registerNode((FromClause) clauseIter.next());
@@ -343,7 +345,7 @@
replaceStringParts(parts);
} else {
// Shouldn't happen, but being tolerant
- replaceStringParts(new Object[] { ReservedWords.FROM });
+ replaceStringParts(new Object[] { SQLReservedWords.FROM });
}
}
@@ -352,15 +354,15 @@
List symbols = obj.getSymbols();
if(symbols.size() == 1) {
replaceStringParts(new Object[] {
- ReservedWords.GROUP, SPACE, ReservedWords.BY, SPACE,
+ SQLReservedWords.GROUP, SPACE, SQLReservedWords.BY, SPACE,
registerNode( (Expression) symbols.get(0) ) });
} else if(symbols.size() > 1) {
parts = new Object[4 + symbols.size() + (symbols.size()-1)];
// Add first clause
- parts[0] = ReservedWords.GROUP;
+ parts[0] = SQLReservedWords.GROUP;
parts[1] = SPACE;
- parts[2] = ReservedWords.BY;
+ parts[2] = SQLReservedWords.BY;
parts[3] = SPACE;
Iterator symbolIter = symbols.iterator();
parts[4] = registerNode((Expression) symbolIter.next());
@@ -374,7 +376,7 @@
replaceStringParts(parts);
} else {
// Shouldn't happen, but being tolerant
- replaceStringParts(new Object[] { ReservedWords.GROUP, SPACE, ReservedWords.BY });
+ replaceStringParts(new Object[] { SQLReservedWords.GROUP, SPACE, SQLReservedWords.BY });
}
}
@@ -384,7 +386,7 @@
if ( obj.getQueryExpression() != null ) {
parts.add(registerNode(obj.getQueryExpression()));
} else {
- parts.add(ReservedWords.VALUES);
+ parts.add(SQLReservedWords.VALUES);
parts.add(" ("); //$NON-NLS-1$
Iterator valueIter = obj.getValues().iterator();
while(valueIter.hasNext()) {
@@ -405,13 +407,13 @@
}
public void visit(Create obj) {
- parts.add(ReservedWords.CREATE);
+ parts.add(SQLReservedWords.CREATE);
parts.add(SPACE);
- parts.add(ReservedWords.LOCAL);
+ parts.add(SQLReservedWords.LOCAL);
parts.add(SPACE);
- parts.add(ReservedWords.TEMPORARY);
+ parts.add(SQLReservedWords.TEMPORARY);
parts.add(SPACE);
- parts.add(ReservedWords.TABLE);
+ parts.add(SQLReservedWords.TABLE);
parts.add(SPACE);
parts.add(registerNode(obj.getTable()));
parts.add(SPACE);
@@ -434,17 +436,17 @@
}
public void visit(Drop obj) {
- parts.add(ReservedWords.DROP);
+ parts.add(SQLReservedWords.DROP);
parts.add(SPACE);
- parts.add(ReservedWords.TABLE);
+ parts.add(SQLReservedWords.TABLE);
parts.add(SPACE);
parts.add(registerNode(obj.getTable()));
}
private void formatBasicInsert(Insert obj) {
- parts.add(ReservedWords.INSERT);
+ parts.add(SQLReservedWords.INSERT);
parts.add(SPACE);
- parts.add(ReservedWords.INTO);
+ parts.add(SQLReservedWords.INTO);
parts.add(SPACE);
parts.add(registerNode(obj.getGroup()));
parts.add(SPACE);
@@ -473,13 +475,13 @@
Object exprPart = registerNode(expr);
parts.add(exprPart);
parts.add(SPACE);
- parts.add(ReservedWords.IS);
+ parts.add(SQLReservedWords.IS);
parts.add(SPACE);
if (obj.isNegated()) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(SPACE);
}
- parts.add(ReservedWords.NULL);
+ parts.add(SQLReservedWords.NULL);
}
public void visit(JoinPredicate obj) {
@@ -518,7 +520,7 @@
List joinCriteria = obj.getJoinCriteria();
if(joinCriteria != null && joinCriteria.size() > 0) {
parts.add(SPACE);
- parts.add(ReservedWords.ON);
+ parts.add(SQLReservedWords.ON);
parts.add(SPACE);
Iterator critIter = joinCriteria.iterator();
while(critIter.hasNext()) {
@@ -533,7 +535,7 @@
if(critIter.hasNext()) {
parts.add(SPACE);
- parts.add(ReservedWords.AND);
+ parts.add(SQLReservedWords.AND);
parts.add(SPACE);
}
}
@@ -570,21 +572,21 @@
public void visit(JoinType obj) {
Object[] parts = null;
if(obj.equals(JoinType.JOIN_INNER)) {
- parts = new Object[] { ReservedWords.INNER, SPACE, ReservedWords.JOIN };
+ parts = new Object[] { SQLReservedWords.INNER, SPACE, SQLReservedWords.JOIN };
} else if(obj.equals(JoinType.JOIN_CROSS)) {
- parts = new Object[] { ReservedWords.CROSS, SPACE, ReservedWords.JOIN };
+ parts = new Object[] { SQLReservedWords.CROSS, SPACE, SQLReservedWords.JOIN };
} else if(obj.equals(JoinType.JOIN_LEFT_OUTER)) {
- parts = new Object[] { ReservedWords.LEFT, SPACE, ReservedWords.OUTER, SPACE, ReservedWords.JOIN };
+ parts = new Object[] { SQLReservedWords.LEFT, SPACE, SQLReservedWords.OUTER, SPACE, SQLReservedWords.JOIN };
} else if(obj.equals(JoinType.JOIN_RIGHT_OUTER)) {
- parts = new Object[] { ReservedWords.RIGHT, SPACE, ReservedWords.OUTER, SPACE, ReservedWords.JOIN };
+ parts = new Object[] { SQLReservedWords.RIGHT, SPACE, SQLReservedWords.OUTER, SPACE, SQLReservedWords.JOIN };
} else if(obj.equals(JoinType.JOIN_FULL_OUTER)) {
- parts = new Object[] { ReservedWords.FULL, SPACE, ReservedWords.OUTER, SPACE, ReservedWords.JOIN };
+ parts = new Object[] { SQLReservedWords.FULL, SPACE, SQLReservedWords.OUTER, SPACE, SQLReservedWords.JOIN };
} else if(obj.equals(JoinType.JOIN_UNION)) {
- parts = new Object[] { ReservedWords.UNION, SPACE, ReservedWords.JOIN };
+ parts = new Object[] { SQLReservedWords.UNION, SPACE, SQLReservedWords.JOIN };
} else if (obj.equals(JoinType.JOIN_SEMI)) {
- parts = new Object[] { "SEMI", SPACE, ReservedWords.JOIN }; //$NON-NLS-1$
+ parts = new Object[] { "SEMI", SPACE, SQLReservedWords.JOIN }; //$NON-NLS-1$
} else if (obj.equals(JoinType.JOIN_ANTI_SEMI)) {
- parts = new Object[] { "ANTI SEMI", SPACE, ReservedWords.JOIN }; //$NON-NLS-1$
+ parts = new Object[] { "ANTI SEMI", SPACE, SQLReservedWords.JOIN }; //$NON-NLS-1$
}
replaceStringParts(parts);
@@ -595,17 +597,17 @@
parts.add(SPACE);
if (obj.isNegated()) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(SPACE);
}
- parts.add(ReservedWords.LIKE);
+ parts.add(SQLReservedWords.LIKE);
parts.add(SPACE);
parts.add(registerNode(obj.getRightExpression()));
if(obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
parts.add(SPACE);
- parts.add(ReservedWords.ESCAPE);
+ parts.add(SQLReservedWords.ESCAPE);
parts.add(" '"); //$NON-NLS-1$
parts.add("" + obj.getEscapeChar()); //$NON-NLS-1$
parts.add("'"); //$NON-NLS-1$
@@ -613,34 +615,34 @@
}
public void visit(NotCriteria obj) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(" ("); //$NON-NLS-1$
parts.add(registerNode(obj.getCriteria()));
parts.add(")"); //$NON-NLS-1$
}
public void visit(Option obj) {
- parts.add(ReservedWords.OPTION);
+ parts.add(SQLReservedWords.OPTION);
if(obj.getShowPlan()) {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.SHOWPLAN);
+ parts.add(SQLReservedWords.SHOWPLAN);
}
if(obj.getPlanOnly()) {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.PLANONLY);
+ parts.add(SQLReservedWords.PLANONLY);
}
if(obj.getDebug()) {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.DEBUG);
+ parts.add(SQLReservedWords.DEBUG);
}
Collection groups = obj.getDependentGroups();
if(groups != null && groups.size() > 0) {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.MAKEDEP);
+ parts.add(SQLReservedWords.MAKEDEP);
parts.add(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
@@ -657,7 +659,7 @@
groups = obj.getNotDependentGroups();
if(groups != null && groups.size() > 0) {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.MAKENOTDEP);
+ parts.add(SQLReservedWords.MAKENOTDEP);
parts.add(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
@@ -674,7 +676,7 @@
groups = obj.getNoCacheGroups();
if(groups != null && groups.size() > 0) {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.NOCACHE);
+ parts.add(SQLReservedWords.NOCACHE);
parts.add(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
@@ -688,15 +690,15 @@
}
}else if(obj.isNoCache()){
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.NOCACHE);
+ parts.add(SQLReservedWords.NOCACHE);
}
}
public void visit(OrderBy obj) {
- parts.add(ReservedWords.ORDER);
+ parts.add(SQLReservedWords.ORDER);
parts.add(SPACE);
- parts.add(ReservedWords.BY);
+ parts.add(SQLReservedWords.BY);
parts.add(SPACE);
for (Iterator<OrderByItem> iterator = obj.getOrderByItems().iterator(); iterator.hasNext();) {
OrderByItem item = iterator.next();
@@ -718,20 +720,20 @@
}
if(!obj.isAscending()) {
parts.add(SPACE);
- parts.add(ReservedWords.DESC);
+ parts.add(SQLReservedWords.DESC);
} // Don't print default "ASC"
}
public void visit(DynamicCommand obj) {
- parts.add(ReservedWords.EXECUTE);
+ parts.add(SQLReservedWords.EXECUTE);
parts.add(SPACE);
- parts.add(ReservedWords.STRING);
+ parts.add(SQLReservedWords.STRING);
parts.add(SPACE);
parts.add(registerNode(obj.getSql()));
if(obj.isAsClauseSet()){
parts.add(SPACE);
- parts.add(ReservedWords.AS);
+ parts.add(SQLReservedWords.AS);
parts.add(SPACE);
for (int i = 0; i < obj.getAsColumns().size(); i++) {
ElementSymbol symbol = (ElementSymbol)obj.getAsColumns().get(i);
@@ -747,21 +749,21 @@
if(obj.getIntoGroup() != null){
parts.add(SPACE);
- parts.add(ReservedWords.INTO);
+ parts.add(SQLReservedWords.INTO);
parts.add(SPACE);
parts.add(registerNode(obj.getIntoGroup()));
}
if(obj.getUsing() != null && !obj.getUsing().isEmpty()) {
parts.add(SPACE);
- parts.add(ReservedWords.USING);
+ parts.add(SQLReservedWords.USING);
parts.add(SPACE);
parts.add(registerNode(obj.getUsing()));
}
if (obj.getUpdatingModelCount() > 0) {
parts.add(SPACE);
- parts.add(ReservedWords.UPDATE);
+ parts.add(SQLReservedWords.UPDATE);
parts.add(SPACE);
if (obj.getUpdatingModelCount() > 1) {
parts.add("*"); //$NON-NLS-1$
@@ -795,7 +797,7 @@
if(obj.getInto() != null){
parts.add(SPACE);
- parts.add(ReservedWords.INTO);
+ parts.add(SQLReservedWords.INTO);
parts.add(SPACE);
parts.add(registerNode(obj.getInto()));
}
@@ -808,7 +810,7 @@
// Where clause
if(obj.getCriteria() != null) {
parts.add(SPACE);
- parts.add(ReservedWords.WHERE);
+ parts.add(SQLReservedWords.WHERE);
parts.add(SPACE);
parts.add(registerNode(obj.getCriteria()));
}
@@ -822,7 +824,7 @@
// Having clause
if(obj.getHaving() != null) {
parts.add(SPACE);
- parts.add(ReservedWords.HAVING);
+ parts.add(SQLReservedWords.HAVING);
parts.add(SPACE);
parts.add(registerNode(obj.getHaving()));
}
@@ -846,33 +848,33 @@
}
public void visit(SearchedCaseExpression obj) {
- parts.add(ReservedWords.CASE);
+ parts.add(SQLReservedWords.CASE);
for (int i = 0; i < obj.getWhenCount(); i++) {
parts.add(SPACE);
- parts.add(ReservedWords.WHEN);
+ parts.add(SQLReservedWords.WHEN);
parts.add(SPACE);
parts.add(registerNode(obj.getWhenCriteria(i)));
parts.add(SPACE);
- parts.add(ReservedWords.THEN);
+ parts.add(SQLReservedWords.THEN);
parts.add(SPACE);
parts.add(registerNode(obj.getThenExpression(i)));
}
parts.add(SPACE);
if (obj.getElseExpression() != null) {
- parts.add(ReservedWords.ELSE);
+ parts.add(SQLReservedWords.ELSE);
parts.add(SPACE);
parts.add(registerNode(obj.getElseExpression()));
parts.add(SPACE);
}
- parts.add(ReservedWords.END);
+ parts.add(SQLReservedWords.END);
}
public void visit(Select obj) {
- parts.add(ReservedWords.SELECT);
+ parts.add(SQLReservedWords.SELECT);
parts.add(SPACE);
if(obj.isDistinct()) {
- parts.add(ReservedWords.DISTINCT);
+ parts.add(SQLReservedWords.DISTINCT);
parts.add(SPACE);
}
@@ -893,10 +895,10 @@
// operator and beginning of list
parts.add(SPACE);
if (obj.isNegated()) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(SPACE);
}
- parts.add(ReservedWords.IN);
+ parts.add(SQLReservedWords.IN);
parts.add(" ("); //$NON-NLS-1$
// value list
@@ -935,7 +937,7 @@
parts.add(SPACE);
if(obj.isAll()) {
- parts.add(ReservedWords.ALL);
+ parts.add(SQLReservedWords.ALL);
parts.add(SPACE);
}
@@ -978,7 +980,7 @@
public void visit(StoredProcedure obj) {
addCacheHint(obj);
//exec clause
- parts.add(ReservedWords.EXEC);
+ parts.add(SQLReservedWords.EXEC);
parts.add(SPACE);
parts.add(obj.getProcedureName());
parts.add("("); //$NON-NLS-1$
@@ -1046,10 +1048,10 @@
// operator and beginning of list
parts.add(SPACE);
if (obj.isNegated()) {
- parts.add(ReservedWords.NOT);
+ parts.add(SQLReservedWords.NOT);
parts.add(SPACE);
}
- parts.add(ReservedWords.IN);
+ parts.add(SQLReservedWords.IN);
parts.add(" ("); //$NON-NLS-1$
parts.add(registerNode(obj.getCommand()));
parts.add(")"); //$NON-NLS-1$
@@ -1064,13 +1066,13 @@
public void visit(Update obj) {
// Update clause
- parts.add(ReservedWords.UPDATE);
+ parts.add(SQLReservedWords.UPDATE);
parts.add(SPACE);
parts.add(registerNode(obj.getGroup()));
parts.add(SPACE);
// Set clause
- parts.add(ReservedWords.SET);
+ parts.add(SQLReservedWords.SET);
parts.add(SPACE);
parts.add(registerNode(obj.getChangeList()));
@@ -1078,7 +1080,7 @@
// Where clause
if(obj.getCriteria() != null) {
parts.add(SPACE);
- parts.add(ReservedWords.WHERE);
+ parts.add(SQLReservedWords.WHERE);
parts.add(SPACE);
parts.add(registerNode(obj.getCriteria()));
}
@@ -1101,12 +1103,12 @@
parts.add("("); //$NON-NLS-1$
if(obj.isDistinct()) {
- parts.add(ReservedWords.DISTINCT);
+ parts.add(SQLReservedWords.DISTINCT);
parts.add(" "); //$NON-NLS-1$
}
if(obj.getExpression() == null) {
- parts.add(ReservedWords.ALL_COLS);
+ parts.add(Tokens.ALL_COLS);
} else {
parts.add(registerNode(obj.getExpression()));
}
@@ -1116,7 +1118,7 @@
public void visit(AliasSymbol obj) {
parts.add(registerNode(obj.getSymbol()));
parts.add(SPACE);
- parts.add(ReservedWords.AS);
+ parts.add(SQLReservedWords.AS);
parts.add(SPACE);
parts.add(escapeSinglePart(obj.getOutputName()));
}
@@ -1136,7 +1138,7 @@
constantParts = new Object[] {"?"}; //$NON-NLS-1$
} else if(obj.isNull()) {
if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- constantParts = new Object[] {ReservedWords.UNKNOWN};
+ constantParts = new Object[] {SQLReservedWords.UNKNOWN};
} else {
constantParts = new Object[] {"null"}; //$NON-NLS-1$
}
@@ -1144,7 +1146,7 @@
if(Number.class.isAssignableFrom(type)) {
constantParts = new Object[] { obj.getValue().toString() };
} else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? ReservedWords.TRUE : ReservedWords.FALSE};
+ constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? SQLReservedWords.TRUE : SQLReservedWords.FALSE};
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
constantParts = new Object[] { "{ts'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
@@ -1206,18 +1208,18 @@
// Hide this function, which is implicit
parts.add(registerNode(args[0]));
- } else if(name.equalsIgnoreCase(ReservedWords.CONVERT) || name.equalsIgnoreCase(ReservedWords.CAST)) {
+ } else if(name.equalsIgnoreCase(SQLReservedWords.CONVERT) || name.equalsIgnoreCase(SQLReservedWords.CAST)) {
parts.add(name);
parts.add("("); //$NON-NLS-1$
if(args != null && args.length > 0) {
parts.add(registerNode(args[0]));
- if(name.equalsIgnoreCase(ReservedWords.CONVERT)) {
+ if(name.equalsIgnoreCase(SQLReservedWords.CONVERT)) {
parts.add(", "); //$NON-NLS-1$
} else {
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.AS);
+ parts.add(SQLReservedWords.AS);
parts.add(" "); //$NON-NLS-1$
}
@@ -1244,7 +1246,7 @@
}
parts.add(")"); //$NON-NLS-1$
- } else if(name.equalsIgnoreCase(ReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(ReservedWords.TIMESTAMPDIFF)) {
+ } else if(name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPDIFF)) {
parts.add(name);
parts.add("("); //$NON-NLS-1$
@@ -1287,7 +1289,7 @@
if(alias != null) {
parts.add(SPACE);
- parts.add(ReservedWords.AS);
+ parts.add(SQLReservedWords.AS);
parts.add(SPACE);
parts.add(escapeSinglePart(alias));
}
@@ -1306,12 +1308,12 @@
public void visit(Block obj) {
List statements = obj.getStatements();
if(statements.size() == 1) {
- replaceStringParts(new Object[] { ReservedWords.BEGIN, "\n", //$NON-NLS-1$
- registerNode((Statement)obj.getStatements().get(0)), "\n", ReservedWords.END}); //$NON-NLS-1$
+ replaceStringParts(new Object[] { SQLReservedWords.BEGIN, "\n", //$NON-NLS-1$
+ registerNode((Statement)obj.getStatements().get(0)), "\n", SQLReservedWords.END}); //$NON-NLS-1$
} else if(statements.size() > 1) {
List parts = new ArrayList();
// Add first clause
- parts.add(ReservedWords.BEGIN);
+ parts.add(SQLReservedWords.BEGIN);
parts.add("\n"); //$NON-NLS-1$
Iterator stmtIter = statements.iterator();
while(stmtIter.hasNext()) {
@@ -1319,12 +1321,12 @@
parts.add(registerNode((Statement) stmtIter.next()));
parts.add("\n"); //$NON-NLS-1$
}
- parts.add(ReservedWords.END);
+ parts.add(SQLReservedWords.END);
replaceStringParts(parts.toArray());
} else {
// Shouldn't happen, but being tolerant
- replaceStringParts(new Object[] { ReservedWords.BEGIN, "\n", //$NON-NLS-1$
- ReservedWords.END });
+ replaceStringParts(new Object[] { SQLReservedWords.BEGIN, "\n", //$NON-NLS-1$
+ SQLReservedWords.END });
}
}
@@ -1334,19 +1336,19 @@
}
public void visit(CreateUpdateProcedureCommand obj) {
- parts.add(ReservedWords.CREATE);
+ parts.add(SQLReservedWords.CREATE);
parts.add(SPACE);
if(!obj.isUpdateProcedure()){
- parts.add(ReservedWords.VIRTUAL);
+ parts.add(SQLReservedWords.VIRTUAL);
parts.add(SPACE);
}
- parts.add(ReservedWords.PROCEDURE);
+ parts.add(SQLReservedWords.PROCEDURE);
parts.add("\n"); //$NON-NLS-1$
parts.add(registerNode(obj.getBlock()));
}
public void visit(DeclareStatement obj) {
- parts.add(ReservedWords.DECLARE);
+ parts.add(SQLReservedWords.DECLARE);
parts.add(SPACE);
parts.add(obj.getVariableType());
parts.add(SPACE);
@@ -1367,14 +1369,14 @@
}
public void visit(IfStatement obj) {
- parts.add(ReservedWords.IF);
+ parts.add(SQLReservedWords.IF);
parts.add("("); //$NON-NLS-1$
parts.add(registerNode(obj.getCondition()));
parts.add(")\n"); //$NON-NLS-1$
parts.add(registerNode(obj.getIfBlock()));
if(obj.hasElseBlock()) {
parts.add("\n"); //$NON-NLS-1$
- parts.add(ReservedWords.ELSE);
+ parts.add(SQLReservedWords.ELSE);
parts.add("\n"); //$NON-NLS-1$
parts.add(registerNode(obj.getElseBlock()));
}
@@ -1385,19 +1387,19 @@
}
public void visit(HasCriteria obj) {
- parts.add( ReservedWords.HAS);
+ parts.add( SQLReservedWords.HAS);
parts.add(SPACE);
parts.add(registerNode(obj.getSelector()));
}
public void visit(TranslateCriteria obj) {
- parts.add(ReservedWords.TRANSLATE);
+ parts.add(SQLReservedWords.TRANSLATE);
parts.add(SPACE);
parts.add(registerNode(obj.getSelector()));
if(obj.hasTranslations()) {
parts.add(SPACE);
- parts.add(ReservedWords.WITH);
+ parts.add(SQLReservedWords.WITH);
parts.add(SPACE);
parts.add("("); //$NON-NLS-1$
Iterator critIter = obj.getTranslations().iterator();
@@ -1437,29 +1439,29 @@
parts.add("<> "); //$NON-NLS-1$
break;
case CriteriaSelector.IN:
- parts.add(ReservedWords.IN);
+ parts.add(SQLReservedWords.IN);
parts.add(SPACE);
break;
case CriteriaSelector.IS_NULL:
- parts.add(ReservedWords.IS);
+ parts.add(SQLReservedWords.IS);
parts.add(SPACE);
- parts.add(ReservedWords.NULL);
+ parts.add(SQLReservedWords.NULL);
parts.add(SPACE);
break;
case CriteriaSelector.LIKE:
- parts.add(ReservedWords.LIKE);
+ parts.add(SQLReservedWords.LIKE);
parts.add(SPACE);
break;
case CriteriaSelector.BETWEEN:
- parts.add(ReservedWords.BETWEEN);
+ parts.add(SQLReservedWords.BETWEEN);
parts.add(SPACE);
break;
}
- parts.add(ReservedWords.CRITERIA);
+ parts.add(SQLReservedWords.CRITERIA);
if(obj.hasElements()) {
parts.add(SPACE);
- parts.add(ReservedWords.ON);
+ parts.add(SQLReservedWords.ON);
parts.add(SPACE);
parts.add("("); //$NON-NLS-1$
@@ -1477,7 +1479,7 @@
public void visit(RaiseErrorStatement obj) {
Object parts[] = new Object[4];
- parts[0] = ReservedWords.ERROR;
+ parts[0] = SQLReservedWords.ERROR;
parts[1] = SPACE;
parts[2] = registerNode(obj.getExpression());
parts[3] = ";"; //$NON-NLS-1$
@@ -1485,23 +1487,23 @@
}
public void visit(BreakStatement obj) {
- parts.add(ReservedWords.BREAK);
+ parts.add(SQLReservedWords.BREAK);
parts.add(";"); //$NON-NLS-1$
}
public void visit(ContinueStatement obj) {
- parts.add(ReservedWords.CONTINUE);
+ parts.add(SQLReservedWords.CONTINUE);
parts.add(";"); //$NON-NLS-1$
}
public void visit(LoopStatement obj) {
- parts.add(ReservedWords.LOOP);
+ parts.add(SQLReservedWords.LOOP);
parts.add(" "); //$NON-NLS-1$
- parts.add(ReservedWords.ON);
+ parts.add(SQLReservedWords.ON);
parts.add(" ("); //$NON-NLS-1$
parts.add(registerNode(obj.getCommand()));
parts.add(") "); //$NON-NLS-1$
- parts.add(ReservedWords.AS);
+ parts.add(SQLReservedWords.AS);
parts.add(" "); //$NON-NLS-1$
parts.add(obj.getCursorName());
parts.add("\n"); //$NON-NLS-1$
@@ -1509,7 +1511,7 @@
}
public void visit(WhileStatement obj) {
- parts.add(ReservedWords.WHILE);
+ parts.add(SQLReservedWords.WHILE);
parts.add("("); //$NON-NLS-1$
parts.add(registerNode(obj.getCondition()));
parts.add(")\n"); //$NON-NLS-1$
@@ -1518,7 +1520,7 @@
public void visit(ExistsCriteria obj) {
// operator and beginning of list
- parts.add(ReservedWords.EXISTS);
+ parts.add(SQLReservedWords.EXISTS);
parts.add(" ("); //$NON-NLS-1$
parts.add(registerNode(obj.getCommand()));
parts.add(")"); //$NON-NLS-1$
@@ -1550,7 +1552,7 @@
public void visit(Limit obj) {
- parts.add(ReservedWords.LIMIT);
+ parts.add(SQLReservedWords.LIMIT);
if (obj.getOffset() != null) {
parts.add(SPACE);
parts.add(registerNode(obj.getOffset()));
@@ -1589,7 +1591,7 @@
if(string == null) {
return false;
}
- return ReservedWords.isReservedWord(string);
+ return SQLReservedWords.isReservedWord(string);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -36,6 +36,7 @@
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.SecurityFunctionEvaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.relational.PlanToProcessConverter;
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -67,7 +68,7 @@
private String vdbName;
- private String vdbVersion;
+ private int vdbVersion;
private Properties environmentProperties;
@@ -96,6 +97,8 @@
private long timeSliceEnd = Long.MAX_VALUE;
private long timeoutEnd = Long.MAX_VALUE;
+
+ private QueryMetadataInterface metadata;
}
private GlobalState globalState = new GlobalState();
@@ -108,7 +111,7 @@
* Construct a new context.
*/
public CommandContext(Object processorID, String connectionID, String userName,
- Serializable commandPayload, String vdbName, String vdbVersion, Properties envProperties, boolean processDebug, boolean collectNodeStatistics) {
+ Serializable commandPayload, String vdbName, int vdbVersion, Properties envProperties, boolean processDebug, boolean collectNodeStatistics) {
setProcessorID(processorID);
setConnectionID(connectionID);
setUserName(userName);
@@ -124,7 +127,7 @@
* Construct a new context.
*/
public CommandContext(Object processorID, String connectionID, String userName,
- String vdbName, String vdbVersion) {
+ String vdbName, int vdbVersion) {
this(processorID, connectionID, userName, null, vdbName,
vdbVersion, null, false, false);
@@ -203,7 +206,7 @@
/**
* @return String
*/
- public String getVdbVersion() {
+ public int getVdbVersion() {
return globalState.vdbVersion;
}
@@ -235,7 +238,7 @@
* Sets the vdbVersion.
* @param vdbVersion The vdbVersion to set
*/
- public void setVdbVersion(String vdbVersion) {
+ public void setVdbVersion(int vdbVersion) {
this.globalState.vdbVersion = vdbVersion;
}
@@ -425,5 +428,12 @@
public void setTimeoutEnd(long timeoutEnd) {
globalState.timeoutEnd = timeoutEnd;
}
+
+ public void setMetadata(QueryMetadataInterface metadata) {
+ globalState.metadata = metadata;
+ }
+ public QueryMetadataInterface getMetadata() {
+ return globalState.metadata;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,10 +25,11 @@
import java.util.Collection;
import java.util.Set;
+import org.teiid.connector.language.SQLReservedWords;
+
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.navigator.PreOrderNavigator;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
@@ -71,10 +72,10 @@
// Verify data type of aggregate expression
String aggregateFunction = obj.getAggregateFunction();
- if((aggregateFunction.equals(ReservedWords.SUM) || aggregateFunction.equals(ReservedWords.AVG)) && obj.getType() == null) {
+ if((aggregateFunction.equals(SQLReservedWords.SUM) || aggregateFunction.equals(SQLReservedWords.AVG)) && obj.getType() == null) {
handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0041, new Object[] {aggregateFunction, obj}), obj);
}
- if((aggregateFunction.equals(ReservedWords.MIN) || aggregateFunction.equals(ReservedWords.MAX)) && DataTypeManager.isNonComparable(DataTypeManager.getDataTypeName(aggExp.getType()))) {
+ if((aggregateFunction.equals(SQLReservedWords.MIN) || aggregateFunction.equals(SQLReservedWords.MAX)) && DataTypeManager.isNonComparable(DataTypeManager.getDataTypeName(aggExp.getType()))) {
handleValidationError(QueryPlugin.Util.getString("AggregateValidationVisitor.non_comparable", new Object[] {aggregateFunction, obj}), obj); //$NON-NLS-1$
}
validateBelow = false;
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -330,8 +330,8 @@
String groupName = variable.getGroupSymbol().getCanonicalName();
if(groupName.equals(ProcedureReservedWords.INPUT) ||
- groupName.equals(ProcedureReservedWords.CHANGING)) {
- handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0012, new Object[] {ProcedureReservedWords.INPUT, ProcedureReservedWords.CHANGING}), obj);
+ groupName.equals(ProcedureReservedWords.CHANGING) || groupName.equals(ProcedureReservedWords.INPUTS)) {
+ handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0012, new Object[] {ProcedureReservedWords.INPUT, ProcedureReservedWords.INPUTS, ProcedureReservedWords.CHANGING}), obj);
}
if(obj.hasCommand()) {
@@ -376,10 +376,9 @@
ElementSymbol variable = obj.getVariable();
String elementname = variable.getShortName().toUpperCase();
- // varaible cnnot be one of the special variables
- if(elementname.equals(ProcedureReservedWords.INPUT) || elementname.equals(ProcedureReservedWords.CHANGING)
- || elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
- handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0017, new Object[] {ProcedureReservedWords.INPUT, ProcedureReservedWords.CHANGING, ProcedureReservedWords.ROWS_UPDATED}), obj);
+ // varible cannot be one of the special variables
+ if(elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
+ handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0017, new Object[] {ProcedureReservedWords.ROWS_UPDATED}), obj);
}
visit((AssignmentStatement)obj);
Modified: trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,6 +25,8 @@
import java.io.Serializable;
import java.util.Date;
+import javax.transaction.xa.Xid;
+
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -35,6 +37,8 @@
public class RequestInfo implements Serializable {
+ private static final long serialVersionUID = -2779106368517784259L;
+
private RequestID requestID;
private String command;
private SessionToken token;
@@ -43,7 +47,7 @@
private boolean isSubscription;
private int nodeID = Integer.MIN_VALUE;
private String connectorBindingUUID;
- private String transactionId;
+ private Xid xid;
private int executionID;
public RequestInfo(RequestID requestId, String originalCommand, Date submittedTime, Date processingTime) {
@@ -152,13 +156,13 @@
}
- public String getTransactionId() {
- return transactionId;
+ public Xid getXid() {
+ return this.xid;
}
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
+ public void setXid(Xid id) {
+ this.xid = id;
}
@Override
Copied: trunk/engine/src/main/java/org/teiid/cache (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/cache)
Deleted: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,135 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.cache;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.metamatrix.cache.Cache;
-import com.metamatrix.cache.CacheConfiguration;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.cache.CacheListener;
-import com.metamatrix.cache.Cache.Type;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-public class DefaultCacheFactory implements CacheFactory, Serializable {
- private static final long serialVersionUID = -5541424157695857527L;
-
- DefaultCache cacheRoot = new DefaultCache("Teiid");
- private volatile boolean destroyed = false;
-
- @Override
- public void destroy() {
- this.destroyed = true;
- }
-
- @Override
- public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
- if (!destroyed) {
- Cache node = cacheRoot.addChild(type.location());
- return node;
- }
- throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
- }
-
- class DefaultCache<K, V> implements Cache<K, V>, Serializable {
- Map<K, V> map = new HashMap();
- Map<String, Cache> children = new HashMap();
- String name;
-
- public DefaultCache(String name) {
- this.name = name;
- }
- public void addListener(CacheListener listener) {
- }
-
- public void clear() {
- map.clear();
- }
-
- public V get(K key) {
- return map.get(key);
- }
-
- public Set<K> keySet() {
- return map.keySet();
- }
-
- public V put(K key, V value) {
- return map.put(key, value);
- }
-
- public V remove(K key) {
- return map.remove(key);
- }
-
- public int size() {
- return map.size();
- }
-
- public Collection<V> values() {
- return map.values();
- }
-
- @Override
- public void removeListener() {
- }
-
- @Override
- public Cache addChild(String name) {
- if (children.get(name) != null) {
- return children.get(name);
- }
-
- Cache c = new DefaultCache(name);
- children.put(name, c);
- return c;
- }
-
- @Override
- public Cache getChild(String name) {
- return children.get(name);
- }
-
- @Override
- public List<Cache> getChildren() {
- return new ArrayList<Cache>(children.values());
- }
-
- @Override
- public boolean removeChild(String name) {
- Object obj = children.remove(name);
- return obj != null;
- }
-
- @Override
- public String getName() {
- return name;
- }
- }
-
-}
Copied: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,135 @@
+/*
+ * 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.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.metamatrix.cache.Cache;
+import com.metamatrix.cache.CacheConfiguration;
+import com.metamatrix.cache.CacheFactory;
+import com.metamatrix.cache.CacheListener;
+import com.metamatrix.cache.Cache.Type;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DefaultCacheFactory implements CacheFactory, Serializable {
+ private static final long serialVersionUID = -5541424157695857527L;
+
+ DefaultCache cacheRoot = new DefaultCache("Teiid");
+ private volatile boolean destroyed = false;
+
+ @Override
+ public void destroy() {
+ this.destroyed = true;
+ }
+
+ @Override
+ public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ if (!destroyed) {
+ Cache node = cacheRoot.addChild(type.location());
+ return node;
+ }
+ throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
+ }
+
+ class DefaultCache<K, V> implements Cache<K, V>, Serializable {
+ Map<K, V> map = new HashMap();
+ Map<String, Cache> children = new HashMap();
+ String name;
+
+ public DefaultCache(String name) {
+ this.name = name;
+ }
+ public void addListener(CacheListener listener) {
+ }
+
+ public void clear() {
+ map.clear();
+ }
+
+ public V get(K key) {
+ return map.get(key);
+ }
+
+ public Set<K> keySet() {
+ return map.keySet();
+ }
+
+ public V put(K key, V value) {
+ return map.put(key, value);
+ }
+
+ public V remove(K key) {
+ return map.remove(key);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public Collection<V> values() {
+ return map.values();
+ }
+
+ @Override
+ public void removeListener() {
+ }
+
+ @Override
+ public Cache addChild(String name) {
+ if (children.get(name) != null) {
+ return children.get(name);
+ }
+
+ Cache c = new DefaultCache(name);
+ children.put(name, c);
+ return c;
+ }
+
+ @Override
+ public Cache getChild(String name) {
+ return children.get(name);
+ }
+
+ @Override
+ public List<Cache> getChildren() {
+ return new ArrayList<Cache>(children.values());
+ }
+
+ @Override
+ public boolean removeChild(String name) {
+ Object obj = children.remove(name);
+ return obj != null;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
+
+}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -21,37 +21,37 @@
*/
package org.teiid.dqp.internal.cache;
-import java.util.Properties;
+import java.io.Serializable;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.name.Named;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.CacheConfiguration.Policy;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.util.LogConstants;
-@Singleton
-public class DQPContextCache {
+public class DQPContextCache implements Serializable{
+ private static final long serialVersionUID = 6958846566556640186L;
+
private static enum Scope {REQUEST,SESSION,SERVICE,VDB,GLOBAL;}
private Cache cache;
private String processIdentifier;
- @Inject
- public DQPContextCache(@Named("DQPProperties") Properties props, CacheFactory cacheFactory) {
+ // called by mc
+ public void setCacheFactory(CacheFactory cacheFactory) {
this.cache = cacheFactory.get(Cache.Type.SCOPED_CACHE, new CacheConfiguration(Policy.LRU, 600, 10000));
- this.processIdentifier = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
}
+ //called by mc
+ public void setProcessName(String name) {
+ this.processIdentifier = name;
+ }
public Cache getGlobalScopedCache() {
return this.cache.addChild(Scope.GLOBAL.name());
}
- public void shutdown() {
+ public void stop() {
try {
this.cache.removeChild(this.processIdentifier);
} catch(IllegalStateException e) {
@@ -115,13 +115,13 @@
}
}
- public Cache getVDBScopedCache(String vdbName, String vdbVersion) {
+ public Cache getVDBScopedCache(String vdbName, int vdbVersion) {
Cache scopeNode = this.cache.addChild(Scope.VDB.name());
String id = vdbName+"-"+vdbVersion; //$NON-NLS-1$
return scopeNode.addChild(id.toUpperCase());
}
- public void removeVDBScopedCache(String vdbName, String vdbVersion) {
+ public void removeVDBScopedCache(String vdbName, int vdbVersion) {
try {
Cache scopeNode = this.cache.addChild(Scope.VDB.name());
if (scopeNode != null) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,25 +22,48 @@
package org.teiid.dqp.internal.datamgr.impl;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.connector.api.ConnectorException;
+
import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
public class AsynchConnectorWorkItem extends ConnectorWorkItem {
-
- AsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
+ private WorkManager workManager;
+
+ AsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver, WorkManager wm) throws ConnectorException {
super(message, manager, resultsReceiver);
+ this.workManager = wm;
}
@Override
protected boolean dataNotAvailable(long delay) {
- this.manager.scheduleTask(this, delay);
+ try {
+ this.manager.scheduleTask(workManager, this, delay);
+ } catch (ConnectorException e) {
+ throw new MetaMatrixRuntimeException(e.getCause());
+ }
return false;
}
@Override
protected void resumeProcessing() {
- this.manager.reenqueueRequest(this);
+ try {
+ this.manager.reenqueueRequest(workManager, this);
+ } catch (ConnectorException e) {
+ throw new MetaMatrixRuntimeException(e.getCause());
+ }
}
+ @Override
+ public void workCompleted(WorkEvent arg0) {
+ if (this.lastBatch) {
+ manager.removeState(this.id);
+ sendClose();
+ }
+ }
}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,224 +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.
- */
-
-/*
- * Date: Sep 10, 2003
- * Time: 3:58:41 PM
- */
-package org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.Properties;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.connector.api.CacheScope;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.datamgr.language.LanguageFactoryImpl;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.cache.Cache;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-
-/**
- * Default Connector Environment.
- */
-public class ConnectorEnvironmentImpl implements ConnectorEnvironment {
-
- private final class ContextClassLoaderPreservingRunnable implements
- Runnable {
- private final Runnable arg0;
- private final ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
- private ContextClassLoaderPreservingRunnable(Runnable arg0) {
- this.arg0 = arg0;
- }
-
- @Override
- public void run() {
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(cl);
- try {
- arg0.run();
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
- }
-
- private static final TypeFacility TYPE_FACILITY = new TypeFacilityImpl();
-
- private ConnectorLogger logger;
- private Properties properties;
- private ApplicationEnvironment env;
- private WorkerPool workerPool;
-
-
- public ConnectorEnvironmentImpl(Properties connectorProperties, ConnectorLogger logger, ApplicationEnvironment env) {
- this(connectorProperties, logger, env, null);
- }
- /**
- * ctor
- * @param connectorProperties - Properties required for this Connector
- * @param logger - Logger to be used by the Connector
- * @param env - Connector Environment.
- */
- public ConnectorEnvironmentImpl(Properties connectorProperties, ConnectorLogger logger, ApplicationEnvironment env, WorkerPool workerPool) {
- this.properties = connectorProperties;
- this.logger = logger;
- this.env = env;
- this.workerPool = workerPool;
- }
-
- /**
- * @see org.teiid.connector.api.ConnectorEnvironment#getProperties()
- */
- public Properties getProperties() {
- return this.properties;
- }
-
- /**
- * @see org.teiid.connector.api.ConnectorEnvironment#getConnectorName()
- */
- public String getConnectorName() {
- return this.properties.getProperty(ConnectorPropertyNames.CONNECTOR_BINDING_NAME);
- }
-
- /**
- * Aquire the logger that the connector using this environment will
- * use to log messages.
- * @return The {@link com.metamatrix.data.ConnectorLogger} for this Connector.
- */
- public ConnectorLogger getLogger() {
- return this.logger;
- }
-
- /**
- * Implement the InternalConnectorEnvironment to allow access for internal connectors
- * to standard Connector Manager resources. For now this is just access to other
- * connector manager services.
- * @param resourceName Resource name - for now only valid names are DQP service names
- * @return The service as requested
- * @see com.metamatrix.dqp.datamgr.InternalConnectorEnvironment#findResource(java.lang.String)
- */
- public Object findResource(String resourceName) {
- return env.findService(resourceName);
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorEnvironment#getLanguageFactory()
- */
- public ILanguageFactory getLanguageFactory() {
- return LanguageFactoryImpl.INSTANCE;
- }
-
- /**
- * @see org.teiid.connector.api.ConnectorEnvironment#getTypeFacility()
- */
- public TypeFacility getTypeFacility() {
- return TYPE_FACILITY;
- }
-
- @Override
- public void execute(Runnable command) {
- if (this.workerPool != null) {
- this.workerPool.execute(new ContextClassLoaderPreservingRunnable(command));
- } else {
- command.run();
- }
- }
-
- @Override
- public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
- long initialDelay, long period, TimeUnit unit) {
- if (this.workerPool != null) {
- return this.workerPool.scheduleAtFixedRate(new ContextClassLoaderPreservingRunnable(command), initialDelay, period, unit);
- }
- return null;
- }
-
- @Override
- public Object getFromCache(CacheScope scope, Object key) {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- checkScopeValidity(scope, context);
-
- Cache cache = getScopedCache(scope, context);
- if (cache != null) {
- return cache.get(key);
- }
- return null;
- }
-
- @Override
- public void storeInCache(CacheScope scope, Object key, Object value) {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- checkScopeValidity(scope, context);
- Cache cache = getScopedCache(scope, context);
- if (cache != null) {
- cache.put(key, value);
- }
- }
-
- private Cache getScopedCache(CacheScope scope, DQPWorkContext context) {
- BufferService service = (BufferService) findResource(DQPServiceNames.BUFFER_SERVICE);
- if (service != null) {
- DQPContextCache contextCache = service.getContextCache();
- switch (scope) {
- case SERVICE:
- return contextCache.getServiceScopedCache(properties.getProperty(ConnectorPropertyNames.CONNECTOR_ID));
- case SESSION:
- return contextCache.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
- case VDB:
- return contextCache.getVDBScopedCache(context.getVdbName(), context.getVdbVersion());
- case GLOBAL:
- return contextCache.getGlobalScopedCache();
- }
- }
- return null;
- }
-
-
- private void checkScopeValidity(CacheScope scope, DQPWorkContext context) {
- if (scope == CacheScope.REQUEST) {
- throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.request_scope_error")); //$NON-NLS-1$
- }
-
- if (scope == CacheScope.SESSION) {
- if (context == null || context.getSessionToken() == null) {
- throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.session_scope_error")); //$NON-NLS-1$
- }
- }
- else if (scope == CacheScope.VDB) {
- if (context == null || context.getVdbName() == null || context.getVdbVersion() == null) {
- throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.vdb_scope_error")); //$NON-NLS-1$
- }
- }
- }
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,63 +26,48 @@
*/
package org.teiid.dqp.internal.datamgr.impl;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkManager;
+
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.teiid.SecurityHelper;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorPropertyNames;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.ConnectorAnnotations.ConnectionPooling;
-import org.teiid.connector.api.ConnectorAnnotations.SynchronousWorkers;
+import org.teiid.connector.basic.WrappedConnection;
+import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.xa.api.XAConnector;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
-import org.teiid.dqp.internal.pooling.connector.PooledConnector;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.admin.objects.MMConnectionPool;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.ClassLoaderManager;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
-import com.metamatrix.common.queue.WorkerPoolStats;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.common.queue.StatsCapturingWorkManager;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.service.BufferService;
import com.metamatrix.dqp.service.CommandLogMessage;
import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -93,103 +78,86 @@
* The <code>ConnectorManager</code> manages a {@link org.teiid.connector.basic.BasicConnector Connector}
* and its associated workers' state.
*/
-public class ConnectorManager implements ApplicationService {
-
+@ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="connectormanager"), properties=ManagementProperties.EXPLICIT)
+public class ConnectorManager {
+
public static final int DEFAULT_MAX_THREADS = 20;
-
- //state constructed in start
- private ConnectorWrapper connector;
- private ConnectorID connectorID;
- private WorkerPool connectorWorkerPool;
- private ConnectorWorkItemFactory workItemFactory;
private String connectorName;
- private int maxResultRows;
- private boolean exceptionOnMaxRows = true;
- private boolean synchWorkers;
- private boolean isXa;
- private boolean isImmutable;
+
+ private StatsCapturingWorkManager workManager;
+ private SecurityHelper securityHelper;
+ protected ConnectorWorkItemFactory workItemFactory;
+
private volatile ConnectorStatus state = ConnectorStatus.NOT_INITIALIZED;
//services acquired in start
- private MetadataService metadataService;
- private TransactionService transactionService;
private BufferService bufferService;
- private ClassLoaderManager clManager;
-
// known requests
private ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem> requestStates = new ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem>();
-
- private Properties props;
- private ClassLoader classloader;
private SourceCapabilities cachedCapabilities;
-
- public void initialize(Properties props) {
- this.props = props;
- this.isImmutable = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.IS_IMMUTABLE, false);
+
+ public ConnectorManager(String name) {
+ this(name, DEFAULT_MAX_THREADS, null);
}
-
- public boolean isImmutable() {
- return isImmutable;
+
+ public ConnectorManager(String name, int maxThreads, SecurityHelper securityHelper) {
+ if (name == null) {
+ throw new IllegalArgumentException("Connector name can not be null");
+ }
+ if (maxThreads <= 0) {
+ maxThreads = DEFAULT_MAX_THREADS;
+ }
+ this.connectorName = name;
+ this.workManager = new StatsCapturingWorkManager(this.connectorName, maxThreads);
+ this.securityHelper = securityHelper;
}
-
- public ClassLoader getClassloader() {
- return classloader;
- }
- public MetadataStore getMetadata(String modelName, Properties importProperties) throws ConnectorException {
- MetadataFactory factory;
- try {
- factory = new MetadataFactory(modelName, this.metadataService.getBuiltinDatatypes(), importProperties);
- } catch (MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
- try {
- currentThread.setContextClassLoader(classloader);
- this.connector.getConnectorMetadata(factory);
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
- return factory.getMetadataStore();
+ SecurityHelper getSecurityHelper() {
+ return securityHelper;
}
- public SourceCapabilities getCapabilities(RequestID requestID, Serializable executionPayload, DQPWorkContext message) throws ConnectorException {
+ public String getName() {
+ return this.connectorName;
+ }
+
+ public MetadataStore getMetadata(String modelName, Map<String, Datatype> datatypes, Properties importProperties) throws ConnectorException {
+
+ MetadataFactory factory = new MetadataFactory(modelName, datatypes, importProperties);
+
+ WrappedConnection conn = null;
+ try {
+ checkStatus();
+ conn = (WrappedConnection)getConnector().getConnection();
+ conn.getConnectorMetadata(factory);
+ } finally {
+ if (conn != null) {
+ conn.close();
+ }
+ }
+ return factory.getMetadataStore();
+ }
+
+
+ public SourceCapabilities getCapabilities() throws ConnectorException {
if (cachedCapabilities != null) {
return cachedCapabilities;
}
Connection conn = null;
- // Defect 17536 - Set the thread-context classloader to the non-delegating classloader when calling
- // methods on the connector.
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
try {
+ checkStatus();
+ Connector connector = getConnector();
ConnectorCapabilities caps = connector.getCapabilities();
- currentThread.setContextClassLoader(classloader);
boolean global = true;
if (caps == null) {
- ExecutionContextImpl context = new ExecutionContextImpl(
- message.getVdbName(),
- message.getVdbVersion(),
- message.getUserName(),
- message.getTrustedPayload(),
- executionPayload,
- "capabilities-request", //$NON-NLS-1$
- connectorID.getID(),
- requestID.toString(),
- "capabilities-request", "0"); //$NON-NLS-1$ //$NON-NLS-2$
-
- context.setContextCache(getContextCache());
-
- conn = connector.getConnection(context, null);
+ conn = connector.getConnection();
caps = conn.getCapabilities();
global = false;
}
- caps = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(caps, this.props));
- BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(caps, getName(), isXa);
+
+ BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(caps, getName(), connector.getConnectorEnvironment().isXaCapable());
if (global) {
resultCaps.setScope(Scope.SCOPE_GLOBAL);
cachedCapabilities = resultCaps;
@@ -201,35 +169,45 @@
if ( conn != null ) {
conn.close();
}
- currentThread.setContextClassLoader(threadContextLoader);
}
}
- public void executeRequest(ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) {
+ public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) throws ConnectorException {
// Set the connector ID to be used; if not already set.
+ checkStatus();
AtomicRequestID atomicRequestId = message.getAtomicRequestID();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$
- ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver);
+ ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver, workManager);
Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
- message.markProcessingStart();
- enqueueRequest(item);
+ enqueueRequest(workManager, item);
}
- private void enqueueRequest(ConnectorWorkItem state) {
- this.connectorWorkerPool.execute(state);
+ private void enqueueRequest(WorkManager workManager, ConnectorWorkItem work) throws ConnectorException {
+ try {
+ // if connector is immutable, then we do not want pass-on the transaction context.
+ if (work.securityContext.isTransactional()) {
+ this.workManager.scheduleWork(workManager, work, work.requestMsg.getTransactionContext(), 0);
+ }
+ else {
+ this.workManager.scheduleWork(workManager, work);
+ }
+ } catch (WorkException e) {
+ throw new ConnectorException(e);
+ }
}
- void reenqueueRequest(AsynchConnectorWorkItem state) {
- enqueueRequest(state);
+ void reenqueueRequest(WorkManager workManager, AsynchConnectorWorkItem work) throws ConnectorException {
+ enqueueRequest(workManager, work);
}
ConnectorWorkItem getState(AtomicRequestID requestId) {
return requestStates.get(requestId);
}
- public void requstMore(AtomicRequestID requestId) {
+ @SuppressWarnings("unused")
+ public void requstMore(AtomicRequestID requestId) throws ConnectorException {
ConnectorWorkItem workItem = getState(requestId);
if (workItem == null) {
return; //already closed
@@ -242,13 +220,7 @@
if (workItem == null) {
return; //already closed
}
- ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classloader);
- workItem.requestCancel();
- } finally {
- Thread.currentThread().setContextClassLoader(contextloader);
- }
+ workItem.requestCancel();
}
public void closeRequest(AtomicRequestID requestId) {
@@ -265,13 +237,21 @@
* @param delay The delay to wait (in ms) before executing the task
* @since 4.3.3
*/
- public void scheduleTask(final AsynchConnectorWorkItem state, long delay) {
- this.connectorWorkerPool.schedule(new Runnable() {
- @Override
- public void run() {
- state.requestMore();
- }
- }, delay, TimeUnit.MILLISECONDS);
+ public void scheduleTask(WorkManager workManager, final AsynchConnectorWorkItem state, long delay) throws ConnectorException {
+ try {
+ this.workManager.scheduleWork(workManager, new Work() {
+ @Override
+ public void run() {
+ state.requestMore();
+ }
+ @Override
+ public void release() {
+
+ }
+ }, null, delay);
+ } catch (WorkException e) {
+ throw new ConnectorException(e);
+ }
}
/**
@@ -287,231 +267,57 @@
return requestStates.size();
}
- public ConnectorStatus getStatus() {
- ConnectorWrapper connectorWrapper = this.connector;
- ConnectorStatus result = this.state;
- if (result != ConnectorStatus.OPEN) {
- return result;
- }
- ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classloader);
- return connectorWrapper.getStatus();
- } finally {
- Thread.currentThread().setContextClassLoader(contextloader);
- }
+ public void setBufferService(BufferService service) {
+ this.bufferService = service;
}
/**
* initialize this <code>ConnectorManager</code>.
*/
- public synchronized void start(ApplicationEnvironment env) throws ApplicationLifecycleException {
+ public synchronized void start() throws ConnectorException {
if (this.state != ConnectorStatus.NOT_INITIALIZED) {
return;
}
this.state = ConnectorStatus.INIT_FAILED;
- connectorName = props.getProperty(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "Unknown_Binding_Name"); //$NON-NLS-1$
- String connIDStr = props.getProperty(ConnectorPropertyNames.CONNECTOR_ID);
- connectorID = new ConnectorID(connIDStr);
- //connector Name - logical name<Unique Id>
- connectorName = connectorName + '<' + connIDStr + '>';
-
LogManager.logInfo(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManagerImpl.Initializing_connector", connectorName)); //$NON-NLS-1$
- this.setTransactionService((TransactionService) env.findService(DQPServiceNames.TRANSACTION_SERVICE));
+ ConnectorEnvironment connectorEnv = null;
+
+ connectorEnv = getConnector().getConnectorEnvironment();
+
+ if (!connectorEnv.isSynchWorkers() && connectorEnv.isXaCapable()) {
+ throw new ConnectorException(DQPPlugin.Util.getString("ConnectorManager.xa_capbility_not_supported", this.connectorName)); //$NON-NLS-1$
+ }
- // Set the class name for the connector class
- String connectorClassString = props.getProperty(ConnectorPropertyNames.CONNECTOR_CLASS);
- if ( connectorClassString == null || connectorClassString.trim().length() == 0 ) {
- throw new ApplicationLifecycleException(DQPPlugin.Util.getString("Missing_required_property", new Object[]{ConnectorPropertyNames.CONNECTOR_CLASS, connectorName})); //$NON-NLS-1$
- }
-
- int maxThreads = PropertiesUtils.getIntProperty(props, ConnectorPropertyNames.MAX_CONNECTIONS, DEFAULT_MAX_THREADS);
-
- connectorWorkerPool = WorkerPoolFactory.newWorkerPool(connectorName, maxThreads);
-
- // Create the Connector env
- Properties clonedProps = new Properties(this.props);
-
- ConnectorEnvironment connectorEnv = new ConnectorEnvironmentImpl(clonedProps, new DefaultConnectorLogger(connectorID), env, connectorWorkerPool);
-
- // Get the metadata service
- this.metadataService = (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE);
- if ( this.metadataService == null ) {
- throw new ApplicationLifecycleException(DQPPlugin.Util.getString("Failed_to_find_service", new Object[]{DQPServiceNames.METADATA_SERVICE, connectorName})); //$NON-NLS-1$
- }
-
- this.maxResultRows = PropertiesUtils.getIntProperty(props, ConnectorPropertyNames.MAX_RESULT_ROWS, 0);
- this.exceptionOnMaxRows = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.EXCEPTION_ON_MAX_ROWS, false);
- this.synchWorkers = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.SYNCH_WORKERS, true);
-
- this.bufferService = (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE);
- // Initialize and start the connector
- initStartConnector(connectorEnv);
- this.workItemFactory = new ConnectorWorkItemFactory(this, synchWorkers);
+ this.workItemFactory = new ConnectorWorkItemFactory(this, connectorEnv.isSynchWorkers());
this.state = ConnectorStatus.OPEN;
}
- private String buildClasspath(Properties connectorProperties) {
- StringBuilder sb = new StringBuilder();
- appendlasspath(connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_CLASSPATH), sb); // this is user defined, could be very specific to the binding
- appendlasspath(connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_TYPE_CLASSPATH), sb); // this is system defined; type classpath
- return sb.toString();
- }
-
- private void appendlasspath(String path, StringBuilder builder) {
- if (path != null && path.length() > 0) {
- builder.append(path);
- if (!path.endsWith(";")) { //$NON-NLS-1$
- builder.append(";"); //$NON-NLS-1$
- }
- }
- }
-
/**
- * Initialize and start the connector.
- * @param env
- * @throws ApplicationLifecycleException
- */
- private void initStartConnector(ConnectorEnvironment env) throws ApplicationLifecycleException {
-
- String connectorClassName = env.getProperties().getProperty(ConnectorPropertyNames.CONNECTOR_CLASS);
-
- String classPath = buildClasspath(env.getProperties());
-
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
-
- if (classPath == null || classPath.trim().length() == 0) {
- classloader = threadContextLoader;
- } else {
- env.getProperties().setProperty(ConnectorPropertyNames.USING_CUSTOM_CLASSLOADER, Boolean.TRUE.toString());
-
- boolean postDelegation = PropertiesUtils.getBooleanProperty(env.getProperties(), ConnectorPropertyNames.USE_POST_DELEGATION, false);
-
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManager.useClassloader", connectorName, postDelegation, classPath)); //$NON-NLS-1$
-
- if (postDelegation) {
- this.classloader = this.clManager.getPostDelegationClassLoader(classPath);
- } else {
- this.classloader = this.clManager.getCommonClassLoader(classPath);
- }
- }
-
- try {
- currentThread.setContextClassLoader(classloader);
- Connector c;
- try {
- Object o = ReflectionHelper.create(connectorClassName, null, classloader);
- if (o instanceof Connector) {
- c = (Connector)o;
- this.isXa = PropertiesUtils.getBooleanProperty(env.getProperties(), ConnectorPropertyNames.IS_XA, false);
- } else {
- try {
- Class legacyConnector = classloader.loadClass("com.metamatrix.data.api.Connector"); //$NON-NLS-1$
- if (!legacyConnector.isAssignableFrom(o.getClass())) {
- throw new ApplicationLifecycleException(DQPPlugin.Util.getString("failed_legacy", connectorClassName)); //$NON-NLS-1$
- }
- c = (Connector)ReflectionHelper.create("com.metamatrix.dqp.internal.datamgr.ConnectorWrapper", new Object[] {o}, new Class[] {legacyConnector}, classloader); //$NON-NLS-1$
- this.isXa = classloader.loadClass("com.metamatrix.data.xa.api.XAConnector").isAssignableFrom(o.getClass()); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_legacy", connectorClassName)); //$NON-NLS-1$
- }
- }
- } catch (MetaMatrixCoreException e) {
- throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
- }
- if (this.synchWorkers) {
- SynchronousWorkers synchWorkerAnnotation = c.getClass().getAnnotation(SynchronousWorkers.class);
- if (synchWorkerAnnotation != null) {
- this.synchWorkers = synchWorkerAnnotation.enabled();
- }
- if (!this.synchWorkers) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Changing asynch connector", getName(), "to non-XA. Consider changing you're connector binding to be non-XA."); //$NON-NLS-1$ //$NON-NLS-2$
- this.isXa = false;
- }
- }
- this.connector = wrapConnector(c, env);
- this.connector.start(env);
- } catch (ConnectorException e) {
- throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_start_Connector", new Object[] {this.getConnectorID(), e.getMessage()})); //$NON-NLS-1$
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
- }
-
- private ConnectorWrapper wrapConnector(Connector c, ConnectorEnvironment connectorEnv) throws ApplicationLifecycleException {
- //the pooling annotation overrides the connector binding
- ConnectionPooling connectionPooling = c.getClass().getAnnotation(ConnectionPooling.class);
- boolean connectionPoolPropertyEnabled = PropertiesUtils.getBooleanProperty(connectorEnv.getProperties(), ConnectorPropertyNames.CONNECTION_POOL_ENABLED, true);
- boolean propertySet = connectorEnv.getProperties().contains(ConnectorPropertyNames.CONNECTION_POOL_ENABLED);
- boolean poolingEnabled = false;
- if (propertySet) {
- poolingEnabled = connectionPoolPropertyEnabled && (connectionPooling == null || connectionPooling.enabled());
- } else {
- poolingEnabled = connectionPooling != null && connectionPooling.enabled();
- }
- if (this.isXa) {
- if(poolingEnabled && !(c instanceof XAConnector)){
- throw new ApplicationLifecycleException(DQPPlugin.Util.getString("non_xa_connector", connectorName)); //$NON-NLS-1$
- }
- if (this.getTransactionService() == null) {
- throw new ApplicationLifecycleException(DQPPlugin.Util.getString("no_txn_manager", connectorName)); //$NON-NLS-1$
- }
- }
- if (poolingEnabled) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Automatic connection pooling was enabled for connector " + getName()); //$NON-NLS-1$
- if (!this.synchWorkers) {
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManager.asynch_worker_warning", ConnectorPropertyNames.SYNCH_WORKERS)); //$NON-NLS-1$
- }
- return new PooledConnector(this.connectorName, c, isXa?this.getTransactionService():null);
- }
- return new ConnectorWrapper(c);
- }
-
- /**
* Stop this connector.
*/
- public void stop() throws ApplicationLifecycleException {
+ public void stop() {
synchronized (this) {
if (this.state == ConnectorStatus.CLOSED) {
return;
}
this.state= ConnectorStatus.CLOSED;
}
- if (this.connectorWorkerPool != null) {
- this.connectorWorkerPool.shutdownNow();
+
+ if (workManager != null) {
+ this.workManager.shutdownNow();
}
//ensure that all requests receive a response
for (ConnectorWorkItem workItem : this.requestStates.values()) {
try {
- workItem.resultsReceiver.exceptionOccurred(new ConnectorException(DQPPlugin.Util.getString("Connector_Shutting_down", new Object[] {workItem.id, connectorID}))); //$NON-NLS-1$
+ workItem.resultsReceiver.exceptionOccurred(new ConnectorException(DQPPlugin.Util.getString("Connector_Shutting_down", new Object[] {workItem.id, this.connectorName}))); //$NON-NLS-1$
} catch (Exception e) {
//ignore
}
}
- if ( this.connector != null ) {
-
- if(this.isXa){
- if (this.getTransactionService() != null) {
- TransactionService ts = this.getTransactionService();
- ts.removeRecoverySource(connectorName);
- }
- }
-
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
- try {
- currentThread.setContextClassLoader(classloader);
- this.connector.stop();
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
-
- }
}
/**
@@ -519,28 +325,12 @@
* this service.
* If there are no queues, an empty Collection is returned.
*/
- public Collection<WorkerPoolStats> getQueueStatistics() {
- if ( this.connectorWorkerPool == null ) {
- return Collections.emptyList();
- }
- return Arrays.asList(connectorWorkerPool.getStats());
+ @ManagementProperty(description="Get Runtime workmanager statistics", use={ViewUse.STATISTIC}, readOnly=true)
+ public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
+ return workManager.getStats();
}
/**
- * Returns a QueueStats object that represent the queue in
- * this service.
- * If there is no queue with the given name, an empty Collection is returned.
- */
- public Collection<WorkerPoolStats> getQueueStatistics(String name) {
- if ( connectorID == null ||
- !name.equalsIgnoreCase(connectorID.getID()) ||
- connectorWorkerPool == null ) {
- return Collections.emptyList();
- }
- return Arrays.asList(connectorWorkerPool.getStats());
- }
-
- /**
* Add begin point to transaction monitoring table.
* @param qr Request that contains the MetaMatrix command information in the transaction.
*/
@@ -556,7 +346,7 @@
String userName = qr.getWorkContext().getUserName();
String transactionID = null;
if ( qr.isTransactional() ) {
- transactionID = qr.getTransactionContext().getTxnID();
+ transactionID = qr.getTransactionContext().getXid().toString();
}
String modelName = qr.getModelName();
@@ -580,7 +370,7 @@
}
message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName, qr.getWorkContext().getConnectionID(), principal, finalRowCnt, isCancelled, errorOccurred, context);
}
- LogManager.log(MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
+ LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
}
/**
@@ -588,107 +378,29 @@
* manager.
* @return the <code>Connector</code>.
*/
- ConnectorWrapper getConnector() {
- return this.connector;
+ Connector getConnector() throws ConnectorException {
+ try {
+ InitialContext ic = new InitialContext();
+ return (Connector)ic.lookup(this.connectorName);
+ } catch (NamingException e) {
+ throw new ConnectorException(e, DQPPlugin.Util.getString("ConnectorManager.failed_to_lookup_connector", this.connectorName)); //$NON-NLS-1$
+ }
}
- void setConnector(ConnectorWrapper connector) {
- this.connector = connector;
- }
-
- int getMaxResultRows() {
- return maxResultRows;
- }
-
- void setMetadataService(MetadataService metadataService) {
- this.metadataService = metadataService;
- }
-
- MetadataService getMetadataService() {
- return metadataService;
- }
-
- boolean isExceptionOnMaxRows() {
- return exceptionOnMaxRows;
- }
-
- void setTransactionService(TransactionService transactionService) {
- this.transactionService = transactionService;
- }
-
- TransactionService getTransactionService() {
- return transactionService;
- }
-
- /**
- * The identifier that code will use to identify this object.
- * @return The <code>ConnectorID</code>.
- */
- public ConnectorID getConnectorID() {
- return connectorID;
- }
-
DQPContextCache getContextCache() {
if (bufferService != null) {
return bufferService.getContextCache();
}
-
return null;
}
- /**
- * Get the human-readable name that this connector is known by.
- * <p>Will be <code>null</code> if connector is not started.</p>
- * @return The connector's name.
- */
- public String getName() {
- return this.connectorName;
+ public ConnectorStatus getStatus() {
+ return this.state;
}
-
- void setConnectorWorkerPool(WorkerPool connectorWorkerPool) {
- this.connectorWorkerPool = connectorWorkerPool;
- }
-
- public boolean isXa() {
- return isXa;
- }
-
- public void setClassLoaderManager(ClassLoaderManager clManager) {
- this.clManager = clManager;
- }
-
- public void setWorkItemFactory(ConnectorWorkItemFactory workItemFactory) {
- this.workItemFactory = workItemFactory;
- }
-
- /**
- * Overloads the connector capabilities with one defined in the connector binding properties
- */
- static final class CapabilitesOverloader implements InvocationHandler {
- ConnectorCapabilities caps;
- Properties properties;
-
- CapabilitesOverloader(ConnectorCapabilities caps, Properties properties){
- this.caps = caps;
- this.properties = properties;
+
+ private void checkStatus() throws ConnectorException {
+ if (this.state != ConnectorStatus.OPEN) {
+ throw new ConnectorException(DQPPlugin.Util.getString("ConnectorManager.not_in_valid_state", this.connectorName));
}
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String value = this.properties.getProperty(method.getName());
- if (value == null || value.trim().length() == 0 || (args != null && args.length != 0)) {
- return method.invoke(this.caps, args);
- }
- return StringUtil.valueOf(value, method.getReturnType());
- }
- }
-
- public Collection<MMConnectionPool> getConnectionPoolStats() {
- if (connector instanceof PooledConnector) {
- PooledConnector pc = (PooledConnector) connector;
-
- return pc.getConnectionPoolStats();
- }
- return Collections.emptyList();
- }
+ }
}
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,46 @@
+/*
+ * 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.dqp.internal.datamgr.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class ConnectorManagerRepository implements Serializable{
+ private static final long serialVersionUID = -1611063218178314458L;
+
+ private Map<String, ConnectorManager> repo = new ConcurrentHashMap<String, ConnectorManager>();
+
+ public void addConnectorManager(String connectorName, ConnectorManager mgr) {
+ this.repo.put(connectorName, mgr);
+ }
+
+ public ConnectorManager getConnectorManager(String connectorName) {
+ return this.repo.get(connectorName);
+ }
+
+ public ConnectorManager removeConnectorManager(String connectorName) {
+ return this.repo.remove(connectorName);
+ }
+}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,19 +27,20 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
+import javax.resource.spi.work.WorkEvent;
+import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.Execution;
import org.teiid.connector.api.ProcedureExecution;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.api.UpdateExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
@@ -75,14 +76,16 @@
protected AtomicRequestID id;
protected ConnectorManager manager;
protected AtomicRequestMessage requestMsg;
- protected boolean isTransactional;
+ protected Connector connector;
+ QueryMetadataInterface queryMetadata;
/* Created on new request */
protected Connection connection;
+ protected ConnectorEnvironment connectorEnv;
protected ExecutionContextImpl securityContext;
protected volatile ResultSetExecution execution;
protected ProcedureBatchHandler procedureBatchHandler;
- private ICommand translatedCommand;
+ private org.teiid.connector.language.Command translatedCommand;
private Class<?>[] schema;
private List<Integer> convertToRuntimeType;
private boolean[] convertToDesiredRuntimeType;
@@ -104,53 +107,51 @@
protected ResultsReceiver<AtomicResultsMessage> resultsReceiver;
- ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
+ ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) throws ConnectorException {
this.id = message.getAtomicRequestID();
this.requestMsg = message;
this.manager = manager;
this.resultsReceiver = resultsReceiver;
AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
- requestMsg.getWorkContext().getVdbVersion(),
- requestMsg.getWorkContext().getUserName(),
- requestMsg.getWorkContext().getTrustedPayload(),
+ requestMsg.getWorkContext().getVdbVersion(),
requestMsg.getExecutionPayload(),
requestMsg.getWorkContext().getConnectionID(),
- requestMsg.getConnectorID().getID(),
+ requestMsg.getConnectorName(),
requestMsg.getRequestID().toString(),
Integer.toString(requestID.getNodeID()),
Integer.toString(requestID.getExecutionId())
);
+ this.securityContext.setUser(requestMsg.getWorkContext().getSubject());
this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
this.securityContext.setContextCache(manager.getContextCache());
+
+ this.connector = manager.getConnector();
+ this.connectorEnv = connector.getConnectorEnvironment();
+ try {
+ VDBMetaData vdb = requestMsg.getWorkContext().getVDB();
+ this.queryMetadata = vdb.getAttachment(QueryMetadataInterface.class);
+ this.queryMetadata = new TempMetadataAdapter(this.queryMetadata, new TempMetadataStore());
+
+ if (requestMsg.isTransactional()){
+ if (this.connectorEnv.isXaCapable()) {
+ this.securityContext.setTransactional(true);
+ } else if (!this.connectorEnv.isImmutable() && requestMsg.getCommand().updatingModelCount(queryMetadata) > 0) {
+ throw new ConnectorException(DQPPlugin.Util.getString("ConnectorWorker.transactionNotSupported")); //$NON-NLS-1$
+ }
+ }
+ } catch(MetaMatrixComponentException e) {
+ throw new ConnectorException(e);
+ }
}
- protected void createConnection(ConnectorWrapper connector, QueryMetadataInterface queryMetadata) throws ConnectorException, MetaMatrixComponentException {
+ protected void createConnection() throws ConnectorException {
LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating connection for atomic-request"}); //$NON-NLS-1$
-
- if (requestMsg.isTransactional()){
- if (manager.isXa()) {
- this.securityContext.setTransactional(true);
- this.isTransactional = true;
- try {
- manager.getTransactionService().getTransactionManager().resume(requestMsg.getTransactionContext().getTransaction());
- } catch (InvalidTransactionException e) {
- throw new ConnectorException(e);
- } catch (SystemException e) {
- throw new ConnectorException(e);
- }
- } else if (!manager.isImmutable() && requestMsg.getCommand().updatingModelCount(queryMetadata) > 0) {
- throw new ConnectorException(DQPPlugin.Util.getString("ConnectorWorker.transactionNotSupported")); //$NON-NLS-1$
- }
- }
-
- connection = connector.getConnection(this.securityContext, this.isTransactional?requestMsg.getTransactionContext():null);
+ this.connection = this.connector.getConnection();
}
protected void process() {
DQPWorkContext.setWorkContext(this.requestMsg.getWorkContext());
- ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(this.manager.getClassloader());
boolean success = true;
try {
checkForCloseEvent();
@@ -180,13 +181,10 @@
this.requestState = RequestState.CLOSE;
handleError(t);
} finally {
- try {
- if (this.requestState == RequestState.CLOSE) {
- processClose(success);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(contextloader);
- }
+ if (this.requestState == RequestState.CLOSE) {
+ processClose(success);
+ }
+ DQPWorkContext.releaseWorkContext();
}
}
@@ -264,26 +262,16 @@
} catch (Throwable e) {
LogManager.logError(LogConstants.CTX_CONNECTOR, e, e.getMessage());
} finally {
- try {
- if (connection != null) {
- connection.close();
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
- }
- } finally {
- manager.removeState(this.id);
- sendClose();
+ // Close the underlying connection, but send the close response only upon the notification from
+ // container in workCompleted call.
+ if (connection != null) {
+ connection.close();
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
}
}
}
- private void sendClose() {
- if (this.isTransactional) {
- try {
- manager.getTransactionService().getTransactionManager().suspend();
- } catch (SystemException e) {
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, e.getMessage());
- }
- }
+ protected void sendClose() {
AtomicResultsMessage response = new AtomicResultsMessage(this.requestMsg);
response.setRequestClosed(true);
this.resultsReceiver.receiveResults(response);
@@ -300,9 +288,8 @@
protected void createExecution() throws MetaMatrixComponentException,
ConnectorException {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$
-
- QueryMetadataInterface queryMetadata = new TempMetadataAdapter(manager.getMetadataService().lookupMetadata(this.requestMsg.getWorkContext().getVdbName(), this.requestMsg.getWorkContext().getVdbVersion()), new TempMetadataStore());
- createConnection(manager.getConnector(), queryMetadata);
+
+ createConnection();
LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating execution for atomic-request"}); //$NON-NLS-1$
@@ -326,14 +313,14 @@
// Create the execution based on mode
final Execution exec = connection.createExecution(this.translatedCommand, this.securityContext, rmd);
- if (this.translatedCommand instanceof IProcedure) {
+ if (this.translatedCommand instanceof Call) {
Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "IProcedure Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
this.execution = (ProcedureExecution)exec;
StoredProcedure proc = (StoredProcedure)command;
if (proc.returnParameters()) {
- this.procedureBatchHandler = new ProcedureBatchHandler((IProcedure)this.translatedCommand, (ProcedureExecution)this.execution);
+ this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
}
- } else if (this.translatedCommand instanceof IQueryCommand){
+ } else if (this.translatedCommand instanceof QueryExpression){
Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "IQueryCommand Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
this.execution = (ResultSetExecution)exec;
} else {
@@ -380,8 +367,14 @@
int batchSize = 0;
List<List> rows = new ArrayList<List>(batchSize/4);
boolean sendResults = true;
- try {
+
+ try {
while (batchSize < this.requestMsg.getFetchSize()) {
+
+ if (shouldAbortProcessing()) {
+ throw new ConnectorException("Container requested to abort the operation!");
+ }
+
List row = this.execution.next();
if (row == null) {
this.lastBatch = true;
@@ -397,13 +390,13 @@
correctTypes(row);
rows.add(row);
// Check for max result rows exceeded
- if(manager.getMaxResultRows() != 0 && this.rowCount >= manager.getMaxResultRows()){
- if (this.rowCount == manager.getMaxResultRows() && !manager.isExceptionOnMaxRows()) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Exceeded max, returning", manager.getMaxResultRows()}); //$NON-NLS-1$
+ if(this.connectorEnv.getMaxResultRows() != 0 && this.rowCount >= this.connectorEnv.getMaxResultRows()){
+ if (this.rowCount == this.connectorEnv.getMaxResultRows() && !this.connectorEnv.isExceptionOnMaxRows()) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Exceeded max, returning", this.connectorEnv.getMaxResultRows()}); //$NON-NLS-1$
this.lastBatch = true;
break;
- } else if (this.rowCount > manager.getMaxResultRows() && manager.isExceptionOnMaxRows()) {
- String msg = DQPPlugin.Util.getString("ConnectorWorker.MaxResultRowsExceed", manager.getMaxResultRows()); //$NON-NLS-1$
+ } else if (this.rowCount > this.connectorEnv.getMaxResultRows() && this.connectorEnv.isExceptionOnMaxRows()) {
+ String msg = DQPPlugin.Util.getString("ConnectorWorker.MaxResultRowsExceed", this.connectorEnv.getMaxResultRows()); //$NON-NLS-1$
throw new ConnectorException(msg);
}
}
@@ -436,7 +429,7 @@
if ( !lastBatch && currentRowCount == 0 ) {
// Defect 13366 - Should send all batches, even if they're zero size.
// Log warning if received a zero-size non-last batch from the connector.
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorID())); //$NON-NLS-1$
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorName())); //$NON-NLS-1$
}
AtomicResultsMessage response = createResultsMessage(this.requestMsg, rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
@@ -535,4 +528,35 @@
return this.id.toString();
}
+ @Override
+ public void workCompleted(WorkEvent arg0) {
+ manager.removeState(this.id);
+ sendClose();
+ }
+
+ @Override
+ public void workRejected(WorkEvent event) {
+ try {
+ asynchCancel();
+ } catch (ConnectorException e) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, event.getException(), this.id.toString());
+ }
+ }
+
+ @Override
+ protected boolean assosiateSecurityContext() {
+ DQPWorkContext context = requestMsg.getWorkContext();
+ if (context.getSubject() != null) {
+ return manager.getSecurityHelper().assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
+ }
+ return false;
+ }
+
+ @Override
+ protected void clearSecurityContext() {
+ DQPWorkContext context = requestMsg.getWorkContext();
+ if (context.getSubject() != null) {
+ manager.getSecurityHelper().clearSecurityContext(context.getSecurityDomain());
+ }
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,6 +23,11 @@
package org.teiid.dqp.internal.datamgr.impl;
+
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.connector.api.ConnectorException;
+
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -37,11 +42,11 @@
this.synchWorkers = synchWorkers;
}
- public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver) {
+ public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver, WorkManager wm) throws ConnectorException {
if (synchWorkers) {
return new SynchConnectorWorkItem(message, manager, receiver);
}
- return new AsynchConnectorWorkItem(message, manager, receiver);
+ return new AsynchConnectorWorkItem(message, manager, receiver, wm);
}
}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,154 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MetadataProvider;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.connector.xa.api.XAConnection;
-import org.teiid.connector.xa.api.XAConnector;
-import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
-
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.dqp.service.ConnectorStatus;
-
-/**
- * ConnectorWrapper adds default behavior to the wrapped connector.
- */
-public class ConnectorWrapper implements MetadataProvider {
-
- private Connector actualConnector;
- private volatile ConnectorStatus status = ConnectorStatus.UNABLE_TO_CHECK;
-
- public ConnectorWrapper(Connector actualConnector){
- this.actualConnector = actualConnector;
- }
-
- public void start(ConnectorEnvironment environment) throws ConnectorException {
- actualConnector.start(environment);
- int interval = PropertiesUtils.getIntProperty(environment.getProperties(), ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, ConnectionPool.DEFAULT_SOURCE_CONNECTION_TEST_INTERVAL);
- if (interval > 0 && isConnectionTestable()) {
- environment.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- updateStatus();
- }
- }, 0, interval, TimeUnit.SECONDS);
- }
- }
-
- protected boolean isConnectionTestable() {
- return supportsSingleIdentity();
- }
-
- public void stop() {
- actualConnector.stop();
- }
-
- public final Connection getConnection(ExecutionContext context, TransactionContext transactionContext)
- throws ConnectorException {
- if (context instanceof ExecutionContextImpl && context.getConnectorIdentity() == null) {
- ((ExecutionContextImpl)context).setConnectorIdentity(createIdentity(context));
- }
- if (transactionContext == null) {
- return getConnectionDirect(context);
- }
- return getXAConnectionDirect(context, transactionContext);
- }
-
- protected Connection getConnectionDirect(ExecutionContext context)
- throws ConnectorException {
- return actualConnector.getConnection(context);
- }
-
- protected XAConnection getXAConnectionDirect(ExecutionContext executionContext,
- TransactionContext transactionContext) throws ConnectorException {
- if (actualConnector instanceof XAConnector) {
- return ((XAConnector)actualConnector).getXAConnection(executionContext, transactionContext);
- }
- return null;
- }
-
- public ConnectorCapabilities getCapabilities() {
- return actualConnector.getCapabilities();
- }
-
- public final ConnectorStatus getStatus() {
- return status;
- }
-
- protected void updateStatus() {
- this.status = testConnection();
- }
-
- protected ConnectorStatus testConnection() {
- if (supportsSingleIdentity()) {
- Connection conn = null;
- try {
- conn = this.getConnectionDirect(null);
- return conn.isAlive()?ConnectorStatus.OPEN:ConnectorStatus.DATA_SOURCE_UNAVAILABLE;
- } catch (ConnectorException e) {
- return ConnectorStatus.DATA_SOURCE_UNAVAILABLE;
- } finally {
- if (conn != null) {
- conn.close();
- }
- }
- }
- return ConnectorStatus.UNABLE_TO_CHECK;
- }
-
- public Connector getActualConnector() {
- return actualConnector;
- }
-
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- return actualConnector.createIdentity(context);
- }
-
- public boolean supportsSingleIdentity() {
- try {
- return createIdentity(null) != null;
- } catch (ConnectorException e) {
- return false;
- }
- }
-
- @Override
- public void getConnectorMetadata(MetadataFactory metadataFactory)
- throws ConnectorException {
- if (this.actualConnector instanceof MetadataProvider) {
- ((MetadataProvider)this.actualConnector).getConnectorMetadata(metadataFactory);
- }
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,111 +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.
- */
-
-/*
- * Date: Sep 16, 2003
- * Time: 11:23:00 AM
- */
-package org.teiid.dqp.internal.datamgr.impl;
-
-import org.teiid.connector.api.ConnectorLogger;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.util.LogConstants;
-
-/**
- * DefaultConnectorLogger.
- */
-public class DefaultConnectorLogger implements ConnectorLogger {
- public DefaultConnectorLogger(ConnectorID loggingID) {
- }
-
- public void logError(String message) {
- LogManager.logError(LogConstants.CTX_CONNECTOR, message);
- }
-
- public void logError(String message, Throwable error) {
- LogManager.logError(LogConstants.CTX_CONNECTOR, error, message);
- }
-
- public void logWarning(String message) {
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, message);
- }
-
- public void logInfo(String message) {
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, message);
- }
-
- public void logDetail(String message) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, message);
- }
-
- public void logTrace(String message) {
- LogManager.logTrace(LogConstants.CTX_CONNECTOR, message);
- }
-
- @Override
- public boolean isDetailEnabled() {
- return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL);
- }
-
- @Override
- public boolean isErrorEnabled() {
- return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.ERROR);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.INFO);
- }
-
- @Override
- public boolean isTraceEnabled() {
- return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.TRACE);
- }
-
- @Override
- public boolean isWarningEnabled() {
- return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.WARNING);
- }
-
- @Override
- public void logDetail(String message, Throwable error) {
- LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_CONNECTOR, error, message);
- }
-
- @Override
- public void logInfo(String message, Throwable error) {
- LogManager.log(MessageLevel.INFO, LogConstants.CTX_CONNECTOR, error, message);
- }
-
- @Override
- public void logTrace(String message, Throwable error) {
- LogManager.log(MessageLevel.TRACE, LogConstants.CTX_CONNECTOR, error, message);
- }
-
- @Override
- public void logWarning(String message, Throwable error) {
- LogManager.log(MessageLevel.WARNING, LogConstants.CTX_CONNECTOR, error, message);
- }
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,17 +23,22 @@
package org.teiid.dqp.internal.datamgr.impl;
import java.io.Serializable;
+import java.security.Principal;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import org.teiid.connector.api.ConnectorIdentity;
+import javax.security.auth.Subject;
+
+import org.teiid.connector.api.CacheScope;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.cache.Cache;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.dqp.DQPPlugin;
/**
*/
@@ -44,15 +49,13 @@
// Access Node ID
private String partID;
// currentConnector ID
- private String connectorID;
+ private String connectorName;
// current VDB
private String vdbName;
// Current VDB's version
- private String vdbVersion;
+ private int vdbVersion;
// User Name
- private String userName;
- // Payload setup on the Connection Object
- private Serializable trustedPayload;
+ private Subject user;
// Payload setup on the Statement object
private Serializable executionPayload;
// ID of the parent JDBC Connection which is executing the statement
@@ -63,24 +66,18 @@
private boolean keepAlive = false;
private boolean isTransactional;
-
- private ConnectorIdentity connectorIdentity;
-
private DQPContextCache contextCache;
private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
private List<Exception> warnings = new LinkedList<Exception>();
- public ExecutionContextImpl(String vdbName, String vdbVersion, String userName,
- Serializable trustedPayload, Serializable executionPayload,
- String originalConnectionID, String connectorId, String requestId, String partId, String execCount) {
+ public ExecutionContextImpl(String vdbName, int vdbVersion, Serializable executionPayload,
+ String originalConnectionID, String connectorName, String requestId, String partId, String execCount) {
this.vdbName = vdbName;
this.vdbVersion = vdbVersion;
- this.userName = userName;
- this.trustedPayload = trustedPayload;
this.executionPayload = executionPayload;
- this.connectorID = connectorId;
+ this.connectorName = connectorName;
this.requestID = requestId;
this.partID = partId;
this.requestConnectionID = originalConnectionID;
@@ -88,43 +85,50 @@
}
public String getConnectorIdentifier() {
- return this.connectorID;
+ return this.connectorName;
}
+ @Override
public String getRequestIdentifier() {
return this.requestID;
}
+ @Override
public String getPartIdentifier() {
return this.partID;
}
+
+ @Override
public String getExecutionCountIdentifier() {
return this.executeCount;
}
+ @Override
public String getVirtualDatabaseName() {
return this.vdbName;
}
-
- public String getVirtualDatabaseVersion() {
+ @Override
+ public int getVirtualDatabaseVersion() {
return this.vdbVersion;
}
-
- public String getUser() {
- return this.userName;
+ @Override
+ public Subject getSubject() {
+ return this.user;
}
-
- public Serializable getTrustedPayload() {
- return this.trustedPayload;
+
+ public void setUser(Subject user) {
+ this.user = user;
}
+ @Override
public Serializable getExecutionPayload() {
return executionPayload;
}
+ @Override
public String getConnectionIdentifier() {
return requestConnectionID;
}
-
+ @Override
public void keepExecutionAlive(boolean alive) {
this.keepAlive = alive;
}
@@ -163,9 +167,16 @@
}
public String toString() {
- return "ExecutionContext<vdb=" + this.vdbName + ", version=" + this.vdbVersion + ", user=" + this.userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String userName = null;
+ if (this.user != null) {
+ for(Principal p:this.user.getPrincipals()) {
+ userName = p.getName();
+ }
+ }
+ return "ExecutionContext<vdb=" + this.vdbName + ", version=" + this.vdbVersion + ", user=" + userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
-
+
+ @Override
public boolean isTransactional() {
return isTransactional;
}
@@ -173,17 +184,8 @@
void setTransactional(boolean isTransactional) {
this.isTransactional = isTransactional;
}
-
+
@Override
- public ConnectorIdentity getConnectorIdentity() {
- return this.connectorIdentity;
- }
-
- public void setConnectorIdentity(ConnectorIdentity connectorIdentity) {
- this.connectorIdentity = connectorIdentity;
- }
-
- @Override
public int getBatchSize() {
return batchSize;
}
@@ -229,4 +231,58 @@
cache.put(key, value);
}
}
+
+
+ @Override
+ public Object getFromCache(CacheScope scope, Object key) {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ checkScopeValidity(scope, context);
+
+ Cache cache = getScopedCache(scope, context);
+ if (cache != null) {
+ return cache.get(key);
+ }
+ return null;
+ }
+
+ @Override
+ public void storeInCache(CacheScope scope, Object key, Object value) {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ checkScopeValidity(scope, context);
+ Cache cache = getScopedCache(scope, context);
+ if (cache != null) {
+ cache.put(key, value);
+ }
+ }
+
+ private Cache getScopedCache(CacheScope scope, DQPWorkContext context) {
+ switch (scope) {
+ case SERVICE:
+ return contextCache.getServiceScopedCache(getConnectorIdentifier());
+ case SESSION:
+ return contextCache.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
+ case VDB:
+ return contextCache.getVDBScopedCache(context.getVdbName(), context.getVdbVersion());
+ case GLOBAL:
+ return contextCache.getGlobalScopedCache();
+ }
+ return null;
+ }
+
+ private void checkScopeValidity(CacheScope scope, DQPWorkContext context) {
+ if (scope == CacheScope.REQUEST) {
+ throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.request_scope_error")); //$NON-NLS-1$
+ }
+
+ if (scope == CacheScope.SESSION) {
+ if (context == null || context.getSessionToken() == null) {
+ throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.session_scope_error")); //$NON-NLS-1$
+ }
+ }
+ else if (scope == CacheScope.VDB) {
+ if (context == null || context.getVdbName() == null || context.getVdbVersion() == 0) {
+ throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.vdb_scope_error")); //$NON-NLS-1$
+ }
+ }
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,36 +28,34 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ProcedureExecution;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IParameter.Direction;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.Argument.Direction;
import com.metamatrix.dqp.DQPPlugin;
class ProcedureBatchHandler {
- private IProcedure proc;
+ private Call proc;
private ProcedureExecution procExec;
private int paramCols = 0;
private int resultSetCols = 0;
private List filler;
- public ProcedureBatchHandler(IProcedure proc, ProcedureExecution procExec) throws ConnectorException {
+ public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) throws ConnectorException {
this.proc = proc;
this.procExec = procExec;
- List params = proc.getParameters();
-
+ List<Argument> params = proc.getArguments();
+ resultSetCols = proc.getResultSetColumnTypes().length;
+ if (proc.getReturnType() != null) {
+ paramCols++;
+ }
if(params != null && !params.isEmpty()){
- Iterator iter = params.iterator();
- while(iter.hasNext()){
- IParameter param = (IParameter)iter.next();
- if (param.getDirection() == Direction.RESULT_SET) {
- resultSetCols = param.getMetadataObject().getChildren().size();
- } else if(param.getDirection() == Direction.RETURN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
+ for (Argument param : params) {
+ if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
paramCols += 1;
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,10 +26,16 @@
import java.util.Map;
import java.util.concurrent.Semaphore;
+import javax.resource.spi.work.WorkEvent;
+import javax.transaction.xa.Xid;
+
+import org.teiid.connector.api.ConnectorException;
+
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.util.LogConstants;
public class SynchConnectorWorkItem extends ConnectorWorkItem {
@@ -39,39 +45,35 @@
int pendingCount;
}
- private static Map<String, TransactionLock> TRANSACTION_LOCKS = new HashMap<String, TransactionLock>();
+ private static Map<Xid, TransactionLock> TRANSACTION_LOCKS = new HashMap<Xid, TransactionLock>();
private TransactionLock lock;
- SynchConnectorWorkItem(AtomicRequestMessage message,
- ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
+ SynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) throws ConnectorException {
super(message, manager, resultsReceiver);
+
+ // since container makes sure that there is no current work registered under current transaction it is
+ // required that lock must be acquired before we schedule the work.
+ try {
+ acquireTransactionLock();
+ } catch (InterruptedException e) {
+ interrupted(e);
+ }
}
@Override
public void run() {
while (!this.isDoneProcessing()) { //process until closed
- try {
- acquireTransactionLock();
- } catch (InterruptedException e) {
- interrupted(e);
- }
- try {
- super.run();
- } finally {
- releaseTxnLock();
- }
+ super.run();
}
}
@Override
protected void pauseProcessing() {
- releaseTxnLock();
try {
while (isIdle()) {
this.wait();
}
- acquireTransactionLock();
} catch (InterruptedException e) {
interrupted(e);
}
@@ -87,11 +89,12 @@
this.notify();
}
- private void acquireTransactionLock() throws InterruptedException {
- if (!this.isTransactional) {
+ private void acquireTransactionLock() throws InterruptedException {
+ if (!this.requestMsg.isTransactional()) {
return;
}
- String key = requestMsg.getTransactionContext().getTxnID();
+ TransactionContext tc = this.requestMsg.getTransactionContext();
+ Xid key = tc.getXid();
TransactionLock existing = null;
synchronized (TRANSACTION_LOCKS) {
@@ -101,20 +104,24 @@
TRANSACTION_LOCKS.put(key, existing);
}
existing.pendingCount++;
+ tc.incrementPartcipatingSourceCount(requestMsg.getConnectorName());
}
existing.lock.acquire();
this.lock = existing;
+ LogManager.logTrace("got the connector lock on =", key);
}
private void releaseTxnLock() {
- if (!this.isTransactional || this.lock == null) {
+ if (!this.requestMsg.isTransactional() || this.lock == null) {
return;
}
+ TransactionContext tc = this.requestMsg.getTransactionContext();
synchronized (TRANSACTION_LOCKS) {
lock.pendingCount--;
if (lock.pendingCount == 0) {
- String key = requestMsg.getTransactionContext().getTxnID();
+ Xid key = tc.getXid();
TRANSACTION_LOCKS.remove(key);
+ LogManager.logTrace("released the connector lock on =", key);
}
}
lock.lock.release();
@@ -128,4 +135,22 @@
return true;
}
+
+ @Override
+ public void workCompleted(WorkEvent event) {
+ try {
+ super.workCompleted(event);
+ } finally {
+ releaseTxnLock();
+ }
+ }
+
+ @Override
+ public void workRejected(WorkEvent event) {
+ try {
+ super.workRejected(event);
+ } finally {
+ releaseTxnLock();
+ }
+ }
}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.teiid.connector.api.TypeFacility;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.TimestampWithTimezone;
-
-/**
- */
-public class TypeFacilityImpl extends TypeFacility {
-
- public TypeFacilityImpl() {
- }
-
- @Override
- public Object convertToRuntimeType(Object value) {
- return DataTypeManager.convertToRuntimeType(value);
- }
-
- @Override
- public Object convertDate(Date date, TimeZone initial, Calendar target,
- Class targetType) {
- return TimestampWithTimezone.create(date, initial, target, targetType);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class AggregateImpl extends BaseLanguageObject implements IAggregate {
-
- private IExpression expression = null;
- private String aggName;
- private boolean isDistinct;
- private Class type;
-
- public AggregateImpl(String aggName, boolean isDistinct, IExpression exp, Class type) {
- this.expression = exp;
- this.aggName = aggName;
- this.isDistinct = isDistinct;
- this.type = type;
- }
-
- /**
- * @see org.teiid.connector.language.IAggregate#getName()
- */
- public String getName() {
- return this.aggName;
- }
-
- /**
- * @see org.teiid.connector.language.IAggregate#isDistinct()
- */
- public boolean isDistinct() {
- return this.isDistinct;
- }
-
- /**
- * @see org.teiid.connector.language.IAggregate#getExpression()
- */
- public IExpression getExpression() {
- return this.expression;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IAggregate#setName(java.lang.String)
- */
- public void setName(String name) {
- this.aggName = name;
- }
-
- /*
- * @see com.metamatrix.data.language.IAggregate#setDistinct(boolean)
- */
- public void setDistinct(boolean isDistinct) {
- this.isDistinct = isDistinct;
- }
-
- /*
- * @see com.metamatrix.data.language.IAggregate#setExpression(com.metamatrix.data.language.IExpression)
- */
- public void setExpression(IExpression expression) {
- this.expression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#getType()
- */
- public Class getType() {
- return this.type;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.visitor.util.SQLStringVisitor;
-
-/**
- */
-public abstract class BaseLanguageObject implements ILanguageObject {
-
- /**
- *
- */
- public BaseLanguageObject() {
- }
-
- public String toString() {
- return SQLStringVisitor.getSQLString(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-
-/**
- * @since 4.2
- */
-public class BatchedUpdatesImpl extends BaseLanguageObject implements
- IBatchedUpdates {
-
- private List updateCommands;
- public BatchedUpdatesImpl(List updateCommands) {
- this.updateCommands = updateCommands;
- }
-
- /**
- * @see org.teiid.connector.language.IBatchedUpdates#getUpdateCommands()
- * @since 4.2
- */
- public List getUpdateCommands() {
- return updateCommands;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(org.teiid.connector.visitor.framework.LanguageObjectVisitor)
- * @since 4.2
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class CompareCriteriaImpl extends BaseLanguageObject implements ICompareCriteria {
-
- private IExpression leftExpression = null;
- private IExpression rightExpression = null;
- private Operator operator;
-
- public CompareCriteriaImpl(IExpression left, IExpression right, Operator operator) {
- leftExpression = left;
- rightExpression = right;
- this.operator = operator;
- }
- /**
- * @see org.teiid.connector.language.ICompareCriteria#getLeftExpression()
- */
- public IExpression getLeftExpression() {
- return leftExpression;
- }
-
- /**
- * @see org.teiid.connector.language.ICompareCriteria#getRightExpression()
- */
- public IExpression getRightExpression() {
- return rightExpression;
- }
-
- /**
- * @see org.teiid.connector.language.ICompareCriteria#getOperator()
- */
- public Operator getOperator() {
- return this.operator;
- }
-
- /*
- * @see com.metamatrix.data.language.ICompareCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
- */
- public void setLeftExpression(IExpression expression) {
- this.leftExpression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.ICompareCriteria#setRightExpression(com.metamatrix.data.language.IExpression)
- */
- public void setRightExpression(IExpression expression) {
- this.rightExpression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.ICompareCriteria#setOperator(int)
- */
- public void setOperator(Operator operator) {
- this.operator = operator;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class CompoundCriteriaImpl extends BaseLanguageObject implements ICompoundCriteria {
-
- private List criteria = null;
- private Operator operator = Operator.AND;
-
- public CompoundCriteriaImpl(List nestedCriteria, Operator operator) {
- criteria = nestedCriteria;
- this.operator = operator;
- }
-
- /**
- * @see org.teiid.connector.language.ICompoundCriteria#getOperator()
- */
- public Operator getOperator() {
- return this.operator;
- }
-
- /**
- * @see org.teiid.connector.language.ICompoundCriteria#getCriteria()
- */
- public List getCriteria() {
- return criteria;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ICompoundCriteria#setOperator(int)
- */
- public void setOperator(Operator operator) {
- this.operator = operator;
- }
-
- /*
- * @see com.metamatrix.data.language.ICompoundCriteria#setCriteria(java.util.List)
- */
- public void setCriteria(List criteria) {
- this.criteria = criteria;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class DeleteImpl extends BaseLanguageObject implements IDelete {
-
- private IGroup group = null;
- private ICriteria criteria = null;
-
- public DeleteImpl(IGroup group, ICriteria criteria) {
- this.group = group;
- this.criteria = criteria;
- }
- /**
- * @see org.teiid.connector.language.IDelete#getGroup()
- */
- public IGroup getGroup() {
- return group;
- }
-
- /**
- * @see org.teiid.connector.language.IDelete#getCriteria()
- */
- public ICriteria getCriteria() {
- return criteria;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IDelete#setGroup(com.metamatrix.data.language.IGroup)
- */
- public void setGroup(IGroup group) {
- this.group = group;
- }
-
- /*
- * @see com.metamatrix.data.language.IDelete#setCriteria(com.metamatrix.data.language.ICriteria)
- */
- public void setCriteria(ICriteria criteria) {
- this.criteria = criteria;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class ElementImpl extends BaseLanguageObject implements IElement {
-
- private IGroup group;
- private String name;
- private Element metadataObject;
- private Class type;
-
- public ElementImpl(IGroup group, String name, Element metadataObject, Class type) {
- this.group = group;
- this.name = name;
- this.metadataObject = metadataObject;
- this.type = type;
- }
-
- /**
- * @see org.teiid.connector.language.IElement#getName()
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * @see org.teiid.connector.language.IElement#getGroup()
- */
- public IGroup getGroup() {
- return group;
- }
-
- @Override
- public Element getMetadataObject() {
- return this.metadataObject;
- }
-
- public void setMetadataObject(Element metadataObject) {
- this.metadataObject = metadataObject;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IElement#setGroup(com.metamatrix.data.language.IGroup)
- */
- public void setGroup(IGroup group) {
- this.group = group;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#getType()
- */
- public Class getType() {
- return this.type;
- }
-
- /*
- * @see com.metamatrix.data.language.IElement#setName(java.lang.String)
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
- /**
- * Compare the symbol based ONLY on name. Symbols are not compared based on
- * their underlying physical metadata IDs but rather on their representation
- * in the context of a particular query. Case is not important when comparing
- * symbol names.
- * @param obj Other object
- * @return True if other obj is a Symbol (or subclass) and name is equal
- */
- public boolean equals(Object obj) {
- if(obj == this) {
- return true;
- }
-
- if(obj != null && obj instanceof IElement) {
- IElement other = (IElement) obj;
-
- // Compare groups
- if(other.getGroup() == null) {
- if(this.getGroup() != null) {
- return false;
- }
- } else {
- if(this.getGroup() == null) {
- return false;
- }
- if(! other.getGroup().equals(this.getGroup())) {
- return false;
- }
- }
-
- // Compare elements
- String thisShortName = this.getName();
- int dotIndex = thisShortName.lastIndexOf('.');
- if(dotIndex >= 0) {
- thisShortName = thisShortName.substring(dotIndex+1);
- }
-
- String otherShortName = other.getName();
- dotIndex = otherShortName.lastIndexOf('.');
- if(dotIndex >= 0) {
- otherShortName = otherShortName.substring(dotIndex+1);
- }
-
- return thisShortName.equalsIgnoreCase(otherShortName);
- }
- return false;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class ExistsCriteriaImpl extends BaseLanguageObject implements IExistsCriteria {
-
- private IQueryCommand query;
-
- /**
- *
- */
- public ExistsCriteriaImpl(IQuery query) {
- this.query = query;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
- */
- public IQueryCommand getQuery() {
- return query;
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
- */
- public void setQuery(IQueryCommand query) {
- this.query = query;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class FromImpl extends BaseLanguageObject implements IFrom {
-
- private List items = null;
-
- public FromImpl(List items) {
- this.items = items;
- }
-
- /**
- * @see org.teiid.connector.language.IFrom#getItems()
- */
- public List getItems() {
- return items;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IFrom#setItems(java.util.List)
- */
- public void setItems(List items) {
- this.items = items;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class FunctionImpl extends BaseLanguageObject implements IFunction {
-
- private String name;
- private List<IExpression> parameters;
- private Class type;
-
- public FunctionImpl(String name, List<? extends IExpression> params, Class type) {
- this.name = name;
- if (params == null) {
- this.parameters = new ArrayList<IExpression>(0);
- } else {
- this.parameters = new ArrayList<IExpression>(params);
- }
- this.type = type;
- }
-
- /**
- * @see org.teiid.connector.language.IFunction#getName()
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * @see org.teiid.connector.language.IFunction#getParameters()
- */
- public List<IExpression> getParameters() {
- return parameters;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IFunction#setName(java.lang.String)
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#getType()
- */
- public Class getType() {
- return this.type;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class GroupByImpl extends BaseLanguageObject implements IGroupBy {
-
- private List elements = null;
-
- public GroupByImpl(List elements) {
- this.elements = elements;
- }
-
- /**
- * @see org.teiid.connector.language.IGroupBy#getElements()
- */
- public List getElements() {
- return elements;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IGroupBy#setElements(java.util.List)
- */
- public void setElements(List elements) {
- this.elements = elements;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.metadata.runtime.Group;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-import com.metamatrix.core.util.HashCodeUtil;
-
-public class GroupImpl extends BaseLanguageObject implements IGroup {
-
- private String context;
- private String definition;
- private Group metadataObject;
-
- public GroupImpl(String context, String definition, Group group) {
- this.context = context;
- this.definition = definition;
- this.metadataObject = group;
- }
-
- /**
- * @see org.teiid.connector.language.IGroup#getContext()
- */
- public String getContext() {
- return context;
- }
-
- /**
- * @see org.teiid.connector.language.IGroup#getDefinition()
- */
- public String getDefinition() {
- return this.definition;
- }
-
- @Override
- public Group getMetadataObject() {
- return this.metadataObject;
- }
-
- public void setMetadataObject(Group metadataObject) {
- this.metadataObject = metadataObject;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IGroup#setDefinition(java.lang.String)
- */
- public void setDefinition(String definition) {
- this.definition = definition;
- }
-
- /*
- * @see com.metamatrix.data.language.IGroup#setContext(java.lang.String)
- */
- public void setContext(String context) {
- this.context = context;
- }
-
- public int hashCode() {
- return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, this.getDefinition()), this.getContext());
- }
-
- public boolean equals(Object obj) {
- if(this == obj) {
- return true;
- }
-
- if(obj == null || ! (obj instanceof IGroup)) {
- return false;
- }
- IGroup other = (IGroup) obj;
-
- // Two group symbols will be equal only if both use aliases or both
- // don't use aliases. In either case, comparing context names is
- // enough.
- if( (this.getDefinition() == null && other.getDefinition() == null) ||
- (this.getDefinition() != null && other.getDefinition() != null) ) {
-
- return this.getContext().equalsIgnoreCase(other.getContext());
-
- }
- return false;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class InCriteriaImpl extends BaseLanguageObject implements IInCriteria {
-
- private IExpression leftExpression = null;
- private List rightExpressions = null;
- private boolean negated = false;
-
- public InCriteriaImpl(IExpression left, List right, boolean negated) {
- leftExpression = left;
- rightExpressions = right;
- this.negated = negated;
- }
- /**
- * @see org.teiid.connector.language.IInCriteria#getLeftExpression()
- */
- public IExpression getLeftExpression() {
- return leftExpression;
- }
-
- /**
- * @see org.teiid.connector.language.IInCriteria#getRightExpressions()
- */
- public List getRightExpressions() {
- return rightExpressions;
- }
-
- /**
- * @see org.teiid.connector.language.IInCriteria#isNegated()
- */
- public boolean isNegated() {
- return this.negated;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.IInCriteria#setRightExpressions(java.util.List)
- */
- public void setRightExpressions(List expressions) {
- this.rightExpressions = expressions;
- }
- /*
- * @see com.metamatrix.data.language.IBaseInCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
- */
- public void setLeftExpression(IExpression expression) {
- this.leftExpression = expression;
- }
- /*
- * @see com.metamatrix.data.language.IBaseInCriteria#setNegated(boolean)
- */
- public void setNegated(boolean negated) {
- this.negated = negated;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- * Inline views are treated like aliased groups
- */
-public class InlineViewImpl extends GroupImpl implements IInlineView {
-
- private String name;
- private IQueryCommand query;
- private String output;
-
- public InlineViewImpl(IQueryCommand query, String name) {
- super(name, name, null);
- this.query = query;
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public IQueryCommand getQuery() {
- return this.query;
- }
-
- public void setQuery(IQueryCommand query) {
- this.query = query;
- }
-
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- public String getOutput() {
- return output;
- }
-
- public void setOutput(String output) {
- this.output = output;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertValueSource;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class InsertImpl extends BaseLanguageObject implements IInsert {
-
- private IGroup group;
- private List elements;
- private IInsertValueSource valueSource;
-
- public InsertImpl(IGroup group, List elements, IInsertValueSource valueSource) {
- this.group = group;
- this.elements = elements;
- this.valueSource = valueSource;
- }
- /**
- * @see org.teiid.connector.language.IInsert#getGroup()
- */
- public IGroup getGroup() {
- return group;
- }
-
- /**
- * @see org.teiid.connector.language.IInsert#getElements()
- */
- public List getElements() {
- return elements;
- }
-
- /**
- * @see org.teiid.connector.language.IInsert#getValueSource()
- */
- public IInsertValueSource getValueSource() {
- return valueSource;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.IInsert#setGroup(com.metamatrix.data.language.IGroup)
- */
- public void setGroup(IGroup group) {
- this.group = group;
- }
- /*
- * @see com.metamatrix.data.language.IInsert#setElements(java.util.List)
- */
- public void setElements(List elements) {
- this.elements = elements;
- }
-
- @Override
- public void setValueSource(IInsertValueSource values) {
- this.valueSource = values;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,27 +0,0 @@
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class InsertValueExpressionsImpl extends BaseLanguageObject implements IInsertExpressionValueSource {
-
- private List<IExpression> values;
-
- public InsertValueExpressionsImpl(List<IExpression> values) {
- this.values = values;
- }
-
- @Override
- public List<IExpression> getValues() {
- return values;
- }
-
- @Override
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class IsNullCriteriaImpl extends BaseLanguageObject implements IIsNullCriteria {
-
- private IExpression expression = null;
- private boolean negated = false;
-
- public IsNullCriteriaImpl(IExpression expr, boolean isNegated) {
- expression = expr;
- this.negated = isNegated;
- }
-
- /**
- * @see org.teiid.connector.language.IIsNullCriteria#getExpression()
- */
- public IExpression getExpression() {
- return expression;
- }
-
- /**
- * @see org.teiid.connector.language.IIsNullCriteria#isNegated()
- */
- public boolean isNegated() {
- return this.negated;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IIsNullCriteria#setExpression(com.metamatrix.data.language.IExpression)
- */
- public void setExpression(IExpression expression) {
- this.expression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.IIsNullCriteria#setNegated(boolean)
- */
- public void setNegated(boolean negated) {
- this.negated = negated;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class JoinImpl extends BaseLanguageObject implements IJoin {
-
- private IFromItem leftItem = null;
- private IFromItem rightItem = null;
- private JoinType joinType;
- private List criteria = null;
-
- public JoinImpl(IFromItem left, IFromItem right, JoinType joinType, List criteria) {
- this.leftItem = left;
- this.rightItem = right;
- this.joinType = joinType;
- this.criteria = criteria;
- }
- /**
- * @see org.teiid.connector.language.IJoin#getLeftItem()
- */
- public IFromItem getLeftItem() {
- return leftItem;
- }
-
- /**
- * @see org.teiid.connector.language.IJoin#getRightItem()
- */
- public IFromItem getRightItem() {
- return rightItem;
- }
-
- /**
- * @see org.teiid.connector.language.IJoin#getJoinType()
- */
- public JoinType getJoinType() {
- return this.joinType;
- }
-
- /**
- * @see org.teiid.connector.language.IJoin#getCriteria()
- */
- public List getCriteria() {
- return criteria;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.IJoin#setLeftItem(com.metamatrix.data.language.IFromItem)
- */
- public void setLeftItem(IFromItem item) {
- this.leftItem = item;
- }
- /*
- * @see com.metamatrix.data.language.IJoin#setRightItem(com.metamatrix.data.language.IFromItem)
- */
- public void setRightItem(IFromItem item) {
- this.rightItem = item;
- }
- /*
- * @see com.metamatrix.data.language.IJoin#setJoinType(int)
- */
- public void setJoinType(JoinType type) {
- this.joinType = type;
- }
- /*
- * @see com.metamatrix.data.language.IJoin#setCriteria(java.util.List)
- */
- public void setCriteria(List criteria) {
- this.criteria = criteria;
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,49 +27,39 @@
import java.util.List;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.connector.language.ISubqueryCompareCriteria.Quantifier;
-import org.teiid.connector.metadata.runtime.Parameter;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Condition;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.InsertValueSource;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.QueryExpression;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.TableReference;
+import org.teiid.connector.language.Argument.Direction;
+import org.teiid.connector.language.Comparison.Operator;
+import org.teiid.connector.language.SortSpecification.Ordering;
+import org.teiid.connector.language.SubqueryComparison.Quantifier;
import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -86,7 +76,6 @@
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.Delete;
import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
import com.metamatrix.query.sql.lang.FromClause;
import com.metamatrix.query.sql.lang.GroupBy;
import com.metamatrix.query.sql.lang.Insert;
@@ -101,7 +90,6 @@
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetClause;
import com.metamatrix.query.sql.lang.SetClauseList;
import com.metamatrix.query.sql.lang.SetCriteria;
@@ -133,7 +121,7 @@
}
}
- public ICommand translate(Command command) throws MetaMatrixComponentException {
+ public org.teiid.connector.language.Command translate(Command command) throws MetaMatrixComponentException {
if (command == null) return null;
if (command instanceof Query) {
return translate((Query)command);
@@ -153,25 +141,25 @@
throw new AssertionError();
}
- IQueryCommand translate(QueryCommand command) throws MetaMatrixComponentException {
+ QueryExpression translate(QueryCommand command) throws MetaMatrixComponentException {
if (command instanceof Query) {
return translate((Query)command);
}
return translate((SetQuery)command);
}
- ISetQuery translate(SetQuery union) throws MetaMatrixComponentException {
- SetQueryImpl result = new SetQueryImpl();
+ org.teiid.connector.language.SetQuery translate(SetQuery union) throws MetaMatrixComponentException {
+ org.teiid.connector.language.SetQuery result = new org.teiid.connector.language.SetQuery();
result.setAll(union.isAll());
switch (union.getOperation()) {
case UNION:
- result.setOperation(ISetQuery.Operation.UNION);
+ result.setOperation(org.teiid.connector.language.SetQuery.Operation.UNION);
break;
case INTERSECT:
- result.setOperation(ISetQuery.Operation.INTERSECT);
+ result.setOperation(org.teiid.connector.language.SetQuery.Operation.INTERSECT);
break;
case EXCEPT:
- result.setOperation(ISetQuery.Operation.EXCEPT);
+ result.setOperation(org.teiid.connector.language.SetQuery.Operation.EXCEPT);
break;
}
result.setLeftQuery(translate(union.getLeftQuery()));
@@ -182,30 +170,18 @@
}
/* Query */
- IQuery translate(Query query) throws MetaMatrixComponentException {
- QueryImpl q = new QueryImpl(translate(query.getSelect()),
- translate(query.getFrom()),
- translate(query.getCriteria()),
- translate(query.getGroupBy()),
- translate(query.getHaving()),
- translate(query.getOrderBy()));
- q.setLimit(translate(query.getLimit()));
- return q;
- }
-
- public ISelect translate(Select select) throws MetaMatrixComponentException {
- List symbols = select.getSymbols();
- List translatedSymbols = new ArrayList(symbols.size());
+ Select translate(Query query) throws MetaMatrixComponentException {
+ List symbols = query.getSelect().getSymbols();
+ List<DerivedColumn> translatedSymbols = new ArrayList<DerivedColumn>(symbols.size());
for (Iterator i = symbols.iterator(); i.hasNext();) {
SingleElementSymbol symbol = (SingleElementSymbol)i.next();
- boolean isAlias = false;
- String alias = symbol.getOutputName();
+ String alias = null;
if(symbol instanceof AliasSymbol) {
+ alias = symbol.getOutputName();
symbol = ((AliasSymbol)symbol).getSymbol();
- isAlias = true;
}
- IExpression iExp = null;
+ org.teiid.connector.language.Expression iExp = null;
if(symbol instanceof ElementSymbol) {
iExp = translate((ElementSymbol)symbol);
} else if(symbol instanceof AggregateSymbol) {
@@ -214,26 +190,26 @@
iExp = translate(((ExpressionSymbol)symbol).getExpression());
}
- SelectSymbolImpl selectSymbol = new SelectSymbolImpl(alias, iExp);
- if(isAlias){
- selectSymbol.setOutputName(alias);
- selectSymbol.setAlias(true);
- }
+ DerivedColumn selectSymbol = new DerivedColumn(alias, iExp);
translatedSymbols.add(selectSymbol);
}
- return new SelectImpl(translatedSymbols, select.isDistinct());
+ List<TableReference> items = null;
+ if (query.getFrom() != null) {
+ List clauses = query.getFrom().getClauses();
+ items = new ArrayList<TableReference>(clauses.size());
+ for (Iterator i = clauses.iterator(); i.hasNext();) {
+ items.add(translate((FromClause)i.next()));
+ }
+ }
+ Select q = new Select(translatedSymbols, query
+ .getSelect().isDistinct(), items,
+ translate(query.getCriteria()), translate(query.getGroupBy()),
+ translate(query.getHaving()), translate(query.getOrderBy()));
+ q.setLimit(translate(query.getLimit()));
+ return q;
}
-
- public IFrom translate(From from) throws MetaMatrixComponentException {
- List clauses = from.getClauses();
- List items = new ArrayList();
- for (Iterator i = clauses.iterator(); i.hasNext();) {
- items.add(translate((FromClause)i.next()));
- }
- return new FromImpl(items);
- }
- public IFromItem translate(FromClause clause) throws MetaMatrixComponentException {
+ public TableReference translate(FromClause clause) throws MetaMatrixComponentException {
if (clause == null) return null;
if (clause instanceof JoinPredicate) {
return translate((JoinPredicate)clause);
@@ -245,41 +221,43 @@
throw new AssertionError();
}
- IJoin translate(JoinPredicate join) throws MetaMatrixComponentException {
+ Join translate(JoinPredicate join) throws MetaMatrixComponentException {
List crits = join.getJoinCriteria();
- List criteria = new ArrayList();
- for (Iterator i = crits.iterator(); i.hasNext();) {
- criteria.add(translate((Criteria)i.next()));
+ Criteria crit = null;
+ if (crits.size() == 1) {
+ crit = (Criteria)crits.get(0);
+ } else if (crits.size() > 1) {
+ crit = new CompoundCriteria(crits);
}
- IJoin.JoinType joinType = IJoin.JoinType.INNER_JOIN;
+ Join.JoinType joinType = Join.JoinType.INNER_JOIN;
if(join.getJoinType().equals(JoinType.JOIN_INNER)) {
- joinType = IJoin.JoinType.INNER_JOIN;
+ joinType = Join.JoinType.INNER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_LEFT_OUTER)) {
- joinType = IJoin.JoinType.LEFT_OUTER_JOIN;
+ joinType = Join.JoinType.LEFT_OUTER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_RIGHT_OUTER)) {
- joinType = IJoin.JoinType.RIGHT_OUTER_JOIN;
+ joinType = Join.JoinType.RIGHT_OUTER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_FULL_OUTER)) {
- joinType = IJoin.JoinType.FULL_OUTER_JOIN;
+ joinType = Join.JoinType.FULL_OUTER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_CROSS)) {
- joinType = IJoin.JoinType.CROSS_JOIN;
+ joinType = Join.JoinType.CROSS_JOIN;
}
- return new JoinImpl(translate(join.getLeftClause()),
+ return new Join(translate(join.getLeftClause()),
translate(join.getRightClause()),
joinType,
- criteria);
+ translate(crit));
}
- IFromItem translate(SubqueryFromClause clause) throws MetaMatrixComponentException {
- return new InlineViewImpl(translate((QueryCommand)clause.getCommand()), clause.getOutputName());
+ TableReference translate(SubqueryFromClause clause) throws MetaMatrixComponentException {
+ return new DerivedTable(translate((QueryCommand)clause.getCommand()), clause.getOutputName());
}
- IGroup translate(UnaryFromClause clause) throws MetaMatrixComponentException {
+ NamedTable translate(UnaryFromClause clause) throws MetaMatrixComponentException {
return translate(clause.getGroup());
}
- public ICriteria translate(Criteria criteria) throws MetaMatrixComponentException {
+ public Condition translate(Criteria criteria) throws MetaMatrixComponentException {
if (criteria == null) return null;
if (criteria instanceof CompareCriteria) {
return translate((CompareCriteria)criteria);
@@ -303,8 +281,8 @@
throw new AssertionError();
}
- ICompareCriteria translate(CompareCriteria criteria) throws MetaMatrixComponentException {
- ICompareCriteria.Operator operator = Operator.EQ;
+ org.teiid.connector.language.Comparison translate(CompareCriteria criteria) throws MetaMatrixComponentException {
+ Operator operator = Operator.EQ;
switch(criteria.getOperator()) {
case CompareCriteria.EQ:
operator = Operator.EQ;
@@ -327,51 +305,52 @@
}
- return new CompareCriteriaImpl(translate(criteria.getLeftExpression()),
+ return new org.teiid.connector.language.Comparison(translate(criteria.getLeftExpression()),
translate(criteria.getRightExpression()), operator);
}
- ICompoundCriteria translate(CompoundCriteria criteria) throws MetaMatrixComponentException {
+ AndOr translate(CompoundCriteria criteria) throws MetaMatrixComponentException {
List nestedCriteria = criteria.getCriteria();
- List translatedCriteria = new ArrayList();
- for (Iterator i = nestedCriteria.iterator(); i.hasNext();) {
- translatedCriteria.add(translate((Criteria)i.next()));
+ int size = nestedCriteria.size();
+ AndOr.Operator op = criteria.getOperator() == CompoundCriteria.AND?AndOr.Operator.AND:AndOr.Operator.OR;
+ AndOr result = new AndOr(translate((Criteria)nestedCriteria.get(size - 2)), translate((Criteria)nestedCriteria.get(size - 1)), op);
+ for (int i = nestedCriteria.size() - 3; i >= 0; i--) {
+ result = new AndOr(translate((Criteria)nestedCriteria.get(i)), result, op);
}
-
- return new CompoundCriteriaImpl(translatedCriteria, criteria.getOperator() == CompoundCriteria.AND?ICompoundCriteria.Operator.AND:ICompoundCriteria.Operator.OR);
+ return result;
}
- IExistsCriteria translate(ExistsCriteria criteria) throws MetaMatrixComponentException {
- return new ExistsCriteriaImpl(translate((Query)criteria.getCommand()));
+ Exists translate(ExistsCriteria criteria) throws MetaMatrixComponentException {
+ return new Exists(translate((QueryCommand)criteria.getCommand()));
}
- IIsNullCriteria translate(IsNullCriteria criteria) throws MetaMatrixComponentException {
- return new IsNullCriteriaImpl(translate(criteria.getExpression()), criteria.isNegated());
+ IsNull translate(IsNullCriteria criteria) throws MetaMatrixComponentException {
+ return new IsNull(translate(criteria.getExpression()), criteria.isNegated());
}
- ILikeCriteria translate(MatchCriteria criteria) throws MetaMatrixComponentException {
+ Like translate(MatchCriteria criteria) throws MetaMatrixComponentException {
Character escapeChar = null;
if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
escapeChar = new Character(criteria.getEscapeChar());
}
- return new LikeCriteriaImpl(translate(criteria.getLeftExpression()),
+ return new Like(translate(criteria.getLeftExpression()),
translate(criteria.getRightExpression()),
escapeChar,
criteria.isNegated());
}
- IInCriteria translate(SetCriteria criteria) throws MetaMatrixComponentException {
+ In translate(SetCriteria criteria) throws MetaMatrixComponentException {
List expressions = criteria.getValues();
List translatedExpressions = new ArrayList();
for (Iterator i = expressions.iterator(); i.hasNext();) {
translatedExpressions.add(translate((Expression)i.next()));
}
- return new InCriteriaImpl(translate(criteria.getExpression()),
+ return new In(translate(criteria.getExpression()),
translatedExpressions,
criteria.isNegated());
}
- ISubqueryCompareCriteria translate(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException {
+ SubqueryComparison translate(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException {
Quantifier quantifier = Quantifier.ALL;
switch(criteria.getPredicateQuantifier()) {
case SubqueryCompareCriteria.ALL:
@@ -385,84 +364,80 @@
break;
}
- ICompareCriteria.Operator operator = ICompareCriteria.Operator.EQ;
+ Operator operator = Operator.EQ;
switch(criteria.getOperator()) {
case SubqueryCompareCriteria.EQ:
- operator = ICompareCriteria.Operator.EQ;
+ operator = Operator.EQ;
break;
case SubqueryCompareCriteria.NE:
- operator = ICompareCriteria.Operator.NE;
+ operator = Operator.NE;
break;
case SubqueryCompareCriteria.LT:
- operator = ICompareCriteria.Operator.LT;
+ operator = Operator.LT;
break;
case SubqueryCompareCriteria.LE:
- operator = ICompareCriteria.Operator.LE;
+ operator = Operator.LE;
break;
case SubqueryCompareCriteria.GT:
- operator = ICompareCriteria.Operator.GT;
+ operator = Operator.GT;
break;
case SubqueryCompareCriteria.GE:
- operator = ICompareCriteria.Operator.GE;
+ operator = Operator.GE;
break;
}
- return new SubqueryCompareCriteriaImpl(translate(criteria.getLeftExpression()),
+ return new SubqueryComparison(translate(criteria.getLeftExpression()),
operator,
quantifier,
- translate((Query)criteria.getCommand()));
+ translate((QueryCommand)criteria.getCommand()));
}
- ISubqueryInCriteria translate(SubquerySetCriteria criteria) throws MetaMatrixComponentException {
- return new SubqueryInCriteriaImpl(translate(criteria.getExpression()),
+ SubqueryIn translate(SubquerySetCriteria criteria) throws MetaMatrixComponentException {
+ return new SubqueryIn(translate(criteria.getExpression()),
criteria.isNegated(),
- translate((Query)criteria.getCommand()));
+ translate((QueryCommand)criteria.getCommand()));
}
- INotCriteria translate(NotCriteria criteria) throws MetaMatrixComponentException {
- return new NotCriteriaImpl(translate(criteria.getCriteria()));
+ Not translate(NotCriteria criteria) throws MetaMatrixComponentException {
+ return new Not(translate(criteria.getCriteria()));
}
- public IGroupBy translate(GroupBy groupBy) throws MetaMatrixComponentException {
+ public org.teiid.connector.language.GroupBy translate(GroupBy groupBy) throws MetaMatrixComponentException {
if(groupBy == null){
return null;
}
List items = groupBy.getSymbols();
- List translatedItems = new ArrayList();
+ List<org.teiid.connector.language.Expression> translatedItems = new ArrayList<org.teiid.connector.language.Expression>();
for (Iterator i = items.iterator(); i.hasNext();) {
translatedItems.add(translate((Expression)i.next()));
}
- return new GroupByImpl(translatedItems);
+ return new org.teiid.connector.language.GroupBy(translatedItems);
}
- public IOrderBy translate(OrderBy orderBy) throws MetaMatrixComponentException {
+ public org.teiid.connector.language.OrderBy translate(OrderBy orderBy) throws MetaMatrixComponentException {
if(orderBy == null){
return null;
}
- List<OrderByItemImpl> translatedItems = new ArrayList<OrderByItemImpl>();
- for (OrderByItem item : orderBy.getOrderByItems()) {
- SingleElementSymbol symbol = item.getSymbol();
- boolean direction = item.isAscending()?IOrderByItem.ASC:IOrderByItem.DESC;
-
- OrderByItemImpl orderByItem = null;
- if(symbol instanceof ElementSymbol){
- IElement innerElement = translate((ElementSymbol)symbol);
- if (item.isUnrelated() || (symbol.getOutputName() != null && symbol.getOutputName().indexOf(ElementSymbol.SEPARATOR) != -1)) {
- orderByItem = new OrderByItemImpl(null, direction, innerElement);
- } else {
- orderByItem = new OrderByItemImpl(symbol.getOutputName(), direction, innerElement);
- }
+ List<OrderByItem> items = orderBy.getOrderByItems();
+ List<SortSpecification> translatedItems = new ArrayList<SortSpecification>();
+ for (int i = 0; i < items.size(); i++) {
+ SingleElementSymbol symbol = items.get(i).getSymbol();
+ Ordering direction = items.get(i).isAscending() ? Ordering.ASC: Ordering.DESC;
+
+ SortSpecification orderByItem = null;
+ if(symbol instanceof AliasSymbol || !items.get(i).isUnrelated()){
+ orderByItem = new SortSpecification(direction, new ColumnReference(null, symbol.getOutputName(), null, symbol.getType()));
} else {
- orderByItem = new OrderByItemImpl(symbol.getOutputName(), direction, null);
+ orderByItem = new SortSpecification(direction, translate(symbol));
}
translatedItems.add(orderByItem);
}
- return new OrderByImpl(translatedItems);
+ return new org.teiid.connector.language.OrderBy(translatedItems);
}
/* Expressions */
- public IExpression translate(Expression expr) throws MetaMatrixComponentException {
+ public org.teiid.connector.language.Expression translate(Expression expr) throws MetaMatrixComponentException {
if (expr == null) return null;
if (expr instanceof Constant) {
return translate((Constant)expr);
@@ -478,46 +453,42 @@
throw new AssertionError();
}
- ILiteral translate(Constant constant) {
- LiteralImpl result = new LiteralImpl(constant.getValue(), constant.getType());
+ Literal translate(Constant constant) {
+ Literal result = new Literal(constant.getValue(), constant.getType());
result.setBindValue(constant.isMultiValued());
result.setMultiValued(constant.isMultiValued());
return result;
}
- IFunction translate(Function function) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Function translate(Function function) throws MetaMatrixComponentException {
Expression [] args = function.getArgs();
- List<IExpression> params = new ArrayList<IExpression>(args.length);
+ List<org.teiid.connector.language.Expression> params = new ArrayList<org.teiid.connector.language.Expression>(args.length);
if (args != null) {
for (int i = 0; i < args.length; i++) {
params.add(translate(args[i]));
}
}
- return new FunctionImpl(function.getName(), params, function.getType());
+ return new org.teiid.connector.language.Function(function.getName(), params, function.getType());
}
- ISearchedCaseExpression translate(SearchedCaseExpression expr) throws MetaMatrixComponentException {
- ArrayList whens = new ArrayList(), thens = new ArrayList();
+ SearchedCase translate(SearchedCaseExpression expr) throws MetaMatrixComponentException {
+ ArrayList<SearchedWhenClause> whens = new ArrayList<SearchedWhenClause>();
for (int i = 0; i < expr.getWhenCount(); i++) {
- whens.add(translate(expr.getWhenCriteria(i)));
- thens.add(translate(expr.getThenExpression(i)));
+ whens.add(new SearchedWhenClause(translate(expr.getWhenCriteria(i)), translate(expr.getThenExpression(i))));
}
- return new SearchedCaseExpressionImpl(whens,
- thens,
+ return new SearchedCase(whens,
translate(expr.getElseExpression()),
expr.getType());
}
- IExpression translate(ScalarSubquery ss) throws MetaMatrixComponentException {
- return new ScalarSubqueryImpl(translate((Query)ss.getCommand()));
+ org.teiid.connector.language.Expression translate(ScalarSubquery ss) throws MetaMatrixComponentException {
+ return new org.teiid.connector.language.ScalarSubquery(translate((QueryCommand)ss.getCommand()));
}
- IExpression translate(SingleElementSymbol symbol) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Expression translate(SingleElementSymbol symbol) throws MetaMatrixComponentException {
if (symbol == null) return null;
- if (symbol instanceof AliasSymbol) {
- return translate((AliasSymbol)symbol);
- } else if (symbol instanceof ElementSymbol) {
+ if (symbol instanceof ElementSymbol) {
return translate((ElementSymbol)symbol);
} else if (symbol instanceof AggregateSymbol) {
return translate((AggregateSymbol)symbol);
@@ -527,14 +498,14 @@
throw new AssertionError();
}
- IExpression translate(AliasSymbol symbol) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Expression translate(AliasSymbol symbol) throws MetaMatrixComponentException {
return translate(symbol.getSymbol());
}
- IElement translate(ElementSymbol symbol) throws MetaMatrixComponentException {
- ElementImpl element = new ElementImpl(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
-
- if (element.getGroup().getMetadataObject() == null) {
+ ColumnReference translate(ElementSymbol symbol) throws MetaMatrixComponentException {
+ ColumnReference element = null;
+ element = new ColumnReference(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
+ if (element.getTable().getMetadataObject() == null) {
return element;
}
@@ -546,74 +517,72 @@
return element;
}
- IAggregate translate(AggregateSymbol symbol) throws MetaMatrixComponentException {
- return new AggregateImpl(symbol.getAggregateFunction(),
+ AggregateFunction translate(AggregateSymbol symbol) throws MetaMatrixComponentException {
+ return new AggregateFunction(symbol.getAggregateFunction(),
symbol.isDistinct(),
translate(symbol.getExpression()),
symbol.getType());
}
- IExpression translate(ExpressionSymbol symbol) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Expression translate(ExpressionSymbol symbol) throws MetaMatrixComponentException {
return translate(symbol.getExpression());
}
/* Insert */
- IInsert translate(Insert insert) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Insert translate(Insert insert) throws MetaMatrixComponentException {
List elements = insert.getVariables();
- List translatedElements = new ArrayList();
+ List<ColumnReference> translatedElements = new ArrayList<ColumnReference>();
for (Iterator i = elements.iterator(); i.hasNext();) {
translatedElements.add(translate((ElementSymbol)i.next()));
}
- IInsertValueSource valueSource = null;
+ InsertValueSource valueSource = null;
if (insert.getQueryExpression() != null) {
valueSource = translate(insert.getQueryExpression());
} else {
// This is for the simple one row insert.
List values = insert.getValues();
- List translatedValues = new ArrayList();
+ List<org.teiid.connector.language.Expression> translatedValues = new ArrayList<org.teiid.connector.language.Expression>();
for (Iterator i = values.iterator(); i.hasNext();) {
translatedValues.add(translate((Expression)i.next()));
}
- valueSource = new InsertValueExpressionsImpl(translatedValues);
+ valueSource = new ExpressionValueSource(translatedValues);
}
- InsertImpl result = new InsertImpl(translate(insert.getGroup()),
+ return new org.teiid.connector.language.Insert(translate(insert.getGroup()),
translatedElements,
valueSource);
- return result;
}
/* Update */
- IUpdate translate(Update update) throws MetaMatrixComponentException {
- UpdateImpl updateImpl = new UpdateImpl(translate(update.getGroup()),
+ org.teiid.connector.language.Update translate(Update update) throws MetaMatrixComponentException {
+ return new org.teiid.connector.language.Update(translate(update.getGroup()),
translate(update.getChangeList()),
translate(update.getCriteria()));
- return updateImpl;
}
- ISetClauseList translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
- List<ISetClause> clauses = new ArrayList<ISetClause>(setClauseList.getClauses().size());
+ List<org.teiid.connector.language.SetClause> translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
+ List<org.teiid.connector.language.SetClause> clauses = new ArrayList<org.teiid.connector.language.SetClause>(setClauseList.getClauses().size());
for (SetClause setClause : setClauseList.getClauses()) {
clauses.add(translate(setClause));
}
- return new SetClauseListImpl(clauses);
+ return clauses;
}
- ISetClause translate(SetClause setClause) throws MetaMatrixComponentException {
- return new SetClauseImpl(translate(setClause.getSymbol()), translate(setClause.getValue()));
+ org.teiid.connector.language.SetClause translate(SetClause setClause) throws MetaMatrixComponentException {
+ return new org.teiid.connector.language.SetClause(translate(setClause.getSymbol()), translate(setClause.getValue()));
}
/* Delete */
- IDelete translate(Delete delete) throws MetaMatrixComponentException {
- DeleteImpl deleteImpl = new DeleteImpl(translate(delete.getGroup()),
+ org.teiid.connector.language.Delete translate(Delete delete) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Delete deleteImpl = new org.teiid.connector.language.Delete(translate(delete.getGroup()),
translate(delete.getCriteria()));
return deleteImpl;
}
/* Execute */
- IProcedure translate(StoredProcedure sp) throws MetaMatrixComponentException {
+ Call translate(StoredProcedure sp) throws MetaMatrixComponentException {
Procedure proc = null;
if(sp.getProcedureID() != null) {
try {
@@ -622,42 +591,50 @@
throw new MetaMatrixComponentException(e);
}
}
-
+ Class<?> returnType = null;
List parameters = sp.getParameters();
- List<IParameter> translatedParameters = new ArrayList<IParameter>();
+ List<Argument> translatedParameters = new ArrayList<Argument>();
for (Iterator i = parameters.iterator(); i.hasNext();) {
- translatedParameters.add(translate((SPParameter)i.next(), proc));
+ SPParameter param = (SPParameter)i.next();
+ Direction direction = Direction.IN;
+ switch(param.getParameterType()) {
+ case ParameterInfo.IN:
+ direction = Direction.IN;
+ break;
+ case ParameterInfo.INOUT:
+ direction = Direction.INOUT;
+ break;
+ case ParameterInfo.OUT:
+ direction = Direction.OUT;
+ break;
+ case ParameterInfo.RESULT_SET:
+ continue; //already part of the metadata
+ case ParameterInfo.RETURN_VALUE:
+ returnType = param.getClassType();
+ break;
+
+ }
+
+ ProcedureParameter metadataParam = metadataFactory.getParameter(param);
+ //we can assume for now that all arguments will be literals, which may be multivalued
+ Literal value = (Literal)translate(param.getExpression());
+ Argument arg = new Argument(direction, value, param.getClassType(), metadataParam);
+ translatedParameters.add(arg);
}
- return new ProcedureImpl(sp.getProcedureName(), translatedParameters, proc);
+ Call call = new Call(sp.getProcedureName(), translatedParameters, proc);
+ call.setReturnType(returnType);
+ return call;
}
- IParameter translate(SPParameter param, Procedure parent) {
- Direction direction = Direction.IN;
- switch(param.getParameterType()) {
- case ParameterInfo.IN:
- direction = Direction.IN;
- break;
- case ParameterInfo.INOUT:
- direction = Direction.INOUT;
- break;
- case ParameterInfo.OUT:
- direction = Direction.OUT;
- break;
- case ParameterInfo.RESULT_SET:
- direction = Direction.RESULT_SET;
- break;
- case ParameterInfo.RETURN_VALUE:
- direction = Direction.RETURN;
- break;
+ public NamedTable translate(GroupSymbol symbol) throws MetaMatrixComponentException {
+ String alias = null;
+ String fullGroup = symbol.getOutputName();
+ if(symbol.getOutputDefinition() != null) {
+ alias = symbol.getOutputName();
+ fullGroup = symbol.getOutputDefinition();
}
-
- Parameter metadataParam = metadataFactory.getParameter(param, parent);
- return new ParameterImpl(param.getIndex(), direction, param.getValue(), param.getClassType(), metadataParam);
- }
-
- public IGroup translate(GroupSymbol symbol) throws MetaMatrixComponentException {
- GroupImpl group = new GroupImpl(symbol.getOutputName(), symbol.getOutputDefinition(), null);
+ NamedTable group = new NamedTable(fullGroup, alias, null);
if (symbol.getMetadataID() instanceof TempMetadataID) {
return group;
}
@@ -671,26 +648,26 @@
}
/* Batched Updates */
- IBatchedUpdates translate(BatchedUpdateCommand command) throws MetaMatrixComponentException {
+ BatchedUpdates translate(BatchedUpdateCommand command) throws MetaMatrixComponentException {
List updates = command.getUpdateCommands();
- List translatedUpdates = new ArrayList(updates.size());
+ List<org.teiid.connector.language.Command> translatedUpdates = new ArrayList<org.teiid.connector.language.Command>(updates.size());
for (Iterator i = updates.iterator(); i.hasNext();) {
translatedUpdates.add(translate((Command)i.next()));
}
- return new BatchedUpdatesImpl(translatedUpdates);
+ return new BatchedUpdates(translatedUpdates);
}
- ILimit translate(Limit limit) throws MetaMatrixComponentException {
+ org.teiid.connector.language.Limit translate(Limit limit) throws MetaMatrixComponentException {
if (limit == null) {
return null;
}
int rowOffset = 0;
if (limit.getOffset() != null) {
- ILiteral c1 = (ILiteral)translate(limit.getOffset());
+ Literal c1 = (Literal)translate(limit.getOffset());
rowOffset = ((Integer)c1.getValue()).intValue();
}
- ILiteral c2 = (ILiteral)translate(limit.getRowLimit());
+ Literal c2 = (Literal)translate(limit.getRowLimit());
int rowLimit = ((Integer)c2.getValue()).intValue();
- return new LimitImpl(rowOffset, rowLimit);
+ return new org.teiid.connector.language.Limit(rowOffset, rowLimit);
}
}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,346 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IInsertValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-
-/**
- */
-public class LanguageFactoryImpl implements ILanguageFactory {
-
- /**
- * Public instance, holds no state so can be shared by everyone.
- */
- public static final LanguageFactoryImpl INSTANCE = new LanguageFactoryImpl();
-
-
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createAggregate(java.lang.String, boolean, com.metamatrix.data.language.IExpression, java.lang.Class)
- */
- public IAggregate createAggregate(String name, boolean isDistinct, IExpression expression, Class type) {
- return new AggregateImpl(name, isDistinct, expression, type);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createCompareCriteria(int, com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IExpression)
- */
- public ICompareCriteria createCompareCriteria(
- ICompareCriteria.Operator operator,
- IExpression leftExpression,
- IExpression rightExpression) {
- return new CompareCriteriaImpl(leftExpression, rightExpression, operator);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createCompoundCriteria(int, java.util.List)
- */
- public ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List innerCriteria) {
- return new CompoundCriteriaImpl(innerCriteria, operator);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createDelete(com.metamatrix.data.language.IGroup, com.metamatrix.data.language.ICriteria)
- */
- public IDelete createDelete(IGroup group, ICriteria criteria) {
- return new DeleteImpl(group, criteria);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createElement(java.lang.String, com.metamatrix.data.language.IGroup, com.metamatrix.data.metadata.runtime.MetadataID)
- */
- public IElement createElement(String name, IGroup group, Element metadataReference, Class type) {
- return new ElementImpl(group, name, metadataReference, type);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createExistsCriteria(com.metamatrix.data.language.IQuery)
- */
- public IExistsCriteria createExistsCriteria(IQuery query) {
- return new ExistsCriteriaImpl(query);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createFrom(java.util.List)
- */
- public IFrom createFrom(List items) {
- return new FromImpl(items);
- }
-
- @Override
- public IFunction createFunction(String functionName, IExpression[] args,
- Class<?> type) {
- return new FunctionImpl(functionName, Arrays.asList(args), type);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createFunction(java.lang.String, com.metamatrix.data.language.IExpression[], java.lang.Class)
- */
- @Override
- public IFunction createFunction(String functionName, List<? extends IExpression> args, Class<?> type) {
- return new FunctionImpl(functionName, args, type);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createGroup(java.lang.String, java.lang.String, com.metamatrix.data.metadata.runtime.MetadataID)
- */
- public IGroup createGroup(String context, String definition, Group metadataReference) {
- return new GroupImpl(context, definition, metadataReference);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createGroupBy(java.util.List)
- */
- public IGroupBy createGroupBy(List items) {
- return new GroupByImpl(items);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createInCriteria(com.metamatrix.data.language.IExpression, java.util.List, boolean)
- */
- public IInCriteria createInCriteria(IExpression leftExpression, List rightExpressions, boolean isNegated) {
- return new InCriteriaImpl(leftExpression, rightExpressions, isNegated);
- }
-
- @Override
- public IInsert createInsert(IGroup group, List<IElement> columns,
- IInsertValueSource valueSource) {
- return new InsertImpl(group, columns, valueSource);
- }
-
- @Override
- public IInsertExpressionValueSource createInsertExpressionValueSource(
- List<IExpression> values) {
- return new InsertValueExpressionsImpl(values);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createIsNullCriteria(com.metamatrix.data.language.IExpression, boolean)
- */
- public IIsNullCriteria createIsNullCriteria(IExpression expression, boolean isNegated) {
- return new IsNullCriteriaImpl(expression, isNegated);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createJoin(int, com.metamatrix.data.language.IFromItem, com.metamatrix.data.language.IFromItem, java.util.List)
- */
- public IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List criteria) {
- return new JoinImpl(leftItem, rightItem, joinType, criteria);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createLikeCriteria(com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IExpression, java.lang.Character, boolean)
- */
- public ILikeCriteria createLikeCriteria(
- IExpression leftExpression,
- IExpression rightExpression,
- Character escapeCharacter,
- boolean isNegated) {
- return new LikeCriteriaImpl(leftExpression, rightExpression, escapeCharacter, isNegated);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createLiteral(java.lang.Object, java.lang.Class)
- */
- public ILiteral createLiteral(Object value, Class type) {
- return new LiteralImpl(value, type);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createNotCriteria(com.metamatrix.data.language.ICriteria)
- */
- public INotCriteria createNotCriteria(ICriteria criteria) {
- return new NotCriteriaImpl(criteria);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createOrderBy(java.util.List)
- */
- public IOrderBy createOrderBy(List items) {
- return new OrderByImpl(items);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createOrderByItem(java.lang.String, com.metamatrix.data.language.IElement, boolean)
- */
- public IOrderByItem createOrderByItem(String name, IElement element, boolean direction) {
- return new OrderByItemImpl(name, direction, element);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createParameter(int, int, java.lang.Object, java.lang.Class)
- */
- public IParameter createParameter(int index, IParameter.Direction direction, Object value, Class type, Parameter metadataReference) {
- return new ParameterImpl(index, direction, value, type, metadataReference);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createProcedure(java.lang.String, java.util.List, com.metamatrix.data.metadata.runtime.MetadataID)
- */
- public IProcedure createProcedure(String name, List parameters, Procedure metadataReference) {
- return new ProcedureImpl(name, parameters, metadataReference);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createQuery(com.metamatrix.data.language.ISelect, com.metamatrix.data.language.IFrom, com.metamatrix.data.language.ICriteria, com.metamatrix.data.language.IGroupBy, com.metamatrix.data.language.ICriteria, com.metamatrix.data.language.IOrderBy)
- */
- public IQuery createQuery(
- ISelect select,
- IFrom from,
- ICriteria where,
- IGroupBy groupBy,
- ICriteria having,
- IOrderBy orderBy) {
- return new QueryImpl(select, from, where, groupBy, having, orderBy);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createScalarSubquery(com.metamatrix.data.language.IQuery)
- */
- public IScalarSubquery createScalarSubquery(IQuery query) {
- return new ScalarSubqueryImpl(query);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createSearchedCaseExpression(java.util.List, java.util.List, com.metamatrix.data.language.IExpression, java.lang.Class)
- */
- public ISearchedCaseExpression createSearchedCaseExpression(
- List whenExpressions,
- List thenExpressions,
- IExpression elseExpression,
- Class type) {
- return new SearchedCaseExpressionImpl(whenExpressions, thenExpressions, elseExpression, type);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createSelect(boolean, java.util.List)
- */
- public ISelect createSelect(boolean isDistinct, List selectSymbols) {
- return new SelectImpl(selectSymbols, isDistinct);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createSelectSymbol(java.lang.String, com.metamatrix.data.language.IExpression)
- */
- public ISelectSymbol createSelectSymbol(String name, IExpression expression) {
- return new SelectSymbolImpl(name, expression);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createSubqueryCompareCriteria(com.metamatrix.data.language.IExpression, int, int, com.metamatrix.data.language.IQuery)
- */
- public ISubqueryCompareCriteria createSubqueryCompareCriteria(
- IExpression leftExpression,
- ICompareCriteria.Operator operator,
- ISubqueryCompareCriteria.Quantifier quantifier,
- IQuery subquery) {
- return new SubqueryCompareCriteriaImpl(leftExpression, operator, quantifier, subquery);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createSubqueryInCriteria(com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IQuery, boolean)
- */
- public ISubqueryInCriteria createSubqueryInCriteria(IExpression expression, IQuery subquery, boolean isNegated) {
- return new SubqueryInCriteriaImpl(expression, isNegated, subquery);
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageFactory#createUpdate(com.metamatrix.data.language.IGroup, java.util.List, com.metamatrix.data.language.ICriteria)
- */
- public IUpdate createUpdate(IGroup group, ISetClauseList updates, ICriteria criteria) {
- return new UpdateImpl(group, updates, criteria);
- }
-
- public IInlineView createInlineView(IQueryCommand query, String name) {
- return new InlineViewImpl(query, name);
- }
-
- public ISetQuery createSetOp(ISetQuery.Operation operation, boolean all, IQueryCommand leftQuery, IQueryCommand rightQuery, IOrderBy orderBy, ILimit limit) {
- SetQueryImpl queryImpl = new SetQueryImpl();
- queryImpl.setOperation(operation);
- queryImpl.setAll(all);
- queryImpl.setLeftQuery(leftQuery);
- queryImpl.setRightQuery(rightQuery);
- queryImpl.setOrderBy(orderBy);
- queryImpl.setLimit(limit);
- return queryImpl;
- }
-
- @Override
- public ISetClause createSetClause(IElement symbol, IExpression value) {
- return new SetClauseImpl(symbol, value);
- }
-
- @Override
- public ISetClauseList createSetClauseList(List<ISetClause> clauses) {
- return new SetClauseListImpl(clauses);
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class LikeCriteriaImpl extends BaseLanguageObject implements ILikeCriteria {
-
- private IExpression leftExpression = null;
- private IExpression rightExpression = null;
- private Character escapeCharacter = null;
- private boolean isNegated = false;
-
- public LikeCriteriaImpl(IExpression left, IExpression right, Character escapeCharacter, boolean negated) {
- leftExpression = left;
- rightExpression = right;
- this.escapeCharacter = escapeCharacter;
- this.isNegated = negated;
-
- }
-
- /**
- * @see org.teiid.connector.language.ILikeCriteria#getLeftExpression()
- */
- public IExpression getLeftExpression() {
- return leftExpression;
- }
-
- /**
- * @see org.teiid.connector.language.ILikeCriteria#getRightExpression()
- */
- public IExpression getRightExpression() {
- return rightExpression;
- }
-
- /**
- * @see org.teiid.connector.language.ILikeCriteria#getEscapeCharacter()
- */
- public Character getEscapeCharacter() {
- return this.escapeCharacter;
- }
-
- /**
- * @see org.teiid.connector.language.ILikeCriteria#isNegated()
- */
- public boolean isNegated() {
- return this.isNegated;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ILikeCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
- */
- public void setLeftExpression(IExpression expression) {
- this.leftExpression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.ILikeCriteria#setRightExpression(com.metamatrix.data.language.IExpression)
- */
- public void setRightExpression(IExpression expression) {
- this.rightExpression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.ILikeCriteria#setEscapeCharacter(java.lang.Character)
- */
- public void setEscapeCharacter(Character character) {
- this.escapeCharacter = character;
- }
-
- /*
- * @see com.metamatrix.data.language.ILikeCriteria#setNegated(boolean)
- */
- public void setNegated(boolean negated) {
- this.isNegated = negated;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-/**
- * @since 4.3
- */
-public class LimitImpl extends BaseLanguageObject implements ILimit {
-
- private int rowOffset;
- private int rowLimit;
-
- public LimitImpl(int offset, int rowLimit) {
- this.rowOffset = offset;
- this.rowLimit = rowLimit;
- }
- /**
- * @see org.teiid.connector.language.ILimit#getRowLimit()
- * @since 4.3
- */
- public int getRowLimit() {
- return rowLimit;
- }
-
- /**
- * @see org.teiid.connector.language.ILimit#getRowOffset()
- * @since 4.3
- */
- public int getRowOffset() {
- return rowOffset;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(org.teiid.connector.visitor.framework.LanguageObjectVisitor)
- * @since 4.3
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class LiteralImpl extends BaseLanguageObject implements ILiteral {
-
- private Object value;
- private Class<?> type;
- private boolean bindValue;
- private boolean multiValued;
-
- public LiteralImpl(Object value, Class<?> type) {
- this.value = value;
- this.type = type;
- }
-
- /**
- * @see org.teiid.connector.language.ILiteral#getValue()
- */
- public Object getValue() {
- return this.value;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ILiteral#getType()
- */
- public Class<?> getType() {
- return this.type;
- }
-
- /*
- * @see com.metamatrix.data.language.ILiteral#setValue(java.lang.Object)
- */
- public void setValue(Object value) {
- this.value = value;
- }
-
- /**
- * @see org.teiid.connector.language.ILiteral#isBindValue()
- */
- public boolean isBindValue() {
- return bindValue;
- }
-
- /**
- * @see org.teiid.connector.language.ILiteral#setBindValue(boolean)
- */
- public void setBindValue(boolean bindValue) {
- this.bindValue = bindValue;
- }
-
- @Override
- public boolean isMultiValued() {
- return multiValued;
- }
-
- @Override
- public void setMultiValued(boolean multiValued) {
- this.multiValued = multiValued;
- }
-
- @Override
- public void setType(Class<?> type) {
- this.type = type;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class NotCriteriaImpl extends BaseLanguageObject implements INotCriteria {
-
- private ICriteria criteria = null;
-
- public NotCriteriaImpl(ICriteria criteria) {
- this.criteria = criteria;
- }
- /**
- * @see org.teiid.connector.language.INotCriteria#getCriteria()
- */
- public ICriteria getCriteria() {
- return criteria;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.INotCriteria#setCriteria(com.metamatrix.data.language.ICriteria)
- */
- public void setCriteria(ICriteria criteria) {
- this.criteria = criteria;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class OrderByImpl extends BaseLanguageObject implements IOrderBy {
-
- private List items = null;
-
- public OrderByImpl(List items) {
- this.items = items;
- }
-
- /**
- * @see org.teiid.connector.language.IOrderBy#getItems()
- */
- public List getItems() {
- return items;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IOrderBy#setItems(java.util.List)
- */
- public void setItems(List items) {
- this.items = items;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class OrderByItemImpl extends BaseLanguageObject implements IOrderByItem {
-
- private String name;
- private boolean direction = false;
- private IElement element; // optional, may be null
-
- public OrderByItemImpl(String name, boolean direction, IElement element) {
- this.name = name;
- this.direction = direction;
- this.element = element;
- }
-
- /**
- * @see org.teiid.connector.language.IOrderByItem#getName()
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * @see org.teiid.connector.language.IOrderByItem#getDirection()
- */
- public boolean getDirection() {
- return direction;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IOrderByItem#setName(java.lang.String)
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /*
- * @see com.metamatrix.data.language.IOrderByItem#setDirection(boolean)
- */
- public void setDirection(boolean direction) {
- this.direction = direction;
- }
-
- /*
- * @see com.metamatrix.data.language.IOrderByElementItem#getElement()
- */
- public IElement getElement() {
- return this.element;
- }
-
- /*
- * @see com.metamatrix.data.language.IOrderByElementItem#setElement(com.metamatrix.data.language.IElement)
- */
- public void setElement(IElement element) {
- this.element = element;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class ParameterImpl extends BaseLanguageObject implements IParameter {
-
- private int index;
- private Direction direction;
- private Object value;
- private boolean valueSpecified;
- private Class type;
- private Parameter metadataObject;
-
- public ParameterImpl(int index, Direction direction, Object value, Class type, Parameter metadataObject) {
- setIndex(index);
- setDirection(direction);
- setValue(value);
- setType(type);
- this.metadataObject = metadataObject;
- }
-
- /**
- * @see org.teiid.connector.language.IParameter#getIndex()
- */
- public int getIndex() {
- return this.index;
- }
-
- /**
- * @see org.teiid.connector.language.IParameter#getDirection()
- */
- public Direction getDirection() {
- return this.direction;
- }
-
- /**
- * @see org.teiid.connector.language.IParameter#getType()
- */
- public Class getType() {
- return this.type;
- }
-
- /*
- * @see com.metamatrix.data.language.IParameter#getValue()
- */
- public Object getValue() {
- return this.value;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IParameter#setIndex(int)
- */
- public void setIndex(int index) {
- this.index = index;
- }
-
- /*
- * @see com.metamatrix.data.language.IParameter#setDirection(int)
- */
- public void setDirection(Direction direction) {
- this.direction = direction;
- }
-
- /*
- * @see com.metamatrix.data.language.IParameter#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
- /*
- * @see com.metamatrix.data.language.IParameter#setValue(java.lang.Object)
- */
- public void setValue(Object value) {
- this.value = value;
- if(value != null) {
- setValueSpecified(true);
- }
- }
-
- @Override
- public Parameter getMetadataObject() {
- return this.metadataObject;
- }
-
- public void setMetadataObject(Parameter metadataObject) {
- this.metadataObject = metadataObject;
- }
-
- /**
- * @see org.teiid.connector.language.IParameter#getValueSpecified()
- * @since 4.3.2
- */
- public boolean getValueSpecified() {
- return this.valueSpecified;
- }
-
- /**
- * @see org.teiid.connector.language.IParameter#setValueSpecified(boolean)
- * @since 4.3.2
- */
- public void setValueSpecified(boolean specified) {
- this.valueSpecified = specified;
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class ProcedureImpl extends BaseLanguageObject implements IProcedure {
-
- private String name;
- private List<IParameter> parameters;
- private Procedure metadataObject;
-
- public ProcedureImpl(String name, List<IParameter> parameters, Procedure metadataObject) {
- this.name = name;
- this.parameters = parameters;
- this.metadataObject = metadataObject;
- }
-
- /**
- * @see com.metamatrix.data.language.IExecute#getProcedureName()
- */
- public String getProcedureName() {
- return this.name;
- }
-
- /**
- * @see com.metamatrix.data.language.IExecute#getVariableValues()
- */
- public List<IParameter> getParameters() {
- return parameters;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IExecute#setProcedureName(java.lang.String)
- */
- public void setProcedureName(String name) {
- this.name = name;
- }
-
- /*
- * @see com.metamatrix.data.language.IExecute#setParameters(java.util.List)
- */
- public void setParameters(List<IParameter> parameters) {
- this.parameters = parameters;
- }
-
- @Override
- public Procedure getMetadataObject() {
- return this.metadataObject;
- }
-
- public void setMetadataObject(Procedure metadataID) {
- this.metadataObject = metadataID;
- }
-
- public boolean equals(Object obj) {
- if(obj == this) {
- return true;
- }
-
- if(obj == null) {
- return false;
- }
-
- IProcedure proc = (IProcedure) obj;
- return getProcedureName().equalsIgnoreCase(proc.getProcedureName());
- }
-
- public Class<?>[] getResultSetColumnTypes() throws ConnectorException {
- for (IParameter param : parameters) {
- if(param.getDirection() == Direction.RESULT_SET){
- List<Element> columnMetadata = param.getMetadataObject().getChildren();
-
- int size = columnMetadata.size();
- Class<?>[] coulmnDTs = new Class[size];
- for(int i =0; i<size; i++ ){
- coulmnDTs[i] = columnMetadata.get(i).getJavaType();
- }
- return coulmnDTs;
- }
- }
- return new Class[0];
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.ISelectSymbol;
-
-
-public abstract class QueryCommandImpl extends BaseLanguageObject implements org.teiid.connector.language.IQueryCommand {
-
- private IOrderBy orderBy = null;
- private ILimit limit = null;
-
- /**
- * @see org.teiid.connector.language.IQuery#getOrderBy()
- */
- public IOrderBy getOrderBy() {
- return orderBy;
- }
-
- /**
- * @see org.teiid.connector.language.IQuery#getLimit()
- */
- public ILimit getLimit() {
- return limit;
- }
-
- public String[] getColumnNames() {
- List selectSymbols = getProjectedQuery().getSelect().getSelectSymbols();
- String[] columnNames = new String[selectSymbols.size()];
- int symbolIndex = 0;
- for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
- columnNames[symbolIndex] = ((ISelectSymbol)i.next()).getOutputName();
- }
- return columnNames;
- }
-
- public Class[] getColumnTypes() {
- List selectSymbols = getProjectedQuery().getSelect().getSelectSymbols();
- Class[] columnTypes = new Class[selectSymbols.size()];
- int symbolIndex = 0;
- for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
- ISelectSymbol symbol = (ISelectSymbol)i.next();
- if (symbol.getExpression() == null) {
- columnTypes[symbolIndex] = null;
- } else {
- columnTypes[symbolIndex] = symbol.getExpression().getType();
- }
- }
- return columnTypes;
- }
-
- /*
- * @see com.metamatrix.data.language.IQuery#setOrderBy(com.metamatrix.data.language.IOrderBy)
- */
- public void setOrderBy(IOrderBy orderBy) {
- this.orderBy = orderBy;
- }
-
- /*
- * @see com.metamatrix.data.language.IQuery#setOrderBy(com.metamatrix.data.language.IOrderBy)
- */
- public void setLimit(ILimit limit) {
- this.limit = limit;
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class QueryImpl extends QueryCommandImpl implements IQuery {
-
- private ISelect select = null;
- private IFrom from = null;
- private ICriteria where = null;
- private IGroupBy groupBy = null;
- private ICriteria having = null;
-
- public QueryImpl(ISelect select, IFrom from, ICriteria where,
- IGroupBy groupBy, ICriteria having, IOrderBy orderBy) {
- this.select = select;
- this.from = from;
- this.where = where;
- this.groupBy = groupBy;
- this.having = having;
- this.setOrderBy(orderBy);
- }
- /**
- * @see org.teiid.connector.language.IQuery#getSelect()
- */
- public ISelect getSelect() {
- return select;
- }
-
- /**
- * @see org.teiid.connector.language.IQuery#getFrom()
- */
- public IFrom getFrom() {
- return from;
- }
-
- /**
- * @see org.teiid.connector.language.IQuery#getWhere()
- */
- public ICriteria getWhere() {
- return where;
- }
-
- /**
- * @see org.teiid.connector.language.IQuery#getGroupBy()
- */
- public IGroupBy getGroupBy() {
- return groupBy;
- }
-
- /**
- * @see org.teiid.connector.language.IQuery#getHaving()
- */
- public ICriteria getHaving() {
- return having;
- }
-
- public String[] getColumnNames() {
- List selectSymbols = getSelect().getSelectSymbols();
- String[] columnNames = new String[selectSymbols.size()];
- int symbolIndex = 0;
- for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
- columnNames[symbolIndex] = ((ISelectSymbol)i.next()).getOutputName();
- }
- return columnNames;
- }
-
- public Class[] getColumnTypes() {
- List selectSymbols = getSelect().getSelectSymbols();
- Class[] columnTypes = new Class[selectSymbols.size()];
- int symbolIndex = 0;
- for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
- ISelectSymbol symbol = (ISelectSymbol)i.next();
- if (symbol.getExpression() == null) {
- columnTypes[symbolIndex] = null;
- } else {
- columnTypes[symbolIndex] = symbol.getExpression().getType();
- }
- }
- return columnTypes;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.IQuery#setSelect(com.metamatrix.data.language.ISelect)
- */
- public void setSelect(ISelect select) {
- this.select = select;
- }
- /*
- * @see com.metamatrix.data.language.IQuery#setFrom(com.metamatrix.data.language.IFrom)
- */
- public void setFrom(IFrom from) {
- this.from = from;
- }
- /*
- * @see com.metamatrix.data.language.IQuery#setWhere(com.metamatrix.data.language.ICriteria)
- */
- public void setWhere(ICriteria criteria) {
- this.where = criteria;
- }
- /*
- * @see com.metamatrix.data.language.IQuery#setGroupBy(com.metamatrix.data.language.IGroupBy)
- */
- public void setGroupBy(IGroupBy groupBy) {
- this.groupBy = groupBy;
- }
- /*
- * @see com.metamatrix.data.language.IQuery#setHaving(com.metamatrix.data.language.ICriteria)
- */
- public void setHaving(ICriteria criteria) {
- this.having = criteria;
- }
-
- /**
- * @see org.teiid.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
- */
- public IQuery getProjectedQuery() {
- return this;
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class ScalarSubqueryImpl extends BaseLanguageObject implements IScalarSubquery {
-
- private IQueryCommand query;
- private Class type;
-
- /**
- *
- */
- public ScalarSubqueryImpl(IQueryCommand query) {
- setQuery(query);
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#getType()
- */
- public Class getType() {
- return this.type;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
- */
- public IQueryCommand getQuery() {
- return this.query;
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
- */
- public void setQuery(IQueryCommand query) {
- this.query = query;
- this.type = query.getColumnTypes()[0];
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SearchedCaseExpressionImpl extends BaseLanguageObject implements ISearchedCaseExpression {
-
- private List whenExpressions;
- private List thenExpressions;
- private IExpression elseExpression;
- private Class type;
-
- public SearchedCaseExpressionImpl(List whens, List thens, IExpression elseExpression, Class type) {
- this.whenExpressions = whens;
- this.thenExpressions = thens;
- this.elseExpression = elseExpression;
- this.type = type;
- }
- /**
- * @see org.teiid.connector.language.ISearchedCaseExpression#getElseExpression()
- */
- public IExpression getElseExpression() {
- return elseExpression;
- }
-
- /**
- * @see org.teiid.connector.language.ISearchedCaseExpression#getThenExpression(int)
- */
- public IExpression getThenExpression(int index) {
- return (IExpression)thenExpressions.get(index);
- }
-
- /**
- * @see org.teiid.connector.language.ISearchedCaseExpression#getWhenCount()
- */
- public int getWhenCount() {
- return whenExpressions.size();
- }
-
- /**
- * @see org.teiid.connector.language.ISearchedCaseExpression#getWhenCriteria(int)
- */
- public ICriteria getWhenCriteria(int index) {
- return (ICriteria)whenExpressions.get(index);
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.ISearchedCaseExpression#setWhenCriteria(int, com.metamatrix.data.language.ICriteria)
- */
- public void setWhenCriteria(int index, ICriteria criteria) {
- this.whenExpressions.set(index, criteria);
- }
- /*
- * @see com.metamatrix.data.language.ISearchedCaseExpression#setThenExpression(int, com.metamatrix.data.language.IExpression)
- */
- public void setThenExpression(int index, IExpression expression) {
- this.thenExpressions.set(index, expression);
- }
- /*
- * @see com.metamatrix.data.language.ISearchedCaseExpression#setElseExpression(com.metamatrix.data.language.IExpression)
- */
- public void setElseExpression(IExpression expression) {
- this.elseExpression = expression;
- }
- /*
- * @see com.metamatrix.data.language.IExpression#getType()
- */
- public Class getType() {
- return this.type;
- }
- /*
- * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SelectImpl extends BaseLanguageObject implements ISelect {
-
- private List selectSymbols = null;
- private boolean isDistinct = false;
-
- public SelectImpl(List symbols, boolean distinct) {
- selectSymbols = symbols;
- this.isDistinct = distinct;
- }
-
- /**
- * @see org.teiid.connector.language.ISelect#getSelectSymbols()
- */
- public List getSelectSymbols() {
- return selectSymbols;
- }
-
- /**
- * @see org.teiid.connector.language.ISelect#isDistinct()
- */
- public boolean isDistinct() {
- return this.isDistinct;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ISelect#setSelectSymbols(java.util.List)
- */
- public void setSelectSymbols(List symbols) {
- this.selectSymbols = symbols;
- }
-
- /*
- * @see com.metamatrix.data.language.ISelect#setDistinct(boolean)
- */
- public void setDistinct(boolean distinct) {
- this.isDistinct = distinct;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SelectSymbolImpl extends BaseLanguageObject implements ISelectSymbol {
-
- private boolean hasAlias;
- private String name;
- private IExpression expression = null;
-
- public SelectSymbolImpl(String name, IExpression expression) {
- this.name = name;
- this.expression = expression;
- }
- /**
- * @see org.teiid.connector.language.ISelectSymbol#hasAlias()
- */
- public boolean hasAlias() {
- return hasAlias;
- }
-
- public void setAlias(boolean alias){
- this.hasAlias = alias;
- }
-
- /**
- * @see org.teiid.connector.language.ISelectSymbol#getOutputName()
- */
- public String getOutputName() {
- return name;
- }
-
- /**
- * @see org.teiid.connector.language.ISelectSymbol#getExpression()
- */
- public IExpression getExpression() {
- return expression;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ISelectSymbol#setOutputName(java.lang.String)
- */
- public void setOutputName(String name) {
- this.name = name;
- }
-
- /*
- * @see com.metamatrix.data.language.ISelectSymbol#setExpression(com.metamatrix.data.language.IExpression)
- */
- public void setExpression(IExpression expression) {
- this.expression = expression;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SetClauseImpl extends BaseLanguageObject implements ISetClause {
-
- private IElement symbol;
- private IExpression value;
-
- public SetClauseImpl(IElement symbol, IExpression value) {
- this.symbol = symbol;
- this.value = value;
- }
-
- @Override
- public IElement getSymbol() {
- return symbol;
- }
-
- @Override
- public IExpression getValue() {
- return value;
- }
-
- @Override
- public void setSymbol(IElement symbol) {
- this.symbol = symbol;
- }
-
- @Override
- public void setValue(IExpression value) {
- this.value = value;
- }
-
- @Override
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SetClauseListImpl extends BaseLanguageObject implements ISetClauseList {
-
- private List<ISetClause> clauses;
-
- public SetClauseListImpl(List<ISetClause> clauses) {
- if (clauses == null) {
- clauses = new ArrayList<ISetClause>();
- }
- this.clauses = clauses;
- }
-
- @Override
- public List<ISetClause> getClauses() {
- return clauses;
- }
-
- @Override
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SetQueryImpl extends QueryCommandImpl implements org.teiid.connector.language.ISetQuery {
-
- private boolean all;
- private IQueryCommand leftQuery;
- private IQueryCommand rightQuery;
- private Operation operation;
-
- /**
- * @see org.teiid.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
- */
- public IQuery getProjectedQuery() {
- if (leftQuery instanceof IQuery) {
- return (IQuery)leftQuery;
- }
- return leftQuery.getProjectedQuery();
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#getLeftQuery()
- */
- public IQueryCommand getLeftQuery() {
- return leftQuery;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#getOperation()
- */
- public Operation getOperation() {
- return operation;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#getRightQuery()
- */
- public IQueryCommand getRightQuery() {
- return rightQuery;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#isAll()
- */
- public boolean isAll() {
- return all;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#setAll(boolean)
- */
- public void setAll(boolean all) {
- this.all = all;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#setLeftQuery(org.teiid.connector.language.IQueryCommand)
- */
- public void setLeftQuery(IQueryCommand leftQuery) {
- this.leftQuery = leftQuery;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#setOperation(org.teiid.connector.language.ISetQuery.Operation)
- */
- public void setOperation(Operation operation) {
- this.operation = operation;
- }
-
- /**
- * @see org.teiid.connector.language.ISetQuery#setRightQuery(org.teiid.connector.language.IQueryCommand)
- */
- public void setRightQuery(IQueryCommand rightQuery) {
- this.rightQuery = rightQuery;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.*;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class SubqueryCompareCriteriaImpl extends BaseLanguageObject implements ISubqueryCompareCriteria {
-
- private IExpression leftExpr;
- private Operator operator;
- private Quantifier quantifier;
- private IQueryCommand query;
-
- /**
- *
- */
- public SubqueryCompareCriteriaImpl(IExpression leftExpr, Operator operator, Quantifier quantifier, IQueryCommand query) {
- this.leftExpr = leftExpr;
- this.operator = operator;
- this.quantifier = quantifier;
- this.query = query;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryCompareCriteria#getLeftExpression()
- */
- public IExpression getLeftExpression() {
- return this.leftExpr;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryCompareCriteria#getOperator()
- */
- public Operator getOperator() {
- return this.operator;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryCompareCriteria#getQuantifier()
- */
- public Quantifier getQuantifier() {
- return this.quantifier;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
- */
- public IQueryCommand getQuery() {
- return this.query;
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryCompareCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
- */
- public void setLeftExpression(IExpression expression) {
- this.leftExpr = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryCompareCriteria#setOperator(int)
- */
- public void setOperator(Operator operator) {
- this.operator = operator;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryCompareCriteria#setQuantifier(int)
- */
- public void setQuantifier(Quantifier quantifier) {
- this.quantifier = quantifier;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
- */
- public void setQuery(IQueryCommand query) {
- this.query = query;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.*;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class SubqueryInCriteriaImpl extends BaseLanguageObject implements ISubqueryInCriteria {
-
- private IExpression leftExpr;
- private boolean isNegated = false;
- private IQueryCommand rightQuery;
-
- /**
- *
- */
- public SubqueryInCriteriaImpl(IExpression leftExpr, boolean isNegated, IQueryCommand rightQuery) {
- this.leftExpr = leftExpr;
- this.isNegated = isNegated;
- this.rightQuery = rightQuery;
- }
-
- /*
- * @see com.metamatrix.data.language.IBaseInCriteria#getLeftExpression()
- */
- public IExpression getLeftExpression() {
- return this.leftExpr;
- }
-
- /*
- * @see com.metamatrix.data.language.IBaseInCriteria#isNegated()
- */
- public boolean isNegated() {
- return this.isNegated;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
- */
- public IQueryCommand getQuery() {
- return this.rightQuery;
- }
-
- /*
- * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IBaseInCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
- */
- public void setLeftExpression(IExpression expression) {
- this.leftExpr = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.IBaseInCriteria#setNegated(boolean)
- */
- public void setNegated(boolean negated) {
- this.isNegated = negated;
- }
-
- /*
- * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
- */
- public void setQuery(IQueryCommand query) {
- this.rightQuery = query;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class UpdateImpl extends BaseLanguageObject implements IUpdate {
-
- private IGroup group;
- private ISetClauseList changes;
- private ICriteria criteria;
-
- public UpdateImpl(IGroup group, ISetClauseList changes, ICriteria criteria) {
- this.group = group;
- this.changes = changes;
- this.criteria = criteria;
- }
-
- /**
- * @see org.teiid.connector.language.IUpdate#getGroup()
- */
- public IGroup getGroup() {
- return group;
- }
-
- /**
- * @see org.teiid.connector.language.IUpdate#getChanges()
- */
- public ISetClauseList getChanges() {
- return changes;
- }
-
- /**
- * @see org.teiid.connector.language.IUpdate#getCriteria()
- */
- public ICriteria getCriteria() {
- return criteria;
- }
-
- /**
- * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /*
- * @see com.metamatrix.data.language.IUpdate#setGroup(com.metamatrix.data.language.IGroup)
- */
- public void setGroup(IGroup group) {
- this.group = group;
- }
-
- public void setChanges(ISetClauseList changes) {
- this.changes = changes;
- }
-
- /*
- * @see com.metamatrix.data.language.IUpdate#setCriteria(com.metamatrix.data.language.ICriteria)
- */
- public void setCriteria(ICriteria criteria) {
- this.criteria = criteria;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,159 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.SupportConstants;
-
-/**
- */
-public class ElementImpl extends TypeModelImpl implements Element {
-
- ElementImpl(Object actualID, RuntimeMetadataImpl factory){
- super(actualID, factory);
- }
-
- public Class getJavaType() throws ConnectorException {
- try {
- String elementType = getMetadata().getElementType(getActualID());
- return DataTypeManager.getDataTypeClass(elementType);
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public int getPosition() throws ConnectorException {
- try {
- return getMetadata().getPosition(getActualID()) - 1;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public Object getMaximumValue() throws ConnectorException {
- try {
- return getMetadata().getMaximumValue(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public Object getMinimumValue() throws ConnectorException {
- try {
- return getMetadata().getMinimumValue(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public int getSearchability() throws ConnectorException {
- try {
- boolean comparable = getMetadata().elementSupports(getActualID(), SupportConstants.Element.SEARCHABLE_COMPARE);
- boolean likable = getMetadata().elementSupports(getActualID(), SupportConstants.Element.SEARCHABLE_LIKE);
- if(comparable) {
- if(likable) {
- return Element.SEARCHABLE;
- }
- return Element.SEARCHABLE_COMPARE;
- }
- if(likable) {
- return Element.SEARCHABLE_LIKE;
- }
- return Element.NOT_SEARCHABLE;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public boolean isAutoIncremented() throws ConnectorException {
- try {
- return getMetadata().elementSupports(getActualID(), SupportConstants.Element.AUTO_INCREMENT);
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public boolean isCaseSensitive() throws ConnectorException {
- try {
- return getMetadata().elementSupports(getActualID(), SupportConstants.Element.CASE_SENSITIVE);
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public String getNativeType() throws ConnectorException {
- try {
- return getMetadata().getNativeType(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- @Override
- public String getFormat() throws ConnectorException {
- try {
- return getMetadata().getFormat(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- @Override
- public Group getParent() throws ConnectorException {
- Object groupId;
- try {
- groupId = this.getMetadata().getGroupIDForElementID(getActualID());
- } catch (QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- return new GroupImpl(groupId, getFactory());
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-
-/**
- */
-public class GroupImpl extends MetadataObjectImpl implements Group {
-
- GroupImpl(Object actualID, RuntimeMetadataImpl factory){
- super(actualID, factory);
- }
-
- @Override
- public List<Element> getChildren() throws ConnectorException {
- try {
- List elementIds = getMetadata().getElementIDsInGroupID(getActualID());
- List<Element> result = new ArrayList<Element>(elementIds.size());
- for (Object elementId : elementIds) {
- result.add(new ElementImpl(elementId, getFactory()));
- }
- return result;
- } catch (QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,116 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.MetadataObject;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-/**
- */
-public abstract class MetadataObjectImpl implements MetadataObject {
- private Object actualID;
- private RuntimeMetadataImpl factory;
- private String fullName;
-
- MetadataObjectImpl(Object actualID, RuntimeMetadataImpl factory){
- this.actualID = actualID;
- this.factory = factory;
- try {
- this.fullName = getMetadata().getFullName(actualID);
- } catch (QueryMetadataException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- public Object getActualID() {
- return actualID;
- }
-
- QueryMetadataInterface getMetadata() {
- return factory.getMetadata();
- }
-
- RuntimeMetadataImpl getFactory() {
- return factory;
- }
-
- public String getNameInSource() throws ConnectorException {
- try {
- return getMetadata().getNameInSource(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public Properties getProperties() throws ConnectorException {
- try {
- return getMetadata().getExtensionProperties(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public boolean equals(Object obj){
- if (this == obj) {
- return true;
- }
-
- if (this.getClass().isInstance(obj)) {
- MetadataObjectImpl that = (MetadataObjectImpl)obj;
- return this.actualID.equals(that.actualID);
- }
-
- return false;
- }
-
- public int hashCode(){
- return actualID.hashCode();
- }
-
- @Override
- public String getName() {
- int index = fullName.lastIndexOf("."); //$NON-NLS-1$
- return fullName.substring(index + 1);
- }
-
- @Override
- public String getFullName() {
- return fullName;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,132 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.sql.lang.SPParameter;
-
-/**
- */
-public class ParameterImpl extends TypeModelImpl implements Parameter {
-
- private SPParameter param;
- private Procedure parent;
-
- /**
- * @param metadataID
- */
- ParameterImpl(RuntimeMetadataImpl factory, SPParameter param, Procedure parent) {
- super(param.getMetadataID(), factory);
- this.parent = parent;
- this.param = param;
- }
-
- private SPParameter getParameterInfo() throws ConnectorException {
- return param;
- }
-
- /*
- * @see com.metamatrix.data.metadata.runtime.Parameter#getIndex()
- */
- public int getIndex() throws ConnectorException {
- SPParameter paramInfo = getParameterInfo();
- return paramInfo.getIndex();
- }
-
- /*
- * @see com.metamatrix.data.metadata.runtime.Parameter#getDirection()
- */
- public int getDirection() throws ConnectorException {
- SPParameter paramInfo = getParameterInfo();
- switch(paramInfo.getParameterType()) {
- case ParameterInfo.IN: return Parameter.IN;
- case ParameterInfo.INOUT: return Parameter.INOUT;
- case ParameterInfo.OUT: return Parameter.OUT;
- case ParameterInfo.RESULT_SET: return Parameter.RESULT_SET;
- case ParameterInfo.RETURN_VALUE: return Parameter.RETURN;
- default:
- throw new ConnectorException(DQPPlugin.Util.getString("ParameterImpl.Invalid_direction", paramInfo.getParameterType())); //$NON-NLS-1$
- }
- }
-
- /*
- * @see com.metamatrix.data.metadata.runtime.Parameter#getJavaType()
- */
- public Class getJavaType() throws ConnectorException {
- SPParameter paramInfo = getParameterInfo();
- return paramInfo.getClassType();
- }
-
- /**
- * @see org.teiid.connector.metadata.runtime.TypeModel#getNullability()
- * @since 4.3
- */
- public int getNullability() throws ConnectorException {
- try {
- boolean allowsNull = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL);
- boolean nullUnknown = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL_UNKNOWN);
- if(nullUnknown) {
- return Element.NULLABLE_UNKNOWN;
- }
- if(allowsNull) {
- return Element.NULLABLE;
- }
- return Element.NOT_NULLABLE;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- @Override
- public List<Element> getChildren() throws ConnectorException {
- if (param.getParameterType() == SPParameter.RESULT_SET) {
- List<Element> result = new ArrayList<Element>(param.getResultSetIDs().size());
- for (Object elementId : param.getResultSetIDs()) {
- result.add(new ElementImpl(elementId, getFactory()));
- }
- return result;
- }
- return Collections.emptyList();
- }
-
- @Override
- public Procedure getParent() throws ConnectorException {
- return parent;
- }
-
-}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.sql.lang.SPParameter;
-
-/**
- */
-public class ProcedureImpl extends MetadataObjectImpl implements Procedure {
-
- private StoredProcedureInfo procInfo;
-
- ProcedureImpl(RuntimeMetadataImpl factory, StoredProcedureInfo procInfo){
- super(procInfo.getProcedureID(), factory);
- this.procInfo = procInfo;
- }
-
- @Override
- public List<Parameter> getChildren() {
- List<Parameter> result = new ArrayList<Parameter>(procInfo.getParameters().size());
- for (SPParameter param : procInfo.getParameters()) {
- result.add(new ParameterImpl(getFactory(), param, this));
- }
- return result;
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -45,10 +45,10 @@
}
@Override
- public Element getElement(String fullName) throws ConnectorException {
+ public Column getElement(String fullName) throws ConnectorException {
try {
- Object elementId = metadata.getElementID(fullName);
- return new ElementImpl(elementId, this);
+ Object metadataId = metadata.getElementID(fullName);
+ return getElement(metadataId);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
} catch (MetaMatrixComponentException e) {
@@ -56,12 +56,15 @@
}
}
- public ElementImpl getElement(Object elementId) {
- return new ElementImpl(elementId, this);
+ public Column getElement(Object elementId) {
+ if (elementId instanceof Column) {
+ return (Column)elementId;
+ }
+ return null;
}
@Override
- public Group getGroup(String fullName) throws ConnectorException {
+ public Table getGroup(String fullName) throws ConnectorException {
try {
Object groupId = metadata.getGroupID(fullName);
return getGroup(groupId);
@@ -72,9 +75,9 @@
}
}
- public GroupImpl getGroup(Object groupId) throws QueryMetadataException, MetaMatrixComponentException {
- if (!metadata.isVirtualGroup(groupId)) {
- return new GroupImpl(groupId, this);
+ public Table getGroup(Object groupId) throws QueryMetadataException, MetaMatrixComponentException {
+ if (!metadata.isVirtualGroup(groupId) && groupId instanceof Table) {
+ return (Table)groupId;
}
return null;
}
@@ -92,11 +95,17 @@
}
public Procedure getProcedure(StoredProcedureInfo sp) {
- return new ProcedureImpl(this, sp);
+ if (sp.getProcedureID() instanceof Procedure) {
+ return (Procedure)sp.getProcedureID();
+ }
+ return null;
}
- public Parameter getParameter(SPParameter param, Procedure parent) {
- return new ParameterImpl(this, param, parent);
+ public ProcedureParameter getParameter(SPParameter param) {
+ if (param.getMetadataID() instanceof ProcedureParameter) {
+ return (ProcedureParameter)param.getMetadataID();
+ }
+ return null;
}
public byte[] getBinaryVDBResource(String resourcePath) throws ConnectorException {
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.TypeModel;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.SupportConstants;
-
-
-/**
- * @since 4.3
- */
-public abstract class TypeModelImpl extends MetadataObjectImpl implements
- TypeModel {
-
- /**
- * @since 4.3
- */
- public TypeModelImpl(Object actualID, RuntimeMetadataImpl factory) {
- super(actualID, factory);
- }
-
- public int getNullability() throws ConnectorException {
- try {
- boolean allowsNull = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL);
- boolean nullUnknown = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL_UNKNOWN);
- if(nullUnknown) {
- return Element.NULLABLE_UNKNOWN;
- }
- if(allowsNull) {
- return Element.NULLABLE;
- }
- return Element.NOT_NULLABLE;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public Object getDefaultValue() throws ConnectorException {
- try {
- return getMetadata().getDefaultValue(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public int getLength() throws ConnectorException {
- try {
- return getMetadata().getElementLength(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public int getPrecision() throws ConnectorException {
- try {
- return getMetadata().getPrecision(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public int getScale() throws ConnectorException {
- try {
- return getMetadata().getScale(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public String getModeledType() throws ConnectorException {
- try {
- return getMetadata().getModeledType(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public String getModeledBaseType() throws ConnectorException {
- try {
- return getMetadata().getModeledBaseType(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
- public String getModeledPrimitiveType() throws ConnectorException {
- try {
- return getMetadata().getModeledPrimitiveType(getActualID());
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
-
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,6 +22,10 @@
package org.teiid.dqp.internal.process;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkListener;
+
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.util.LogConstants;
@@ -30,20 +34,23 @@
* Represents a task that performs work that may take more than one processing pass to complete.
* During processing the WorkItem may receive events asynchronously through the moreWork method.
*/
-public abstract class AbstractWorkItem implements Runnable {
+public abstract class AbstractWorkItem implements Work, WorkListener {
enum ThreadState {
MORE_WORK, WORKING, IDLE, DONE
}
private ThreadState threadState = ThreadState.MORE_WORK;
+ private volatile boolean release = false;
public void run() {
try {
+ assosiateSecurityContext();
startProcessing();
process();
} finally {
endProcessing();
+ clearSecurityContext();
}
}
@@ -125,5 +132,34 @@
protected abstract boolean isDoneProcessing();
+ protected abstract boolean assosiateSecurityContext();
+
+ protected abstract void clearSecurityContext();
+
public abstract String toString();
+
+ @Override
+ public void release() {
+ this.release = true;
+ }
+
+ public boolean shouldAbortProcessing() {
+ return this.release;
+ }
+
+ @Override
+ public void workAccepted(WorkEvent arg0) {
+ }
+
+ @Override
+ public void workCompleted(WorkEvent arg0) {
+ }
+
+ @Override
+ public void workRejected(WorkEvent event) {
+ }
+
+ @Override
+ public void workStarted(WorkEvent arg0) {
+ }
}
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,25 @@
+package org.teiid.dqp.internal.process;
+
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+
+public class AsyncRequestWorkItem extends RequestWorkItem {
+
+ public AsyncRequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg,
+ Request request, ResultsReceiver<ResultsMessage> receiver,
+ RequestID requestID, DQPWorkContext workContext) {
+ super(dqpCore, requestMsg, request, receiver, requestID, workContext);
+ }
+
+
+ @Override
+ protected void resumeProcessing() {
+ dqpCore.addWork(this);
+ }
+
+ @Override
+ protected void pauseProcessing() {
+ }
+}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- */
-public class CachedFinder implements CapabilitiesFinder {
-
- private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
-
- private DataService dataService;
- private RequestMessage requestMessage;
- private DQPWorkContext workContext;
-
- private Map<String, SourceCapabilities> userCache = new HashMap<String, SourceCapabilities>();
-
- /**
- * Construct a CacheFinder that wraps another finder
- * @param internalFinder Finder to wrap
- */
- public CachedFinder(DataService dataService, RequestMessage requestMessage, DQPWorkContext workContext) {
- this.dataService = dataService;
- this.requestMessage = requestMessage;
- this.workContext = workContext;
- userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
- }
-
- /**
- * Find capabilities used the cache if possible, otherwise do the lookup.
- */
- public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
- SourceCapabilities caps = userCache.get(modelName);
- if(caps != null) {
- return caps;
- }
- caps = dataService.getCapabilities(requestMessage, workContext, modelName);
- userCache.put(modelName, caps);
- return caps;
- }
-
-}
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.process;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+
+/**
+ */
+public class CachedFinder implements CapabilitiesFinder {
+
+ private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
+
+ private ConnectorManagerRepository connectorRepo;
+ private VDBMetaData vdb;
+
+ private Map<String, SourceCapabilities> userCache = new HashMap<String, SourceCapabilities>();
+
+ /**
+ * Construct a CacheFinder that wraps another finder
+ * @param internalFinder Finder to wrap
+ */
+ public CachedFinder(ConnectorManagerRepository repo, VDBMetaData vdb) {
+ this.connectorRepo = repo;
+ this.vdb = vdb;
+ userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
+ }
+
+ /**
+ * Find capabilities used the cache if possible, otherwise do the lookup.
+ */
+ public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
+ SourceCapabilities caps = userCache.get(modelName);
+ if(caps != null) {
+ return caps;
+ }
+ ConnectorException exception = null;
+ ModelMetaData model = vdb.getModel(modelName);
+ for (String sourceName:model.getSourceNames()) {
+ try {
+ ConnectorManager mgr = this.connectorRepo.getConnectorManager(model.getSourceJndiName(sourceName));
+ caps = mgr.getCapabilities();
+ break;
+ } catch(ConnectorException e) {
+ if (exception == null) {
+ exception = e;
+ }
+ }
+ }
+
+ if (exception != null) {
+ throw new MetaMatrixComponentException(exception);
+ }
+
+ userCache.put(modelName, caps);
+ return caps;
+ }
+
+}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -250,7 +250,7 @@
private int hashCode;
- public CacheKey(String codeTable, String returnElement, String keyElement, String vdbName, String vdbVersion) {
+ public CacheKey(String codeTable, String returnElement, String keyElement, String vdbName, int vdbVersion) {
this.codeTable = codeTable;
this.returnElement = returnElement;
this.keyElement = keyElement;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,36 @@
+/*
+ * 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.dqp.internal.process;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+
+public interface ContainerServiceProvider {
+
+ XATerminator getXATerminator();
+
+ WorkManager getWorkManager();
+
+ DQPConfiguration getDQPConfiguration();
+
+}
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,165 @@
+/*
+ * 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.dqp.internal.process;
+
+import com.metamatrix.dqp.message.RequestMessage;
+
+public class DQPConfiguration{
+
+ //Constants
+ static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
+ static final int DEFAULT_MAX_CODE_TABLES = 200;
+ static final int DEFAULT_MAX_CODE_RECORDS = 200000;
+ static final int DEFAULT_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
+ static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
+ static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
+ static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
+ static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
+
+
+ private String processName = "localhost";
+ private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
+ private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
+ private boolean processDebugAllowed;
+ private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
+ private int lobChunkSizeInKB = 100;
+ private int preparedPlanCacheMaxCount = SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL;
+ private int codeTablesMaxCount = DEFAULT_MAX_CODE_TABLES;
+ private int codeTablesMaxRowsPerTable = DEFAULT_MAX_CODE_TABLE_RECORDS;
+ private int codeTablesMaxRows = DEFAULT_MAX_CODE_RECORDS;
+ private String bindAddress = "localhost";
+ private int portNumber = 31000;
+ private boolean resultSetCacheEnabled = false;
+ private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
+
+ public String getProcessName() {
+ return processName;
+ }
+
+ public void setProcessName(String processName) {
+ this.processName = processName;
+ }
+
+ public int getMaxThreads() {
+ return maxThreads;
+ }
+
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
+ }
+
+ public int getTimeSliceInMilli() {
+ return timeSliceInMilli;
+ }
+
+ public void setTimeSliceInMilli(int timeSliceInMilli) {
+ this.timeSliceInMilli = timeSliceInMilli;
+ }
+
+ public boolean isProcessDebugAllowed() {
+ return processDebugAllowed;
+ }
+
+ public void setProcessDebugAllowed(boolean processDebugAllowed) {
+ this.processDebugAllowed = processDebugAllowed;
+ }
+
+ public int getMaxRowsFetchSize() {
+ return maxRowsFetchSize;
+ }
+
+ public void setMaxRowsFetchSize(int maxRowsFetchSize) {
+ this.maxRowsFetchSize = maxRowsFetchSize;
+ }
+
+ public int getLobChunkSizeInKB() {
+ return lobChunkSizeInKB;
+ }
+
+ public void setLobChunkSizeInKB(int lobChunkSizeInKB) {
+ this.lobChunkSizeInKB = lobChunkSizeInKB;
+ }
+
+ public int getPreparedPlanCacheMaxCount() {
+ return preparedPlanCacheMaxCount;
+ }
+
+ public void setPreparedPlanCacheMaxCount(int preparedPlanCacheMaxCount) {
+ this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
+ }
+
+ public int getCodeTablesMaxCount() {
+ return codeTablesMaxCount;
+ }
+
+ public void setCodeTablesMaxCount(int codeTablesMaxCount) {
+ this.codeTablesMaxCount = codeTablesMaxCount;
+ }
+
+ public int getCodeTablesMaxRowsPerTable() {
+ return codeTablesMaxRowsPerTable;
+ }
+
+ public void setCodeTablesMaxRowsPerTable(int codeTablesMaxRowsPerTable) {
+ this.codeTablesMaxRowsPerTable = codeTablesMaxRowsPerTable;
+ }
+
+ public int getCodeTablesMaxRows() {
+ return codeTablesMaxRows;
+ }
+
+ public void setCodeTablesMaxRows(int codeTablesMaxRows) {
+ this.codeTablesMaxRows = codeTablesMaxRows;
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public void setBindAddress(String bindAddress) {
+ this.bindAddress = bindAddress;
+ }
+
+ public int getPortNumber() {
+ return portNumber;
+ }
+
+ public void setPortNumber(int portNumber) {
+ this.portNumber = portNumber;
+ }
+
+ public int getResultSetCacheMaxEntries() {
+ return this.maxResultSetCacheEntries;
+ }
+
+ public void setResultSetCacheMaxEntries(int value) {
+ this.maxResultSetCacheEntries = value;
+ }
+
+ public boolean isResultSetCacheEnabled() {
+ return this.resultSetCacheEnabled;
+ }
+
+ public void setResultSetCacheEnabled(boolean value) {
+ this.resultSetCacheEnabled = value;
+ }
+}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,78 +23,116 @@
package org.teiid.dqp.internal.process;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
+import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
-import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.SecurityHelper;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.common.application.ServiceLoader;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.lob.LobChunk;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
+import com.metamatrix.common.queue.StatsCapturingWorkManager;
import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.BufferService;
import com.metamatrix.dqp.service.CommandLogMessage;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.platform.security.api.service.SessionService;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.server.serverapi.RequestInfo;
/**
* Implements the core DQP processing.
*/
-@Singleton
public class DQPCore implements ClientSideDQP {
+ private final static class FutureWork<T> implements Work, WorkListener {
+ private final ResultsReceiver<T> receiver;
+ private final Callable<T> toCall;
+
+ private FutureWork(ResultsReceiver<T> receiver,
+ Callable<T> processor) {
+ this.receiver = receiver;
+ this.toCall = processor;
+ }
+
+ @Override
+ public void run() {
+ try {
+ receiver.receiveResults(toCall.call());
+ } catch (Throwable t) {
+ receiver.exceptionOccurred(t);
+ }
+ }
+
+ @Override
+ public void release() {
+
+ }
+
+ @Override
+ public void workAccepted(WorkEvent arg0) {
+
+ }
+
+ @Override
+ public void workCompleted(WorkEvent arg0) {
+
+ }
+
+ @Override
+ public void workRejected(WorkEvent arg0) {
+ receiver.exceptionOccurred(arg0.getException());
+ }
+
+ @Override
+ public void workStarted(WorkEvent arg0) {
+
+ }
+ }
+
static class ClientState {
List<RequestID> requests;
TempTableStoreImpl tempTableStoreImpl;
@@ -125,22 +163,15 @@
}
- //Constants
- private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
- private static final int DEFAULT_MAX_CODE_TABLES = 200;
- private static final int DEFAULT_MAX_CODE_RECORDS = 200000;
- private static final int DEFAULT_MAX_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
- private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
- private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
- private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
- private static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
-
+ private WorkManager workManager;
+ private StatsCapturingWorkManager processWorkerPool;
+
// System properties for Code Table
- private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
- private int maxCodeTables = DEFAULT_MAX_CODE_TABLES;
- private int maxCodeRecords = DEFAULT_MAX_CODE_RECORDS;
+ private int maxCodeTableRecords = DQPConfiguration.DEFAULT_MAX_CODE_TABLE_RECORDS;
+ private int maxCodeTables = DQPConfiguration.DEFAULT_MAX_CODE_TABLES;
+ private int maxCodeRecords = DQPConfiguration.DEFAULT_MAX_CODE_RECORDS;
- private int maxFetchSize = DEFAULT_MAX_FETCH_SIZE;
+ private int maxFetchSize = DQPConfiguration.DEFAULT_FETCH_SIZE;
// Resources
private BufferManager bufferManager;
@@ -148,11 +179,13 @@
private SessionAwareCache<PreparedPlan> prepPlanCache;
private SessionAwareCache<CachedResults> rsCache;
private TransactionService transactionService;
- private MetadataService metadataService;
+ private AuthorizationService authorizationService;
+ private BufferService bufferService;
+ private SessionService sessionService;
+ private ConnectorManagerRepository connectorManagerRepository;
// Query worker pool for processing plans
- private WorkerPool processWorkerPool;
- private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
+ private int processorTimeslice = DQPConfiguration.DEFAULT_PROCESSOR_TIMESLICE;
private boolean processorDebugAllowed;
private int chunkSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
@@ -160,35 +193,26 @@
private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();
private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
private DQPContextCache contextCache;
- private ServiceLoader loader = new ServiceLoader();
- private CacheFactory cacheFactory;
+ private SecurityHelper securityHelper;
- private ApplicationEnvironment environment = new ApplicationEnvironment();
-
/**
* perform a full shutdown and wait for 10 seconds for all threads to finish
- * @throws ApplicationLifecycleException
*/
- public void stop() throws ApplicationLifecycleException {
- LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
+ public void stop() {
processWorkerPool.shutdownNow();
try {
processWorkerPool.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
}
- contextCache.shutdown();
- this.environment.stop();
-
- if (cacheFactory != null) {
- cacheFactory.destroy();
- }
+ // TODO: Should we be doing more cleanup here??
+ LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
}
/**
- * Return a list of {@link RequestInfo} for the given session
+ * Return a list of {@link RequestMetadata} for the given session
*/
- public List<RequestInfo> getRequestsByClient(String clientConnection) {
- ClientState state = getClientState(clientConnection, false);
+ public List<RequestMetadata> getRequestsForSession(long sessionId) {
+ ClientState state = getClientState(String.valueOf(sessionId), false);
if (state == null) {
return Collections.emptyList();
}
@@ -207,38 +231,48 @@
}
/**
- * Return a list of all {@link RequestInfo}
+ * Return a list of all {@link RequestMetadata}
*/
- public List<RequestInfo> getRequests() {
+ public List<RequestMetadata> getRequests() {
return buildRequestInfos(requests.keySet());
}
- private List<RequestInfo> buildRequestInfos(Collection<RequestID> ids) {
- List<RequestInfo> results = new ArrayList<RequestInfo>();
- for (RequestID requestID : ids) {
+ private List<RequestMetadata> buildRequestInfos(Collection<RequestID> ids) {
+ List<RequestMetadata> results = new ArrayList<RequestMetadata>();
+
+ for (RequestID requestID : ids) {
RequestWorkItem holder = requests.get(requestID);
if(holder != null && !holder.isCanceled()) {
- RequestInfo req = new RequestInfo(holder.requestID, holder.requestMsg.getCommandString(), holder.requestMsg.getSubmittedTimestamp(), holder.requestMsg.getProcessingTimestamp());
- req.setSessionToken(holder.getDqpWorkContext().getSessionToken());
- if (holder.getTransactionContext() != null && holder.getTransactionContext().isInTransaction()) {
- req.setTransactionId(holder.getTransactionContext().getTxnID());
+ RequestMetadata req = new RequestMetadata();
+
+ req.setExecutionId(holder.requestID.getExecutionID());
+ req.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
+ req.setCommand(holder.requestMsg.getCommandString());
+ req.setProcessingTime(holder.getProcessingTimestamp());
+
+ if (holder.getTransactionContext() != null && holder.getTransactionContext().getXid() != null) {
+ req.setTransactionId(holder.getTransactionContext().getXid().toString());
}
for (DataTierTupleSource conInfo : holder.getConnectorRequests()) {
- ConnectorID connectorID = conInfo.getConnectorId();
+ String connectorName = conInfo.getConnectorName();
- if (connectorID == null) {
+ if (connectorName == null) {
continue;
}
// If the request has not yet completed processing, then
// add all the subrequest messages
AtomicRequestMessage arm = conInfo.getAtomicRequestMessage();
- RequestInfo info = new RequestInfo(arm.getRequestID(), arm.getCommand().toString(), arm.getSubmittedTimestamp(), arm.getProcessingTimestamp());
- info.setSessionToken(holder.getDqpWorkContext().getSessionToken());
- info.setConnectorBindingUUID(arm.getConnectorBindingID());
- info.setNodeID(arm.getAtomicRequestID().getNodeID());
- info.setExecutionID(arm.getAtomicRequestID().getExecutionId());
+ RequestMetadata info = new RequestMetadata();
+
+ info.setExecutionId(arm.getRequestID().getExecutionID());
+ info.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
+ info.setCommand(arm.getCommand().toString());
+ info.setProcessingTime(arm.getProcessingTimestamp());
+ info.setSourceRequest(true);
+ info.setNodeId(arm.getAtomicRequestID().getNodeID());
+
results.add(info);
}
results.add(req);
@@ -247,11 +281,9 @@
return results;
}
- public ResultsFuture<ResultsMessage> executeRequest(long reqID,
- RequestMessage requestMsg) {
+ public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage requestMsg) {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID requestID = workContext.getRequestID(reqID);
- requestMsg.markProcessingStart();
requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), maxFetchSize));
Request request = null;
if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
@@ -260,16 +292,14 @@
request = new Request();
}
ClientState state = this.getClientState(workContext.getConnectionID(), true);
- request.initialize(requestMsg, environment, bufferManager,
- dataTierMgr, transactionService, processorDebugAllowed,
+ request.initialize(requestMsg, bufferManager,
+ dataTierMgr, transactionService, authorizationService, processorDebugAllowed,
state.tempTableStoreImpl, workContext,
- chunkSize);
+ chunkSize, connectorManagerRepository);
ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
-
RequestWorkItem workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
-
- logMMCommand(workItem, true, false, 0); //TODO: there is no transaction at this point
+ logMMCommand(workItem, true, false, 0);
addRequest(requestID, workItem, state);
this.addWork(workItem);
@@ -302,10 +332,27 @@
contextCache.removeRequestScopedCache(workItem.requestID.toString());
}
- void addWork(Runnable r) {
- this.processWorkerPool.execute(r);
+ void addWork(Work work) {
+ try {
+ this.processWorkerPool.scheduleWork(this.workManager, work);
+ } catch (WorkException e) {
+ //TODO: cancel? close?
+ throw new MetaMatrixRuntimeException(e);
+ }
}
+ public void setWorkManager(WorkManager mgr) {
+ this.workManager = mgr;
+ }
+
+ SecurityHelper getSecurityHelper() {
+ return this.securityHelper;
+ }
+
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
+ }
+
public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
long requestId, String streamId)
throws MetaMatrixProcessingException {
@@ -317,7 +364,7 @@
if (workItem != null) {
workItem.removeLobStream(lobRequestId);
}
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
@@ -332,20 +379,20 @@
return resultsFuture;
}
- /**
- * Cancels a node in the request. (This request is called by the
- * client directly using the admin API), so if this does not support
- * partial results then remove the original request.
- * @throws MetaMatrixComponentException
- */
- public void cancelAtomicRequest(AtomicRequestID requestID) throws MetaMatrixComponentException {
- RequestWorkItem workItem = safeGetWorkItem(requestID.getRequestID());
- if (workItem == null) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Could not cancel", requestID, "parent request does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
- workItem.requestAtomicRequestCancel(requestID);
- }
+// /**
+// * Cancels a node in the request. (This request is called by the
+// * client directly using the admin API), so if this does not support
+// * partial results then remove the original request.
+// * @throws MetaMatrixComponentException
+// */
+// public void cancelAtomicRequest(AtomicRequestID requestID) throws MetaMatrixComponentException {
+// RequestWorkItem workItem = safeGetWorkItem(requestID.getRequestID());
+// if (workItem == null) {
+// LogManager.logDetail(LogConstants.CTX_DQP, "Could not cancel", requestID, "parent request does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
+// return;
+// }
+// workItem.requestAtomicRequestCancel(requestID);
+// }
RequestWorkItem getRequestWorkItem(RequestID reqID) throws MetaMatrixProcessingException {
RequestWorkItem result = this.requests.get(reqID);
@@ -358,42 +405,19 @@
RequestWorkItem safeGetWorkItem(Object processorID) {
return this.requests.get(processorID);
}
-
+
/**
* Returns a list of QueueStats objects that represent the queues in
* this service.
* If there are no queues, an empty Collection is returned.
*/
- public Collection getQueueStatistics() {
- if ( this.processWorkerPool == null ) {
- return Collections.EMPTY_LIST;
- }
-
- return Arrays.asList(processWorkerPool.getStats());
+ public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
+ return processWorkerPool.getStats();
}
-
- /**
- * Returns a QueueStats object that represent the queue in
- * this service.
- * If there is no queue with the given name, an empty Collection is returned.
- */
- public Collection getQueueStatistics(String name) {
- if ( !name.equalsIgnoreCase(PROCESS_PLAN_QUEUE_NAME)) {
- return Collections.EMPTY_LIST;
- }
- return getQueueStatistics();
- }
-
- /**
- * Cancel and close all requests associated with the clientConnection/session. Also runs a final cleanup any caches within
- * the session's scope.
- * @param clientConnection
- * @param sendCancellationsToClient Notify the client that each request has been closed.
- * @throws MetaMatrixComponentException
- * @since 4.2
- */
- public void terminateConnection(String sessionId) throws MetaMatrixComponentException {
-
+
+ public void terminateSession(long terminateeId) {
+ String sessionId = String.valueOf(terminateeId);
+
// sometimes there will not be any atomic requests pending, in that
// situation we still need to clear the master request from our map
ClientState state = getClientState(sessionId, false);
@@ -410,18 +434,19 @@
if (transactionService != null) {
try {
transactionService.cancelTransactions(sessionId, false);
- } catch (InvalidTransactionException err) {
+ } catch (XATransactionException err) {
LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
- } catch (SystemException err) {
- throw new MetaMatrixComponentException(err);
- }
+ }
}
contextCache.removeSessionScopedCache(sessionId);
}
- public boolean cancelRequest(RequestID requestID)
- throws MetaMatrixComponentException {
-
+ public boolean cancelRequest(long sessionId, long requestId) throws MetaMatrixComponentException {
+ RequestID requestID = new RequestID(String.valueOf(sessionId), requestId);
+ return cancelRequest(requestID);
+ }
+
+ private boolean cancelRequest(RequestID requestID) throws MetaMatrixComponentException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
}
@@ -443,7 +468,7 @@
public ResultsFuture<?> closeRequest(long requestId) throws MetaMatrixProcessingException, MetaMatrixComponentException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
closeRequest(workContext.getRequestID(requestId));
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
/**
@@ -464,23 +489,78 @@
}
}
- public void clearPlanCache(){
+ private void clearPlanCache(){
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache")); //$NON-NLS-1$
this.prepPlanCache.clearAll();
}
- public void clearCodeTableCache(){
+ private void clearCodeTableCache(){
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_code_table_cache")); //$NON-NLS-1$
this.dataTierMgr.clearCodeTables();
}
-
- public void clearResultSetCache() {
+
+ private void clearResultSetCache() {
//clear cache in server
if(rsCache != null){
rsCache.clearAll();
}
}
+
+
+ public Collection<String> getCacheTypes(){
+ ArrayList<String> caches = new ArrayList<String>();
+ caches.add(Admin.Cache.CODE_TABLE_CACHE.toString());
+ caches.add(Admin.Cache.PREPARED_PLAN_CACHE.toString());
+ caches.add(Admin.Cache.CONNECTOR_RESULT_SET_CACHE.toString());
+ caches.add(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString());
+ return caches;
+ }
+
+ public void clearCache(String cacheType) {
+ Admin.Cache cache = Admin.Cache.valueOf(cacheType);
+ switch (cache) {
+ case CODE_TABLE_CACHE:
+ clearCodeTableCache();
+ break;
+ case PREPARED_PLAN_CACHE:
+ clearPlanCache();
+ break;
+ case CONNECTOR_RESULT_SET_CACHE:
+ clearResultSetCache();
+ break;
+ case QUERY_SERVICE_RESULT_SET_CACHE:
+ break;
+ }
+ }
+ public Collection<SessionMetadata> getActiveSessions() throws SessionServiceException {
+ if (this.sessionService == null) {
+ return Collections.emptyList();
+ }
+ return this.sessionService.getActiveSessions();
+ }
+
+ public int getActiveSessionsCount() throws SessionServiceException{
+ if (this.sessionService == null) {
+ return 0;
+ }
+ return this.sessionService.getActiveSessionsCount();
+ }
+
+ public Collection<org.teiid.adminapi.Transaction> getTransactions() {
+ if (this.transactionService == null) {
+ return Collections.emptyList();
+ }
+ return this.transactionService.getTransactions();
+ }
+
+ public void terminateTransaction(String xid) throws AdminException {
+ if (this.transactionService == null) {
+ return;
+ }
+ this.transactionService.terminateTransaction(xid);
+ }
+
void logMMCommand(RequestWorkItem workItem, boolean isBegin, boolean isCancel, int rowCount) {
if (!LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) {
return;
@@ -495,8 +575,8 @@
}
String txnID = null;
TransactionContext tc = workItem.getTransactionContext();
- if (tc != null) {
- txnID = tc.getTxnID();
+ if (tc != null && tc.getXid() != null) {
+ txnID = tc.getXid().toString();
}
String appName = workContext.getAppName();
// Log to request log
@@ -523,7 +603,7 @@
}
message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getConnectionID(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, isCancelled, errorOccurred);
}
- LogManager.log(MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
+ LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
}
ProcessorDataManager getDataTierManager() {
@@ -544,10 +624,6 @@
}
return transactionService;
}
-
- public TransactionService getTransactionServiceDirect() {
- return transactionService;
- }
SessionAwareCache<CachedResults> getRsCache() {
return rsCache;
@@ -560,173 +636,188 @@
int getChunkSize() {
return chunkSize;
}
-
- /*
- * @see com.metamatrix.common.application.Application#initialize(java.util.Properties)
- */
- public void start(DQPConfigSource configSource) throws ApplicationInitializationException {
-
- // Load services into DQP
- for(int i=0; i<DQPServiceNames.ALL_SERVICES.length; i++) {
-
- final String serviceName = DQPServiceNames.ALL_SERVICES[i];
- final Class<? extends ApplicationService> type = DQPServiceNames.ALL_SERVICE_CLASSES[i];
-
- ApplicationService appService = configSource.getServiceInstance(type);
- if (appService == null) {
- LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPLauncher.InstallService_ServiceIsNull", serviceName)); //$NON-NLS-1$
- continue;
- }
-
- appService = loader.loadService(serviceName, appService);
- String loggingContext = DQPServiceNames.SERVICE_LOGGING_CONTEXT[i];
- if (loggingContext != null) {
- appService = (ApplicationService)LogManager.createLoggingProxy(loggingContext, appService, new Class[] {type}, MessageLevel.DETAIL);
- }
-
- appService.initialize(configSource.getProperties());
- this.environment.installService(serviceName, appService);
- LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPLauncher.InstallService_ServiceInstalled", serviceName)); //$NON-NLS-1$
- }
-
- ConfigurationService cs = (ConfigurationService)this.environment.findService(DQPServiceNames.CONFIGURATION_SERVICE);
- Properties p = configSource.getProperties();
- if (cs != null) {
- p = cs.getSystemProperties();
- }
- start(p);
- }
-
- public void start(Properties props) {
- PropertiesUtils.setBeanProperties(this, props, null);
+ public void start(DQPConfiguration config) {
- this.processorTimeslice = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_TIMESLICE, DEFAULT_PROCESSOR_TIMESLICE);
- this.maxFetchSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_FETCH_SIZE, DEFAULT_MAX_FETCH_SIZE);
- this.processorDebugAllowed = PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.PROCESSOR_DEBUG_ALLOWED, true);
- this.maxCodeTableRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS_PER_TABLE, DEFAULT_MAX_CODE_TABLE_RECORDS);
- this.maxCodeTables = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLES, DEFAULT_MAX_CODE_TABLES);
- this.maxCodeRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS, DEFAULT_MAX_CODE_RECORDS);
+ Assertion.isNotNull(this.workManager);
+
+ this.processorTimeslice = config.getTimeSliceInMilli();
+ this.maxFetchSize = config.getMaxRowsFetchSize();
+ this.processorDebugAllowed = config.isProcessDebugAllowed();
+ this.maxCodeTableRecords = config.getCodeTablesMaxRowsPerTable();
+ this.maxCodeTables = config.getCodeTablesMaxCount();
+ this.maxCodeRecords = config.getCodeTablesMaxRows();
- this.chunkSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.STREAMING_BATCH_SIZE, 100) * 1024;
+ this.chunkSize = config.getLobChunkSizeInKB() * 1024;
//result set cache
- if(PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.USE_RESULTSET_CACHE, true)){
- this.rsCache = new SessionAwareCache<CachedResults>(PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_RESULTSET_CACHE_ENTRIES, DEFAULT_MAX_RESULTSET_CACHE_ENTRIES));
+ if (config.isResultSetCacheEnabled()) {
+ this.rsCache = new SessionAwareCache<CachedResults>(config.getResultSetCacheMaxEntries());
}
//prepared plan cache
- int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_PLAN_CACHE_SIZE, SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL);
- prepPlanCache = new SessionAwareCache<PreparedPlan>(maxSizeTotal);
+ prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount());
// Processor debug flag
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
//get buffer manager
- BufferService bufferService = (BufferService) this.environment.findService(DQPServiceNames.BUFFER_SERVICE);
- bufferManager = bufferService.getBufferManager();
- contextCache = bufferService.getContextCache();
+ this.bufferManager = bufferService.getBufferManager();
+ this.contextCache = bufferService.getContextCache();
- transactionService = (TransactionService )this.environment.findService(DQPServiceNames.TRANSACTION_SERVICE);
- metadataService = (MetadataService) this.environment.findService(DQPServiceNames.METADATA_SERVICE);
-
- // Create the worker pools to tie the queues together
- processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS));
-
+ this.processWorkerPool = new StatsCapturingWorkManager(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
+
dataTierMgr = new DataTierManagerImpl(this,
- (DataService) this.environment.findService(DQPServiceNames.DATA_SERVICE),
- (VDBService) this.environment.findService(DQPServiceNames.VDB_SERVICE),
- (BufferService) this.environment.findService(DQPServiceNames.BUFFER_SERVICE),
- metadataService,
+ this.connectorManagerRepository,
+ this.bufferService,
+ this.workManager,
this.maxCodeTables,
this.maxCodeRecords,
- this.maxCodeTableRecords);
+ this.maxCodeTableRecords);
+
}
- public List getXmlSchemas(String docName) throws MetaMatrixComponentException,
- QueryMetadataException {
+ public void setBufferService(BufferService service) {
+ this.bufferService = service;
+ setContextCache(service.getContextCache());
+ }
+
+ public void setAuthorizationService(AuthorizationService service) {
+ this.authorizationService = service;
+ }
+
+ public void setContextCache(DQPContextCache cache) {
+ this.contextCache = cache;
+ }
+
+ public void setTransactionService(TransactionService service) {
+ this.transactionService = service;
+ }
+
+ public List<String> getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- QueryMetadataInterface metadata = metadataService.lookupMetadata(workContext.getVdbName(), workContext.getVdbVersion());
+ QueryMetadataInterface metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
Object groupID = metadata.getGroupID(docName);
return metadata.getXMLSchemas(groupID);
}
- public void cancelRequest(long requestID)
+ @Override
+ public boolean cancelRequest(long requestID)
throws MetaMatrixProcessingException, MetaMatrixComponentException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- this.cancelRequest(workContext.getRequestID(requestID));
+ return this.cancelRequest(workContext.getRequestID(requestID));
}
- public void begin() throws XATransactionException {
+ // local txn
+ public ResultsFuture<?> begin() throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- try {
- this.getTransactionService().begin(threadId);
- } catch (SystemException e) {
- throw new XATransactionException(e);
- }
+ this.getTransactionService().begin(threadId);
+ return ResultsFuture.NULL_FUTURE;
}
- public void commit() throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- try {
- this.getTransactionService().commit(threadId);
- } catch (SystemException e) {
- throw new XATransactionException(e);
- }
+ // local txn
+ public ResultsFuture<?> commit() throws XATransactionException {
+ final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().commit(threadId);
+ return null;
+ }
+ };
+ return addWork(processor);
}
- public void rollback() throws XATransactionException {
- try {
- this.getTransactionService().rollback(
- DQPWorkContext.getWorkContext().getConnectionID());
- } catch (SystemException e) {
- throw new XATransactionException(e);
- }
+ // local txn
+ public ResultsFuture<?> rollback() throws XATransactionException {
+ final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().rollback(threadId);
+ return null;
+ }
+ };
+ return addWork(processor);
}
- public void commit(MMXid xid, boolean onePhase)
- throws XATransactionException {
+ // global txn
+ public ResultsFuture<?> commit(final MMXid xid, final boolean onePhase) throws XATransactionException {
+ final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().commit(threadId, xid, onePhase, false);
+ return null;
+ }
+ };
+ return addWork(processor);
+ }
+ // global txn
+ public ResultsFuture<?> end(MMXid xid, int flags) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().commit(threadId, xid, onePhase);
+ this.getTransactionService().end(threadId, xid, flags, false);
+ return ResultsFuture.NULL_FUTURE;
}
-
- public void end(MMXid xid, int flags) throws XATransactionException {
+ // global txn
+ public ResultsFuture<?> forget(MMXid xid) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().end(threadId, xid, flags);
+ this.getTransactionService().forget(threadId, xid, false);
+ return ResultsFuture.NULL_FUTURE;
}
+
+ // global txn
+ public ResultsFuture<Integer> prepare(final MMXid xid) throws XATransactionException {
+ Callable<Integer> processor = new Callable<Integer>() {
+ @Override
+ public Integer call() throws Exception {
+ return getTransactionService().prepare(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+ }
+ };
+ return addWork(processor);
+ }
- public void forget(MMXid xid) throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().forget(threadId, xid);
+ private <T> ResultsFuture<T> addWork(Callable<T> processor) {
+ ResultsFuture<T> result = new ResultsFuture<T>();
+ ResultsReceiver<T> receiver = result.getResultsReceiver();
+ try {
+ this.workManager.scheduleWork(new FutureWork<T>(receiver, processor));
+ } catch (WorkException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return result;
}
- public int prepare(MMXid xid) throws XATransactionException {
- return this.getTransactionService().prepare(
- DQPWorkContext.getWorkContext().getConnectionID(),
- xid);
+ // global txn
+ public ResultsFuture<Xid[]> recover(int flag) throws XATransactionException {
+ ResultsFuture<Xid[]> result = new ResultsFuture<Xid[]>();
+ result.getResultsReceiver().receiveResults(this.getTransactionService().recover(flag, false));
+ return result;
}
-
- public Xid[] recover(int flag) throws XATransactionException {
- return this.getTransactionService().recover(flag);
+ // global txn
+ public ResultsFuture<?> rollback(final MMXid xid) throws XATransactionException {
+ Callable<Void> processor = new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ getTransactionService().rollback(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+ return null;
+ }
+ };
+ return addWork(processor);
}
-
- public void rollback(MMXid xid) throws XATransactionException {
- this.getTransactionService().rollback(
- DQPWorkContext.getWorkContext().getConnectionID(),
- xid);
- }
-
- public void start(MMXid xid, int flags, int timeout)
+ // global txn
+ public ResultsFuture<?> start(MMXid xid, int flags, int timeout)
throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.getTransactionService().start(threadId, xid, flags, timeout);
+ this.getTransactionService().start(threadId, xid, flags, timeout, false);
+ return ResultsFuture.NULL_FUTURE;
}
public MetadataResult getMetadata(long requestID)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment, workContext.getVdbName(), workContext.getVdbVersion());
+ MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache, workContext.getVdbName(), workContext.getVdbVersion());
return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
}
@@ -734,21 +825,28 @@
boolean allowDoubleQuotedVariable)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment, workContext.getVdbName(), workContext.getVdbVersion());
+ MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache, workContext.getVdbName(), workContext.getVdbVersion());
return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
}
- public ApplicationEnvironment getEnvironment() {
- return environment;
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.connectorManagerRepository = repo;
}
- @Inject
- public void setCacheFactory(CacheFactory cacheFactory) {
- this.cacheFactory = cacheFactory;
- this.environment.setCacheFactory(cacheFactory);
+ public ConnectorManagerRepository getConnectorManagerRepository() {
+ return this.connectorManagerRepository;
}
- public void setEnvironment(ApplicationEnvironment environment) {
- this.environment = environment;
+ public void setSessionService(SessionService service) {
+ this.sessionService = service;
+ service.setDqp(this);
}
+
+ public SessionService getSessionService() {
+ return this.sessionService;
+ }
+
+ public AuthorizationService getAuthorizationService() {
+ return this.authorizationService;
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,8 +24,11 @@
import java.io.Serializable;
+import javax.security.auth.Subject;
+
+import org.teiid.adminapi.impl.VDBMetaData;
+
import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class DQPWorkContext implements Serializable {
@@ -45,14 +48,22 @@
public static void setWorkContext(DQPWorkContext context) {
CONTEXTS.set(context);
}
+
+ public static void releaseWorkContext() {
+ CONTEXTS.set(null);
+ }
- private Serializable trustedPayload;
private String vdbName;
- private String vdbVersion;
+ private int vdbVersion;
private String appName;
private SessionToken sessionToken;
private String clientAddress;
private String clientHostname;
+ private Subject subject;
+ private String securityDomain;
+ private Object securityContext;
+ private VDBMetaData vdb;
+ private boolean admin;
public DQPWorkContext() {
}
@@ -60,19 +71,20 @@
/**
* @return
*/
- public Serializable getTrustedPayload() {
- return trustedPayload;
- }
-
- /**
- * @return
- */
public String getUserName() {
if (this.sessionToken == null) {
return null;
}
return this.sessionToken.getUsername();
}
+
+ public Subject getSubject() {
+ return this.subject;
+ }
+
+ public void setSubject(Subject subject) {
+ this.subject = subject;
+ }
/**
* @return
@@ -84,18 +96,11 @@
/**
* @return
*/
- public String getVdbVersion() {
+ public int getVdbVersion() {
return vdbVersion;
}
/**
- * @param serializable
- */
- public void setTrustedPayload(Serializable trustedPayload) {
- this.trustedPayload = trustedPayload;
- }
-
- /**
* @param string
*/
public void setVdbName(String vdbName) {
@@ -105,20 +110,17 @@
/**
* @param string
*/
- public void setVdbVersion(String vdbVersion) {
+ public void setVdbVersion(int vdbVersion) {
this.vdbVersion = vdbVersion;
}
public String getConnectionID() {
- if (this.sessionToken == null) {
- return null;
- }
- return this.sessionToken.getSessionIDValue();
+ return String.valueOf(getSessionId());
}
- public MetaMatrixSessionID getSessionId() {
+ public long getSessionId() {
if (this.sessionToken == null) {
- return null;
+ return -1;
}
return this.sessionToken.getSessionID();
}
@@ -162,8 +164,44 @@
public void reset() {
setSessionToken(null);
setAppName(null);
- setTrustedPayload(null);
setVdbName(null);
- setVdbVersion(null);
+ setVdbVersion(0);
+ setSecurityContext(null);
+ setSecurityDomain(null);
+ setVdb(null);
+ setSubject(null);
+ setSessionToken(null);
}
+
+ public void setSecurityDomain(String securityDomain) {
+ this.securityDomain = securityDomain;
+ }
+
+ public String getSecurityDomain() {
+ return this.securityDomain;
+ }
+
+ public Object getSecurityContext() {
+ return this.securityContext;
+ }
+
+ public void setSecurityContext(Object securityContext) {
+ this.securityContext = securityContext;
+ }
+
+ public void setVdb(VDBMetaData vdb) {
+ this.vdb = vdb;
+ }
+
+ public VDBMetaData getVDB() {
+ return vdb;
+ }
+
+ public void markAsAdmin() {
+ this.admin = true;
+ }
+
+ public boolean isAdmin() {
+ return this.admin;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,22 +31,29 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import javax.resource.spi.work.WorkManager;
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.language.SQLReservedWords;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
+import org.teiid.connector.metadata.runtime.Procedure;
import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -54,33 +61,24 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
import com.metamatrix.query.processor.CollectionTupleSource;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.lang.UnaryFromClause;
+import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.util.CommandContext;
@@ -108,29 +106,28 @@
// Resources
private DQPCore requestMgr;
- private DataService dataService;
- private VDBService vdbService;
private BufferService bufferService;
- private MetadataService metadataService;
+ private ConnectorManagerRepository connectorManagerRepository;
+ private WorkManager workManager;
// Processor state
private CodeTableCache codeTableCache;
- public DataTierManagerImpl(DQPCore requestMgr,
- DataService dataService, VDBService vdbService, BufferService bufferService, MetadataService metadataService,
- int maxCodeTables, int maxCodeRecords, int maxCodeTableRecords) {
+ public DataTierManagerImpl(DQPCore requestMgr, ConnectorManagerRepository connectorRepo, BufferService bufferService, WorkManager wm, int maxCodeTables, int maxCodeRecords, int maxCodeTableRecords) {
this.requestMgr = requestMgr;
- this.dataService = dataService;
- this.vdbService = vdbService;
+ this.connectorManagerRepository = connectorRepo;
this.bufferService = bufferService;
- this.metadataService = metadataService;
+ this.workManager = wm;
this.codeTableCache = new CodeTableCache(maxCodeTables, maxCodeRecords, maxCodeTableRecords);
}
+
+ private ConnectorManager getCM(String connectorName) {
+ return this.connectorManagerRepository.getConnectorManager(connectorName);
+ }
- public TupleSource registerRequest(Object processorId, Command command,
- String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleSource registerRequest(Object processorId, Command command, String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
if(CoreConstants.SYSTEM_MODEL.equals(modelName)) {
@@ -138,7 +135,7 @@
}
AtomicRequestMessage aqr = createRequest(processorId, command, modelName, connectorBindingId, nodeID);
- DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorID(), workItem);
+ DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorName(), workItem);
tupleSource.open();
return tupleSource;
}
@@ -154,8 +151,9 @@
private TupleSource processSystemQuery(Command command,
RequestWorkItem workItem) throws MetaMatrixComponentException {
String vdbName = workItem.getDqpWorkContext().getVdbName();
- String vdbVersion = workItem.getDqpWorkContext().getVdbVersion();
- CompositeMetadataStore metadata = this.metadataService.getMetadataObjectSource(vdbName, vdbVersion);
+ int vdbVersion = workItem.getDqpWorkContext().getVdbVersion();
+ VDBMetaData vdb = workItem.getDqpWorkContext().getVDB();
+ CompositeMetadataStore metadata = vdb.getAttachment(CompositeMetadataStore.class);
Collection rows = new ArrayList();
if (command instanceof Query) {
Query query = (Query)command;
@@ -175,27 +173,27 @@
rows.add(Arrays.asList(vdbName, vdbVersion));
break;
case SCHEMAS:
- for (Schema model : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
+ for (Schema model : getVisibleSchemas(vdb, metadata)) {
rows.add(Arrays.asList(vdbName, model.getName(), model.isPhysical(), model.getUUID(), model.getAnnotation(), model.getPrimaryMetamodelUri()));
}
break;
case PROCEDURES:
- for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
- for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
- rows.add(Arrays.asList(vdbName, proc.getSchema().getName(), proc.getName(), proc.getNameInSource(), proc.getResultSet() != null, proc.getUUID(), proc.getAnnotation()));
+ for (Schema schema : getVisibleSchemas(vdb, metadata)) {
+ for (Procedure proc : schema.getProcedures().values()) {
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), proc.getNameInSource(), proc.getResultSet() != null, proc.getUUID(), proc.getAnnotation()));
}
}
break;
case PROCEDUREPARAMS:
- for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
- for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
+ for (Schema schema : getVisibleSchemas(vdb, metadata)) {
+ for (Procedure proc : schema.getProcedures().values()) {
for (ProcedureParameter param : proc.getParameters()) {
- rows.add(Arrays.asList(vdbName, proc.getSchema().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(),
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(),
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
}
if (proc.getResultSet() != null) {
for (Column param : proc.getResultSet().getColumns()) {
- rows.add(Arrays.asList(vdbName, proc.getSchema().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), ProcedureParameter.Type.ResultSet.toString(), false,
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), ProcedureParameter.Type.ResultSet.toString(), false,
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
}
}
@@ -205,7 +203,7 @@
case PROPERTIES: //TODO: consider storing separately in the metadatastore
Collection<AbstractMetadataRecord> records = new LinkedHashSet<AbstractMetadataRecord>();
records.addAll(metadata.getDatatypes());
- for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
+ for (Schema schema : getVisibleSchemas(vdb, metadata)) {
records.add(schema);
records.addAll(schema.getTables().values());
for (Table table : schema.getTables().values()) {
@@ -213,7 +211,7 @@
records.addAll(table.getColumns());
records.addAll(table.getAllKeys());
}
- for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
+ for (Procedure proc : schema.getProcedures().values()) {
records.add(proc);
records.addAll(proc.getParameters());
if (proc.getResultSet() != null) {
@@ -228,7 +226,7 @@
}
break;
default:
- for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
+ for (Schema schema : getVisibleSchemas(vdb, metadata)) {
for (Table table : schema.getTables().values()) {
switch (sysTable) {
case TABLES:
@@ -242,14 +240,14 @@
}
rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), column.getName(), column.getPosition(), column.getNameInSource(),
column.getDatatype().getRuntimeTypeName(), column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
- column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncrementable(), column.getNullType().toString(), column.getMinValue(),
- column.getMaxValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(),
+ column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncremented(), column.getNullType().toString(), column.getMinimumValue(),
+ column.getMaximumValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(),
column.getCharOctetLength(), column.getRadix(), column.getUUID(), column.getAnnotation()));
}
break;
case KEYS:
for (KeyRecord key : table.getAllKeys()) {
- rows.add(Arrays.asList(vdbName, table.getSchema().getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(),
+ rows.add(Arrays.asList(vdbName, table.getParent().getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(),
false, (key instanceof ForeignKey)?((ForeignKey)key).getUniqueKeyID():null, key.getUUID()));
}
break;
@@ -266,8 +264,8 @@
for (ForeignKey key : table.getForeignKeys()) {
short postition = 0;
for (Column column : key.getColumns()) {
- Table pkTable = key.getPrimaryKey().getTable();
- rows.add(Arrays.asList(vdbName, pkTable.getSchema().getName(), pkTable.getName(), key.getPrimaryKey().getColumns().get(postition).getName(), vdbName, schema.getName(), table.getName(), column.getName(),
+ Table pkTable = key.getPrimaryKey().getParent();
+ rows.add(Arrays.asList(vdbName, pkTable.getParent().getName(), pkTable.getName(), key.getPrimaryKey().getColumns().get(postition).getName(), vdbName, schema.getName(), table.getName(), column.getName(),
++postition, DatabaseMetaData.importedKeyNoAction, DatabaseMetaData.importedKeyNoAction, key.getName(), key.getPrimaryKey().getName(), DatabaseMetaData.importedKeyInitiallyDeferred));
}
}
@@ -278,36 +276,36 @@
break;
}
} else {
- StoredProcedure proc = (StoredProcedure)command;
+ TransformationMetadata indexMetadata = vdb.getAttachment(TransformationMetadata.class);
+ StoredProcedure proc = (StoredProcedure)command;
final SystemProcs sysTable = SystemProcs.valueOf(proc.getProcedureCallableName().substring(CoreConstants.SYSTEM_MODEL.length() + 1).toUpperCase());
switch (sysTable) {
case GETVDBRESOURCEPATHS:
- Set<String> filePaths = metadata.getMetadataSource().getEntries();
+ String[] filePaths = indexMetadata.getVDBResourcePaths();
for (String filePath : filePaths) {
- if (vdbService.getFileVisibility(vdbName, vdbVersion, filePath) != ModelInfo.PUBLIC) {
- continue;
- }
rows.add(Arrays.asList(filePath, filePath.endsWith(".INDEX"))); //$NON-NLS-1$
}
break;
case GETBINARYVDBRESOURCE:
- String filePath = (String)proc.getParameter(0).getValue();
- if (metadata.getMetadataSource().getEntries().contains(filePath) && vdbService.getFileVisibility(vdbName, vdbVersion, filePath) == ModelInfo.PUBLIC) {
+ String filePath = (String)((Constant)proc.getParameter(0).getExpression()).getValue();
+ byte[] contents = indexMetadata.getBinaryVDBResource(filePath);
+ if (contents != null) {
try {
- rows.add(Arrays.asList(new SerialBlob(MetadataSourceUtil.getFileContentAsString(filePath, metadata.getMetadataSource()).getBytes())));
+ rows.add(Arrays.asList(new SerialBlob(contents)));
} catch (SQLException e) {
throw new MetaMatrixComponentException(e);
- }
+ }
}
break;
case GETCHARACTERVDBRESOURCE:
- filePath = (String)proc.getParameter(0).getValue();
- if (metadata.getMetadataSource().getEntries().contains(filePath) && vdbService.getFileVisibility(vdbName, vdbVersion, filePath) == ModelInfo.PUBLIC) {
+ filePath = (String)((Constant)proc.getParameter(0).getExpression()).getValue();
+ String filecontents = indexMetadata.getCharacterVDBResource(filePath);
+ if (filecontents != null) {
try {
- rows.add(Arrays.asList(new SerialClob(MetadataSourceUtil.getFileContentAsString(filePath, metadata.getMetadataSource()).toCharArray())));
+ rows.add(Arrays.asList(new SerialClob(filecontents.toCharArray())));
} catch (SQLException e) {
throw new MetaMatrixComponentException(e);
- }
+ }
}
break;
}
@@ -315,10 +313,11 @@
return new CollectionTupleSource(rows.iterator(), command.getProjectedSymbols());
}
- private List<Schema> getVisibleSchemas(String vdbName, String vdbVersion, CompositeMetadataStore metadata) throws MetaMatrixComponentException {
+ private List<Schema> getVisibleSchemas(VDBMetaData vdb, CompositeMetadataStore metadata) {
ArrayList<Schema> result = new ArrayList<Schema>();
for (Schema schema : metadata.getSchemas().values()) {
- if(vdbService.getModelVisibility(vdbName, vdbVersion, schema.getName()) == ModelInfo.PUBLIC) {
+ ModelMetaData model = vdb.getModel(schema.getName());
+ if(model.isVisible()) {
result.add(schema);
}
}
@@ -333,7 +332,6 @@
RequestMessage request = workItem.requestMsg;
// build the atomic request based on original request + context info
AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID);
- aqr.markSubmissionStart();
aqr.setCommand(command);
aqr.setModelName(modelName);
aqr.setUseResultSetCache(request.useResultSetCache());
@@ -343,57 +341,44 @@
}
aqr.setFetchSize(this.bufferService.getBufferManager().getConnectorBatchSize());
if (connectorBindingId == null) {
- List bindings = vdbService.getConnectorBindingNames(workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion(), modelName);
+ VDBMetaData vdb = workItem.getDqpWorkContext().getVDB();
+ ModelMetaData model = vdb.getModel(modelName);
+ List<String> bindings = model.getSourceNames();
if (bindings == null || bindings.size() != 1) {
// this should not happen, but it did occur when setting up the SystemAdmin models
throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DataTierManager.could_not_obtain_connector_binding", new Object[]{modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion() })); //$NON-NLS-1$
}
- connectorBindingId = (String)bindings.get(0);
+ connectorBindingId = model.getSourceJndiName(bindings.get(0));
Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$
}
- aqr.setConnectorBindingID(connectorBindingId);
- // Select any connector instance for this connector binding
- ConnectorID connectorID = this.dataService.selectConnector(connectorBindingId);
- // if we had this as null before
- aqr.setConnectorID(connectorID);
+ aqr.setConnectorName(connectorBindingId);
return aqr;
}
- String getConnectorName(String connectorBindingID) {
- try {
- return vdbService.getConnectorName(connectorBindingID);
- } catch (MetaMatrixComponentException t) {
- // OK
- }
- return connectorBindingID;
+ void executeRequest(AtomicRequestMessage aqr, String connectorName,ResultsReceiver<AtomicResultsMessage> receiver) throws MetaMatrixComponentException {
+ try {
+ getCM(connectorName).executeRequest(this.workManager, receiver, aqr);
+ } catch (ConnectorException e) {
+ throw new MetaMatrixComponentException(e);
+ }
}
+
+ public void closeRequest(AtomicRequestID request, String connectorName) {
+ getCM(connectorName).closeRequest(request);
+ }
- void executeRequest(AtomicRequestMessage aqr, ConnectorID connectorId,
- ResultsReceiver<AtomicResultsMessage> receiver)
- throws MetaMatrixComponentException {
- this.dataService.executeRequest(aqr, connectorId, receiver);
+ public void cancelRequest(AtomicRequestID request, String connectorName) {
+ getCM(connectorName).cancelRequest(request);
}
- public void closeRequest(AtomicRequestID request, ConnectorID connectorId) {
+ void requestBatch(AtomicRequestID request, String connectorName) throws MetaMatrixComponentException {
try {
- this.dataService.closeRequest(request, connectorId);
- } catch (MetaMatrixComponentException e) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
- }
+ getCM(connectorName).requstMore(request);
+ } catch (ConnectorException e) {
+ throw new MetaMatrixComponentException(e);
}
}
-
- public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
- this.dataService.cancelRequest(request, connectorId);
- }
- void requestBatch(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
- this.dataService.requestBatch(request, connectorId);
- }
-
/**
* Notify each waiting request that the code table data is now available.
* @param requests
@@ -437,7 +422,7 @@
String keyElementName)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
- String query = ReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + ReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$
+ String query = SQLReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + SQLReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$
final CacheKey codeRequestId = this.codeTableCache.createCacheRequest(codeTableName, returnElementName, keyElementName, context);
@@ -465,5 +450,5 @@
public void clearCodeTables() {
this.codeTableCache.clearAll();
}
-
+
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,7 +31,6 @@
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -45,7 +44,7 @@
private final List schema;
private final AtomicRequestMessage aqr;
private final DataTierManagerImpl dataMgr;
- private final ConnectorID connectorId;
+ private final String connectorName;
private final RequestWorkItem workItem;
// Data state
@@ -64,11 +63,11 @@
/**
* Constructor for DataTierTupleSource.
*/
- public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, ConnectorID connectorID, RequestWorkItem workItem) {
+ public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, String connectorName, RequestWorkItem workItem) {
this.schema = schema;
this.aqr = aqr;
this.dataMgr = dataMgr;
- this.connectorId = connectorID;
+ this.connectorName = connectorName;
this.workItem = workItem;
}
@@ -104,9 +103,9 @@
synchronized (this) {
this.waitingForData = true;
try {
- this.dataMgr.executeRequest(aqr, this.connectorId, this);
+ this.dataMgr.executeRequest(aqr, this.connectorName, this);
} catch (MetaMatrixComponentException e) {
- exceptionOccurred(e);
+ exceptionOccurred(e, true);
}
}
}
@@ -139,7 +138,7 @@
}
// Request the next batch immediately
if (!this.isLast && !waitingForData) {
- this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), connectorId);
+ this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), this.connectorName);
// update waitingForData
this.waitingForData = true;
@@ -150,11 +149,11 @@
}
public void fullyCloseSource() {
- this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
+ this.dataMgr.closeRequest(aqr.getAtomicRequestID(), this.connectorName);
}
public void cancelRequest() throws MetaMatrixComponentException {
- this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), connectorId);
+ this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), this.connectorName);
}
/**
@@ -162,24 +161,30 @@
*/
public void closeSource() {
if (this.supportsImplicitClose) {
- this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
+ this.dataMgr.closeRequest(aqr.getAtomicRequestID(), this.connectorName);
}
}
public void exceptionOccurred(Throwable e) {
+ exceptionOccurred(e, false);
+ }
+
+ private void exceptionOccurred(Throwable e, boolean removeState) {
+
synchronized (this) {
if(workItem.requestMsg.supportsPartialResults()) {
nextBatch = new List[0];
nextBatchIsLast = true;
- String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
- SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, e, true);
+ SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), e, true);
workItem.addSourceFailureDetails(sourceFailure);
} else {
this.exception = e;
}
waitingForData = false;
}
- workItem.closeAtomicRequest(aqr.getAtomicRequestID());
+ if (removeState) {
+ workItem.closeAtomicRequest(aqr.getAtomicRequestID());
+ }
this.workItem.moreWork();
}
@@ -201,9 +206,8 @@
waitingForData = false;
}
if (response.getWarnings() != null) {
- String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
for (Exception warning : response.getWarnings()) {
- SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, warning, true);
+ SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), warning, true);
workItem.addSourceFailureDetails(sourceFailure);
}
}
@@ -217,8 +221,8 @@
return aqr;
}
- public ConnectorID getConnectorId() {
- return connectorId;
+ public String getConnectorName() {
+ return this.connectorName;
}
public boolean isTransactional() {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,6 +26,8 @@
import java.nio.charset.Charset;
import java.sql.SQLException;
+import javax.resource.spi.work.Work;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.lob.ByteLobChunkStream;
@@ -40,7 +42,7 @@
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.util.LogConstants;
-public class LobWorkItem implements Runnable {
+public class LobWorkItem implements Work {
private RequestWorkItem parent;
private int chunkSize;
@@ -133,4 +135,9 @@
Assertion.isNull(this.resultsReceiver, "Cannot request results with a pending request"); //$NON-NLS-1$
this.resultsReceiver = resultsReceiver;
}
+
+ @Override
+ public void release() {
+
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,14 @@
package org.teiid.dqp.internal.process;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.teiid.connector.language.SQLReservedWords;
import org.teiid.dqp.internal.process.DQPCore.ClientState;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
@@ -38,16 +39,12 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.XMLType;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
import com.metamatrix.dqp.metadata.ResultsMetadataDefaults;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.SupportConstants;
@@ -56,7 +53,6 @@
import com.metamatrix.query.parser.ParseInfo;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.XQuery;
@@ -75,22 +71,17 @@
public class MetaDataProcessor {
// Resources
- private MetadataService metadataService;
private DQPCore requestManager;
private QueryMetadataInterface metadata;
private SessionAwareCache<PreparedPlan> planCache;
- private ApplicationEnvironment env;
private String vdbName;
- private String vdbVersion;
+ private int vdbVersion;
private RequestID requestID;
-
- public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, SessionAwareCache<PreparedPlan> planCache, ApplicationEnvironment env, String vdbName, String vdbVersion) {
- this.metadataService = metadataService;
+ public MetaDataProcessor(DQPCore requestManager, SessionAwareCache<PreparedPlan> planCache, String vdbName, int vdbVersion) {
this.requestManager = requestManager;
this.planCache = planCache;
- this.env = env;
this.vdbName = vdbName;
this.vdbVersion = vdbVersion;
}
@@ -105,13 +96,12 @@
* @throws MetaMatrixProcessingException
*/
MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- final VDBService vdbService = (VDBService)env.findService(DQPServiceNames.VDB_SERVICE);
this.requestID = requestId;
- this.metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
+ this.metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
// If multi-source, use the multi-source wrapper as well
- Collection multiModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
+ Set<String> multiModels = workContext.getVDB().getMultiSourceModelNames();
if(multiModels != null && multiModels.size() > 0) {
this.metadata = new MultiSourceMetadataWrapper(this.metadata, multiModels);
}
@@ -325,7 +315,7 @@
Expression expression = symbol.getExpression();
String function = symbol.getAggregateFunction();
- if(function.equals(ReservedWords.MIN) || function.equals(ReservedWords.MAX)){
+ if(function.equals(SQLReservedWords.MIN) || function.equals(SQLReservedWords.MAX)){
if(expression instanceof ElementSymbol) {
return createColumnMetadata(shortColumnName, (ElementSymbol)expression);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -41,6 +41,7 @@
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.batch.BatchedUpdatePlanner;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -102,7 +103,7 @@
List<SPParameter> spParams = proc.getParameters();
proc.clearParameters();
int inParameterCount = values.size();
- if (this.requestMsg.isPreparedBatchUpdate() && values.size() > 0) {
+ if (this.requestMsg.isBatchedUpdate() && values.size() > 0) {
inParameterCount = ((List)values.get(0)).size();
}
int index = 1;
@@ -160,13 +161,13 @@
createCommandContext();
}
- if (requestMsg.isPreparedBatchUpdate()) {
+ if (requestMsg.isBatchedUpdate()) {
handlePreparedBatchUpdate();
} else {
List<Reference> params = prepPlan.getReferences();
List<?> values = requestMsg.getParameterValues();
- PreparedStatementRequest.resolveParameterValues(params, values, this.context);
+ PreparedStatementRequest.resolveParameterValues(params, values, this.context, this.metadata);
}
}
@@ -185,7 +186,7 @@
*/
private void handlePreparedBatchUpdate() throws QueryMetadataException,
MetaMatrixComponentException, QueryResolverException, QueryPlannerException, QueryValidatorException {
- List<List<?>> paramValues = requestMsg.getParameterValues();
+ List<List<?>> paramValues = (List<List<?>>) requestMsg.getParameterValues();
if (paramValues.isEmpty()) {
throw new QueryValidatorException("No batch values sent for prepared batch update"); //$NON-NLS-1$
}
@@ -205,7 +206,7 @@
List<VariableContext> contexts = new LinkedList<VariableContext>();
List<List<Object>> multiValues = new ArrayList<List<Object>>(this.prepPlan.getReferences().size());
for (List<?> values : paramValues) {
- PreparedStatementRequest.resolveParameterValues(this.prepPlan.getReferences(), values, this.context);
+ PreparedStatementRequest.resolveParameterValues(this.prepPlan.getReferences(), values, this.context, this.metadata);
contexts.add(this.context.getVariableContext());
if(supportPreparedBatchUpdate){
if (multiValues.isEmpty()) {
@@ -256,7 +257,7 @@
* @throws QueryValidatorException
*/
public static void resolveParameterValues(List<Reference> params,
- List values, CommandContext context) throws QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
+ List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
VariableContext result = new VariableContext();
//the size of the values must be the same as that of the parameters
if (params.size() != values.size()) {
@@ -274,7 +275,7 @@
if(value != null && !(value instanceof List)) {
try {
String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
- Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName);
+ Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName, metadata);
value = Evaluator.evaluate(expr);
} catch (ExpressionEvaluationException e) {
String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,15 +24,12 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
-import javax.transaction.SystemException;
-
-import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
@@ -45,7 +42,6 @@
import com.metamatrix.api.exception.query.QueryPlannerException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
@@ -56,16 +52,13 @@
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.metadata.TempMetadataStore;
@@ -110,12 +103,11 @@
// init state
protected RequestMessage requestMsg;
private String vdbName;
- private String vdbVersion;
- private ApplicationEnvironment env;
- private VDBService vdbService;
+ private int vdbVersion;
private BufferManager bufferManager;
private ProcessorDataManager processorDataManager;
private TransactionService transactionService;
+ private AuthorizationService authService;
private TempTableStore tempTableStore;
protected IDGenerator idGenerator = new IDGenerator();
private boolean procDebugAllowed = false;
@@ -125,7 +117,7 @@
// acquired state
protected CapabilitiesFinder capabilitiesFinder;
protected QueryMetadataInterface metadata;
- private Set multiSourceModels;
+ private Set<String> multiSourceModels;
// internal results
protected boolean addedLimit;
@@ -137,36 +129,37 @@
protected List schemas;
protected TransactionContext transactionContext;
-
+ protected ConnectorManagerRepository connectorManagerRepo;
private int chunkSize;
protected Command userCommand;
protected boolean returnsUpdateCount;
void initialize(RequestMessage requestMsg,
- ApplicationEnvironment env,
BufferManager bufferManager,
ProcessorDataManager processorDataManager,
TransactionService transactionService,
+ AuthorizationService authService,
boolean procDebugAllowed,
TempTableStore tempTableStore,
DQPWorkContext workContext,
- int chunckSize) {
+ int chunckSize,
+ ConnectorManagerRepository repo) {
this.requestMsg = requestMsg;
this.vdbName = workContext.getVdbName();
this.vdbVersion = workContext.getVdbVersion();
- this.env = env;
- this.vdbService = (VDBService) env.findService(DQPServiceNames.VDB_SERVICE);
this.bufferManager = bufferManager;
this.processorDataManager = processorDataManager;
this.transactionService = transactionService;
+ this.authService = authService;
this.procDebugAllowed = procDebugAllowed;
this.tempTableStore = tempTableStore;
idGenerator.setDefaultFactory(new IntegerIDFactory());
this.workContext = workContext;
this.requestId = workContext.getRequestID(this.requestMsg.getExecutionId());
this.chunkSize = chunckSize;
+ this.connectorManagerRepo = repo;
}
void setMetadata(CapabilitiesFinder capabilitiesFinder, QueryMetadataInterface metadata, Set multiSourceModels) {
@@ -185,25 +178,11 @@
return;
}
// Prepare dependencies for running the optimizer
- this.capabilitiesFinder =
- new CachedFinder(
- (DataService) this.env.findService(DQPServiceNames.DATA_SERVICE),
- requestMsg,
- workContext);
+ this.capabilitiesFinder = new CachedFinder(this.connectorManagerRepo, workContext.getVDB());
- MetadataService metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
- if(metadataService == null){
- //should not come here. Per defect 15087,
- //in a rare situation it might be null
- //try to get it again
- metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
- if(metadataService == null){
- String msg = DQPPlugin.Util.getString("Request.MetadataServiceIsNull"); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
- }
- }
- metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
+ metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
+
if (metadata == null) {
throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", this.vdbName, this.vdbVersion)); //$NON-NLS-1$
}
@@ -211,9 +190,9 @@
this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
// Check for multi-source models and further wrap the metadata interface
- List multiSourceModelList = vdbService.getMultiSourceModels(this.vdbName, this.vdbVersion);
+ Set<String> multiSourceModelList = workContext.getVDB().getMultiSourceModelNames();
if(multiSourceModelList != null && multiSourceModelList.size() > 0) {
- this.multiSourceModels = new HashSet(multiSourceModelList);
+ this.multiSourceModels = multiSourceModelList;
this.metadata = new MultiSourceMetadataWrapper(this.metadata, this.multiSourceModels);
}
}
@@ -236,8 +215,9 @@
StoredProcedure proc = (StoredProcedure)userCommand;
returnsResultSet = proc.returnsResultSet();
}
- if (this.requestMsg.getRequireResultSet() != null && this.requestMsg.getRequireResultSet() != returnsResultSet) {
- throw new QueryValidatorException(DQPPlugin.Util.getString(this.requestMsg.getRequireResultSet()?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
+ if ((this.requestMsg.getResultsMode() == ResultsMode.UPDATECOUNT && !returnsUpdateCount)
+ || (this.requestMsg.getResultsMode() == ResultsMode.RESULTSET && !returnsResultSet)) {
+ throw new QueryValidatorException(DQPPlugin.Util.getString(this.requestMsg.getResultsMode()==ResultsMode.RESULTSET?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
}
// Create command context, used in rewriting, planning, and processing
@@ -268,13 +248,14 @@
if (multiSourceModels != null) {
MultiSourcePlanToProcessConverter modifier = new MultiSourcePlanToProcessConverter(
metadata, idGenerator, analysisRecord, capabilitiesFinder,
- multiSourceModels, vdbName, vdbService, vdbVersion, context);
+ multiSourceModels, workContext, context);
context.setPlanToProcessConverter(modifier);
}
- context.setSecurityFunctionEvaluator((SecurityFunctionEvaluator)this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE));
+ context.setSecurityFunctionEvaluator(this.authService);
context.setTempTableStore(tempTableStore);
context.setQueryProcessorFactory(this);
+ context.setMetadata(this.metadata);
}
protected void checkReferences(List<Reference> references) throws QueryValidatorException {
@@ -309,7 +290,7 @@
private Command parseCommand() throws QueryParserException {
String[] commands = requestMsg.getCommands();
ParseInfo parseInfo = createParseInfo(this.requestMsg);
- if (!requestMsg.isBatchedUpdate()) {
+ if (requestMsg.isPreparedStatement() || requestMsg.isCallableStatement() || !requestMsg.isBatchedUpdate()) {
String commandStr = commands[0];
return QueryParser.getQueryParser().parseCommand(commandStr, parseInfo);
}
@@ -352,9 +333,9 @@
if (tc != null){
Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
}
-
- if (tc == null || !tc.isInTransaction()) {
- //if not under a transaction
+
+ // If local or global transaction is not started.
+ if (tc == null || tc.getXid() == null) {
boolean startAutoWrapTxn = false;
@@ -376,8 +357,6 @@
tc = transactionService.start(tc);
} catch (XATransactionException err) {
throw new MetaMatrixComponentException(err);
- } catch (SystemException err) {
- throw new MetaMatrixComponentException(err);
}
}
}
@@ -592,13 +571,9 @@
return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
}
- protected void validateAccess(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
- // Validate the query (may only want to validate entitlement)
- AuthorizationService authSvc = (AuthorizationService) this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE);
-
+ protected void validateAccess(Command command) throws QueryValidatorException, MetaMatrixComponentException {
// See if entitlement checking is turned on
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.workContext.getConnectionID(), authSvc, this.vdbService, this.vdbName, this.vdbVersion);
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.authService, this.workContext.getVDB());
validateWithVisitor(visitor, this.metadata, command);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -33,10 +33,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-
-import org.teiid.connector.xa.api.TransactionContext;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -60,6 +56,7 @@
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.service.CommandLogMessage;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.analysis.AnalysisRecord;
@@ -85,7 +82,7 @@
/*
* Obtained at construction time
*/
- private final DQPCore dqpCore;
+ protected final DQPCore dqpCore;
final RequestMessage requestMsg;
final RequestID requestID;
private Request request; //provides the processing plan, held on a temporary basis
@@ -123,11 +120,14 @@
private TupleBatch savedBatch;
private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
+ /**The time when command begins processing on the server.*/
+ private long processingTimestamp = System.currentTimeMillis();
+
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
this.requestMsg = requestMsg;
this.requestID = requestID;
this.processorTimeslice = dqpCore.getProcessorTimeSlice();
- this.transactionService = dqpCore.getTransactionServiceDirect();
+ this.transactionService = dqpCore.getTransactionService();
this.dqpCore = dqpCore;
this.request = request;
this.dqpWorkContext = workContext;
@@ -221,11 +221,12 @@
this.processingException = new IllegalStateException("Request is already closed"); //$NON-NLS-1$
}
sendError();
- }
+ }
+ DQPWorkContext.releaseWorkContext();
}
}
- protected void processMore() throws SystemException, BlockedException, MetaMatrixCoreException {
+ protected void processMore() throws BlockedException, MetaMatrixCoreException {
if (this.processor != null) {
this.processor.getContext().setTimeSliceEnd(System.currentTimeMillis() + this.processorTimeslice);
}
@@ -315,9 +316,7 @@
this.transactionService.rollback(transactionContext);
} catch (XATransactionException e1) {
LogManager.logWarning(LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
- } catch (SystemException err) {
- LogManager.logWarning(LogConstants.CTX_DQP, err, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
- }
+ }
}
isClosed = true;
@@ -361,7 +360,7 @@
resultsBuffer.setForwardOnly(isForwardOnly());
analysisRecord = request.analysisRecord;
transactionContext = request.transactionContext;
- if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
+ if (this.transactionContext != null && this.transactionContext.getXid() != null) {
this.transactionState = TransactionState.ACTIVE;
}
if (analysisRecord.recordQueryPlan()) {
@@ -570,9 +569,8 @@
if (transactionService != null) {
try {
transactionService.cancelTransactions(requestID.getConnectionID(), true);
- } catch (InvalidTransactionException err) {
+ } catch (XATransactionException err) {
LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
- } catch (SystemException err) {
throw new MetaMatrixComponentException(err);
}
}
@@ -643,8 +641,8 @@
*/
private void logCommandError() {
String transactionID = null;
- if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
- transactionID = this.transactionContext.getTxnID();
+ if (this.transactionContext != null && this.transactionContext.getXid() != null) {
+ transactionID = this.transactionContext.getXid().toString();
}
CommandLogMessage message = new CommandLogMessage(System.currentTimeMillis(), requestID.toString(), transactionID == null ? null : transactionID, requestID.getConnectionID(), dqpWorkContext.getUserName(), dqpWorkContext.getVdbName(), dqpWorkContext.getVdbVersion(), -1, false, true);
LogManager.log(MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
@@ -672,9 +670,6 @@
return transactionContext;
}
- void setTransactionContext(TransactionContext transactionContext) {
- this.transactionContext = transactionContext;
- }
Collection<DataTierTupleSource> getConnectorRequests() {
return new LinkedList<DataTierTupleSource>(this.connectorInfo.values());
@@ -696,5 +691,23 @@
public DQPWorkContext getDqpWorkContext() {
return dqpWorkContext;
}
-
+
+ public long getProcessingTimestamp() {
+ return processingTimestamp;
+ }
+
+ @Override
+ protected boolean assosiateSecurityContext() {
+ if (dqpWorkContext.getSubject() != null) {
+ return dqpCore.getSecurityHelper().assosiateSecurityContext(dqpWorkContext.getSecurityDomain(),dqpWorkContext.getSecurityContext());
+ }
+ return false;
+ }
+
+ @Override
+ protected void clearSecurityContext() {
+ if (dqpWorkContext.getSubject() != null) {
+ dqpCore.getSecurityHelper().clearSecurityContext(dqpWorkContext.getSecurityDomain());
+ }
+ }
}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import com.metamatrix.admin.objects.MMQueueWorkerPool;
-import com.metamatrix.common.queue.WorkerPoolStats;
-
-public class Util {
-
- public static MMQueueWorkerPool convertStats(final WorkerPoolStats src, String ... identifier) {
- MMQueueWorkerPool pool = new MMQueueWorkerPool(identifier);
- pool.setRegistered(true);
- pool.setQueued(src.getQueued());
- pool.setThreads(src.getActiveThreads());
- pool.setHighestQueued(src.getHighestQueued());
- pool.setHighestThreads(src.getHighestActiveThreads());
- pool.setTotalCompleted(src.getTotalCompleted());
- pool.setTotalSubmitted(src.getTotalSubmitted());
- return pool;
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,10 +23,10 @@
package org.teiid.dqp.internal.process.multisource;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -41,9 +41,9 @@
*/
public class MultiSourceMetadataWrapper extends BasicQueryMetadataWrapper {
- private Collection multiSourceModels;
+ private Set<String> multiSourceModels;
- public MultiSourceMetadataWrapper(QueryMetadataInterface actualMetadata, Collection multiSourceModels){
+ public MultiSourceMetadataWrapper(QueryMetadataInterface actualMetadata, Set<String> multiSourceModels){
super(actualMetadata);
this.multiSourceModels = multiSourceModels;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,16 +23,18 @@
package org.teiid.dqp.internal.process.multisource;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.CriteriaEvaluationException;
import com.metamatrix.api.exception.query.QueryPlannerException;
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -51,19 +53,15 @@
public class MultiSourcePlanToProcessConverter extends PlanToProcessConverter {
private Set<String> multiSourceModels;
- private String vdbName;
- private String vdbVersion;
- private VDBService vdbService;
+ private DQPWorkContext workContext;
public MultiSourcePlanToProcessConverter(QueryMetadataInterface metadata,
IDGenerator idGenerator, AnalysisRecord analysisRecord,
CapabilitiesFinder capFinder, Set<String> multiSourceModels,
- String vdbName, VDBService vdbService, String vdbVersion, CommandContext context) {
+ DQPWorkContext workContext, CommandContext context) {
super(metadata, idGenerator, analysisRecord, capFinder);
this.multiSourceModels = multiSourceModels;
- this.vdbName = vdbName;
- this.vdbService = vdbService;
- this.vdbVersion = vdbVersion;
+ this.workContext = workContext;
}
protected RelationalNode convertNode(PlanNode planNode) throws QueryPlannerException, MetaMatrixComponentException {
@@ -86,24 +84,23 @@
if(!this.multiSourceModels.contains(modelName)) {
return accessNode;
}
- List bindings = vdbService.getConnectorBindingNames(vdbName, vdbVersion, modelName);
- List<AccessNode> accessNodes = new ArrayList<AccessNode>(bindings.size());
- Iterator bindingIter = bindings.iterator();
- while(bindingIter.hasNext()) {
- String bindingUUID = (String) bindingIter.next();
- String bindingName = vdbService.getConnectorName(bindingUUID);
+ VDBMetaData vdb = workContext.getVDB();
+ ModelMetaData model = vdb.getModel(modelName);
+ List<AccessNode> accessNodes = new ArrayList<AccessNode>();
+
+ for(String sourceName:model.getSourceNames()) {
// Create a new cloned version of the access node and set it's model name to be the bindingUUID
AccessNode instanceNode = (AccessNode) accessNode.clone();
instanceNode.setID(getID());
- instanceNode.setConnectorBindingId(bindingUUID);
+ instanceNode.setConnectorBindingId(model.getSourceJndiName(sourceName));
// Modify the command to pull the instance column and evaluate the criteria
Command command = (Command)instanceNode.getCommand().clone();
// Replace all multi-source elements with the source name
- DeepPreOrderNavigator.doVisit(command, new MultiSourceElementReplacementVisitor(bindingName));
+ DeepPreOrderNavigator.doVisit(command, new MultiSourceElementReplacementVisitor(sourceName));
// Rewrite the command now that criteria may have been simplified
try {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,15 +31,16 @@
import java.util.List;
import java.util.Map;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.resolver.util.ResolverUtil;
@@ -59,23 +60,12 @@
public class AuthorizationValidationVisitor extends AbstractValidationVisitor {
- private String connectionID;
private AuthorizationService authInterface;
- private VDBService vdbService;
- private String vdbName;
- private String vdbVersion;
+ private VDBMetaData vdb;
- public AuthorizationValidationVisitor(
- String connectionID,
- AuthorizationService authInterface,
- VDBService vdbService,
- String vdbName,
- String vdbVersion) {
- this.connectionID = connectionID;
+ public AuthorizationValidationVisitor(AuthorizationService authInterface, VDBMetaData vdb) {
this.authInterface = authInterface;
- this.vdbService = vdbService;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
+ this.vdb = vdb;
}
// ############### Visitor methods for language objects ##################
@@ -281,7 +271,7 @@
if (!nameToSymbolMap.isEmpty()) {
try {
- Collection inaccessibleResources = this.authInterface.getInaccessibleResources(connectionID, actionCode, nameToSymbolMap.keySet(), auditContext);
+ Collection inaccessibleResources = this.authInterface.getInaccessibleResources(actionCode, nameToSymbolMap.keySet(), auditContext);
if(inaccessibleResources.size() > 0) {
List inaccessibleSymbols = new ArrayList(inaccessibleResources.size());
Iterator nameIter = inaccessibleResources.iterator();
@@ -294,7 +284,7 @@
// is not authorized in the exception message
handleValidationError(
- DQPPlugin.Util.getString("ERR.018.005.0095", new Object[]{this.connectionID, getActionLabel(actionCode)}), //$NON-NLS-1$
+ DQPPlugin.Util.getString("ERR.018.005.0095", new Object[]{DQPWorkContext.getWorkContext().getConnectionID(), getActionLabel(actionCode)}), //$NON-NLS-1$
inaccessibleSymbols);
}
} catch(MetaMatrixComponentException e) {
@@ -310,8 +300,8 @@
}
try {
String modelName = getMetadata().getFullName(modelID);
- int visibility = this.vdbService.getModelVisibility(this.vdbName, this.vdbVersion, modelName);
- if(visibility != ModelInfo.PUBLIC) {
+ ModelMetaData model = vdb.getModel(modelName);
+ if(!model.isVisible()) {
handleValidationError(DQPPlugin.Util.getString("ERR.018.005.0088", getMetadata().getFullName(group.getMetadataID()))); //$NON-NLS-1$
}
} catch (MetaMatrixComponentException e) {
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,38 @@
+/*
+ * 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.dqp.internal.transaction;
+
+import javax.resource.spi.XATerminator;
+
+public class ContainerTransactionProvider implements TransactionProvider {
+ XATerminator terminator;
+
+ public ContainerTransactionProvider(XATerminator terminator) {
+ this.terminator = terminator;
+ }
+
+ @Override
+ public XATerminator getXATerminator() {
+ return terminator;
+ }
+}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.transaction;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.transaction.Transaction;
-import javax.transaction.xa.XAResource;
-
-import org.teiid.connector.xa.api.TransactionContext;
-
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.DQPPlugin;
-
-class TransactionContextImpl implements
- TransactionContext, Externalizable {
-
- private String threadId;
- private MMXid xid;
- private String txnID;
- private Transaction transaction;
- private Scope transactionType = Scope.NONE;
- private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
- private int transactionTimeout = -1;
- private Set<XAResource> xaResources = Collections.newSetFromMap(new ConcurrentHashMap<XAResource, Boolean>());
- private long creationTime;
-
- public TransactionContextImpl() {}
-
- public boolean isInTransaction() {
- return getTransaction() != null;
- }
-
- /**
- * @param transaction
- * The transaction to set.
- */
- void setTransaction(Transaction transaction, String id) {
- this.transaction = transaction;
- this.txnID = id;
- this.creationTime = System.currentTimeMillis();
- }
-
- long getCreationTime() {
- return creationTime;
- }
-
- /**
- * @return Returns the transaction.
- */
- public Transaction getTransaction() {
- return transaction;
- }
-
- /**
- * @return Returns the txnID.
- */
- public String getTxnID() {
- return this.txnID;
- }
-
- void setTransactionType(Scope transactionType) {
- this.transactionType = transactionType;
- }
-
- public Scope getTransactionType() {
- return transactionType;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer sb = new StringBuffer();
- this.buildString(sb);
- return sb.toString();
- }
-
- private void buildString(StringBuffer sb) {
- sb.append("TxnContext: ").append(this.txnID); //$NON-NLS-1$
- }
-
- void setThreadId(String threadId) {
- this.threadId = threadId;
- }
-
- String getThreadId() {
- return threadId;
- }
-
- public MMXid getXid() {
- return this.xid;
- }
-
- void setXid(MMXid xid) {
- this.xid = xid;
- }
-
- Set<String> getSuspendedBy() {
- return this.suspendedBy;
- }
-
- /**
- * @see org.teiid.connector.xa.api.TransactionContext#getTransactionTimeout()
- */
- int getTransactionTimeout() {
- return this.transactionTimeout;
- }
-
- void setTransactionTimeout(int transactionTimeout) {
- this.transactionTimeout = transactionTimeout;
- }
-
- void addXAResource(XAResource resource) {
- this.xaResources.add(resource);
- }
-
- Set<XAResource> getXAResources() {
- return xaResources;
- }
-
- /**
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
-
- }
-
- /**
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException {
- if (this.transaction != null) {
- throw new MetaMatrixRuntimeException(DQPPlugin.Util.getString("TransactionContextImpl.remote_not_supported")); //$NON-NLS-1$
- }
- }
-
-}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,43 +22,11 @@
package org.teiid.dqp.internal.transaction;
-import java.sql.SQLException;
-import java.util.Properties;
-
import javax.resource.spi.XATerminator;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.common.xa.XATransactionException;
-
public interface TransactionProvider {
- public interface XAConnectionSource {
-
- XAResource getXAResource() throws SQLException;
-
- void close();
-
- }
-
- void init(Properties props) throws XATransactionException;
-
XATerminator getXATerminator();
- TransactionManager getTransactionManager();
-
- Transaction importTransaction(MMXid xid, int timeout) throws XAException, SystemException;
-
- String getTransactionID(Transaction tx);
-
- void shutdown();
-
- void registerRecoverySource(String name, XAConnectionSource resource);
-
- void removeRecoverySource(String name);
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,42 +25,26 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
+import javax.resource.NotSupportedException;
import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
-import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
+import org.teiid.adminapi.impl.TransactionMetadata;
-import com.metamatrix.admin.objects.MMAdminObject;
-import com.metamatrix.admin.objects.TransactionImpl;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
public class TransactionServerImpl implements TransactionService {
@@ -68,15 +52,15 @@
private static class TransactionMapping {
// (connection -> transaction for global and local)
- private Map<String, TransactionContextImpl> threadToTransactionContext = new HashMap<String, TransactionContextImpl>();
- // (MMXid -> global transactions keyed)
- private Map<MMXid, TransactionContextImpl> xidToTransactionContext = new HashMap<MMXid, TransactionContextImpl>();
+ private Map<String, TransactionContext> threadToTransactionContext = new HashMap<String, TransactionContext>();
+ // (MMXid -> global transactions keyed)
+ private Map<Integer, TransactionContext> xidToTransactionContext = new HashMap<Integer, TransactionContext>();
- public synchronized TransactionContextImpl getOrCreateTransactionContext(String threadId) {
- TransactionContextImpl tc = threadToTransactionContext.get(threadId);
+ public synchronized TransactionContext getOrCreateTransactionContext(String threadId) {
+ TransactionContext tc = threadToTransactionContext.get(threadId);
if (tc == null) {
- tc = new TransactionContextImpl();
+ tc = new TransactionContext();
tc.setThreadId(threadId);
threadToTransactionContext.put(threadId, tc);
}
@@ -84,34 +68,34 @@
return tc;
}
- public synchronized TransactionContextImpl getTransactionContext(String threadId) {
+ public synchronized TransactionContext getTransactionContext(String threadId) {
return threadToTransactionContext.get(threadId);
}
- public synchronized TransactionContextImpl getTransactionContext(MMXid xid) {
- return xidToTransactionContext.get(xid);
+ public synchronized TransactionContext getTransactionContext(MMXid xid) {
+ return xidToTransactionContext.get(xid.hashCode());
}
-
- public synchronized TransactionContextImpl removeTransactionContext(String threadId) {
+
+ public synchronized TransactionContext getTransactionContext(int hash) {
+ return xidToTransactionContext.get(hash);
+ }
+
+ public synchronized TransactionContext removeTransactionContext(String threadId) {
return threadToTransactionContext.remove(threadId);
}
- public synchronized void removeTransactionContext(TransactionContextImpl tc) {
+ public synchronized void removeTransactionContext(TransactionContext tc) {
if (tc.getXid() != null) {
- this.xidToTransactionContext.remove(tc.getXid());
+ this.xidToTransactionContext.remove(tc.getXid().hashCode());
}
if (tc.getThreadId() != null) {
this.threadToTransactionContext.remove(tc.getThreadId());
}
}
- public synchronized void removeTransactionContext(MMXid xid) {
- this.xidToTransactionContext.remove(xid);
- }
-
- public synchronized void addTransactionContext(TransactionContextImpl tc) {
+ public synchronized void addTransactionContext(TransactionContext tc) {
if (tc.getXid() != null) {
- this.xidToTransactionContext.put(tc.getXid(), tc);
+ this.xidToTransactionContext.put(tc.getXid().hashCode(), tc);
}
if (tc.getThreadId() != null) {
this.threadToTransactionContext.put(tc.getThreadId(), tc);
@@ -123,6 +107,7 @@
private TransactionProvider provider;
private String processName = "embedded"; //$NON-NLS-1$
+ private XidFactory xidFactory;
public TransactionServerImpl() {
}
@@ -135,148 +120,131 @@
this.provider = theProvider;
}
- @SuppressWarnings("finally")
- public int prepare(final String threadId,
- MMXid xid) throws XATransactionException {
- TransactionContextImpl impl = checkXAState(threadId, xid, true, false);
- if (!impl.getSuspendedBy().isEmpty()) {
+ /**
+ * Global Transaction
+ */
+ public int prepare(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException {
+ TransactionContext tc = checkXAState(threadId, xid, true, false);
+ if (!tc.getSuspendedBy().isEmpty()) {
throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.suspended_exist", xid)); //$NON-NLS-1$
+ }
+
+ if (tc.shouldRollback()) {
+ throw new XATransactionException(XAException.XAER_RMERR, DQPPlugin.Util.getString("TransactionServer.rollback_set", xid));
}
+
+ // In the container this pass though
+ if (singleTM) {
+ return XAResource.XA_RDONLY;
+ }
+
try {
- getTransactionManager().resume(impl.getTransaction());
- try {
- endAssociations(impl);
- } finally {
- return this.provider.getXATerminator().prepare(xid);
- }
- } catch (XAException err) {
- throw new XATransactionException(err);
- } catch (SystemException err) {
- throw new XATransactionException(err);
- } catch (InvalidTransactionException err) {
- throw new XATransactionException(err);
- } catch (IllegalStateException err) {
- throw new XATransactionException(err);
- } finally {
- try {
- getTransactionManager().suspend();
- } catch (SystemException err) {
- throw new XATransactionException(err);
- }
- }
- }
-
- private void endAssociations(TransactionContextImpl impl) throws XATransactionException, SystemException {
- Transaction tx = getTransactionManager().getTransaction();
- Assertion.isNotNull(tx);
- for (XAResource resource : impl.getXAResources()) {
- if (!tx.delistResource(resource, XAResource.TMSUCCESS)) {
- throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.failed_to_delist")); //$NON-NLS-1$
- }
+ return this.provider.getXATerminator().prepare(tc.getXid());
+ } catch (XAException e) {
+ throw new XATransactionException(e);
}
- impl.getXAResources().clear();
}
-
- public void commit(final String threadId,
- MMXid xid,
- boolean onePhase) throws XATransactionException {
-
- TransactionContextImpl tc = checkXAState(threadId, xid, true, false);
- try {
- if (onePhase && prepare(threadId, xid) == XAResource.XA_RDONLY) {
- return;
- }
- // TODO: for one phase, MM needs to check if there are multiple resources involved
- // or single, in its txn, if it has single it can use onePhase.
- // Also, Arjuna has bug JBTM-457, where on single phase commit, they do not call the synchronization
- // when they fix the bug, we can re-write next couple lines differently to make use of the
- // optimization of onePhase.
- this.provider.getXATerminator().commit(xid, false);
- } catch (XAException err) {
- throw new XATransactionException(err);
+
+ /**
+ * Global Transaction
+ */
+ public void commit(final String threadId, MMXid xid, boolean onePhase, boolean singleTM) throws XATransactionException {
+ TransactionContext tc = checkXAState(threadId, xid, true, false);
+ try {
+ // In the case of single TM, the container directly commits the sources.
+ if (!singleTM) {
+ // In the case of onePhase containers call commit directly. If Teiid is also one phase let it pass through,
+ // otherwise force the prepare.
+ boolean singlePhase = tc.isOnePhase();
+ if (onePhase && !singlePhase) {
+ prepare(threadId, xid, singleTM);
+ }
+ this.provider.getXATerminator().commit(tc.getXid(), singlePhase);
+ }
+ } catch (XAException e) {
+ throw new XATransactionException(e);
} finally {
- this.transactions.removeTransactionContext(tc);
- }
+ this.transactions.removeTransactionContext(tc);
+ }
}
-
- public void rollback(final String threadId,
- MMXid xid) throws XATransactionException {
- TransactionContextImpl tc = checkXAState(threadId, xid, true, false);
- try {
- this.provider.getXATerminator().rollback(xid);
- } catch (XAException err) {
- throw new XATransactionException(err);
+
+ /**
+ * Global Transaction
+ */
+ public void rollback(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException {
+ TransactionContext tc = checkXAState(threadId, xid, true, false);
+ try {
+ // In the case of single TM, the container directly roll backs the sources.
+ if (!singleTM) {
+ this.provider.getXATerminator().rollback(tc.getXid());
+ }
+ } catch (XAException e) {
+ throw new XATransactionException(e);
} finally {
- this.transactions.removeTransactionContext(tc);
- }
+ this.transactions.removeTransactionContext(tc);
+ }
}
- public Xid[] recover(int flag) throws XATransactionException {
- try {
- return this.provider.getXATerminator().recover(flag);
- } catch (XAException err) {
- throw new XATransactionException(err);
- }
+ /**
+ * Global Transaction
+ */
+ public Xid[] recover(int flag, boolean singleTM) throws XATransactionException {
+ // In case of single TM, container knows this list.
+ if (singleTM) {
+ return new Xid[0];
+ }
+
+ try {
+ return this.provider.getXATerminator().recover(flag);
+ } catch (XAException e) {
+ throw new XATransactionException(e);
+ }
}
- public void forget(final String threadId,
- MMXid xid) throws XATransactionException {
+ /**
+ * Global Transaction
+ */
+ public void forget(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException {
+ TransactionContext tc = checkXAState(threadId, xid, true, false);
try {
+ if (singleTM) {
+ return;
+ }
this.provider.getXATerminator().forget(xid);
} catch (XAException err) {
throw new XATransactionException(err);
} finally {
- this.transactions.removeTransactionContext(xid);
+ this.transactions.removeTransactionContext(tc);
}
}
- public void start(final String threadId,
- final MMXid xid,
- int flags,
- int timeout) throws XATransactionException {
+ /**
+ * Global Transaction
+ */
+ public void start(final String threadId, final MMXid xid, int flags, int timeout, boolean singleTM) throws XATransactionException {
- TransactionContextImpl tc = null;
+ TransactionContext tc = null;
switch (flags) {
case XAResource.TMNOFLAGS: {
- checkXAState(threadId, xid, false, false);
- tc = transactions.getOrCreateTransactionContext(threadId);
- if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
- throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
- }
- Transaction tx;
try {
- tx = this.provider.importTransaction(xid, timeout);
- } catch (XAException err) {
- throw new XATransactionException(err);
- } catch (SystemException err) {
- throw new XATransactionException(err);
- }
-
- try {
- tx.registerSynchronization(new Synchronization() {
-
- public void afterCompletion(int arg0) {
- transactions.removeTransactionContext(xid);
- }
-
- public void beforeCompletion() {
- }});
- } catch (RollbackException err) {
- throw new XATransactionException(err, XAException.XA_RBROLLBACK);
- } catch (SystemException err) {
- throw new XATransactionException(err, XAException.XAER_RMERR);
- }
- tc.setTransaction(tx, provider.getTransactionID(tx));
- tc.setTransactionTimeout(timeout);
- tc.setXid(xid);
- tc.setTransactionType(TransactionContext.Scope.GLOBAL);
+ checkXAState(threadId, xid, false, false);
+ tc = transactions.getOrCreateTransactionContext(threadId);
+ if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
+ throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+ }
+ tc.setTransactionTimeout(timeout);
+ tc.setXid(xid);
+ tc.setTransactionType(TransactionContext.Scope.GLOBAL);
+ } catch (NotSupportedException e) {
+ throw new XATransactionException(XAException.XAER_INVAL, e.getMessage()); //$NON-NLS-1$
+ }
break;
}
case XAResource.TMJOIN:
case XAResource.TMRESUME: {
tc = checkXAState(threadId, xid, true, false);
- TransactionContextImpl threadContext = transactions.getOrCreateTransactionContext(threadId);
+ TransactionContext threadContext = transactions.getOrCreateTransactionContext(threadId);
if (threadContext.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
@@ -294,10 +262,11 @@
transactions.addTransactionContext(tc);
}
- public void end(final String threadId,
- MMXid xid,
- int flags) throws XATransactionException {
- TransactionContextImpl tc = checkXAState(threadId, xid, true, true);
+ /**
+ * Global Transaction
+ */
+ public void end(final String threadId, MMXid xid, int flags, boolean singleTM) throws XATransactionException {
+ TransactionContext tc = checkXAState(threadId, xid, true, true);
try {
switch (flags) {
case XAResource.TMSUSPEND: {
@@ -309,11 +278,7 @@
break;
}
case XAResource.TMFAIL: {
- try {
- tc.getTransaction().setRollbackOnly();
- } catch (SystemException err) {
- throw new XATransactionException(err, XAException.XAER_RMERR);
- }
+ tc.setRollbackOnly();
break;
}
default:
@@ -325,10 +290,8 @@
}
}
- private TransactionContextImpl checkXAState(final String threadId,
- final MMXid xid,
- boolean transactionExpected, boolean threadBound) throws XATransactionException {
- TransactionContextImpl tc = transactions.getTransactionContext(xid);
+ private TransactionContext checkXAState(final String threadId, final MMXid xid, boolean transactionExpected, boolean threadBound) throws XATransactionException {
+ TransactionContext tc = transactions.getTransactionContext(xid);
if (transactionExpected && tc == null) {
throw new XATransactionException(XAException.XAER_NOTA, DQPPlugin.Util.getString("TransactionServer.no_global_transaction", xid)); //$NON-NLS-1$
@@ -356,23 +319,18 @@
return tc;
}
- private TransactionContextImpl checkLocalTransactionState(String threadId,
- boolean transactionExpected) throws NotSupportedException,
- SystemException,
- InvalidTransactionException {
+ private TransactionContext checkLocalTransactionState(String threadId, boolean transactionExpected)
+ throws InvalidTransactionException {
- final TransactionContextImpl tc = transactions.getOrCreateTransactionContext(threadId);
+ final TransactionContext tc = transactions.getOrCreateTransactionContext(threadId);
- final TransactionManager tm = getTransactionManager();
-
if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
if (tc.getTransactionType() != TransactionContext.Scope.LOCAL) {
- throw new NotSupportedException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+ throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
if (!transactionExpected) {
- throw new NotSupportedException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+ throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
- tm.resume(tc.getTransaction());
} else if (transactionExpected) {
throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.no_transaction", threadId)); //$NON-NLS-1$
}
@@ -380,191 +338,146 @@
return tc;
}
- public TransactionContext begin(String threadId) throws XATransactionException, SystemException {
+ /**
+ * Local Transaction
+ */
+ public TransactionContext begin(String threadId) throws XATransactionException {
try {
- TransactionContextImpl tc = checkLocalTransactionState(threadId, false);
- final TransactionManager tm = getTransactionManager();
- tm.begin();
- Transaction tx = tm.suspend();
- tc.setTransaction(tx, provider.getTransactionID(tx));
+ TransactionContext tc = checkLocalTransactionState(threadId, false);
+ tc.setXid(this.xidFactory.createXid());
+ tc.setCreationTime(System.currentTimeMillis());
tc.setTransactionType(TransactionContext.Scope.LOCAL);
return tc;
} catch (InvalidTransactionException err) {
throw new XATransactionException(err);
- } catch (NotSupportedException err) {
- throw new XATransactionException(err);
- }
+ }
}
- public void commit(String threadId) throws XATransactionException, SystemException {
- TransactionContextImpl tc;
+ /**
+ * Local Transaction
+ */
+ public void commit(String threadId) throws XATransactionException {
+ TransactionContext tc;
try {
tc = checkLocalTransactionState(threadId, true);
} catch (InvalidTransactionException err) {
throw new XATransactionException(err);
- } catch (NotSupportedException err) {
- throw new XATransactionException(err);
}
- final TransactionManager tm = getTransactionManager();
+
+ if (tc.shouldRollback()) {
+ rollback(threadId);
+ }
try {
- try {
- endAssociations(tc);
- } finally {
- tm.commit();
+ if (tc.isInTransaction()) {
+ directCommit(tc);
}
- } catch (IllegalStateException err) {
- throw new XATransactionException(err);
- } catch (RollbackException err) {
- throw new XATransactionException(err);
- } catch (HeuristicMixedException err) {
- throw new XATransactionException(err);
- } catch (HeuristicRollbackException err) {
- throw new XATransactionException(err);
+ } catch (XAException e) {
+ throw new XATransactionException(e);
} finally {
transactions.removeTransactionContext(tc);
}
-
}
- public void rollback(String threadId) throws XATransactionException, SystemException {
- TransactionContextImpl tc;
+ /**
+ * Local Transaction
+ */
+ public void rollback(String threadId) throws XATransactionException {
+ TransactionContext tc;
try {
tc = checkLocalTransactionState(threadId, true);
} catch (InvalidTransactionException err) {
throw new XATransactionException(err);
- } catch (NotSupportedException err) {
- throw new XATransactionException(err);
}
- final TransactionManager tm = getTransactionManager();
try {
- tm.rollback();
- } catch (IllegalStateException err) {
- throw new XATransactionException(err);
+ if (tc.isInTransaction()) {
+ this.provider.getXATerminator().rollback(tc.getXid());
+ }
+ } catch (XAException e) {
+ throw new XATransactionException(e);
} finally {
transactions.removeTransactionContext(tc);
}
}
- public TransactionManager getTransactionManager() {
- return provider.getTransactionManager();
- }
public TransactionContext getOrCreateTransactionContext(String threadId) {
return transactions.getOrCreateTransactionContext(threadId);
}
- // request level transaction
- public TransactionContext start(TransactionContext context) throws XATransactionException, SystemException {
- TransactionManager tm = getTransactionManager();
-
- TransactionContextImpl tc = (TransactionContextImpl)context;
-
- try {
- if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
- throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
- }
- tm.begin();
- Transaction tx = tm.suspend();
-
- tc.setTransaction(tx, provider.getTransactionID(tx));
- tc.setTransactionType(TransactionContext.Scope.REQUEST);
- return tc;
- } catch (NotSupportedException e) {
- throw new XATransactionException(e);
+ /**
+ * Request level transaction
+ */
+ public TransactionContext start(TransactionContext context) throws XATransactionException{
+ if (context.getTransactionType() != TransactionContext.Scope.NONE) {
+ throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
+ context.setXid(this.xidFactory.createXid());
+ context.setCreationTime(System.currentTimeMillis());
+ context.setTransactionType(TransactionContext.Scope.REQUEST);
+ return context;
}
- public TransactionContext commit(TransactionContext context) throws XATransactionException, SystemException {
+ /**
+ * Request level transaction
+ */
+ public TransactionContext commit(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
- TransactionContextImpl tc = (TransactionContextImpl)context;
//commit may be called multiple times by the processworker, if this is a subsequent call, then the current
//context will not be active
- TransactionContextImpl currentContext = transactions.getTransactionContext(tc.getThreadId());
- if (currentContext == null || currentContext.getTransactionType() == TransactionContext.Scope.NONE) {
- return currentContext;
+ TransactionContext tc = transactions.getTransactionContext(context.getThreadId());
+ if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
+ return tc;
}
- TransactionManager tm = getTransactionManager();
+ Assertion.assertTrue(!tc.shouldRollback());
+
try {
- tm.resume(context.getTransaction());
- try {
- endAssociations(tc);
- } finally {
- tm.commit();
- }
- } catch (InvalidTransactionException e) {
+ if (tc.isInTransaction()) {
+ directCommit(tc);
+ }
+ } catch (XAException e) {
throw new XATransactionException(e);
- } catch (RollbackException e) {
- throw new XATransactionException(e);
- } catch (HeuristicMixedException e) {
- throw new XATransactionException(e);
- } catch (HeuristicRollbackException e) {
- throw new XATransactionException(e);
} finally {
- transactions.removeTransactionContext(tc);
+ transactions.removeTransactionContext(context);
}
return context;
}
- public TransactionContext rollback(TransactionContext context) throws XATransactionException, SystemException {
+ private void directCommit(TransactionContext tc) throws XAException {
+ boolean commit = true;
+ boolean onePhase = tc.isOnePhase();
+ if (!onePhase) {
+ int prepare = this.provider.getXATerminator().prepare(tc.getXid());
+ commit = (prepare == XAResource.XA_OK);
+ }
+
+ if (commit) {
+ this.provider.getXATerminator().commit(tc.getXid(), onePhase);
+ }
+ }
+
+ /**
+ * Request level transaction
+ */
+ public TransactionContext rollback(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
- TransactionManager tm = getTransactionManager();
try {
- tm.resume(context.getTransaction());
- tm.rollback();
- } catch (InvalidTransactionException e) {
+ this.provider.getXATerminator().rollback(context.getXid());
+ } catch (XAException e) {
throw new XATransactionException(e);
} finally {
- transactions.removeTransactionContext((TransactionContextImpl)context);
- }
- return context;
- }
-
- public TransactionContext enlist(TransactionContext context,
- XAResource resource) throws XATransactionException {
- TransactionManager tm = getTransactionManager();
- TransactionContextImpl tc = (TransactionContextImpl)context;
-
- try {
- if (tc.getTransactionTimeout() > 0 && tc.getTransactionTimeout() != resource.getTransactionTimeout()) {
- resource.setTransactionTimeout(tc.getTransactionTimeout());
- }
- Transaction tx = tm.getTransaction();
- if (tx == null) {
- tm.resume(context.getTransaction());
- } else if (!tx.equals(context.getTransaction())) {
- throw new XATransactionException(context.getTransaction() + " != " + tx); //$NON-NLS-1$
- }
-
- if (!context.getTransaction().enlistResource(resource)) {
- context.getTransaction().delistResource(resource, XAResource.TMFAIL);
- throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.failed_to_enlist")); //$NON-NLS-1$
- }
- tc.addXAResource(resource);
- } catch (SystemException err) {
- throw new XATransactionException(err);
- } catch (InvalidTransactionException err) {
- throw new XATransactionException(err);
- } catch (RollbackException err) {
- throw new XATransactionException(err);
- } catch (IllegalStateException err) {
- throw new XATransactionException(err);
- } catch (XAException err) {
- throw new XATransactionException(err);
+ transactions.removeTransactionContext(context);
}
-
- return context;
+ return context;
}
- /**
- * @throws IllegalStateException
- * @throws InvalidTransactionException
- * @see com.metamatrix.dqp.transaction.TransactionServer#cancelTransactions(java.lang.String)
+ /**
+ * Request level transaction
*/
- public void cancelTransactions(String threadId, boolean requestOnly) throws InvalidTransactionException, SystemException {
- TransactionContextImpl tc = transactions.getTransactionContext(threadId);
+ public void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException {
+ TransactionContext tc = transactions.getTransactionContext(threadId);
if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
return;
@@ -574,133 +487,64 @@
return;
}
- cancelTransaction(tc);
- }
-
- private void cancelTransaction(TransactionContextImpl tc)
- throws InvalidTransactionException, SystemException {
- TransactionManager tm = getTransactionManager();
+ tc.setRollbackOnly();
- try {
- tm.resume(tc.getTransaction());
- tm.setRollbackOnly();
- } finally {
- tm.suspend();
- //transactions.removeTransactionContext(tc);
+ if (requestOnly) {
+ rollback(tc);
}
- }
-
- public synchronized void registerRecoverySource(String name, XAConnectionSource resource) {
- this.provider.registerRecoverySource(name, resource);
+ else {
+ rollback(threadId);
+ }
}
- public synchronized void removeRecoverySource(String name) {
- this.provider.removeRecoverySource(name);
- }
-
@Override
public Collection<org.teiid.adminapi.Transaction> getTransactions() {
- Set<TransactionContextImpl> txnSet = Collections.newSetFromMap(new IdentityHashMap<TransactionContextImpl, Boolean>());
+ Set<TransactionContext> txnSet = Collections.newSetFromMap(new IdentityHashMap<TransactionContext, Boolean>());
synchronized (this.transactions) {
txnSet.addAll(this.transactions.threadToTransactionContext.values());
txnSet.addAll(this.transactions.xidToTransactionContext.values());
}
Collection<org.teiid.adminapi.Transaction> result = new ArrayList<org.teiid.adminapi.Transaction>(txnSet.size());
- for (TransactionContextImpl transactionContextImpl : txnSet) {
- if (transactionContextImpl.getTxnID() == null) {
+ for (TransactionContext TransactionContext : txnSet) {
+ if (TransactionContext.getXid() == null) {
continue;
}
- TransactionImpl txnImpl = new TransactionImpl(processName, transactionContextImpl.getTxnID());
- txnImpl.setAssociatedSession(transactionContextImpl.getThreadId());
- txnImpl.setCreated(new Date(transactionContextImpl.getCreationTime()));
- txnImpl.setScope(transactionContextImpl.getTransactionType().toString());
- try {
- txnImpl.setStatus(getStatusString(transactionContextImpl.getTransaction().getStatus()));
- } catch (SystemException e) {
- txnImpl.setStatus(getStatusString(Status.STATUS_UNKNOWN));
- }
- txnImpl.setXid(transactionContextImpl.getXid());
+ TransactionMetadata txnImpl = new TransactionMetadata();
+ txnImpl.setAssociatedSession(Long.parseLong(TransactionContext.getThreadId()));
+ txnImpl.setCreatedTime(TransactionContext.getCreationTime());
+ txnImpl.setScope(TransactionContext.getTransactionType().toString());
+ txnImpl.setXid(TransactionContext.getXid().toString());
result.add(txnImpl);
}
return result;
}
- public static String getStatusString(int status) {
- switch (status) {
- case Status.STATUS_ACTIVE:
- return "ACTIVE"; //$NON-NLS-1$
- case Status.STATUS_COMMITTED:
- return "COMMITTED"; //$NON-NLS-1$
- case Status.STATUS_COMMITTING:
- return "COMMITTING"; //$NON-NLS-1$
- case Status.STATUS_MARKED_ROLLBACK:
- return "MARKED_ROLLBACK"; //$NON-NLS-1$
- case Status.STATUS_NO_TRANSACTION:
- return "NO_TRANSACTION"; //$NON-NLS-1$
- case Status.STATUS_PREPARED:
- return "PREPARED"; //$NON-NLS-1$
- case Status.STATUS_PREPARING:
- return "PREPARING"; //$NON-NLS-1$
- case Status.STATUS_ROLLEDBACK:
- return "ROLLEDBACK"; //$NON-NLS-1$
- case Status.STATUS_ROLLING_BACK:
- return "ROLLING_BACK"; //$NON-NLS-1$
- }
- return "UNKNOWN"; //$NON-NLS-1$
- }
-
@Override
- public void terminateTransaction(Xid transactionId) throws AdminException {
- if (transactionId == null) {
+ public void terminateTransaction(String xid) throws AdminException {
+ if (xid == null) {
return;
}
- TransactionContextImpl context = this.transactions.getTransactionContext(new MMXid(transactionId));
- if (context != null) {
- try {
- cancelTransaction(context);
- } catch (InvalidTransactionException e) {
- throw new AdminProcessingException(e);
- } catch (SystemException e) {
- throw new AdminComponentException(e);
+ TransactionContext context = this.transactions.getTransactionContext(xid.hashCode());
+ context.setRollbackOnly();
+
+ try {
+ if (context.getTransactionType() == TransactionContext.Scope.REQUEST ) {
+ rollback(context);
}
+
+ if (context.getTransactionType() == TransactionContext.Scope.LOCAL ) {
+ rollback(context.getThreadId());
+ }
+
+ if (context.getTransactionType() == TransactionContext.Scope.GLOBAL ) {
+ throw new AdminProcessingException("Can not terminate global transactions!");
+ }
+ } catch (XATransactionException e) {
+ throw new AdminProcessingException(e.getMessage());
}
}
- @Override
- public void terminateTransaction(String transactionId, String sessionId) throws AdminException {
- if (transactionId == null) {
- return;
- }
- String[] id = MMAdminObject.buildIdentifierArray(transactionId);
- if (!this.processName.equalsIgnoreCase(id[0]) || id.length != 2) {
- return;
- }
- TransactionContextImpl context = this.transactions.getTransactionContext(sessionId);
- if (context != null && id[1].equalsIgnoreCase(context.getTxnID())) {
- try {
- cancelTransaction(context);
- } catch (InvalidTransactionException e) {
- throw new AdminProcessingException(e);
- } catch (SystemException e) {
- throw new AdminComponentException(e);
- }
- }
+ public void setXidFactory(XidFactory f) {
+ this.xidFactory = f;
}
-
- @Override
- public void initialize(Properties props)
- throws ApplicationInitializationException {
- }
-
- @Override
- public void start(ApplicationEnvironment environment)
- throws ApplicationLifecycleException {
-
- }
-
- @Override
- public synchronized void stop() throws ApplicationLifecycleException {
- this.provider.shutdown();
- }
-
}
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,41 @@
+/*
+ * 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.dqp.internal.transaction;
+
+import java.util.Random;
+
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.common.xa.MMXid;
+
+public class XidFactory {
+ Random r = new Random(System.currentTimeMillis());
+ public Xid createXid() {
+
+ byte[] global = new byte[10];
+ byte[] branch = new byte[10];
+ r.nextBytes(global);
+ r.nextBytes(branch);
+
+ return new MMXid(78923, global, branch);
+ }
+}
Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,14 +28,13 @@
import java.util.List;
import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
+import org.teiid.connector.metadata.runtime.Procedure;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.Table.Type;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
/**
* Aggregates the metadata from multiple stores.
@@ -43,16 +42,22 @@
*/
public class CompositeMetadataStore extends MetadataStore {
- private MetadataSource metadataSource;
- public CompositeMetadataStore(List<MetadataStore> metadataStores, MetadataSource metadataSource) {
- this.metadataSource = metadataSource;
+ public CompositeMetadataStore(MetadataStore metadataStore) {
+ addMetadataStore(metadataStore);
+ }
+
+ public CompositeMetadataStore(List<MetadataStore> metadataStores) {
for (MetadataStore metadataStore : metadataStores) {
- this.schemas.putAll(metadataStore.getSchemas());
- this.datatypes.addAll(metadataStore.getDatatypes());
+ addMetadataStore(metadataStore);
}
}
+ public void addMetadataStore(MetadataStore metadataStore) {
+ this.schemas.putAll(metadataStore.getSchemas());
+ this.datatypes.addAll(metadataStore.getDatatypes());
+ }
+
public Schema getSchema(String fullName)
throws QueryMetadataException {
Schema result = getSchemas().get(fullName);
@@ -94,13 +99,13 @@
return result;
}
- public Collection<ProcedureRecordImpl> getStoredProcedure(String name)
+ public Collection<Procedure> getStoredProcedure(String name)
throws MetaMatrixComponentException, QueryMetadataException {
- List<ProcedureRecordImpl> result = new LinkedList<ProcedureRecordImpl>();
+ List<Procedure> result = new LinkedList<Procedure>();
int index = name.indexOf(TransformationMetadata.DELIMITER_STRING);
if (index > -1) {
String schema = name.substring(0, index);
- ProcedureRecordImpl proc = getSchema(schema).getProcedures().get(name.substring(index + 1));
+ Procedure proc = getSchema(schema).getProcedures().get(name.substring(index + 1));
if (proc != null) {
result.add(proc);
return result;
@@ -109,7 +114,7 @@
//assume it's a partial name
name = TransformationMetadata.DELIMITER_STRING + name;
for (Schema schema : getSchemas().values()) {
- for (ProcedureRecordImpl p : schema.getProcedures().values()) {
+ for (Procedure p : schema.getProcedures().values()) {
String fullName = p.getFullName();
if (fullName.regionMatches(true, fullName.length() - name.length(), name, 0, name.length())) {
result.add(p);
@@ -122,10 +127,6 @@
return result;
}
- public MetadataSource getMetadataSource() {
- return metadataSource;
- }
-
/*
* The next method is a hold over from XML/UUID resolving and will perform poorly
*/
@@ -133,7 +134,7 @@
public Collection<Table> getXMLTempGroups(Table tableRecord) {
ArrayList<Table> results = new ArrayList<Table>();
String namePrefix = tableRecord.getFullName() + TransformationMetadata.DELIMITER_STRING;
- for (Table table : tableRecord.getSchema().getTables().values()) {
+ for (Table table : tableRecord.getParent().getTables().values()) {
if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
results.add(table);
}
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,7 +24,9 @@
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -34,14 +36,16 @@
import java.util.Map;
import java.util.Properties;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.ColumnSet;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
+import org.teiid.connector.metadata.runtime.Procedure;
import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
@@ -50,16 +54,21 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.LRUCache;
+import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
import com.metamatrix.query.QueryPlugin;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.FunctionTree;
+import com.metamatrix.query.function.SystemFunctionManager;
+import com.metamatrix.query.function.UDFSource;
+import com.metamatrix.query.function.metadata.FunctionMethod;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingDocument;
import com.metamatrix.query.mapping.xml.MappingLoader;
@@ -74,9 +83,10 @@
* Modelers implementation of QueryMetadataInterface that reads columns, groups, models etc.
* index files for various metadata properties.
*/
-public class TransformationMetadata extends BasicQueryMetadata {
-
- /** Delimiter character used when specifying fully qualified entity names */
+public class TransformationMetadata extends BasicQueryMetadata implements Serializable {
+ private static final long serialVersionUID = 1058627332954475287L;
+
+ /** Delimiter character used when specifying fully qualified entity names */
public static final char DELIMITER_CHAR = StringUtil.Constants.DOT_CHAR;
public static final String DELIMITER_STRING = String.valueOf(DELIMITER_CHAR);
@@ -86,9 +96,10 @@
private static UnmodifiableProperties EMPTY_PROPS = new UnmodifiableProperties(new Properties());
private final CompositeMetadataStore store;
- private String vdbVersion;
- private VDBService vdbService;
-
+ private Map<VirtualFile, Boolean> vdbEntries;
+ private FunctionLibrary functionLibrary;
+ private VDBMetaData vdbMetaData;
+
/*
* TODO: move caching to jboss cache structure
*/
@@ -100,15 +111,18 @@
* TransformationMetadata constructor
* @param context Object containing the info needed to lookup metadta.
*/
- public TransformationMetadata(final CompositeMetadataStore store) {
- this(store, null, null);
- }
-
- public TransformationMetadata(final CompositeMetadataStore store, VDBService service, String vdbVersion) {
+ public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore store, Map<VirtualFile, Boolean> vdbEntries, Collection <FunctionMethod> udfMethods) {
ArgCheck.isNotNull(store);
+ this.vdbMetaData = vdbMetadata;
this.store = store;
- this.vdbService = service;
- this.vdbVersion = vdbVersion;
+ if (vdbEntries == null) {
+ vdbEntries = Collections.emptyMap();
+ }
+ this.vdbEntries = vdbEntries;
+ if (udfMethods == null) {
+ udfMethods = Collections.emptyList();
+ }
+ this.functionLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(udfMethods)));
}
//==================================================================================
@@ -163,7 +177,7 @@
Collection<String> filteredResult = new ArrayList<String>(matches.size());
for (Table table : matches) {
- if (vdbService == null || vdbService.getModelVisibility(getVirtualDatabaseName(), vdbVersion, table.getParent().getName()) == ModelInfo.PUBLIC) {
+ if (vdbMetaData == null || vdbMetaData.getModel(table.getParent().getName()).isVisible()) {
filteredResult.add(table.getFullName());
}
}
@@ -277,9 +291,9 @@
Collection<StoredProcedureInfo> results = this.procedureCache.get(lowerGroupName);
if (results == null) {
- Collection<ProcedureRecordImpl> procRecords = getMetadataStore().getStoredProcedure(lowerGroupName);
+ Collection<Procedure> procRecords = getMetadataStore().getStoredProcedure(lowerGroupName);
results = new ArrayList<StoredProcedureInfo>(procRecords.size());
- for (ProcedureRecordImpl procRecord : procRecords) {
+ for (Procedure procRecord : procRecords) {
String procedureFullName = procRecord.getFullName();
// create the storedProcedure info object that would hold procedure's metadata
@@ -288,7 +302,7 @@
procInfo.setProcedureID(procRecord);
// modelID for the procedure
- procInfo.setModelID(procRecord.getSchema());
+ procInfo.setModelID(procRecord.getParent());
// get the parameter metadata info
for (ProcedureParameter paramRecord : procRecord.getParameters()) {
@@ -303,7 +317,7 @@
// if the procedure returns a resultSet, obtain resultSet metadata
if(procRecord.getResultSet() != null) {
- ColumnSet<ProcedureRecordImpl> resultRecord = procRecord.getResultSet();
+ ColumnSet<Procedure> resultRecord = procRecord.getResultSet();
// resultSet is the last parameter in the procedure
int lastParamIndex = procInfo.getParameters().size() + 1;
SPParameter param = new SPParameter(lastParamIndex, SPParameter.RESULT_SET, resultRecord.getFullName());
@@ -335,7 +349,7 @@
for (StoredProcedureInfo storedProcedureInfo : results) {
Schema schema = (Schema)storedProcedureInfo.getModelID();
- if(vdbService == null || vdbService.getModelVisibility(getVirtualDatabaseName(), vdbVersion, schema.getName()) == ModelInfo.PUBLIC){
+ if(vdbMetaData == null || vdbMetaData.getModel(schema.getName()).isVisible()){
if (result != null) {
throw new QueryMetadataException(QueryPlugin.Util.getString("ambiguous_procedure", fullyQualifiedProcedureName)); //$NON-NLS-1$
}
@@ -396,7 +410,7 @@
public Object getMinimumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
if(elementID instanceof Column) {
- return ((Column) elementID).getMinValue();
+ return ((Column) elementID).getMinimumValue();
} else if(elementID instanceof ProcedureParameter){
return null;
} else {
@@ -406,7 +420,7 @@
public Object getMaximumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
if(elementID instanceof Column) {
- return ((Column) elementID).getMaxValue();
+ return ((Column) elementID).getMaximumValue();
} else if(elementID instanceof ProcedureParameter){
return null;
} else {
@@ -427,7 +441,7 @@
* @since 4.2
*/
public boolean isProcedure(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- if(groupID instanceof ProcedureRecordImpl) {
+ if(groupID instanceof Procedure) {
return true;
}
if(groupID instanceof Table){
@@ -559,7 +573,7 @@
}
return true;
case SupportConstants.Element.AUTO_INCREMENT:
- return columnRecord.isAutoIncrementable();
+ return columnRecord.isAutoIncremented();
case SupportConstants.Element.CASE_SENSITIVE:
return columnRecord.isCaseSensitive();
case SupportConstants.Element.SIGNED:
@@ -773,14 +787,24 @@
return null;
}
- /* (non-Javadoc)
+ /**
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
*/
public String getVirtualDatabaseName() throws MetaMatrixComponentException, QueryMetadataException {
- return this.getMetadataStore().getMetadataSource().getName();
+ if (vdbMetaData == null) {
+ return null;
+ }
+ return vdbMetaData.getName();
}
- /* (non-Javadoc)
+ public int getVirtualDatabaseVersion() {
+ if (vdbMetaData == null) {
+ return 0;
+ }
+ return vdbMetaData.getVersion();
+ }
+
+ /**
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
*/
public Collection getXMLTempGroups(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
@@ -948,8 +972,7 @@
* @see com.metamatrix.query.metadata.BasicQueryMetadata#getBinaryVDBResource(java.lang.String)
* @since 4.3
*/
- public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException,
- QueryMetadataException {
+ public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
String content = this.getCharacterVDBResource(resourcePath);
if(content != null) {
return content.getBytes();
@@ -961,9 +984,23 @@
* @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());
+ public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ for (VirtualFile f:this.vdbEntries.keySet()) {
+ if (f.getPathName().equals(resourcePath)) {
+ Boolean v = this.vdbEntries.get(f);
+ if (v.booleanValue()) {
+ try {
+ return ObjectConverterUtil.convertToString(f.openStream());
+ } catch (IOException e) {
+ LogManager.logError(LogConstants.CTX_CONFIG, e, e.getMessage());
+ }
+ }
+ else {
+ break;
+ }
+ }
+ }
+ return null;
}
public CompositeMetadataStore getMetadataStore() {
@@ -974,9 +1011,15 @@
* @see com.metamatrix.query.metadata.BasicQueryMetadata#getVDBResourcePaths()
* @since 4.3
*/
- public String[] getVDBResourcePaths() throws MetaMatrixComponentException,
- QueryMetadataException {
- return getMetadataStore().getMetadataSource().getEntries().toArray(new String[0]);
+ public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
+ ArrayList<String> paths = new ArrayList<String>();
+ for (VirtualFile f:this.vdbEntries.keySet()) {
+ Boolean v = this.vdbEntries.get(f);
+ if (v.booleanValue()) {
+ paths.add(f.getPathName());
+ }
+ }
+ return paths.toArray(new String[paths.size()]);
}
/**
@@ -1053,4 +1096,8 @@
return record.getUUID() + "/" + key; //$NON-NLS-1$
}
+ @Override
+ public FunctionLibrary getFunctionLibrary() {
+ return this.functionLibrary;
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2010-03-05 14:26:51 UTC (rev 1916)
@@ -60,16 +60,22 @@
TOKEN: /* Data types */
{
<STRING: "string">
+| <VARCHAR: "varchar">
| <BOOLEAN: "boolean">
| <BYTE: "byte">
+| <TINYINT: "tinyint">
| <SHORT: "short">
+| <SMALLINT: "smallint">
| <CHAR: "char">
| <INTEGER: "integer">
| <LONG: "long">
+| <BIGINT: "bigint">
| <BIGINTEGER: "biginteger">
-| <FLOAT: "float">
+| <FLOAT: "float">
+| <REAL: "real">
| <DOUBLE: "double">
| <BIGDECIMAL: "bigdecimal">
+| <DECIMAL: "decimal">
| <DATE: "date">
| <TIME: "time">
| <TIMESTAMP: "timestamp">
@@ -97,24 +103,54 @@
TOKEN : /* Reserved words */
{
- <ALL: "all">
+ <ADD: "add">
+| <ALL: "all">
+| <ALTER: "alter">
| <AND: "and">
| <ANY: "any">
+| <ARRAY: "array">
| <AS: "as">
| <ASC: "asc">
+| <ATOMIC: "atomic">
+| <AUTORIZATION: "authorization">
| <BEGIN: "begin">
| <BETWEEN: "between">
+| <BINARY: "binary">
+| <BOTH: "both">
| <BREAK: "break">
| <BY: "by">
+| <CALL: "call">
+| <CALLED: "called">
+| <CASCADED: "cascaded">
| <CASE: "case">
+| <CHARACTER: "character">
+| <CHECK: "check">
+| <CLOSE: "close">
+| <COLLATE: "collate">
+| <COLUMN: "column">
+| <COMMIT: "commit">
+| <CONNECT: "connect">
+| <CONSTRAINT: "constraint">
| <CONTINUE: "continue">
+| <CORRESPONDING: "corresponding">
+| <CURRENT_DATE: "current_date">
+| <CURRENT_TIME: "current_time">
+| <CURRENT_TIMESTAMP: "current_timestamp">
+| <CURRENT_USER: "current_user">
| <CREATE: "create">
| <CRITERIA: "criteria">
| <CROSS: "cross">
+| <CURSOR: "cursor">
+| <DAY: "day">
+| <DEALLOCATE: "deallocate">
+| <DEFAULT_KEYWORD: "default">
| <DEBUG: "debug">
| <DECLARE: "declare">
| <DELETE: "delete">
| <DESC: "desc">
+| <DESCRIBE: "describe">
+| <DETERMINISTIC: "deterministic">
+| <DISCONNECT: "disconnect">
| <DISTINCT: "distinct">
| <DROP: "drop">
| <ELSE: "else">
@@ -124,63 +160,181 @@
| <EXCEPT: "except">
| <EXEC: "exec">
| <EXECUTE: "execute">
+| <EXTERNAL: "external">
| <EXISTS: "exists">
| <FALSE: "false">
+| <FETCH: "fetch">
+| <FILTER: "filter">
| <FN: "fn">
| <FOR: "for">
+| <FORIEGN: "foriegn">
| <FROM: "from">
| <FULL: "full">
+| <FUNCTION: "function">
+| <GET: "get">
+| <GLOBAL: "global">
+| <GRANT: "grant">
| <GROUP: "group">
| <HAS: "has">
| <HAVING: "having">
+| <HOLD: "hold">
+| <HOUR: "hour">
| <IF: "if">
+| <IDENTITY: "identity">
+| <IMMEDIATE: "immediate">
| <IN: "in">
+| <INDICATOR: "indicator">
| <INNER: "inner">
+| <INPUT: "input">
+| <INOUT: "inout">
+| <INSENSITIVE: "insensitive">
| <INSERT: "insert">
| <INTERSECT: "intersect">
+| <INTERVAL: "interval">
| <INTO: "into">
| <IS: "is">
+| <ISOLATION: "isolation">
| <JOIN: "join">
| <LEFT: "left">
+| <LANGUAGE: "language">
+| <LARGE: "large">
+| <LEADING: "leading">
| <LIKE: "like">
| <LIMIT: "limit">
| <LOCAL: "local">
| <LOOP: "loop">
| <MAKEDEP: "makedep">
| <MAKENOTDEP: "makenotdep">
+| <MATCH: "match">
+| <MERGE: "merge">
+| <METHOD: "method">
+| <MINUTE: "minute">
+| <MODIFIES: "modifies">
+| <MODULE: "module">
+| <MONTH: "month">
+| <NATURAL: "natural">
+| <NEW: "new">
| <NOCACHE: "nocache">
+| <NO: "no">
+| <NONE: "none">
| <NOT: "not">
| <NULL: "null">
+| <OF: "of">
+| <OLD: "old">
| <ON: "on">
+| <ONLY: "only">
| <OJ: "oj">
+| <OPEN: "open">
| <OPTION: "option">
| <OR: "or">
| <ORDER: "order">
| <OUTER: "outer">
+| <OUTPUT: "output">
+| <OVER: "over">
+| <OVERLAPS: "OVERLAPS">
+| <PARAMETER: "parameter">
+| <PARTITION: "partition">
| <PLANONLY: "planonly">
+| <PRECISION: "precision">
+| <PREPARE: "prepare">
+| <PRIMARY: "primary">
| <PROCEDURE: "procedure">
+| <RANGE: "range">
+| <READS: "reads">
+| <RECURSIVE: "recursive">
+| <REFERENCES: "REFERENCES">
+| <REFERENCING: "REFERENCING">
+| <RETURN: "return">
+| <RETURNS: "returns">
+| <REVOKE: "REVOKE">
| <RIGHT: "right">
+| <ROLLBACK: "ROLLBACK">
+| <ROLLUP: "ROLLUP">
+| <ROW: "row">
+| <ROWS: "rows">
+| <SAVEPOINT: "savepoint">
+| <SCROLL: "scroll">
+| <SEARCH: "search">
+| <SECOND: "second">
| <SELECT: "select">
+| <SENSITIVE: "sensitive">
+| <SESSION_USER: "session_user">
| <SET: "set">
| <SHOWPLAN: "showplan">
+| <SIMILAR: "similar">
+| <SPECIFIC: "specific">
| <SOME: "some">
+| <SQL: "sql">
+| <SQLEXCEPTION: "sqlexception">
+| <SQLSTATE: "sqlstate">
+| <SQLWARNING: "sqlwarning">
+| <START: "start">
+| <STATIC: "static">
+| <SYSTEM: "system">
+| <SYSTEM_USER: "system_user">
| <TABLE: "table">
| <TEMPORARY: "temporary">
| <THEN: "then">
+| <TIMEZONE_HOUR: "timezone_hour">
+| <TIMEZONE_MINUTE: "timezone_minute">
+| <TO: "to">
+| <TRAILING: "trailing">
| <TRANSLATE: "translate">
+| <TRIGGER: "trigger">
| <TRUE: "true">
| <UNION: "union">
+| <UNIQUE: "unique">
| <UNKNOWN: "unknown">
+| <USER: "user">
| <UPDATE: "update">
| <USING: "using">
+| <VALUE: "value">
| <VALUES: "values">
| <VIRTUAL: "virtual">
| <WHEN: "when">
+| <WHENEVER: "whenever">
| <WHERE: "where">
| <WITH: "with">
| <WHILE: "while">
+| <WINDOW: "window">
+| <WITHIN: "within">
+| <WITHOUT: "without">
+| <YEAR: "year">
}
+TOKEN : /* SQL/XML Reserved words */
+{
+ <XMLAGG: "xmlagg">
+| <XMLATTRIBUTES: "xmlattributes">
+| <XMLBINARY: "xmlbinary">
+| <XMLCONCAT: "xmlconcat">
+| <XMLCOMMENT: "xmlcomment">
+| <XMLELEMENT: "xmlelement">
+| <XMLFOREST: "xmlforest">
+| <XMLNAMESPACES: "xmlnamespaces">
+| <XMLPARSE: "xmlparse">
+| <XMLPI: "xmlpi">
+| <XMLROOT: "xmlroot">
+| <XMLSERIALIZE: "xmlserialize">
+}
+
+TOKEN : /* SQL/MED Reserved words */
+{
+ <DATALINK: "datalink">
+| <DLNEWCOPY: "dlnewcopy">
+| <DLPREVIOUSCOPY: "dlpreviouscopy">
+| <DLURLCOMPLETE: "dlurlcomplete">
+| <DLURLCOMPLETEWRITE: "dlurlcompletewrite">
+| <DLURLCOMPLETEONLY: "dlurlcompleteonly">
+| <DLURLPATH: "dlurlpath">
+| <DLURLPATHWRITE: "dlurlpathwrite">
+| <DLURLPATHONLY: "dlurlpathonly">
+| <DLURLSCHEME: "dlurlscheme">
+| <DLURLSERVER: "dlurlserver">
+| <DLVALUE: "dlvalue">
+| <IMPORT: "import">
+}
+
TOKEN : /* Special function words */
{
<SQL_TSI_FRAC_SECOND: "SQL_TSI_FRAC_SECOND">
@@ -957,14 +1111,8 @@
storedProcedure.setParameter(parameter);
}
]
- call = <ID>
+ <CALL> procName = id()
{
- if (!"call".equalsIgnoreCase(call.image)) { //$NON-NLS-1$
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.call_expected")); //$NON-NLS-1$
- }
- }
- procName = id()
- {
storedProcedure.setProcedureName(procName);
}
@@ -1007,6 +1155,8 @@
(execToken = <EXEC> { setQueryCacheOption(execToken, info); })
|
(execToken = <EXECUTE> { setQueryCacheOption(execToken, info); })
+ |
+ (execToken = <CALL> { setQueryCacheOption(execToken, info); })
)
procName = id()
{
@@ -2765,7 +2915,9 @@
)
|
(
- (funcToken = <LEFT> | funcToken = <RIGHT> | funcToken = <CHAR>)
+ (funcToken = <LEFT> | funcToken = <RIGHT> | funcToken = <CHAR> | funcToken = <USER>
+ | funcToken = <YEAR> | funcToken = <MONTH> | funcToken = <HOUR>
+ | funcToken = <MINUTE> | funcToken = <SECOND>)
<LPAREN>
[
expression = expression(info)
@@ -2869,17 +3021,23 @@
}
{
(
- typeToken = <STRING> |
+ typeToken = <STRING> |
+ typeToken = <VARCHAR> |
typeToken = <BOOLEAN> |
typeToken = <BYTE> |
+ typeToken = <TINYINT> |
typeToken = <SHORT> |
+ typeToken = <SMALLINT> |
typeToken = <CHAR> |
typeToken = <INTEGER> |
typeToken = <LONG> |
+ typeToken = <BIGINT> |
typeToken = <BIGINTEGER> |
- typeToken = <FLOAT> |
+ typeToken = <FLOAT> |
+ typeToken = <REAL> |
typeToken = <DOUBLE> |
- typeToken = <BIGDECIMAL> |
+ typeToken = <BIGDECIMAL> |
+ typeToken = <DECIMAL> |
typeToken = <DATE> |
typeToken = <TIME> |
typeToken = <TIMESTAMP> |
Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2010-03-05 14:26:51 UTC (rev 1916)
@@ -33,11 +33,14 @@
AtomicRequestID.Unable_to_create_ID_for_null_AtomicRequestMessage=Unable to create an ID for a null AtomicRequestMessage.
AtomicRequestID.Unable_to_create_ID_for_AtomicRequestMessage_with_null_RequestID=Unable to create an ID for an AtomicRequestMessage with null RequestID.
+
+ConnectorManager.failed_to_lookup_connector=Failed to look up Connector instance {0}
+ConnectorManager.xa_capbility_not_supported=XA support by the Connector {0} is not possible when "SyncWorkers" is set to false
+ConnectorManager.not_in_valid_state=Connector is not in OPEN state
ConnectorManagerImpl.Initializing_connector=Initializing connector {0}
ConnectorManagerImpl.Couldn__t_parse_property=Could not parse property: {0}
Error_closing_client_connection=Error closing client connection in ConnectorManager
-failed_find_Connector_class=Could not find Connector class {0}
failed_legacy=The specified connector class {0} is not an instance of a Teiid connector. This may be due to an inappropriate classpath entry. An attempt was also made to treat the class as a legacy MetaMatrix connector, however this was not successful either.
failed_instantiate_Connector_class=Could not instantiate Connector class {0}
failed_start_Connector=Could not start Connector {0}. {1}
@@ -63,6 +66,7 @@
no_txn_manager=No Transaction Manger found in the configuration, Failed to start connector \"{0}\"
Connector_State_not_active=Connector request state is not active for request {0} in Connector {1}
Missing_required_property=Connector is missing required property {0} or wrong value supplied {1}
+Cancel_failed=Request {0} failed to cancel.
ConnectorWorker.Can__t_communicate_error_to_client=Can not not communicate error to client
ConnectorWorker.Command_null=Command is null.
@@ -435,7 +439,7 @@
TransactionServer.suspended_exist=Suspended work still exists on transaction {0}.
TransactionServer.failed_to_enlist=Failed to enlist the XAResource in Transaction.
TransactionServer.failed_to_delist=Failed to delist the XAResource from Transaction.
-
+TransactionServer.rollback_set=Rollback Only has been set on transaction {0}. This may be result of a cancel request.
TransactionContextImpl.remote_not_supported=Remote connector calls under a transaction are not supported
CodeTableCache.duplicate_key=Duplicate code table ''{0}'' key ''{1}'' value ''{2}''
Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,6 @@
package com.metamatrix.common.buffer;
-import java.util.Properties;
-
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.buffer.impl.MemoryStorageManager;
@@ -51,8 +49,7 @@
public static BufferManager getStandaloneBufferManager() throws MetaMatrixComponentException {
if (INSTANCE == null) {
BufferManagerImpl bufferMgr = new BufferManagerImpl();
- Properties props = new Properties();
- bufferMgr.initialize(props);
+ bufferMgr.initialize();
// Add unmanaged memory storage manager
bufferMgr.setStorageManager(new MemoryStorageManager());
Copied: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl)
Deleted: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,96 +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.common.buffer.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Random;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.core.util.UnitTestUtil;
-public class TestFileStorageManager {
-
- public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
- FileStorageManager sm = new FileStorageManager();
- sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
- if (maxFileSize != null) {
- sm.setMaxFileSizeDirect(maxFileSize);
- }
- if (openFiles != null) {
- sm.setMaxOpenFiles(openFiles);
- }
- sm.initialize();
- return sm;
- }
-
- @Test public void testAddGetBatch1() throws Exception {
- StorageManager sm = getStorageManager(null, null, null);
- String tsID = "local,1:0"; //$NON-NLS-1$
- // Add one batch
- FileStore store = sm.createFileStore(tsID);
- writeBytes(store);
- // Get that batch
- store.remove();
- }
-
- @Test public void testCreatesSpillFiles() throws Exception {
- FileStorageManager sm = getStorageManager(1024, null, null); // 1KB
- String tsID = "local,1:0"; //$NON-NLS-1$
- // Add one batch
- FileStore store = sm.createFileStore(tsID);
- writeBytes(store);
-
- Map<File, RandomAccessFile> cache = sm.getFileCache();
- assertEquals(1, cache.size());
-
- writeBytes(store);
-
- assertEquals(2, cache.size());
-
- store.remove();
-
- assertEquals(0, cache.size());
- }
-
- static Random r = new Random();
-
- private void writeBytes(FileStore store)
- throws MetaMatrixComponentException {
- byte[] bytes = new byte[2048];
- r.nextBytes(bytes);
- long start = store.write(bytes, 0, bytes.length);
- byte[] bytesRead = new byte[2048];
- store.readFully(start, bytesRead, 0, bytesRead.length);
- assertTrue(Arrays.equals(bytes, bytesRead));
- }
-
-}
Copied: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,96 @@
+/*
+ * 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.common.buffer.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Random;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.FileStore;
+import com.metamatrix.common.buffer.StorageManager;
+import com.metamatrix.core.util.UnitTestUtil;
+public class TestFileStorageManager {
+
+ public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
+ FileStorageManager sm = new FileStorageManager();
+ sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
+ if (maxFileSize != null) {
+ sm.setMaxFileSizeDirect(maxFileSize);
+ }
+ if (openFiles != null) {
+ sm.setMaxOpenFiles(openFiles);
+ }
+ sm.initialize();
+ return sm;
+ }
+
+ @Test public void testAddGetBatch1() throws Exception {
+ StorageManager sm = getStorageManager(null, null, null);
+ String tsID = "local,1:0"; //$NON-NLS-1$
+ // Add one batch
+ FileStore store = sm.createFileStore(tsID);
+ writeBytes(store);
+ // Get that batch
+ store.remove();
+ }
+
+ @Test public void testCreatesSpillFiles() throws Exception {
+ FileStorageManager sm = getStorageManager(1024, null, null); // 1KB
+ String tsID = "local,1:0"; //$NON-NLS-1$
+ // Add one batch
+ FileStore store = sm.createFileStore(tsID);
+ writeBytes(store);
+
+ Map<File, RandomAccessFile> cache = sm.getFileCache();
+ assertEquals(1, cache.size());
+
+ writeBytes(store);
+
+ assertEquals(2, cache.size());
+
+ store.remove();
+
+ assertEquals(0, cache.size());
+ }
+
+ static Random r = new Random();
+
+ private void writeBytes(FileStore store)
+ throws MetaMatrixComponentException {
+ byte[] bytes = new byte[2048];
+ r.nextBytes(bytes);
+ long start = store.write(bytes, 0, bytes.length);
+ byte[] bytesRead = new byte[2048];
+ store.readFully(start, bytesRead, 0, bytesRead.length);
+ assertTrue(Arrays.equals(bytes, bytesRead));
+ }
+
+}
Copied: trunk/engine/src/test/java/com/metamatrix/common/queue (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue)
Deleted: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.common.queue;
-
-import java.sql.Timestamp;
-
-import javax.resource.spi.work.Work;
-
-/**
- */
-public class FakeWorkItem implements Work {
-
- private static boolean DEBUG = false;
-
- long begin = 0;
- long end = 0;
- private long waitTime;
-
- /**
- * Constructor for FakeWorker.
- */
- public FakeWorkItem(long waitTime) {
- this.waitTime = waitTime;
- }
-
- /**
- * @see com.metamatrix.common.queue.QueueWorker#process(Object)
- */
- public void run() {
- if(begin == 0) {
- begin = System.currentTimeMillis();
- }
-
- log("Processing"); //$NON-NLS-1$
-
- // Sleep for time
- try {
- Thread.sleep(waitTime);
- } catch(Exception e) {
- }
-
- end = System.currentTimeMillis();
- log("Done"); //$NON-NLS-1$
- }
-
- private void log(String msg) {
- if (DEBUG) {
- System.out.println((new Timestamp(System.currentTimeMillis())).toString() + " " + //$NON-NLS-1$
- Thread.currentThread().getName() + ": " + msg); //$NON-NLS-1$
- }
- }
-
- @Override
- public void release() {
-
- }
-
-}
Copied: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,78 @@
+/*
+ * 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.common.queue;
+
+import java.sql.Timestamp;
+
+import javax.resource.spi.work.Work;
+
+/**
+ */
+public class FakeWorkItem implements Work {
+
+ private static boolean DEBUG = false;
+
+ long begin = 0;
+ long end = 0;
+ private long waitTime;
+
+ /**
+ * Constructor for FakeWorker.
+ */
+ public FakeWorkItem(long waitTime) {
+ this.waitTime = waitTime;
+ }
+
+ /**
+ * @see com.metamatrix.common.queue.QueueWorker#process(Object)
+ */
+ public void run() {
+ if(begin == 0) {
+ begin = System.currentTimeMillis();
+ }
+
+ log("Processing"); //$NON-NLS-1$
+
+ // Sleep for time
+ try {
+ Thread.sleep(waitTime);
+ } catch(Exception e) {
+ }
+
+ end = System.currentTimeMillis();
+ log("Done"); //$NON-NLS-1$
+ }
+
+ private void log(String msg) {
+ if (DEBUG) {
+ System.out.println((new Timestamp(System.currentTimeMillis())).toString() + " " + //$NON-NLS-1$
+ Thread.currentThread().getName() + ": " + msg); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void release() {
+
+ }
+
+}
Deleted: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,73 +0,0 @@
-package com.metamatrix.common.queue;
-
-import javax.resource.spi.work.ExecutionContext;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
-
-import org.mockito.Mockito;
-
-public class FakeWorkManager implements WorkManager {
- private Thread t;
-
- @Override
- public void doWork(Work arg0) throws WorkException {
- execute(arg0, null, true);
- }
-
- @Override
- public void doWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- execute(arg0, arg3, true);
- }
-
- @Override
- public void scheduleWork(Work arg0) throws WorkException {
- execute(arg0, null, false);
- }
-
- @Override
- public void scheduleWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- execute(arg0, arg3, false);
- }
-
- @Override
- public long startWork(Work arg0) throws WorkException {
- execute(arg0, null, false);
- return 0;
- }
-
- @Override
- public long startWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
- execute(arg0, arg3, false);
- return 0;
- }
-
- void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
- if (arg3 != null) {
- arg3.workAccepted(Mockito.mock(WorkEvent.class));
- arg3.workStarted(Mockito.mock(WorkEvent.class));
- }
-
- t = new Thread(new Runnable() {
-
- @Override
- public void run() {
- arg0.run();
- if (arg3 != null) {
- arg3.workCompleted(Mockito.mock(WorkEvent.class));
- }
- }
- });
- t.start();
- if (join) {
- try {
- t.join();
- } catch (InterruptedException e) {
- throw new WorkException(e);
- }
- }
- }
-
-}
Copied: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,73 @@
+package com.metamatrix.common.queue;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+
+import org.mockito.Mockito;
+
+public class FakeWorkManager implements WorkManager {
+ private Thread t;
+
+ @Override
+ public void doWork(Work arg0) throws WorkException {
+ execute(arg0, null, true);
+ }
+
+ @Override
+ public void doWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+ execute(arg0, arg3, true);
+ }
+
+ @Override
+ public void scheduleWork(Work arg0) throws WorkException {
+ execute(arg0, null, false);
+ }
+
+ @Override
+ public void scheduleWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+ execute(arg0, arg3, false);
+ }
+
+ @Override
+ public long startWork(Work arg0) throws WorkException {
+ execute(arg0, null, false);
+ return 0;
+ }
+
+ @Override
+ public long startWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+ execute(arg0, arg3, false);
+ return 0;
+ }
+
+ void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
+ if (arg3 != null) {
+ arg3.workAccepted(Mockito.mock(WorkEvent.class));
+ arg3.workStarted(Mockito.mock(WorkEvent.class));
+ }
+
+ t = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ arg0.run();
+ if (arg3 != null) {
+ arg3.workCompleted(Mockito.mock(WorkEvent.class));
+ }
+ }
+ });
+ t.start();
+ if (join) {
+ try {
+ t.join();
+ } catch (InterruptedException e) {
+ throw new WorkException(e);
+ }
+ }
+ }
+
+}
Deleted: trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java 2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,176 +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.common.queue;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkManager;
-import javax.resource.spi.work.WorkRejectedException;
-
-import org.junit.Test;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-/**
- */
-public class TestStatsCapturingWorkManager {
-
- private WorkManager manager = new FakeWorkManager();
-
- @Test public void testQueuing() throws Exception {
- final long SINGLE_WAIT = 50;
- final int WORK_ITEMS = 10;
- final int MAX_THREADS = 5;
-
- final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS); //$NON-NLS-1$
-
- for(int i=0; i<WORK_ITEMS; i++) {
- pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
- }
-
- pool.shutdown();
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- assertTrue(pool.isTerminated());
- WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals(10, stats.getTotalCompleted());
- assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
- }
-
- @Test public void testThreadReuse() throws Exception {
- final long SINGLE_WAIT = 50;
- final long NUM_THREADS = 5;
-
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-
- for(int i=0; i<NUM_THREADS; i++) {
- pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
-
- try {
- Thread.sleep(SINGLE_WAIT*2);
- } catch(InterruptedException e) {
- }
- }
-
- pool.shutdown();
-
- WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
-
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- }
-
- @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- pool.shutdown();
- pool.scheduleWork(manager, new FakeWorkItem(1));
- }
-
- /*@Test public void testScheduleCancel() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- }
- }, 0, 5, TimeUnit.MILLISECONDS);
- future.cancel(true);
- assertFalse(future.cancel(true));
- }*/
-
- @Test public void testSchedule() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- final ArrayList<String> result = new ArrayList<String>();
- pool.scheduleWork(manager, new Work() {
-
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- }
-
- @Override
- public void release() {
-
- }
- }, null, 5);
- Thread.sleep(10);
- pool.shutdown();
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- assertEquals(1, result.size());
- }
-
- /*(a)Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- ScheduledFuture<?> future = pool.schedule(new Runnable() {
- @Override
- public void run() {
- throw new RuntimeException();
- }
- }, 0, TimeUnit.MILLISECONDS);
- future.get();
- }*/
-
- /**
- * Here each execution exceeds the period
- */
- /*@Test public void testScheduleRepeated() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- final ArrayList<String> result = new ArrayList<String>();
- ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- try {
- Thread.sleep(75);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- }, 0, 10, TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- future.cancel(true);
- assertEquals(2, result.size());
- }*/
-
- @Test public void testFailingWork() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- final AtomicInteger count = new AtomicInteger();
- pool.scheduleWork(manager, new Work() {
- @Override
- public void run() {
- count.getAndIncrement();
- throw new RuntimeException();
- }
-
- @Override
- public void release() {
-
- }
- });
- Thread.sleep(100);
- assertEquals(1, count.get());
- }
-
-}
Copied: trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,176 @@
+/*
+ * 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.common.queue;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.junit.Test;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+/**
+ */
+public class TestStatsCapturingWorkManager {
+
+ private WorkManager manager = new FakeWorkManager();
+
+ @Test public void testQueuing() throws Exception {
+ final long SINGLE_WAIT = 50;
+ final int WORK_ITEMS = 10;
+ final int MAX_THREADS = 5;
+
+ final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS); //$NON-NLS-1$
+
+ for(int i=0; i<WORK_ITEMS; i++) {
+ pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+ }
+
+ pool.shutdown();
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ assertTrue(pool.isTerminated());
+ WorkerPoolStatisticsMetadata stats = pool.getStats();
+ assertEquals(10, stats.getTotalCompleted());
+ assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
+ }
+
+ @Test public void testThreadReuse() throws Exception {
+ final long SINGLE_WAIT = 50;
+ final long NUM_THREADS = 5;
+
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+
+ for(int i=0; i<NUM_THREADS; i++) {
+ pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+
+ try {
+ Thread.sleep(SINGLE_WAIT*2);
+ } catch(InterruptedException e) {
+ }
+ }
+
+ pool.shutdown();
+
+ WorkerPoolStatisticsMetadata stats = pool.getStats();
+ assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
+
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ }
+
+ @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ pool.shutdown();
+ pool.scheduleWork(manager, new FakeWorkItem(1));
+ }
+
+ /*@Test public void testScheduleCancel() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ }
+ }, 0, 5, TimeUnit.MILLISECONDS);
+ future.cancel(true);
+ assertFalse(future.cancel(true));
+ }*/
+
+ @Test public void testSchedule() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ final ArrayList<String> result = new ArrayList<String>();
+ pool.scheduleWork(manager, new Work() {
+
+ @Override
+ public void run() {
+ result.add("hello"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void release() {
+
+ }
+ }, null, 5);
+ Thread.sleep(10);
+ pool.shutdown();
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ assertEquals(1, result.size());
+ }
+
+ /*(a)Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ ScheduledFuture<?> future = pool.schedule(new Runnable() {
+ @Override
+ public void run() {
+ throw new RuntimeException();
+ }
+ }, 0, TimeUnit.MILLISECONDS);
+ future.get();
+ }*/
+
+ /**
+ * Here each execution exceeds the period
+ */
+ /*@Test public void testScheduleRepeated() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ final ArrayList<String> result = new ArrayList<String>();
+ ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ result.add("hello"); //$NON-NLS-1$
+ try {
+ Thread.sleep(75);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }, 0, 10, TimeUnit.MILLISECONDS);
+ Thread.sleep(100);
+ future.cancel(true);
+ assertEquals(2, result.size());
+ }*/
+
+ @Test public void testFailingWork() throws Exception {
+ StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+ final AtomicInteger count = new AtomicInteger();
+ pool.scheduleWork(manager, new Work() {
+ @Override
+ public void run() {
+ count.getAndIncrement();
+ throw new RuntimeException();
+ }
+
+ @Override
+ public void release() {
+
+ }
+ });
+ Thread.sleep(100);
+ assertEquals(1, count.get());
+ }
+
+}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.dqp.config;
-
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.dqp.internal.process.DQPCore;
-
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.FakeAbstractService;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.MetadataService;
-
-/**
- */
-public class TestDQPLauncher extends TestCase {
-
- /**
- * Constructor for TestDQPLauncher.
- * @param name
- */
- public TestDQPLauncher(String name) {
- super(name);
- }
-
- public void testLaunch() throws Exception {
- DQPConfigSource configSource = Mockito.mock(DQPConfigSource.class);
- Mockito.stub(configSource.getProperties()).toReturn(new Properties());
-
- String[] services = new String[] {DQPServiceNames.BUFFER_SERVICE, DQPServiceNames.METADATA_SERVICE, DQPServiceNames.DATA_SERVICE};
-
- Mockito.stub(configSource.getServiceInstance(BufferService.class)).toReturn(new FakeBufferService());
- Mockito.stub(configSource.getServiceInstance(MetadataService.class)).toReturn(new FakeMetadataService());
- Mockito.stub(configSource.getServiceInstance(DataService.class)).toReturn(new AutoGenDataService());
-
- DQPCore dqpCore = new DQPCore();
- dqpCore.start(configSource);
-
- assertNotNull("DQP should not be null", dqpCore); //$NON-NLS-1$
-
- // Check that bootstrapping occurred
- for(int i=0; i<services.length; i++) {
- FakeAbstractService svc = (FakeAbstractService)dqpCore.getEnvironment().findService(services[i]);
- assertEquals("service " + svc.getClass().getName() + " not init'ed correct # of times ", 1, svc.getInitializeCount()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("service " + svc.getClass().getName() + " not start'ed correct # of times ", 1, svc.getStartCount()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("service " + svc.getClass().getName() + " not stop'ed correct # of times ", 0, svc.getStopCount()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
-}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,16 +22,12 @@
package com.metamatrix.dqp.message;
-import java.util.Date;
+import junit.framework.TestCase;
import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
import org.teiid.dqp.internal.process.DQPWorkContext;
-import junit.framework.TestCase;
-
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestAtomicRequestMessage extends TestCase {
@@ -47,32 +43,30 @@
public static AtomicRequestMessage example() {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(2), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(2, "foo")); //$NON-NLS-1$
AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
- message.setCommand(TestQueryImpl.helpExample());
+ message.setCommand(TestQueryImpl.helpExample(true));
message.setFetchSize(100);
message.setPartialResults(true);
- message.setProcessingTimestamp(new Date(12345678L));
message.setRequestID(new RequestID(5000L));
//AtomicRequestMessage-specific stuff
- message.setConnectorBindingID("connectorBindingID"); //$NON-NLS-1$
- message.setConnectorID(new ConnectorID("10000")); //$NON-NLS-1$
+ message.setConnectorName("connectorBindingID"); //$NON-NLS-1$
return message;
}
public void testSerialize() throws Exception {
- AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example());
+ AtomicRequestMessage example = example();
+ AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example);
- assertEquals(TestQueryImpl.helpExample(), copy.getCommand());
+ assertEquals(TestQueryImpl.helpExample(true), copy.getCommand());
assertEquals(100, copy.getFetchSize());
- assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
+ assertEquals(example.getProcessingTimestamp(), copy.getProcessingTimestamp());
assertEquals(new RequestID(5000L), copy.getRequestID());
assertEquals("2", copy.getWorkContext().getConnectionID()); //$NON-NLS-1$
//AtomicRequestMessage-specific stuff
- assertEquals("connectorBindingID", copy.getConnectorBindingID()); //$NON-NLS-1$
- assertEquals(new ConnectorID("10000"), copy.getConnectorID()); //$NON-NLS-1$
+ assertEquals("connectorBindingID", copy.getConnectorName()); //$NON-NLS-1$
assertEquals(1000, copy.getAtomicRequestID().getNodeID());
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,25 +25,19 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
-import org.teiid.connector.metadata.runtime.MetadataStore;
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
@@ -52,22 +46,17 @@
* This data service will automatically generate results when called with a query - basically
* the same as the old loopback connector.
*/
-public class AutoGenDataService extends FakeAbstractService implements DataService {
+public class AutoGenDataService extends ConnectorManager{
// Number of rows that will be generated for each query
private int rows = 10;
private SourceCapabilities caps;
- /**
- *
- */
public AutoGenDataService() {
- this(new BasicSourceCapabilities());
+ super("FakeConnector");
+ caps = new BasicSourceCapabilities();
}
- public AutoGenDataService(SourceCapabilities caps) {
- this.caps = caps;
- }
public void setRows(int rows) {
this.rows = rows;
@@ -77,17 +66,9 @@
return this.rows;
}
- /*
- * @see com.metamatrix.dqp.service.DataService#selectConnector(java.lang.String)
- */
- public ConnectorID selectConnector(String connectorBindingID) {
- return null;
- }
-
- public void executeRequest(AtomicRequestMessage request,
- ConnectorID connector,
- ResultsReceiver<AtomicResultsMessage> resultListener)
- throws MetaMatrixComponentException {
+ @Override
+ public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> resultListener, AtomicRequestMessage request)
+ throws ConnectorException{
List projectedSymbols = (request.getCommand()).getProjectedSymbols();
List[] results = createResults(projectedSymbols);
@@ -165,94 +146,10 @@
}
@Override
- public SourceCapabilities getCapabilities(RequestMessage request,
- DQPWorkContext dqpWorkContext, String modelName)
- throws MetaMatrixComponentException {
- return caps;
+ public SourceCapabilities getCapabilities(){
+ return caps;
}
-
- /**
- * @see com.metamatrix.dqp.service.DataService#startConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,
- MetaMatrixComponentException {
- }
- /**
- * @see com.metamatrix.dqp.service.DataService#stopConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,
- MetaMatrixComponentException {
- }
- /**
- * @see com.metamatrix.dqp.service.DataService#getConnectorBindings()
- * @since 4.3
- */
- public List getConnectorBindings() throws MetaMatrixComponentException {
- return null;
- }
- /**
- * @see com.metamatrix.dqp.service.DataService#getConnectorBindingState(java.lang.String)
- * @since 4.3
- */
- public ConnectorStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.dqp.service.DataService#getConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.dqp.service.DataService#getConnectorBindingStatistics(java.lang.String)
- * @since 4.3
- */
- public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.dqp.service.DataService#getConnectionPoolStatistics(java.lang.String)
- * @since 6.1
- */
- public Collection getConnectionPoolStatistics(String connectorBindingName) throws MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.dqp.service.DataService#clearConnectorBindingCache(java.lang.String)
- * @since 4.3
- */
- public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {
- }
-
- public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
-
- }
-
- public void closeRequest(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
-
- }
-
- public void requestBatch(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
-
- }
-
- @Override
- public MetadataStore getConnectorMetadata(String vdbName,
- String vdbVersion, String modelName, Properties importProperties) {
- throw new UnsupportedOperationException();
- }
-
}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,82 +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.dqp.service;
-
-import java.util.Properties;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
-/**
- */
-public class FakeAbstractService implements ApplicationService {
-
- private int initializeCount = 0;
- private int startCount = 0;
- private int stopCount = 0;
-
-
- /**
- *
- */
- public FakeAbstractService() {
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
- */
- public void initialize(Properties props) throws ApplicationInitializationException {
- this.initializeCount++;
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
- */
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
- this.startCount++;
-
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#stop()
- */
- public void stop() throws ApplicationLifecycleException {
- this.stopCount++;
-
- }
-
- public int getInitializeCount() {
- return this.initializeCount;
- }
-
- public int getStartCount() {
- return this.startCount;
- }
-
- public int getStopCount() {
- return this.stopCount;
- }
-
-}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,19 +22,18 @@
package com.metamatrix.dqp.service;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.platform.security.api.AuthorizationPolicy;
import com.metamatrix.platform.security.api.AuthorizationRealm;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-import com.metamatrix.platform.security.api.SessionToken;
/**
*/
@@ -48,14 +47,14 @@
this.defaultAllow = defaultAllow;
}
- public void addResource(String connectionID, int action, String resource) {
- knownResources.add(new Resource(connectionID, action, resource));
+ public void addResource(int action, String resource) {
+ knownResources.add(new Resource(action, resource));
}
/*
* @see com.metamatrix.dqp.service.AuthorizationService#getInaccessibleResources(java.lang.String, int, java.util.Collection, int)
*/
- public Collection getInaccessibleResources(String connectionID, int action, Collection resources, int context)
+ public Collection getInaccessibleResources(int action, Collection resources, int context)
throws MetaMatrixComponentException {
List found = new ArrayList();
@@ -68,7 +67,7 @@
while(rIter.hasNext()) {
String resourceName = (String) rIter.next();
- Resource key = new Resource(connectionID, action, resourceName);
+ Resource key = new Resource(action, resourceName);
boolean foundResource = knownResources.contains(key);
if (!foundResource && !defaultAllow) {
@@ -90,34 +89,11 @@
return true;
}
- /*
- * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
- */
- public void initialize(Properties props) throws ApplicationInitializationException {
-
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
- */
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#stop()
- */
- public void stop() throws ApplicationLifecycleException {
-
- }
-
private static class Resource {
- public String connectionID;
public int action;
public String resource;
- public Resource(String connectionID, int action, String resource) {
- this.connectionID = connectionID;
+ public Resource(int action, String resource) {
this.action = action;
this.resource = resource;
}
@@ -148,7 +124,6 @@
Resource other = (Resource)obj;
return other.action == this.action
- && other.connectionID.equalsIgnoreCase(this.connectionID)
&& other.resource.equalsIgnoreCase(this.resource);
}
}
@@ -156,14 +131,13 @@
/**
* @see com.metamatrix.dqp.service.AuthorizationService#hasRole(java.lang.String, java.lang.String, java.lang.String)
*/
- public boolean hasRole(String connectionID,
- String roleType,
+ public boolean hasRole(String roleType,
String roleName) throws MetaMatrixComponentException {
return false;
}
@Override
- public boolean isCallerInRole(SessionToken session, String roleName)
+ public boolean isCallerInRole(String roleName)
throws AuthorizationMgmtException {
return false;
}
@@ -176,12 +150,6 @@
}
@Override
- public Collection<String> getRoleNamesForPrincipal(MetaMatrixPrincipalName principal) throws InvalidSessionException,
- AuthorizationException, AuthorizationMgmtException {
- return null;
- }
-
- @Override
public void updatePoliciesInRealm(AuthorizationRealm realm,
Collection<AuthorizationPolicy> policies)
throws AuthorizationMgmtException {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,18 +22,17 @@
package com.metamatrix.dqp.service;
-import java.util.Properties;
-
import org.teiid.dqp.internal.cache.DQPContextCache;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
/**
*/
-public class FakeBufferService extends FakeAbstractService implements BufferService {
+public class FakeBufferService implements BufferService {
private BufferManager bufferMgr;
@@ -59,6 +58,14 @@
@Override
public DQPContextCache getContextCache() {
- return new DQPContextCache(new Properties(), new FakeCacheFactory());
+ DQPContextCache cache = new DQPContextCache();
+ cache.setCacheFactory(new FakeCacheFactory());
+ cache.setProcessName("test");
+ return cache;
}
+
+ @Override
+ public CacheFactory getCacheFactory() {
+ return null;
+ }
}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +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.dqp.service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.metadata.CompositeMetadataStore;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-/**
- */
-public class FakeMetadataService extends FakeAbstractService implements MetadataService {
-
- /**
- * Map of vdbname.vdbversion -> QueryMetadataInterface
- */
- private Map vdbMap = new HashMap();
-
- /**
- *
- */
- public FakeMetadataService() {
- super();
-
- // Load some default VDBs
- addVdb(null, null, FakeMetadataFactory.exampleBQTCached());
- addVdb("bqt", "1", FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$ //$NON-NLS-2$
- addVdb("example1", "1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private String getKey(String vdbName, String vdbVersion) {
- if(vdbName == null) {
- vdbName = ""; //$NON-NLS-1$
- }
- if(vdbVersion == null) {
- vdbVersion = ""; //$NON-NLS-1$
- }
- String vdbID = vdbName + "." + vdbVersion; //$NON-NLS-1$
- return vdbID.toLowerCase();
- }
-
- public synchronized void addVdb(String vdbName, String vdbVersion, QueryMetadataInterface metadata) {
- this.vdbMap.put(getKey(vdbName, vdbVersion), metadata);
- }
-
- /*
- * @see com.metamatrix.dqp.service.MetadataService#lookupMetadata(java.lang.String, java.lang.String)
- */
- public synchronized QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion) {
- return (QueryMetadataInterface) vdbMap.get(getKey(vdbName, vdbVersion));
- }
-
- @Override
- public CompositeMetadataStore getMetadataObjectSource(String vdbName,
- String vdbVersion) throws MetaMatrixComponentException {
- return null;
- }
-
- @Override
- public Map<String, Datatype> getBuiltinDatatypes()
- throws MetaMatrixComponentException {
- return null;
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,276 +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.dqp.service;
-
-import java.io.InputStream;
-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 java.util.Properties;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.vdb.runtime.VDBKey;
-
-/**
- */
-public class FakeVDBService extends FakeAbstractService implements VDBService {
- private Map vdbsMap = new HashMap(); // VdbInfo -> Map<Model name (upper), <ModelInfo>>
- private Map bindingNames = new HashMap(); // binding UUID -> binding name
- public Collection publicFiles = new HashSet();
- private boolean defaultPrivate;
-
- private static class FakeModel {
- String modelName;
- boolean multiSource = false;
- int visibility = ModelInfo.PUBLIC;;
- List bindingNames = new ArrayList(); // mapped to UUIDs
- List bindingUUIDs = new ArrayList(); // mapped to names
- }
-
- public void setDefaultPrivate(boolean defaultPrivate) {
- this.defaultPrivate = defaultPrivate;
- }
-
- /**
- * Method for testing - add a model with the specified properties. The vdb will be created
- * automatically under the hood.
- * @param vdbName vdb name
- * @param version vdb version
- * @param modelName model name
- * @param visibility MODEL_PUBLIC or MODEL_PRIVATE
- * @param multiSource true if model is multi-source
- * @since 4.2
- */
- public void addModel(String vdbName, String version, String modelName, int visibility, boolean multiSource) {
- FakeModel model = new FakeModel();
- model.visibility = visibility;
- model.multiSource = multiSource;
- model.modelName = modelName;
-
- VDBKey vdb = new VDBKey(vdbName, version);
- Map vdbModels = (Map)this.vdbsMap.get(vdb);
- if(vdbModels == null) {
- vdbModels = new HashMap();
- vdbsMap.put(vdb, vdbModels);
- }
- vdbModels.put(modelName.toUpperCase(), model);
- }
-
- /**
- * Method for testing - add a binding to a model with the specified names. If the model does not
- * exist, it will be created automatically with default properties.
- *
- * @param vdbName vdb name
- * @param version vdb version
- * @param model
- * @param connectorBindingID
- * @param connectorBindingName
- * @since 4.2
- */
- public void addBinding(String vdbName, String version, String modelName, String connectorBindingID, String connectorBindingName) {
- FakeModel model = null;
-
- // Find existing model
- VDBKey vdb = new VDBKey(vdbName, version);
- Map vdbModels = (Map)this.vdbsMap.get(vdb);
- if(vdbModels != null) {
- model = (FakeModel) vdbModels.get(modelName.toUpperCase());
- }
-
- // If model hasn't been added yet, add it with defaults
- if(model == null) {
- addModel(vdbName, version, modelName, ModelInfo.PUBLIC, false);
-
- // Re-lookup
- vdbModels = (Map)this.vdbsMap.get(vdb);
- model = (FakeModel) vdbModels.get(modelName.toUpperCase());
- }
-
- // Add binding to model
- model.bindingNames.add(connectorBindingName);
- model.bindingUUIDs.add(connectorBindingID);
-
- // Add uuid to name mapping
- this.bindingNames.put(connectorBindingID, connectorBindingName);
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.dqp.service.VDBService#isActiveVDB(java.lang.String, java.lang.String)
- */
- public boolean isActiveVDB(String vdbName, String vdbVersion) {
- return vdbsMap.containsKey(new VDBKey(vdbName, vdbVersion));
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.dqp.service.VDBService#getConnectorBinding(java.lang.String, java.lang.String, java.lang.String)
- */
- public List getConnectorBindingNames(String vdbName, String vdbVersion, String modelName) {
- VDBKey vdb = new VDBKey(vdbName, vdbVersion);
- Map vdbModels = (Map)this.vdbsMap.get(vdb);
- if(vdbModels != null) {
- FakeModel model = (FakeModel) vdbModels.get(modelName.toUpperCase());
- return model.bindingUUIDs;
- }
-
- return Collections.EMPTY_LIST;
- }
-
- /*
- * (non-Javadoc)
- * @see com.metamatrix.dqp.service.VDBService#getConnectorName(java.lang.String)
- */
- public String getConnectorName(String connectorBindingID) {
- return (String) this.bindingNames.get(connectorBindingID);
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.dqp.service.VDBService#getModelVisibility(java.lang.String, java.lang.String, java.lang.String)
- */
- public int getModelVisibility(String vdbName, String vdbVersion, String modelName) {
- VDBKey vdb = new VDBKey(vdbName, vdbVersion);
- Map vdbModels = (Map)this.vdbsMap.get(vdb);
- if(vdbModels != null) {
- FakeModel model = (FakeModel) vdbModels.get(modelName.toUpperCase());
- if(model != null) {
- return model.visibility;
- }
- }
- if (defaultPrivate) {
- return ModelInfo.PRIVATE;
- }
- return ModelInfo.PUBLIC;
- }
-
- /**
- * @see com.metamatrix.dqp.service.VDBConfiguration#getFileVisibility(java.lang.String, java.lang.String, java.lang.String)
- * @since 4.2
- */
- public int getFileVisibility(String vdbName, String vdbVersion, String pathInVDB) throws MetaMatrixComponentException {
- if(this.publicFiles.contains(pathInVDB)) {
- return ModelInfo.PUBLIC;
- }
- return ModelInfo.PRIVATE;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.dqp.service.VDBService#getVDBResourceFile(java.lang.String, java.lang.String)
- */
- public String getVDBResourceFile(String vdbName, String vdbVersion) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
- */
- public void initialize(Properties props) throws ApplicationInitializationException {
-// vdbsMap = props;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
- */
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.common.application.ApplicationService#stop()
- */
- public void stop() throws ApplicationLifecycleException {
- // TODO Auto-generated method stub
-
- }
-
- public List getMultiSourceModels(String vdbName,
- String vdbVersion) throws MetaMatrixComponentException {
-
- VDBKey vdb = new VDBKey(vdbName, vdbVersion);
- Map vdbModels = (Map)this.vdbsMap.get(vdb);
- if(vdbModels != null) {
- List multiModels = new ArrayList();
-
- Iterator modelIter = vdbModels.values().iterator();
- while(modelIter.hasNext()) {
- FakeModel model = (FakeModel) modelIter.next();
- if(model.multiSource) {
- multiModels.add(model.modelName);
- }
- }
-
- return multiModels;
- }
-
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @see com.metamatrix.dqp.service.VDBService#getVDBResource(java.lang.String, java.lang.String)
- * @since 4.3
- */
- public InputStream getVDBResource(String vdbName,
- String vdbVersion) throws MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.dqp.service.VDBService#getVDBStatus(java.lang.String, java.lang.String)
- * @since 4.3
- */
- public int getVDBStatus(String vdbName,
- String vdbVersion) throws MetaMatrixComponentException {
- return 0;
- }
-
- /**
- * @see com.metamatrix.dqp.service.VDBService#changeVDBStatus(java.lang.String, java.lang.String, int)
- * @since 4.3
- */
- public void changeVDBStatus(String vdbName,String vdbVersion,int status) throws ApplicationLifecycleException,MetaMatrixComponentException {
- }
-
- /**
- * @see com.metamatrix.dqp.service.VDBService#getAvailableVDBs()
- * @since 4.3
- */
- public List getAvailableVDBs() throws MetaMatrixComponentException {
- return null;
- }
-
- @Override
- public VDBArchive getVDB(String vdbName, String vdbVersion)
- throws MetaMatrixComponentException {
- throw new UnsupportedOperationException();
- }
-
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,7 +24,7 @@
import java.util.*;
-import com.metamatrix.core.util.StringUtilities;
+import com.metamatrix.core.util.StringUtil;
import junit.framework.TestCase;
@@ -75,7 +75,7 @@
rec.println("b"); //$NON-NLS-1$
String log = rec.getDebugLog();
- assertEquals("a" + StringUtilities.LINE_SEPARATOR + "b" + StringUtilities.LINE_SEPARATOR, log); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("a" + StringUtil.LINE_SEPARATOR + "b" + StringUtil.LINE_SEPARATOR, log); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -33,9 +33,9 @@
import java.util.Properties;
import org.junit.Test;
+import org.teiid.connector.language.SQLReservedWords;
import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.unittest.TimestampUtil;
import com.metamatrix.query.util.CommandContext;
@@ -845,18 +845,18 @@
}
@Test public void testTimestampAdd2() throws Exception {
- assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
+ assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(SQLReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
}
@Test public void testTimestampDiffTimeStamp_FracSec_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 1),
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100000000),
new Long(99999999));
}
@Test public void testTimestampDiffTimeStamp_FracSec_2() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
// 1 day (8.64 x 10^10 nanos) and 1 nano
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 2),
TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 3),
@@ -864,7 +864,7 @@
}
@Test public void testTimestampDiffTimeStamp_FracSec_3() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
// 1 day (8.64 x 10^10 nanos) less 1 nano
TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 2),
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 3),
@@ -872,28 +872,28 @@
}
@Test public void testTimestampDiffTimeStamp_FracSec_4() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 1),
TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 3),
new Long(00000002));
}
@Test public void testTimestampDiffTimeStamp_FracSec_5() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 1),
TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 10),
new Long(9));
}
@Test public void testTimestampDiffTimeStamp_FracSec_6() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 2),
TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 3),
new Long(1));
}
@Test public void testTimestampDiffTimeStamp_FracSec_7() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
// 1 nano diff
TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
@@ -901,7 +901,7 @@
}
@Test public void testTimestampDiffTimeStamp_FracSec_8() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
// 1 nano diff
TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
@@ -909,98 +909,98 @@
}
@Test public void testTimestampDiffTimeStamp_Min_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp(0, 0, 0, 2, 34, 12, 0),
TimestampUtil.createTimestamp(0, 0, 0, 12, 0, 0, 0),
new Long(565));
}
@Test public void testTimestampDiffTimeStamp_Min_2() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 0, 0, 2, 0, 0, 0),
TimestampUtil.createTimestamp((2001-1900), 0, 0, 0, 33, 12, 0),
new Long(-86));
}
@Test public void testTimestampDiffTimeStamp_Min_3() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 65497),
TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 483219),
new Long(4277));
}
@Test public void testTimestampDiffTimeStamp_Min_4() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 0),
TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 0),
new Long(4277));
}
@Test public void testTimestampDiffTimeStamp_Min_5() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 1),
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 0),
new Long(0));
}
@Test public void testTimestampDiffTimeStamp_Hour_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR,
TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 0, 0, 0),
TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 59, 59, 999999999),
new Long(0));
}
@Test public void testTimestampDiffTimeStamp_Week_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_WEEK,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_WEEK,
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100),
TimestampUtil.createTimestamp((2001-1900), 4, 2, 5, 19, 35, 500),
new Long(-7));
}
@Test public void testTimestampDiffTimeStamp_Month_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 0),
TimestampUtil.createTimestamp((2004-1900), 11, 20, 12, 0, 0, 0),
new Long(7));
}
@Test public void testTimestampDiffTimeStamp_Month_2() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0, 1000000),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 12, 0, 0, 1),
new Long(6));
}
@Test public void testTimestampDiffTimeStamp_Month_3() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 1),
TimestampUtil.createTimestamp((2004-1900), 11, 18, 12, 0, 0, 1000000),
new Long(7));
}
@Test public void testTimestampDiffTimeStamp_Month_4() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 0, 1000000),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
new Long(7));
}
@Test public void testTimestampDiffTimeStamp_Month_5() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
new Long(7));
}
@Test public void testTimestampDiffTimeStamp_Month_6() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 2, 0),
new Long(7));
}
@Test public void testTimestampDiffTimeStamp_Day_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_DAY,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
TimestampUtil.createTimestamp((2004-1900), 3, 1, 0, 0, 0, 0),
new Long(31));
@@ -1008,20 +1008,20 @@
@Test public void testTimestampDiffTimeStamp_Day_2() throws Exception {
// Leap year
- helpTestTimestampDiff(ReservedWords.SQL_TSI_DAY,
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
TimestampUtil.createTimestamp((2004-1900), 1, 1, 0, 0, 0, 0),
TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
new Long(29));
}
@Test public void testTimestampDiffTime_Hour_1() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR, new Timestamp(
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(
TimestampUtil.createTime(5, 5, 36).getTime()), new Long(2));
}
@Test public void testTimestampDiffTime_Hour_2() throws Exception {
- helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR, new Timestamp(
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
TimestampUtil.createTime(5, 0, 30).getTime()), new Timestamp(
TimestampUtil.createTime(3, 0, 31).getTime()), new Long(-1));
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,7 +22,12 @@
package com.metamatrix.query.function;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -30,6 +35,7 @@
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Properties;
import java.util.TimeZone;
@@ -38,13 +44,12 @@
import org.junit.Before;
import org.junit.Test;
import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.SQLReservedWords;
import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.InvalidFunctionException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.unittest.TimestampUtil;
import com.metamatrix.query.util.CommandContext;
@@ -63,7 +68,7 @@
private static final Class T_DATE = DataTypeManager.DefaultDataClasses.DATE;
private static final Class T_TIMESTAMP = DataTypeManager.DefaultDataClasses.TIMESTAMP;
- private FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
+ private FunctionLibrary library = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
@Before public void setUp() {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00")); //$NON-NLS-1$
@@ -175,14 +180,14 @@
}
}
- private void helpInvokeMethod(String fname, Class[] types, Object[] inputs, CommandContext context, Object expectedOutput) throws InvalidFunctionException, FunctionExecutionException {
+ private void helpInvokeMethod(String fname, Class[] types, Object[] inputs, CommandContext context, Object expectedOutput) throws FunctionExecutionException {
Object actualOutput = helpInvokeMethod(fname, types, inputs, context);
assertEquals("Actual function output not equal to expected: ", expectedOutput, actualOutput); //$NON-NLS-1$
}
private Object helpInvokeMethod(String fname, Class[] types,
Object[] inputs, CommandContext context)
- throws InvalidFunctionException, FunctionExecutionException {
+ throws FunctionExecutionException {
if (types == null) {
// Build type signature
types = new Class[inputs.length];
@@ -196,27 +201,27 @@
Object actualOutput = null;
// Find function descriptor
FunctionDescriptor descriptor = library.findFunction(fname, types);
- if (descriptor != null && descriptor.requiresContext()) {
+ if (descriptor.requiresContext()) {
// Invoke function with inputs
Object[] in = new Object[inputs.length+1];
in[0] = context;
for (int i = 0; i < inputs.length; i++) {
in[i+1] = inputs[i];
}
- actualOutput = library.invokeFunction(descriptor, in);
+ actualOutput = descriptor.invokeFunction(in);
}
else {
// Invoke function with inputs
- actualOutput = library.invokeFunction(descriptor, inputs);
+ actualOutput = descriptor.invokeFunction(inputs);
}
return actualOutput;
}
- private void helpInvokeMethodFail(String fname, Object[] inputs) throws InvalidFunctionException {
+ private void helpInvokeMethodFail(String fname, Object[] inputs) {
helpInvokeMethodFail(fname, null, inputs);
}
- private void helpInvokeMethodFail(String fname, Class<?> types[], Object[] inputs) throws InvalidFunctionException {
+ private void helpInvokeMethodFail(String fname, Class<?> types[], Object[] inputs) {
try {
helpInvokeMethod(fname, types, inputs, null);
fail("expected exception"); //$NON-NLS-1$
@@ -460,15 +465,13 @@
// Walk through all functions by metadata
@Test public void testEnumerateForms() {
- FunctionLibrary lib = FunctionLibraryManager.getFunctionLibrary();
-
- Collection categories = lib.getFunctionCategories();
+ Collection categories = library.getFunctionCategories();
Iterator catIter = categories.iterator();
while(catIter.hasNext()) {
String category = (String) catIter.next();
//System.out.println("Category: " + category);
- Collection functions = lib.getFunctionForms(category);
+ Collection functions = library.getFunctionForms(category);
Iterator functionIter = functions.iterator();
while(functionIter.hasNext()) {
FunctionForm form = (FunctionForm) functionIter.next();
@@ -984,68 +987,68 @@
/** date + month --> count=18, inteval=month, result should be 2004-11-15 */
@Test public void testInvokeTimestampAddDate2() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
new Integer(18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 10, 15).getTime()));
}
/** date + month --> count=-18, inteval=month, result should be 2001-11-15 */
@Test public void testInvokeTimestampAddDate2a() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
new Integer(-18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(101, 10, 15).getTime()));
}
/** date + week --> count=6, inteval=week, result should be 2003-04-03 */
@Test public void testInvokeTimestampAddDate3() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
new Integer(-6), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(103, 3, 3).getTime()));
}
/** date + quarter --> count=3, inteval=quarter, result should be 2004-2-15 */
@Test public void testInvokeTimestampAddDate4() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_QUARTER, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_QUARTER, //$NON-NLS-1$
new Integer(3), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 1, 15).getTime()));
}
/** date + year --> count=-1, inteval=year, result should be 2002-5-15 */
@Test public void testInvokeTimestampAddDate5() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_YEAR, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_YEAR, //$NON-NLS-1$
new Integer(-1), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(102, 4, 15).getTime()));
}
/** time + minute --> count=23, inteval=3, result should be 03:32:12 */
@Test public void testInvokeTimestampAddTime1() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MINUTE, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MINUTE, //$NON-NLS-1$
new Integer(23), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 32, 12).getTime()));
}
/** time + hour --> count=21, inteval=4, result should be 00:09:12 and overflow */
@Test public void testInvokeTimestampAddTime2() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
new Integer(21), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 0, 9, 12, 0));
}
/** time + hour --> count=2, inteval=4, result should be 01:12:12*/
@Test public void testInvokeTimestampAddTime3() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
new Integer(2), new Timestamp(TimestampUtil.createTime(23, 12, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 1, 12, 12, 0));
}
/** time + second --> count=23, inteval=2, result should be 03:10:01 */
@Test public void testInvokeTimestampAddTime4() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
new Integer(49), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 10, 1).getTime()));
}
/** timestamp + second --> count=23, inteval=2, result should be 2003-05-15 03:09:35.100 */
@Test public void testInvokeTimestampAddTimestamp1() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
new Integer(23), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)},
TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 35, 100));
}
/** timestamp + nanos --> count=1, inteval=1, result should be 2003-05-15 03:09:12.000000101 */
@Test public void testInvokeTimestampAddTimestamp2() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
new Integer(1), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)},
TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 101));
}
@@ -1054,14 +1057,14 @@
* with increase in second and minutes, because second already at 59 sec originally
*/
@Test public void testInvokeTimestampAddTimestamp3() {
- helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
new Integer(2100000000), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 59, 1)},
TimestampUtil.createTimestamp(103, 4, 15, 3, 10, 1, 100000003));
}
/** time --> interval=hour, time1 = 03:04:45, time2= 05:05:36 return = 2 */
@Test public void testInvokeTimestampDiffTime1() {
- helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
new Timestamp(TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(TimestampUtil.createTime(5, 5, 36).getTime()) },
new Long(2));
}
@@ -1077,7 +1080,7 @@
* time2= 2003-05-02 05:19:35.500 return = 45
*/
@Test public void testInvokeTimestampDiffTimestamp1() {
- helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100), TimestampUtil.createTimestamp(103, 4, 2, 5, 19, 35, 500) },
new Long(45));
}
@@ -1087,7 +1090,7 @@
* time2= 2002-06-21 03:09:35.100000000 return = 999999999
*/
@Test public void testInvokeTimestampDiffTimestamp2() {
- helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 1), TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100000000) },
new Long(99999999));
}
@@ -1097,7 +1100,7 @@
* time2= 2002-06-22 03:09:35.000000001 return =
*/
@Test public void testInvokeTimestampDiffTimestamp3() {
- helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 2), TimestampUtil.createTimestamp(102, 5, 22, 3, 9, 35, 1) },
new Long(86399999999999L));
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,6 @@
package com.metamatrix.query.function;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -99,13 +97,9 @@
public Class getInvocationClass(String className) throws ClassNotFoundException {
throw new ClassNotFoundException("Could not find class " + className); //$NON-NLS-1$
}
-
- public void loadFunctions(InputStream source) throws IOException{
- }
};
- FunctionLibraryManager.registerSource(dummySource);
- FunctionLibraryManager.reloadSources();
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(dummySource.getFunctionMethods())));
}
public void testNullCategory() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -34,6 +34,7 @@
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.util.ResolverVisitor;
import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestResolvedFunctions extends TestCase {
@@ -88,7 +89,7 @@
BlockedException,
MetaMatrixComponentException, QueryResolverException {
Expression expr = QueryParser.getQueryParser().parseExpression(sql);
- ResolverVisitor.resolveLanguageObject(expr, null);
+ ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1());
return Evaluator.evaluate(expr);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,10 @@
package com.metamatrix.query.optimizer;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.function.FunctionMetadataSource;
import com.metamatrix.query.function.metadata.FunctionMethod;
import com.metamatrix.query.function.metadata.FunctionParameter;
@@ -54,9 +51,6 @@
return Class.forName(className);
}
- public void loadFunctions(InputStream source) throws IOException{
- }
-
// dummy function
public static Object xyz() {
return null;
@@ -67,9 +61,4 @@
String string = (String)astring;
return string.trim();
}
-
- public static void setupFunctionLibrary() {
- FunctionLibraryManager.registerSource(new FakeFunctionMetadataSource());
- }
-
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,6 +26,7 @@
import org.junit.Test;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -354,7 +355,7 @@
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(
"select count(*), a.intnum from bqt1.smalla as a, bqt2.smallb as b where a.intkey = b.intkey group by a.intnum", //$NON-NLS-1$
@@ -394,7 +395,7 @@
String sql = "select a11.intkey ITEM_ID, sum(a11.intnum) WJXBFS1 from bqt1.smalla a11 join bqt2.smalla a12 on (a11.stringkey = a12.stringkey) join bqt2.smallb a13 on (a11.intkey = a13.intkey) where a13.intnum in (10) group by a11.intkey"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQT(), null, capFinder,
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
new String[] {"SELECT g_0.stringkey FROM bqt2.smalla AS g_0", "SELECT g_0.stringkey, g_0.intkey, SUM(g_0.intnum) FROM bqt1.smalla AS g_0 GROUP BY g_0.stringkey, g_0.intkey", "SELECT g_0.intkey FROM bqt2.smallb AS g_0 WHERE g_0.intnum = 10"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -423,7 +424,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(
"select count(*) from bqt1.smalla", //$NON-NLS-1$
@@ -442,7 +443,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(
"select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1", //$NON-NLS-1$
@@ -514,14 +515,14 @@
String sql = "SELECT Q1.S, Q2.C, Q1.PRODUCT, Q1.REGION AS Q1R, Q2.REGION AS Q2R FROM " + //$NON-NLS-1$
"(SELECT SUM(SALES) AS S, REGION, PRODUCT FROM DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT) Q1 " + //$NON-NLS-1$
"FULL OUTER JOIN " + //$NON-NLS-1$
- "(SELECT SUM(COSTS) AS C, REGION FROM ORACLE_TABLE WHERE YEAR = '1999' GROUP BY REGION) Q2 " + //$NON-NLS-1$
+ "(SELECT SUM(COSTS) AS C, REGION FROM ORACLE_TABLE WHERE \"YEAR\" = '1999' GROUP BY REGION) Q2 " + //$NON-NLS-1$
"ON Q1.REGION = Q2.REGION"; //$NON-NLS-1$
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
new String[] {"SELECT REGION, SUM(SALES), PRODUCT FROM db2model.DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT", //$NON-NLS-1$
- "SELECT REGION, SUM(COSTS) FROM oraclemodel.Oracle_table WHERE YEAR = '1999' GROUP BY REGION"}, //$NON-NLS-1$
+ "SELECT REGION, SUM(COSTS) FROM oraclemodel.Oracle_table WHERE \"YEAR\" = '1999' GROUP BY REGION"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, new int[] {
@@ -567,8 +568,8 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_0.MONTH, g_0.YEAR FROM msModel.\"TIME\" AS g_0 WHERE g_0.YEAR = '1999'", //$NON-NLS-1$
- "SELECT DISTINCT g_0.MONTH AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.MONTH IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.MONTH, g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
+ new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
+ "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
"SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
@@ -615,8 +616,8 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_0.MONTH, g_0.YEAR FROM msModel.\"TIME\" AS g_0 WHERE g_0.YEAR = '1999'", //$NON-NLS-1$
- "SELECT DISTINCT g_0.MONTH AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.MONTH IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.MONTH, g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
+ new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
+ "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
"SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
@@ -663,8 +664,8 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT DISTINCT g_0.MONTH AS c_0, g_1.REGION AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.MONTH IN (<dependent values>)) GROUP BY g_0.MONTH, g_1.REGION ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.MONTH AS c_0, g_0.YEAR AS c_1 FROM msModel.\"TIME\" AS g_0 WHERE g_0.YEAR = '1999' ORDER BY c_0"}, //$NON-NLS-1$
+ new String[] {"SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_1.REGION AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.\"MONTH\" IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_1.REGION ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.\"MONTH\" AS c_0, g_0.\"YEAR\" AS c_1 FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999' ORDER BY c_0"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,6 +29,9 @@
import junit.framework.TestCase;
+import org.teiid.metadata.TransformationMetadata;
+
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -731,11 +734,9 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
- FakeMetadataObject g2 = metadata.getStore().findObject("BQT2.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(
"SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey", //$NON-NLS-1$
@@ -777,11 +778,9 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
- FakeMetadataObject g2 = metadata.getStore().findObject("BQT2.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+ TransformationMetadata metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(
"SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey AND table1comp.key1 = BQT1.SmallA.StringNum", //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,18 +31,18 @@
import org.junit.Test;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestInlineView {
- public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ public static QueryMetadataInterface createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
@@ -245,7 +245,7 @@
protected void runTest(InlineViewCase testCase) throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -256,7 +256,7 @@
@Test public void testAliasCreationWithInlineView() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
@@ -268,7 +268,7 @@
@Test public void testAliasPreservationWithInlineView() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
@@ -283,7 +283,7 @@
*/
@Test public void testCrossSourceInlineView() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -34,6 +34,7 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -146,7 +147,7 @@
capFinder.addCapabilities(BQT1, caps);
capFinder.addCapabilities(BQT2, caps);
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
@@ -510,7 +511,7 @@
}
@Test public void testRulePushNonJoinCriteriaPreservesOuterJoin() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select b.intkey from (select intkey from bqt1.smalla) a left outer join (select intkey from bqt1.smallb) b on (1 = 1)"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
@@ -520,7 +521,7 @@
}
@Test public void testOuterToInnerJoinConversion() {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smallb.intnum = 1)"}); //$NON-NLS-1$
@@ -528,21 +529,21 @@
//same as above, but with a right outer join
@Test public void testOuterToInnerJoinConversion1() {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla right outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb, bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = 1)"}); //$NON-NLS-1$
}
@Test public void testOuterToInnerJoinConversion2() {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb LEFT OUTER JOIN bqt1.smalla ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smallb.intnum = 1"}); //$NON-NLS-1$
}
@Test public void testOuterToInnerJoinConversion3() {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smalla.intnum = 1"}); //$NON-NLS-1$
@@ -552,7 +553,7 @@
* non-depenent criteria on each side of a full outer creates an inner join
*/
@Test public void testOuterToInnerJoinConversion4() {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = bqt1.smallb.intnum"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = bqt1.smallb.intnum)"}); //$NON-NLS-1$
@@ -571,7 +572,7 @@
caps.setFunctionSupport("concat2", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where concat2(bqt1.smallb.intnum, '1') = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[]{"SELECT bqt1.smallb.intnum, bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -44,6 +44,10 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.FunctionTree;
+import com.metamatrix.query.function.SystemFunctionManager;
+import com.metamatrix.query.function.UDFSource;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -164,7 +168,7 @@
}
public static ProcessorPlan helpPlan(String sql,
- FakeMetadataFacade md, String[] expected,
+ QueryMetadataInterface md, String[] expected,
CapabilitiesFinder capFinder,
ComparisonMode mode) throws QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
return helpPlan(sql, md, null, capFinder, expected, mode);
@@ -2722,7 +2726,7 @@
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(
"SELECT StringCol AS E " + //$NON-NLS-1$
@@ -2753,7 +2757,7 @@
}
@Test public void testDefect9827() {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan("SELECT intkey, c FROM (SELECT DISTINCT b.intkey, b.intnum, a.stringkey AS c FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY) AS x ORDER BY x.intkey", metadata, //$NON-NLS-1$
new String[] {"SELECT DISTINCT b.intkey, b.intnum, a.stringkey FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY"} ); //$NON-NLS-1$
@@ -3432,7 +3436,7 @@
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql, metadata,
null, capFinder,
@@ -3617,46 +3621,6 @@
});
}
- @Test public void testDefect12298() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- capFinder.addCapabilities("SystemPhysical", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT VDBName PKVDB, PKGroupFullName, PKElementName, VDBName FKVDB,FKGroupFullName, FKElementName, convert(FKPosition, short) As FKPosition, FKKeyName, PKKeyName " + //$NON-NLS-1$
- "FROM System.ReferenceKeyElements WHERE PKKeyType = 'Primary' AND FKKeyType = 'Foreign' AND FKGroupFullName = 'PartsOracle.SUPPLIER_PARTS'", //$NON-NLS-1$
- FakeMetadataFactory.exampleSystemPhysical(),
- null, capFinder,
- new String[] {
- "SELECT g_2.VDB_NM, g_1.PATH_1, g_8.ELMNT_NM, g_10.PATH_1, g_17.ELMNT_NM, g_16.POSITION, g_9.KEY_NM, g_0.KEY_NM FROM ((((SystemPhysical.RT_KY_IDXES AS g_0 INNER JOIN ((SystemPhysical.RT_GRPS AS g_1 INNER JOIN ((SystemPhysical.RT_VIRTUAL_DBS AS g_2 INNER JOIN SystemPhysical.RT_VDB_MDLS AS g_3 ON g_2.VDB_UID = g_3.VDB_UID) INNER JOIN SystemPhysical.RT_MDLS AS g_4 ON g_3.MDL_UID = g_4.MDL_UID) ON g_1.MDL_UID = g_4.MDL_UID) INNER JOIN SystemPhysical.RT_TABLE_TYPES AS g_5 ON g_1.TABLE_TYPE = g_5.TABLE_TYPE_CODE) ON g_0.GRP_UID = g_1.GRP_UID) INNER JOIN SystemPhysical.RT_KEY_TYPES AS g_6 ON g_0.KEY_TYPE = g_6.KEY_TYPE_CODE) LEFT OUTER JOIN SystemPhysical.RT_KY_IDX_ELMNTS AS g_7 ON g_7.KEY_UID = g_0.KEY_UID) INNER JOIN SystemPhysical.RT_ELMNTS AS g_8 ON g_7.ELMNT_UID = g_8.ELMNT_UID) INNER JOIN ((((SystemPhysical.RT_KY_IDXES AS g_9 INNER JOIN ((SystemPhysical.RT_GRPS AS g_10 INNER JOIN ((SystemPhysical.RT_VIRTUAL_DBS AS g_11 INNER JOIN SystemPhysical.RT!
_VDB_MDLS AS g_12 ON g_11.VDB_UID = g_12.VDB_UID) INNER JOIN SystemPhysical.RT_MDLS AS g_13 ON g_12.MDL_UID = g_13.MDL_UID) ON g_10.MDL_UID = g_13.MDL_UID) INNER JOIN SystemPhysical.RT_TABLE_TYPES AS g_14 ON g_10.TABLE_TYPE = g_14.TABLE_TYPE_CODE) ON g_9.GRP_UID = g_10.GRP_UID) INNER JOIN SystemPhysical.RT_KEY_TYPES AS g_15 ON g_9.KEY_TYPE = g_15.KEY_TYPE_CODE) LEFT OUTER JOIN SystemPhysical.RT_KY_IDX_ELMNTS AS g_16 ON g_16.KEY_UID = g_9.KEY_UID) INNER JOIN SystemPhysical.RT_ELMNTS AS g_17 ON g_16.ELMNT_UID = g_17.ELMNT_UID) ON g_0.KEY_UID = g_9.REF_KEY_UID AND g_7.POSITION = g_16.POSITION WHERE (g_1.TABLE_TYPE <> 5) AND (g_3.VISIBILITY = 0) AND (g_5.TABLE_TYPE_CODE <> 5) AND (g_6.KEY_TYPE_NM = 'Primary') AND (g_10.TABLE_TYPE <> 5) AND (g_10.PATH_1 = 'PartsOracle.SUPPLIER_PARTS') AND (g_12.VISIBILITY = 0) AND (g_14.TABLE_TYPE_CODE <> 5) AND (g_15.KEY_TYPE_NM = 'Foreign')" //$NON-NLS-1$
- },
- ComparisonMode.EXACT_COMMAND_STRING);
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
-
- });
- }
-
// SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
@Test public void testCase1727_1() {
ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
@@ -3793,7 +3757,7 @@
expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" }; //$NON-NLS-1$//$NON-NLS-2$
}
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql, metadata,
null, capFinder, expectedSql, SHOULD_SUCCEED);
@@ -4099,7 +4063,7 @@
caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan("SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB", metadata, //$NON-NLS-1$
null, capFinder,
@@ -4242,7 +4206,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT intnum, 10 FROM bqt1.smalla) AS x", //$NON-NLS-1$
- FakeMetadataFactory.exampleBQT(),
+ FakeMetadataFactory.exampleBQTCached(),
null, capFinder,
new String[] {"SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT IntNum, 10 FROM bqt1.smalla"}, //$NON-NLS-1$
SHOULD_SUCCEED);
@@ -4360,7 +4324,6 @@
}
@Test public void testPushdownFunctionNotEvaluated() {
- FakeFunctionMetadataSource.setupFunctionLibrary();
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4370,7 +4333,9 @@
caps.setFunctionSupport("xyz", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+
ProcessorPlan plan = helpPlan(
"SELECT e1 FROM pm1.g1 WHERE xyz() > 0", //$NON-NLS-1$
@@ -4406,7 +4371,7 @@
}
/** defect 14510 */
- @Test public void testDefect14510LookupFunction() {
+ @Test public void testDefect14510LookupFunction() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4417,11 +4382,9 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("BQT1.SmallB", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.smallb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
ProcessorPlan plan = helpPlan(
"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = lookup('BQT1.SmallB', 'IntKey', 'StringKey', BQT1.SmallB.StringKey)) AND (BQT1.SmallA.IntKey = 1)", //$NON-NLS-1$
@@ -4449,7 +4412,7 @@
}
/** defect 14510 */
- @Test public void testDefect14510LookupFunction2() {
+ @Test public void testDefect14510LookupFunction2() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4461,11 +4424,9 @@
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("BQT1.MediumB", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
ProcessorPlan plan = helpPlan(
"SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT1.MediumB ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey', BQT1.MediumB.StringKey)", //$NON-NLS-1$
@@ -4493,7 +4454,7 @@
}
/** defect 14510 */
- @Test public void testDefect14510LookupFunction3() {
+ @Test public void testDefect14510LookupFunction3() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4505,11 +4466,9 @@
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("BQT1.MediumB", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
ProcessorPlan plan = helpPlan(
"SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.MediumB RIGHT OUTER JOIN BQT1.SmallA ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey',BQT1.MediumB.StringKey)", //$NON-NLS-1$
@@ -4756,7 +4715,7 @@
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT t.intkey FROM (SELECT a.IntKey FROM bqt1.smalla a left outer join bqt1.smallb b on a.intkey=b.intkey, bqt1.smalla x) as t full outer JOIN bqt1.smallb c on t.intkey = c.intkey"; //$NON-NLS-1$
@@ -4957,7 +4916,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql,
metadata,
@@ -5000,7 +4959,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql,
metadata,
@@ -5283,7 +5242,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql,
metadata,
@@ -5334,7 +5293,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql,
metadata,
@@ -5394,7 +5353,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql,
metadata,
@@ -5507,7 +5466,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql,
metadata,
@@ -5567,7 +5526,7 @@
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT intkey, x FROM (select intkey, intkey x from bqt1.smalla) z ORDER BY x, intkey"; //$NON-NLS-1$
@@ -5598,7 +5557,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT vqt.smallb.a12345 FROM vqt.smallb ORDER BY vqt.smallb.a12345"; //$NON-NLS-1$
@@ -5627,7 +5586,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as EXPR, bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR, EXPR_1"; //$NON-NLS-1$
@@ -5656,7 +5615,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum), bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR_1"; //$NON-NLS-1$
@@ -5686,7 +5645,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT b1.intkey from (bqt1.SmallA a1 cross join bqt1.smalla a2 cross join bqt1.mediuma b1) " + //$NON-NLS-1$
" left outer join bqt1.mediumb b2 on b1.intkey = b2.intkey"; //$NON-NLS-1$
@@ -5715,7 +5674,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT bqt1.SmallA.intkey from (bqt1.SmallA inner join (" //$NON-NLS-1$
+ "SELECT BAD.intkey from bqt1.SmallB as BAD left outer join bqt1.MediumB on BAD.intkey = bqt1.MediumB.intkey) as X on bqt1.SmallA.intkey = X.intkey) inner join bqt1.MediumA on X.intkey = bqt1.MediumA.intkey"; //$NON-NLS-1$
@@ -5785,7 +5744,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select bqt1.smalla.intkey from bqt1.smalla, bqt2.smalla, bqt2.smallb where bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.intkey = bqt2.smallb.intkey and bqt2.smalla.stringkey = bqt2.smallb.stringkey"; //$NON-NLS-1$
@@ -5833,7 +5792,7 @@
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT * from (select '1' as test, intkey from bqt2.smalla) foo, (select '2' as test, intkey from bqt2.smalla) foo2 where foo.intkey = foo2.intkey"; //$NON-NLS-1$
@@ -6143,7 +6102,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
@@ -6174,7 +6133,7 @@
caps.setFunctionSupport("+", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
@@ -6233,7 +6192,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
@@ -6301,7 +6260,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(
"SELECT A.IntKey, B.IntKey FROM BQT1.SmallA A LEFT OUTER JOIN BQT2.MediumB B ON A.IntKey = B.IntKey", //$NON-NLS-1$
@@ -6332,7 +6291,7 @@
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(
"SELECT 'a' as A FROM BQT1.SmallA A UNION select 'b' as B from BQT1.MediumB B", //$NON-NLS-1$
@@ -6350,7 +6309,7 @@
caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "select b from (select distinct booleanvalue b, intkey from bqt1.smalla) as x"; //$NON-NLS-1$
@@ -6386,7 +6345,7 @@
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String sql = "SELECT a.intkey as stringkey, b.stringkey as key2 from bqt1.smalla a, bqt1.smallb b where a.intkey = b.intkey order by stringkey"; //$NON-NLS-1$
@@ -6404,7 +6363,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
// Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(
"SELECT intkey from bqt1.smalla WHERE stringkey = convert(objectvalue, string)", //$NON-NLS-1$
@@ -6439,7 +6398,7 @@
capFinder.addCapabilities("LOB", caps); //$NON-NLS-1$
// Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(
"SELECT ClobValue from LOB.LobTbl WHERE convert(ClobValue, string) = ?", //$NON-NLS-1$
@@ -6529,7 +6488,7 @@
String sql = "select count(*) from (select intkey from bqt1.smalla union all select intkey from bqt1.smallb) as a"; //$NON-NLS-1$
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQT(), null, capFinder,
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
new String[] {"SELECT COUNT(*) FROM (SELECT intkey FROM bqt1.smalla UNION ALL SELECT intkey FROM bqt1.smallb) AS a"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -6649,7 +6608,7 @@
@Test public void testCopyCriteriaWithIsNull() {
String sql = "select * from (select a.intnum, a.intkey y, b.intkey from bqt1.smalla a, bqt2.smalla b where a.intkey = b.intkey) x where intkey is null"; //$NON-NLS-1$
- helpPlan(sql, FakeMetadataFactory.exampleBQT(), new String[] {});
+ helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {});
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,6 +26,7 @@
import org.junit.Test;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
@@ -281,7 +282,7 @@
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,13 +26,13 @@
import junit.framework.TestCase;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -67,7 +67,7 @@
String sql = "select * from ( select intkey as cola, null as colb, intnum as colc from bqt1.smalla union all select null, intkey, intnum from bqt2.smalla) as X where X.cola = 1"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQT(),
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
new String[] {"SELECT intkey, null, intnum FROM bqt1.smalla WHERE intkey = 1"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
@@ -263,7 +263,7 @@
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,141 +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.query.optimizer.relational;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-import static org.junit.Assert.*;
-
-import java.util.Collection;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.analysis.QueryAnnotation;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestMaterialization {
-
- @Test public void testMaterializedTransformation() throws Exception {
- String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
- @Test public void testMaterializedTransformationLoading() throws Exception {
- String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- @Test public void testMaterializedTransformationNoCache() throws Exception {
- String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- //related to defect 14423
- @Test public void testMaterializedTransformationNoCache2() throws Exception {
- String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- @Test public void testNoCacheInTransformation() throws Exception {
- String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testTableNoCacheDoesntCascade() throws Exception {
- String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testNoCacheCascade() throws Exception {
- String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
-}
Copied: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,141 @@
+/*
+ * 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.query.optimizer.relational;
+
+import static com.metamatrix.query.optimizer.TestOptimizer.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestMaterialization {
+
+ @Test public void testMaterializedTransformation() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
+ @Test public void testMaterializedTransformationLoading() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testMaterializedTransformationNoCache() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ //related to defect 14423
+ @Test public void testMaterializedTransformationNoCache2() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheInTransformation() throws Exception {
+ String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testTableNoCacheDoesntCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -59,7 +59,7 @@
Criteria result = QueryParser.getQueryParser().parseCriteria(critString);
QueryResolver.resolveCriteria(result, metadata);
- result = QueryRewriter.rewriteCriteria(result, null, new CommandContext(), null);
+ result = QueryRewriter.rewriteCriteria(result, null, new CommandContext(), metadata);
return result;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,6 +25,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.teiid.connector.language.SQLReservedWords;
+
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -34,7 +36,6 @@
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -190,7 +191,7 @@
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -202,7 +203,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -214,7 +215,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
@@ -226,7 +227,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -238,7 +239,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -250,7 +251,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
@@ -261,7 +262,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -272,7 +273,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
@@ -283,7 +284,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -294,7 +295,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
@@ -305,7 +306,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -316,7 +317,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
@@ -327,7 +328,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -338,7 +339,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
@@ -350,7 +351,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, false);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, false);
}
@@ -362,7 +363,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, true);
- AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -119,7 +119,7 @@
SubqueryCompareCriteria crit = new SubqueryCompareCriteria(e1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
SubqueryCompareCriteria expected = new SubqueryCompareCriteria(x1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
- FrameUtil.convertCriteria(crit, symbolMap);
+ FrameUtil.convertCriteria(crit, symbolMap, null);
assertEquals(crit, expected);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,14 @@
package com.metamatrix.query.parser;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.query.sql.lang.StoredProcedure;
-public class TestCallableStatementParsing extends junit.framework.TestCase {
+public class TestCallableStatementParsing {
private void helpTestIllegalCall(String call) {
try {
@@ -44,14 +48,14 @@
assertEquals("EXEC procedure_name(?, ?, ?)", sp.toString()); //$NON-NLS-1$
}
- public void testCallNoParams() throws QueryParserException {
+ @Test public void testCallNoParams() throws QueryParserException {
StoredProcedure sp = (StoredProcedure)QueryParser.getQueryParser().parseCommand("{call procedure_name}"); //$NON-NLS-1$
assertFalse(sp.returnsScalarValue());
assertEquals("procedure_name", sp.getProcedureName()); //$NON-NLS-1$
assertEquals(0, sp.getParameters().size());
}
- public void testCallWithReturnParam() throws QueryParserException {
+ @Test public void testCallWithReturnParam() throws QueryParserException {
helpTestGetExec("{?=call procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
helpTestGetExec(" {?=call procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
helpTestGetExec("{ ?=call procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
@@ -60,7 +64,7 @@
helpTestGetExec("{?=\ncall procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
}
- public void testIllegalCalls() {
+ @Test public void testIllegalCalls() {
helpTestIllegalCall("{call procedure_name"); //$NON-NLS-1$
helpTestIllegalCall("call procedure_name}"); //$NON-NLS-1$
helpTestIllegalCall("{call procedure_name(}"); //$NON-NLS-1$
@@ -73,7 +77,7 @@
helpTestIllegalCall("{?=cal procedure_name}"); //$NON-NLS-1$
}
- public void testGetExec() throws QueryParserException {
+ @Test public void testGetExec() throws QueryParserException {
helpTestGetExec("{call procedure_name(?, ?, ?)}", false); //$NON-NLS-1$
helpTestGetExec(" {call procedure_name(?, ?, ?)}", false); //$NON-NLS-1$
helpTestGetExec("{ call procedure_name(?, ?, ?)}", false); //$NON-NLS-1$
@@ -83,13 +87,8 @@
helpTestGetExec("{CALL procedure_name(?, ?, ?)} ", false); //$NON-NLS-1$
}
- public void testBadCallKeyword() {
- try {
- QueryParser.getQueryParser().parseCommand("{calli procedure_name}"); //$NON-NLS-1$
- fail("expected exception"); //$NON-NLS-1$
- } catch (QueryParserException qpe) {
- assertEquals("Parsing error: Call keyword expected in callable statement", qpe.getMessage()); //$NON-NLS-1$
- }
+ @Test(expected=QueryParserException.class) public void testBadCallKeyword() throws Exception {
+ QueryParser.getQueryParser().parseCommand("{calli procedure_name}"); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -300,7 +300,7 @@
ElementSymbol x = new ElementSymbol("a.x", true); //$NON-NLS-1$
ElementSymbol y = new ElementSymbol("b.y", true); //$NON-NLS-1$
- Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("function", new Expression[] {y})); //$NON-NLS-1$
+ Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("func", new Expression[] {y})); //$NON-NLS-1$
JoinPredicate predicate = new JoinPredicate(new UnaryFromClause(a), new UnaryFromClause(b), JoinType.JOIN_INNER, Arrays.asList(new Object[] {criteria}));
From from = new From(Arrays.asList(new Object[] {predicate}));
predicate.getLeftClause().setMakeNotDep(true);
@@ -308,8 +308,8 @@
Select select = new Select(Arrays.asList(new Object[] {x, y}));
Query query = new Query(select, from, null, null, null, null, null);
- TestParser.helpTest("Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = function(b.y)", //$NON-NLS-1$
- "SELECT a.x, b.y FROM a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = function(b.y)", //$NON-NLS-1$
+ TestParser.helpTest("Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)", //$NON-NLS-1$
+ "SELECT a.x, b.y FROM a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)", //$NON-NLS-1$
query);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -681,9 +681,9 @@
query);
}
- /** SELECT left(fullname, 3) as x FROM system.groups */
+ /** SELECT left(fullname, 3) as x FROM sys.groups */
@Test public void testLeftFunction() {
- GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+ GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -696,14 +696,14 @@
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT left(fullname, 3) as x FROM system.groups", //$NON-NLS-1$
- "SELECT left(fullname, 3) AS x FROM system.groups", //$NON-NLS-1$
+ helpTest("SELECT left(fullname, 3) as x FROM sys.groups", //$NON-NLS-1$
+ "SELECT left(fullname, 3) AS x FROM sys.groups", //$NON-NLS-1$
query);
}
- /** SELECT right(fullname, 3) as x FROM system.groups */
+ /** SELECT right(fullname, 3) as x FROM sys.groups */
@Test public void testRightFunction() {
- GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+ GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -716,14 +716,14 @@
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT right(fullname, 3) as x FROM system.groups", //$NON-NLS-1$
- "SELECT right(fullname, 3) AS x FROM system.groups", //$NON-NLS-1$
+ helpTest("SELECT right(fullname, 3) as x FROM sys.groups", //$NON-NLS-1$
+ "SELECT right(fullname, 3) AS x FROM sys.groups", //$NON-NLS-1$
query);
}
- /** SELECT char('x') AS x FROM system.groups */
+ /** SELECT char('x') AS x FROM sys.groups */
@Test public void testCharFunction() {
- GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+ GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -736,14 +736,14 @@
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT char('x') AS x FROM system.groups", //$NON-NLS-1$
- "SELECT char('x') AS x FROM system.groups", //$NON-NLS-1$
+ helpTest("SELECT char('x') AS x FROM sys.groups", //$NON-NLS-1$
+ "SELECT char('x') AS x FROM sys.groups", //$NON-NLS-1$
query);
}
- /** SELECT insert('x', 1, 'a') as x FROM system.groups */
+ /** SELECT insert('x', 1, 'a') as x FROM sys.groups */
@Test public void testInsertFunction() {
- GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+ GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -756,15 +756,15 @@
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT insert('x', 1, 'a') AS x FROM system.groups", //$NON-NLS-1$
- "SELECT insert('x', 1, 'a') AS x FROM system.groups", //$NON-NLS-1$
+ helpTest("SELECT insert('x', 1, 'a') AS x FROM sys.groups", //$NON-NLS-1$
+ "SELECT insert('x', 1, 'a') AS x FROM sys.groups", //$NON-NLS-1$
query);
}
@Test public void testInsertIntoSelect() {
- GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+ GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -786,9 +786,9 @@
insert);
}
- /** SELECT translate('x', 'x', 'y') FROM system.groups */
+ /** SELECT translate('x', 'x', 'y') FROM sys.groups */
@Test public void testTranslateFunction() {
- GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+ GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -800,8 +800,8 @@
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT translate('x', 'x', 'y') FROM system.groups", //$NON-NLS-1$
- "SELECT translate('x', 'x', 'y') FROM system.groups", //$NON-NLS-1$
+ helpTest("SELECT translate('x', 'x', 'y') FROM sys.groups", //$NON-NLS-1$
+ "SELECT translate('x', 'x', 'y') FROM sys.groups", //$NON-NLS-1$
query);
}
@@ -2030,7 +2030,7 @@
query.setFrom(from);
query.setCriteria(crit);
helpTest("SELECT a from db.g where a <> \"value\"", //$NON-NLS-1$
- "SELECT a FROM db.g WHERE a <> value", //$NON-NLS-1$
+ "SELECT a FROM db.g WHERE a <> \"value\"", //$NON-NLS-1$
query);
}
@@ -2225,8 +2225,8 @@
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT g.x AS year FROM g", //$NON-NLS-1$
- "SELECT g.x AS year FROM g", //$NON-NLS-1$
+ helpTest("SELECT g.x AS \"year\" FROM g", //$NON-NLS-1$
+ "SELECT g.x AS \"year\" FROM g", //$NON-NLS-1$
query);
}
@@ -6167,7 +6167,7 @@
}
@Test public void testNationCharString2() throws Exception {
- Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT DISTINCT TABLE_QUALIFIER, NULL AS TABLE_OWNER, NULL AS TABLE_NAME, NULL AS TABLE_TYPE, NULL AS REMARKS FROM ATIODBCSystem.OA_TABLES WHERE TABLE_QUALIFIER LIKE N'%' ESCAPE '\\' ORDER BY TABLE_QUALIFIER "); //$NON-NLS-1$
+ Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT DISTINCT TABLE_QUALIFIER, NULL AS TABLE_OWNER, NULL AS TABLE_NAME, NULL AS TABLE_TYPE, NULL AS REMARKS FROM ATIODBCSYSTEM.OA_TABLES WHERE TABLE_QUALIFIER LIKE N'%' ESCAPE '\\' ORDER BY TABLE_QUALIFIER "); //$NON-NLS-1$
MatchCriteria matchCrit = (MatchCriteria) query.getCriteria();
Constant c = (Constant) matchCrit.getRightExpression();
assertEquals(c, new Constant("%")); //$NON-NLS-1$
@@ -6568,11 +6568,7 @@
@Test public void testCreateTempTable5() {
helpException("Create local TEMPORARY table tempTable (c1 boolean primary, c2 byte)"); //$NON-NLS-1$
}
-
- @Test public void testCreateTempTable6() {
- helpException("Create local TEMPORARY table tempTable (c1 varchar, c2 byte)"); //$NON-NLS-1$
- }
-
+
@Test public void testCreateTempTable7() {
helpException("Create local TEMPORARY table tempTable (c1.x boolean, c2 byte)" ,"Parsing error: Invalid simple identifier format: [c1.x]"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -6687,5 +6683,28 @@
"INSERT INTO m.g VALUES ('a', 'b')", //$NON-NLS-1$
insert);
}
-
+
+ @Test public void testTypeAliases() {
+ Create create = new Create();
+ create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$
+ List columns = new ArrayList();
+ ElementSymbol column = new ElementSymbol("c1");//$NON-NLS-1$
+ column.setType(DataTypeManager.DefaultDataClasses.STRING);
+ columns.add(column);
+ column = new ElementSymbol("c2");//$NON-NLS-1$
+ column.setType(DataTypeManager.DefaultDataClasses.BYTE);
+ columns.add(column);
+ column = new ElementSymbol("c3");//$NON-NLS-1$
+ column.setType(DataTypeManager.DefaultDataClasses.SHORT);
+ columns.add(column);
+ column = new ElementSymbol("c4");//$NON-NLS-1$
+ column.setType(DataTypeManager.DefaultDataClasses.FLOAT);
+ columns.add(column);
+ column = new ElementSymbol("c5");//$NON-NLS-1$
+ column.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);
+ columns.add(column);
+ create.setColumns(columns);
+ helpTest("Create local TEMPORARY table tempTable (c1 varchar, c2 tinyint, c3 smallint, c4 real, c5 decimal)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 string, c2 byte, c3 short, c4 float, c5 bigdecimal)", create); //$NON-NLS-1$
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,11 +31,14 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.CriteriaEvaluationException;
+import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataID;
+import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Delete;
@@ -387,5 +390,12 @@
this.recordingCommands = shouldRecord;
}
+ public void registerTuples(QueryMetadataInterface metadata, String groupName, List[] tuples) throws QueryResolverException, MetaMatrixComponentException {
+ GroupSymbol group = new GroupSymbol(groupName);
+ ResolverUtil.resolveGroup(group, metadata);
+ List<ElementSymbol> elementSymbols = ResolverUtil.resolveElementsInGroup(group, metadata);
+ this.registerTuples(group.getMetadataID(), elementSymbols, tuples);
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,25 +31,20 @@
import org.junit.Test;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestAggregatePushdown;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
public class TestAggregateProcessing {
static void sampleDataBQT3(FakeDataManager dataMgr) throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
// Group bqt1.smalla
- FakeMetadataObject groupID = (FakeMetadataObject) metadata
- .getGroupID("bqt1.smalla"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
List[] tuples = new List[20];
for (int i = 0; i < tuples.length; i++) {
@@ -62,13 +57,8 @@
}
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
- // Group bqt2.mediumb
- groupID = (FakeMetadataObject) metadata.getGroupID("bqt2.mediumb"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
tuples = new List[20];
for (int i = 0; i < tuples.length; i++) {
tuples[i] = new ArrayList(17);
@@ -78,18 +68,12 @@
}
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
}
private void sampleDataBQT_defect9842(FakeDataManager dataMgr) throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- // Group bqt1.smalla
- FakeMetadataObject groupID = (FakeMetadataObject) metadata
- .getGroupID("bqt1.smalla"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
List[] tuples = new List[5];
for (int i = 0; i < tuples.length; i++) {
int k = i + 10;
@@ -112,7 +96,7 @@
tuples[i].add(null);
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
}
@Test public void testAggregateOnBQT() throws Exception {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -42,6 +42,7 @@
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -724,7 +725,7 @@
StoredProcedure proc = (StoredProcedure)command;
List<SPParameter> params = proc.getInputParameters();
assertEquals(1, params.size());
- int value = (Integer)params.get(0).getValue();
+ int value = (Integer)((Constant)params.get(0).getExpression()).getValue();
return new FakeTupleSource(command.getProjectedSymbols(), new List[] {
Arrays.asList(value+2), Arrays.asList(value+5)
});
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -45,7 +45,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.buffer.TupleBuffer;
@@ -57,6 +56,10 @@
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.FunctionTree;
+import com.metamatrix.query.function.SystemFunctionManager;
+import com.metamatrix.query.function.UDFSource;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.FakeFunctionMetadataSource;
@@ -131,14 +134,14 @@
static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata) {
return helpGetPlan(command, metadata, new DefaultCapabilitiesFinder());
}
-
+
static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) {
CommandContext context = new CommandContext();
context.setProcessorBatchSize(2000);
context.setConnectorBatchSize(2000);
return helpGetPlan(command, metadata, capFinder, context);
}
-
+
static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) {
if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
@@ -205,7 +208,7 @@
BufferManager bufferMgr = null;
try {
bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("0", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("0", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
@@ -295,7 +298,7 @@
Properties props = new Properties();
props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", "1", props, DEBUG, DEBUG); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
context.setProcessorBatchSize(2000);
context.setConnectorBatchSize(2000);
return context;
@@ -538,13 +541,10 @@
}
private void sampleDataBQT1(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
try {
// Group bqt1.smalla
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
List[] tuples = new List[20];
for(int i=0; i<tuples.length; i++) {
@@ -555,13 +555,9 @@
}
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
// Group bqt2.mediumb
- groupID = (FakeMetadataObject) metadata.getGroupID("bqt2.mediumb"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
tuples = new List[20];
for(int i=0; i<tuples.length; i++) {
tuples[i] = new ArrayList(17);
@@ -571,16 +567,14 @@
}
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
-
+ dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
} catch(MetaMatrixException e) {
throw new RuntimeException(e);
}
}
-
- private void sampleDataBQT2(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ private void sampleDataBQT2(FakeDataManager dataMgr) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -588,10 +582,6 @@
for(int i=0; i<groups.length; i++) {
String groupName = groups[i];
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID(groupName);
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
List[] tuples = new List[30];
for(int row=0; row<tuples.length; row++) {
tuples[row] = new ArrayList(17);
@@ -601,7 +591,7 @@
}
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, groupName, tuples);
}
} catch(MetaMatrixException e) {
@@ -615,14 +605,9 @@
* @since 4.2
*/
private void sampleDataBQT_defect11682(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
try {
- // Group bqt1.smalla
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
List[] tuples = new List[2];
for(int i=1; i<=tuples.length; i++) {
int index=i-1;
@@ -645,23 +630,18 @@
tuples[index].add(new BigDecimal(i+".0")); //$NON-NLS-1$
tuples[index].add(null);
}
-
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
-
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
+
} catch(MetaMatrixException e) {
throw new RuntimeException(e);
}
}
private void sampleDataBQTSmall(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
try {
- // Group bqt1.smalla
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
List[] tuples = new List[1];
for(int i=0; i<tuples.length; i++) {
tuples[i] = new ArrayList(17);
@@ -671,7 +651,7 @@
}
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
} catch(MetaMatrixException e) {
throw new RuntimeException(e);
@@ -687,17 +667,9 @@
}
private void sampleDataBQT_case1566(FakeDataManager dataMgr) throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
+ dataMgr.registerTuples(metadata, "bqt1.smalla", new List[] { //$NON-NLS-1$
createRowWithTimestamp("2002-01-01 10:00:00"), //$NON-NLS-1$
createRowWithTimestamp("2002-01-01 14:00:00"), //$NON-NLS-1$
createRowWithTimestamp("2002-01-02 10:00:00"), //$NON-NLS-1$
@@ -1198,6 +1170,7 @@
CommandContext context = createCommandContext();
context.setProcessorBatchSize(2);
context.setConnectorBatchSize(2);
+ context.setMetadata(FakeMetadataFactory.example1Cached());
// Plan query
ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
@@ -2342,113 +2315,6 @@
helpProcess(plan, dataManager, expected);
}
- private static FakeMetadataFacade virtualBQT() {
- // Create models
- FakeMetadataObject bqt1 = FakeMetadataFactory.createPhysicalModel("BQT1"); //$NON-NLS-1$
- FakeMetadataObject bqt2 = FakeMetadataFactory.createPhysicalModel("BQT2"); //$NON-NLS-1$
- FakeMetadataObject bqt3 = FakeMetadataFactory.createPhysicalModel("BQT3"); //$NON-NLS-1$
- FakeMetadataObject vqt = FakeMetadataFactory.createVirtualModel("BQT_V"); //$NON-NLS-1$
- FakeMetadataObject vqt2 = FakeMetadataFactory.createVirtualModel("BQT2_V"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject bqt1SmallA = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt1SmallB = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallB", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt1MediumA = FakeMetadataFactory.createPhysicalGroup("BQT1.MediumA", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt1MediumB = FakeMetadataFactory.createPhysicalGroup("BQT1.MediumB", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt2SmallA = FakeMetadataFactory.createPhysicalGroup("BQT2.SmallA", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt2SmallB = FakeMetadataFactory.createPhysicalGroup("BQT2.SmallB", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt2MediumA = FakeMetadataFactory.createPhysicalGroup("BQT2.MediumA", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt2MediumB = FakeMetadataFactory.createPhysicalGroup("BQT2.MediumB", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt3SmallA = FakeMetadataFactory.createPhysicalGroup("BQT3.SmallA", bqt3); //$NON-NLS-1$
- FakeMetadataObject bqt3SmallB = FakeMetadataFactory.createPhysicalGroup("BQT3.SmallB", bqt3); //$NON-NLS-1$
- FakeMetadataObject bqt3MediumA = FakeMetadataFactory.createPhysicalGroup("BQT3.MediumA", bqt3); //$NON-NLS-1$
- FakeMetadataObject bqt3MediumB = FakeMetadataFactory.createPhysicalGroup("BQT3.MediumB", bqt3); //$NON-NLS-1$
-
- // Create virtual groups
- QueryNode vqtn1 = new QueryNode("BQT_V.BQT_V", "SELECT a.* FROM BQT1.SMALLA AS a WHERE a.INTNUM = (SELECT MIN(b.INTNUM) FROM BQT1.SMALLA AS b WHERE b.INTKEY = a.IntKey ) OPTION MAKEDEP a"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg1 = FakeMetadataFactory.createUpdatableVirtualGroup("BQT_V.BQT_V", vqt, vqtn1); //$NON-NLS-1$
- QueryNode vqt2n1 = new QueryNode("BQT2_V.BQT2_V", "SELECT BQT2.SmallA.* FROM BQT2.SmallA, BQT_V.BQT_V WHERE BQT2.SmallA.IntKey = BQT_V.BQT_V.IntKey"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqt2g1 = FakeMetadataFactory.createUpdatableVirtualGroup("BQT2_V.BQT2_V", vqt2, vqt2n1); //$NON-NLS-1$
-
-
- // Create physical elements
- String[] elemNames = new String[] {
- "IntKey", "StringKey", //$NON-NLS-1$ //$NON-NLS-2$
- "IntNum", "StringNum", //$NON-NLS-1$ //$NON-NLS-2$
- "FloatNum", "LongNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DoubleNum", "ByteNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DateValue", "TimeValue", //$NON-NLS-1$ //$NON-NLS-2$
- "TimestampValue", "BooleanValue", //$NON-NLS-1$ //$NON-NLS-2$
- "CharValue", "ShortValue", //$NON-NLS-1$ //$NON-NLS-2$
- "BigIntegerValue", "BigDecimalValue", //$NON-NLS-1$ //$NON-NLS-2$
- "ObjectValue" }; //$NON-NLS-1$
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG,
- DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE,
- DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME,
- DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT,
- DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
- DataTypeManager.DefaultDataTypes.OBJECT };
-
- List bqt1SmallAe = FakeMetadataFactory.createElements(bqt1SmallA, elemNames, elemTypes);
- List bqt1SmallBe = FakeMetadataFactory.createElements(bqt1SmallB, elemNames, elemTypes);
- List bqt1MediumAe = FakeMetadataFactory.createElements(bqt1MediumA, elemNames, elemTypes);
- List bqt1MediumBe = FakeMetadataFactory.createElements(bqt1MediumB, elemNames, elemTypes);
- List bqt2SmallAe = FakeMetadataFactory.createElements(bqt2SmallA, elemNames, elemTypes);
- List bqt2SmallBe = FakeMetadataFactory.createElements(bqt2SmallB, elemNames, elemTypes);
- List bqt2MediumAe = FakeMetadataFactory.createElements(bqt2MediumA, elemNames, elemTypes);
- List bqt2MediumBe = FakeMetadataFactory.createElements(bqt2MediumB, elemNames, elemTypes);
- List bqt3SmallAe = FakeMetadataFactory.createElements(bqt3SmallA, elemNames, elemTypes);
- List bqt3SmallBe = FakeMetadataFactory.createElements(bqt3SmallB, elemNames, elemTypes);
- List bqt3MediumAe = FakeMetadataFactory.createElements(bqt3MediumA, elemNames, elemTypes);
- List bqt3MediumBe = FakeMetadataFactory.createElements(bqt3MediumB, elemNames, elemTypes);
- // Create virtual elements
- List vqtg1e = FakeMetadataFactory.createElements(vqtg1, elemNames, elemTypes);
- List vqt2g1e = FakeMetadataFactory.createElements(vqt2g1, elemNames, elemTypes);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(bqt1);
- store.addObject(bqt1SmallA);
- store.addObjects(bqt1SmallAe);
- store.addObject(bqt1SmallB);
- store.addObjects(bqt1SmallBe);
- store.addObject(bqt1MediumA);
- store.addObjects(bqt1MediumAe);
- store.addObject(bqt1MediumB);
- store.addObjects(bqt1MediumBe);
-
- store.addObject(bqt2);
- store.addObject(bqt2SmallA);
- store.addObjects(bqt2SmallAe);
- store.addObject(bqt2SmallB);
- store.addObjects(bqt2SmallBe);
- store.addObject(bqt2MediumA);
- store.addObjects(bqt2MediumAe);
- store.addObject(bqt2MediumB);
- store.addObjects(bqt2MediumBe);
-
- store.addObject(bqt3);
- store.addObject(bqt3SmallA);
- store.addObjects(bqt3SmallAe);
- store.addObject(bqt3SmallB);
- store.addObjects(bqt3SmallBe);
- store.addObject(bqt3MediumA);
- store.addObjects(bqt3MediumAe);
- store.addObject(bqt3MediumB);
- store.addObjects(bqt3MediumBe);
-
- store.addObject(vqtg1);
- store.addObjects(vqtg1e);
- store.addObject(vqt2g1);
- store.addObjects(vqt2g1e);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
-
- }
@Test public void testCorrelatedSubquery_CASE2022() {
String sql = "select * from BQT2_V WHERE BQT2_V.IntKey < 50"; //$NON-NLS-1$
@@ -2476,8 +2342,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
// Plan query
- ProcessorPlan plan = helpGetPlan(helpParse(sql), virtualBQT(), capFinder);
- //ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), capFinder);
// Run query
helpProcess(plan, dataManager, expected);
@@ -5200,7 +5065,9 @@
g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder,context);
//Verify a dependent join (not merge join) was used
assertTrue(plan instanceof RelationalPlan);
@@ -5210,7 +5077,7 @@
assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
// Run query
- helpProcess(plan, dataManager, expected);
+ helpProcess(plan, context, dataManager, expected);
}
/** RLM Case 2077 */
@@ -5244,7 +5111,9 @@
g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
//Verify a dependent join (not merge join) was used
assertTrue(plan instanceof RelationalPlan);
@@ -5254,7 +5123,7 @@
assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
// Run query
- helpProcess(plan, dataManager, expected);
+ helpProcess(plan, context, dataManager, expected);
}
@Test public void testPushingCriteriaUnderJoinButNotToSource() {
@@ -5312,7 +5181,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5348,7 +5217,7 @@
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5359,7 +5228,6 @@
/** defect 15348*/
@Test public void testPreparedStatementDefect15348(){
- FakeFunctionMetadataSource.setupFunctionLibrary();
String sql = "SELECT e1 from pm1.g1 where myrtrim(?)=e1"; //$NON-NLS-1$
// Create expected results
@@ -5378,16 +5246,19 @@
caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+
Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
// Collect reference, set value
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
VariableContext vc = new VariableContext();
vc.setGlobalValue(ref.getContextSymbol(), "a "); //$NON-NLS-1$
- CommandContext context = createCommandContext();
context.setVariableContext(vc);
// Run query
helpProcess(plan, context, dataManager, expected);
@@ -5396,8 +5267,6 @@
/** defect 15348*/
@Test public void testPreparedStatementDefect15348b(){
- FakeFunctionMetadataSource.setupFunctionLibrary();
-
String sql = "SELECT e1 from pm4.g1 where myrtrim(concat(?, 'a '))=e1"; //$NON-NLS-1$
// Create expected results
@@ -5417,16 +5286,19 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+
Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
// Collect reference, set value
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
VariableContext vc = new VariableContext();
vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
- CommandContext context = createCommandContext();
context.setVariableContext(vc);
// Run query
@@ -5446,7 +5318,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5477,7 +5349,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5525,7 +5397,7 @@
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5572,7 +5444,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5608,7 +5480,7 @@
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5646,7 +5518,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5685,7 +5557,7 @@
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5718,7 +5590,7 @@
BasicSourceCapabilities caps = new BasicSourceCapabilities();
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5757,7 +5629,7 @@
caps.setCapabilitySupport(Capability.QUERY_UNION, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5854,7 +5726,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
@@ -5916,9 +5788,8 @@
BasicSourceCapabilities caps = new BasicSourceCapabilities();
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
null, capFinder,
@@ -6453,18 +6324,14 @@
helpProcess(plan, dataManager, expected);
}
- private void sampleDataBQT2a(FakeDataManager dataMgr) throws QueryMetadataException, MetaMatrixComponentException {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ private void sampleDataBQT2a(FakeDataManager dataMgr) throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
for(int groupIndex=0; groupIndex<groups.length; groupIndex++) {
String groupName = groups[groupIndex];
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID(groupName);
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
List[] tuples = new List[3];
for(int row=0; row<tuples.length; row++) {
tuples[row] = new ArrayList(17);
@@ -6479,7 +6346,7 @@
tuples[row].add(new BigDecimal(row)); //BigDecimalValue
tuples[row].add(null); //ObjectValue
}
- dataMgr.registerTuples(groupID, elementSymbols, tuples);
+ dataMgr.registerTuples(metadata, groupName, tuples);
}
}
@@ -6549,7 +6416,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6579,7 +6446,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6609,7 +6476,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6639,7 +6506,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6669,7 +6536,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6699,7 +6566,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6729,7 +6596,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6759,7 +6626,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6789,7 +6656,7 @@
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6842,8 +6709,11 @@
// Plan query
String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) = e1";//$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
// Run query
List[] expected = new List[] {
@@ -6857,7 +6727,7 @@
dataManager.defineCodeTable("pm1.g1", "e2", "e1", valueMap); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
dataManager.setThrowBlocked(true);
- helpProcess(plan, dataManager, expected);
+ helpProcess(plan, context, dataManager, expected);
}
@Test public void testRaiseNullWithSelectInto() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -55,7 +55,7 @@
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
FakeDataManager dataManager = new FakeDataManager();
- CommandContext context = new CommandContext("pid", "group", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "group", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
BatchCollector collector = processor.createBatchCollector();
TupleBuffer tsID = null;
@@ -136,5 +136,4 @@
FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
helpTestProcessor(plan, 1000, expectedResults);
}
-
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -78,9 +78,7 @@
CommandContext context = new CommandContext();
context.setSecurityFunctionEvaluator(new SecurityFunctionEvaluator() {
-
- public boolean hasRole(String connectionID,
- String roleType,
+ public boolean hasRole(String roleType,
String roleName) throws MetaMatrixComponentException {
return false;
}});
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -491,10 +491,9 @@
private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
BufferManagerImpl bufferMgr = new BufferManagerImpl();
- Properties props = new Properties();
bufferMgr.setConnectorBatchSize(batchSize);
bufferMgr.setProcessorBatchSize(batchSize);
- bufferMgr.initialize(props);
+ bufferMgr.initialize();
// Add unmanaged memory storage manager
bufferMgr.setStorageManager(new MemoryStorageManager());
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,7 +39,7 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.lang.CollectionValueIterator;
@@ -198,7 +198,7 @@
e2.setType(String.class);
Function func = new Function("concat", new Expression[] { e1, e2 }); //$NON-NLS-1$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -220,7 +220,7 @@
e2.setType(String.class);
Function func = new Function("concat", new Expression[] { e2, e1 }); //$NON-NLS-1$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -241,7 +241,7 @@
e1.setType(Integer.class);
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), e1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -313,11 +313,11 @@
public void testUser() throws Exception {
Function func = new Function("user", new Expression[] {}); //$NON-NLS-1$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("user", new Class[] {} ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("user", new Class[] {} ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
- CommandContext context = new CommandContext(new Long(1), null, null, null, null);
+ CommandContext context = new CommandContext(new Long(1), null, null, null, 0);
context.setUserName("logon"); //$NON-NLS-1$
assertEquals(context.getUserName(), new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList()) );
}
@@ -330,7 +330,7 @@
*/
public void testEnv() throws Exception {
Function func = new Function("env", new Expression[] {}); //$NON-NLS-1$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("env", new Class[] {String.class} ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("env", new Class[] {String.class} ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
@@ -338,7 +338,7 @@
Properties props = new Properties();
props.setProperty("http_host", "testHostName"); //$NON-NLS-1$ //$NON-NLS-2$
props.setProperty("http_port", "8000"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext(new Long(1), null, null, null, null, null, props, false, false);
+ CommandContext context = new CommandContext(new Long(1), null, null, null, null, 0, props, false, false);
func.setArgs(new Expression[] {new Constant("http_host")}); //$NON-NLS-1$
assertEquals("testHostName", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
@@ -356,11 +356,11 @@
} else {
parameterSignature = new Class[] { String.class };
}
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("commandpayload", parameterSignature ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("commandpayload", parameterSignature ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
- CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", "1", null, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", 1, null, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if(property != null) {
func.setArgs(new Expression[] {new Constant(property)});
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -45,10 +45,10 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.XMLType;
import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.StringUtilities;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.QueryOptimizer;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -110,13 +110,17 @@
}
}
- static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
+ static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr, QueryMetadataInterface metadata) throws SQLException, MetaMatrixCoreException {
// Process twice, testing reset and clone method of Processor plan
for (int i=1; i<=2; i++) {
- BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
+
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
context.getNextRand(0);
context.setProcessDebug(DEBUG);
+ context.setMetadata(metadata);
+
+ BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
+
QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
@@ -173,7 +177,7 @@
//reset and clone after 1st run
if (i==1) {
procPlan.reset();
- procPlan = (ProcessorPlan)procPlan.clone();
+ procPlan = procPlan.clone();
}
}
}
@@ -192,12 +196,12 @@
}
private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
- helpTestProcess(procPlan, expectedRows, null, false, dataMgr);
+ helpTestProcess(procPlan, expectedRows, null, false, dataMgr, null);
}
static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, List[] expectedResults,
ProcessorDataManager dataMgr, boolean shouldFail) throws SQLException, MetaMatrixCoreException {
- helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr);
+ helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr, null);
}
// Helper to create a list of elements - used in creating sample data
@@ -2257,9 +2261,10 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcess(plan, new List[] {
+
+ helpTestProcess(plan, 0, new List[] {
Arrays.asList(new Object[] {new Integer(240)}),
- Arrays.asList(new Object[] {new Integer(637)})}, dataMgr);
+ Arrays.asList(new Object[] {new Integer(637)})}, false, dataMgr, metadata);
}
private FakeMetadataFacade createProcedureMetadata(String procedure) {
@@ -2326,7 +2331,7 @@
FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
QueryNode sq2n1 = new QueryNode("xqttest.proc", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "declare integer VARIABLES.x = input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; END"); //$NON-NLS-1$
+ + "declare integer VARIABLES.x = xqttest.proc.input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; END"); //$NON-NLS-1$
FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("xqttest.proc", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
metadata.getStore().addObject(rs2);
@@ -2348,14 +2353,14 @@
FakeDataManager dataMgr = TestXMLProcessor.exampleDataManagerNested(metadata);
String resultFile = "TestXMLProcessor-testNested2WithContextCriteria5d.xml"; //$NON-NLS-1$
String expectedDoc = TestXMLProcessor.readFile(resultFile);
- expectedDoc = StringUtilities.removeChars(expectedDoc, new char[] {'\r'});
+ expectedDoc = expectedDoc.replaceAll("\\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject pm1 = metadata.getStore().findObject("xqttest",FakeMetadataObject.MODEL); //$NON-NLS-1$
FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs2", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.XML }); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
QueryNode sq2n1 = new QueryNode("xqttest.proc", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "declare integer VARIABLES.x = input; declare xml y = SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; select convert(y, string); END"); //$NON-NLS-1$
+ + "declare integer VARIABLES.x = xqttest.proc.input; declare xml y = SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; select convert(y, string); END"); //$NON-NLS-1$
FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("xqttest.proc", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
metadata.getStore().addObject(rs2);
@@ -2422,7 +2427,7 @@
FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
QueryNode sq2n1 = new QueryNode("xmltest.proc", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "declare integer VARIABLES.x = input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, SupplierID)=x; END"); //$NON-NLS-1$
+ + "declare integer VARIABLES.x = xmltest.proc.input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, SupplierID)=x; END"); //$NON-NLS-1$
FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("xmltest.proc", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
metadata.getStore().addObject(rs2);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -41,21 +41,19 @@
bufferManager.setProcessorBatchSize(procBatchSize);
bufferManager.setConnectorBatchSize(connectorBatchSize);
// Get the properties for BufferManager
- Properties bmProps = new Properties();
- return createBufferManager(bufferManager, bmProps);
+ return createBufferManager(bufferManager);
}
static BufferManager getTestBufferManager(long bytesAvailable, int procBatchSize) {
BufferManagerImpl bufferManager = new BufferManagerImpl();
bufferManager.setProcessorBatchSize(procBatchSize);
// Get the properties for BufferManager
- Properties bmProps = new Properties();
- return createBufferManager(bufferManager, bmProps);
+ return createBufferManager(bufferManager);
}
- static BufferManager createBufferManager(BufferManagerImpl bufferManager, Properties bmProps) {
+ static BufferManager createBufferManager(BufferManagerImpl bufferManager) {
try {
- bufferManager.initialize(bmProps);
+ bufferManager.initialize();
} catch (MetaMatrixComponentException e) {
throw new RuntimeException(e);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -61,6 +61,7 @@
BatchedUpdateNode node = new BatchedUpdateNode(1, commands, Collections.EMPTY_LIST, shouldEvaluate, "myModelName"); //$NON-NLS-1$
CommandContext context = new CommandContext();
context.setProcessorID("myProcessorID"); //$NON-NLS-1$
+ context.setMetadata(md);
node.initialize(context, Mockito.mock(BufferManager.class), pdm);
return node;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -43,7 +43,7 @@
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.function.aggregate.AggregateFunction;
import com.metamatrix.query.function.aggregate.NullFilter;
import com.metamatrix.query.processor.FakeDataManager;
@@ -156,7 +156,7 @@
List groupingElements = new ArrayList();
groupingElements.add(col1);
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(2), new Integer(1), new Integer(1), new Long(3), new Long(3), new Double(3.0), new Double(3.0), new Integer(3), new Integer(3), new Integer(3), new Integer(3) }),
@@ -182,7 +182,7 @@
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
GroupingNode node = getExampleGroupingNode();
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -204,7 +204,7 @@
((BufferManagerImpl)mgr).setProcessorBatchSize(5);
GroupingNode node = getExampleGroupingNode();
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -235,7 +235,7 @@
// Set grouping elements to null
node.setGroupingElements(null);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] data = new List[] {
Arrays.asList(new Object[] { new BigDecimal("0.0") }), //$NON-NLS-1$
@@ -275,7 +275,7 @@
List groupingElements = new ArrayList();
groupingElements.add(col1); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] data = new List[] {
Arrays.asList(new Object[] { new Integer(1), new BigDecimal("0.0") }), //$NON-NLS-1$
@@ -310,7 +310,7 @@
col2.setType(Integer.class);
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), col2 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -323,7 +323,7 @@
List groupingElements = new ArrayList();
groupingElements.add(col1); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
FakeDataManager dataMgr = new FakeDataManager();
dataMgr.setThrowBlocked(true);
@@ -370,7 +370,7 @@
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
}
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] data = new List[] {
};
@@ -407,7 +407,7 @@
GroupingNode node = getExampleGroupingNode();
node.setRemoveDuplicates(true);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1) }),
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,7 +22,7 @@
package com.metamatrix.query.processor.relational;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,7 +40,7 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -203,7 +203,7 @@
case FUNCTION_CRITERIA :
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria joinCriteria = new CompareCriteria(es2, CompareCriteria.EQ, func);
@@ -232,7 +232,7 @@
public void helpTestJoinDirect(List[] expectedResults, int batchSize) throws MetaMatrixComponentException, MetaMatrixProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, batchSize);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
join.addChild(leftNode);
join.addChild(rightNode);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,7 +39,7 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.symbol.Constant;
@@ -63,7 +63,7 @@
public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) throws MetaMatrixComponentException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
FakeRelationalNode dataNode = new FakeRelationalNode(2, data);
dataNode.setElements(childElements);
@@ -211,7 +211,7 @@
elements.add(es1);
Function func = new Function("concat", new Expression[] { es1, new Constant("abc")}); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionDescriptor fd = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+ FunctionDescriptor fd = SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.STRING);
ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
@@ -235,7 +235,7 @@
elements.add(es1);
Function func = new Function("convert", new Expression[] { es1, new Constant("integer")}); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionDescriptor fd = FunctionLibraryManager.getFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+ FunctionDescriptor fd = SystemFunctionManager.getSystemFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
@@ -258,7 +258,7 @@
elements.add(es1);
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.STRING);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -116,7 +116,7 @@
FakeRelationalNode fakeNode = new FakeRelationalNode(1, data, 100);
fakeNode.setElements(elements);
- CommandContext context = new CommandContext("pid", "group", null, null, null, null, null, false, true); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "group", null, null, null, 1, null, false, true); //$NON-NLS-1$ //$NON-NLS-2$
fakeNode.initialize(context, BufferManagerFactory.getStandaloneBufferManager(), null);
return fakeNode;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -38,8 +38,9 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.processor.BatchIterator;
+import com.metamatrix.query.processor.BatchIterator;
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -68,7 +69,7 @@
public void helpTestSelect(List elements, Criteria criteria, List childElements, ProcessorDataManager dataMgr, List[] expected, RelationalNode child) throws MetaMatrixComponentException, MetaMatrixProcessingException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
child.setElements(childElements);
child.initialize(context, mgr, dataMgr);
@@ -203,7 +204,7 @@
elements.add(es1);
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria crit = new CompareCriteria(func, CompareCriteria.EQ, new Constant(new Integer(1)));
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -52,7 +52,7 @@
private void helpTestSort(List elements, List[] data, List sortElements, List sortTypes, List[] expected, Mode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(100, BATCH_SIZE, BATCH_SIZE);
- CommandContext context = new CommandContext ("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext ("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
BlockingFakeRelationalNode dataNode = new BlockingFakeRelationalNode(2, data);
dataNode.setReturnPeriod(3);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -51,7 +51,7 @@
public void helpTestUnion(RelationalNode[] children, RelationalNode union, List[] expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, 2);
- CommandContext context = new CommandContext("pid", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
for(int i=0; i<children.length; i++) {
union.addChild(children[i]);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -348,7 +348,7 @@
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
XMLPlan temp = new XMLPlan(env);
- CommandContext context = new CommandContext("pid", null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pid", null, null, null, 1); //$NON-NLS-1$
temp.initialize(context,null,bufferMgr);
List schema = new ArrayList();
@@ -404,7 +404,7 @@
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
XMLPlan temp = new XMLPlan(env);
- CommandContext context = new CommandContext("pid", null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pid", null, null, null, 1); //$NON-NLS-1$
temp.initialize(context,null,bufferMgr);
env.addData(resultSetName, command.getProjectedSymbols(), new List[] {
Arrays.asList( new Object[] { "001", "Lamp", new Integer(5) } ), //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -2962,7 +2962,7 @@
// Process twice, to test reset and clone methods
for (int i=1; i<=2; i++) {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pID", "TestConn", "testUser", null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ CommandContext context = new CommandContext("pID", "TestConn", "testUser", null, 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
context.setProcessDebug(DEBUG);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
@@ -2999,7 +2999,7 @@
XMLPlan plan = (XMLPlan)QueryOptimizer.optimizePlan(command, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
@@ -3045,7 +3045,7 @@
}
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
@@ -6053,7 +6053,7 @@
XMLPlan plan = TestXMLPlanner.preparePlan(command, metadata, new DefaultCapabilitiesFinder(), null);
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
Deleted: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,1639 +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.query.resolver;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-
-public class TestProcedureResolving {
-
- private QueryMetadataInterface exampleStoredProcedure(String procedure) {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
-
- FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
- FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
- FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure); //$NON-NLS-1$
- FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
-
- metadata.getStore().addObject(rs2);
- metadata.getStore().addObject(sq1);
-
- return metadata;
- }
-
- private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
- helpFailUpdateProcedure(procedure, userUpdateStr, procedureType, null);
- }
-
- private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType, String msg) {
- // resolve
- try {
- helpResolveUpdateProcedure(procedure, userUpdateStr, procedureType);
- fail("Expected a QueryResolverException but got none."); //$NON-NLS-1$
- } catch(QueryResolverException ex) {
- if (msg != null) {
- assertEquals(msg, ex.getMessage());
- }
- } catch (MetaMatrixComponentException e) {
- throw new RuntimeException(e);
- } catch (QueryParserException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
- Map externalMetadata = new HashMap();
-
- // Look up elements for the virtual group
- List elements = ResolverUtil.resolveElementsInGroup(virtualGroup, metadata);
- // virtual group metadata info
- externalMetadata.put(virtualGroup, elements);
-
- // INPUT group metadata info
- GroupSymbol inputGroup = new GroupSymbol(ProcedureReservedWords.INPUT);
- List inputElments = new ArrayList(elements.size());
- List elementIds = new ArrayList();
- for(int i=0; i<elements.size(); i++) {
- ElementSymbol virtualElmnt = (ElementSymbol)elements.get(i);
- ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
- inputElments.add(inputElement);
- elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + virtualElmnt.getShortName(), virtualElmnt.getType()));
- }
- inputGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.INPUT, elementIds));
- externalMetadata.put(inputGroup, inputElments);
-
- // CHANGING group metadata info
- // Switch type to be boolean for all CHANGING variables
- GroupSymbol changeGroup = new GroupSymbol(ProcedureReservedWords.CHANGING);
- List changingElments = new ArrayList(elements.size());
- elementIds = new ArrayList();
- for(int i=0; i<elements.size(); i++) {
- ElementSymbol changeElement = (ElementSymbol)((ElementSymbol)elements.get(i)).clone();
- changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
- changingElments.add(changeElement);
- elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + changeElement.getShortName(), changeElement.getType()));
- }
- changeGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.CHANGING, elementIds));
- externalMetadata.put(changeGroup, changingElments);
-
- return externalMetadata;
- }
-
- @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\nDECLARE string var1;") //$NON-NLS-1$
- .append("\nvar1 = '';") //$NON-NLS-1$
- .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
- .append("\n BEGIN") //$NON-NLS-1$
- .append("\n LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor2") //$NON-NLS-1$
- .append("\n BEGIN") //$NON-NLS-1$
- .append("\n var1 = CONCAT(var1, CONCAT(' ', loopCursor2.e1));") //$NON-NLS-1$
- .append("\n END") //$NON-NLS-1$
- .append("\n END") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- Command command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- Map tempIDs = command.getTemporaryMetadata();
- assertNotNull(tempIDs);
- assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
- assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-
- Command subCommand = command.getSubCommands().get(0);
- tempIDs = subCommand.getTemporaryMetadata();
- assertNotNull(tempIDs);
- assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
- assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-
- subCommand = command.getSubCommands().get(1);
- tempIDs = subCommand.getTemporaryMetadata();
- assertNotNull(tempIDs);
- assertNotNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
- assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
- }
-
- private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
- return resolveProcedure(userUpdateStr, metadata);
- }
-
- private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
- QueryMetadataInterface metadata) throws QueryParserException,
- QueryResolverException, MetaMatrixComponentException,
- QueryMetadataException {
- ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
- QueryResolver.resolveCommand(userCommand, metadata);
- metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(userCommand.getTemporaryMetadata()));
- return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
- }
-
- private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, MetaMatrixComponentException {
- try {
- helpResolve(userUpdateStr, metadata);
- } catch (QueryResolverException e) {
- assertEquals(msg, e.getMessage());
- }
- }
-
- private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
- return resolveProcedure(userUpdateStr, metadata);
- }
-
- /**
- * Constants will now auto resolve if they are consistently representable in the target type
- */
- @Test public void testDefect23257() throws Exception{
- CreateUpdateProcedureCommand command = helpResolve("EXEC pm5.vsp59()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
-
- CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1);
-
- Insert insert = (Insert)cs.getCommand();
-
- assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
- }
-
- @Test public void testProcedureScoping() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- //note that this declare takes presedense over the proc INPUT.e1 and CHANGING.e1 variables
- .append("\n declare integer e1 = 1;") //$NON-NLS-1$
- .append("\n e1 = e1;") //$NON-NLS-1$
- .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
- .append("\n BEGIN") //$NON-NLS-1$
- //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
- .append("\n variables.e1 = convert(e1, integer);") //$NON-NLS-1$
- .append("\n END") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
-
- Block block = command.getBlock();
-
- AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
- assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
- assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
-
- Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
-
- assStmt = (AssignmentStatement)inner.getStatements().get(0);
-
- ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
-
- assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
- }
-
- // variable resolution, variable used in if statement, variable compared against
- // different datatype element
- @Test public void testCreateUpdateProcedure4() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1);\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution, variable used in if statement, invalid operation on variable
- @Test public void testCreateUpdateProcedure5() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = var1 + var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 whwre var1 = var1+var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution, variables declared in different blocks local variables
- // should not override
- @Test public void testCreateUpdateProcedure6() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable var1 was previously declared."); //$NON-NLS-1$
- }
-
- // variable resolution, variables declared in different blocks local variables
- // inner block using outer block variables
- @Test public void testCreateUpdateProcedure7() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE boolean var2;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution, variables declared in different blocks local variables
- // outer block cannot use inner block variables
- @Test public void testCreateUpdateProcedure8() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var2;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "var2 = 1\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution, variables declared in different blocks local variables
- // should override, outer block variables still valid afetr inner block is declared
- @Test public void testCreateUpdateProcedure9() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = var1 +1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable ROWS_UPDATED resolution
- @Test public void testCreateUpdateProcedure10() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable ROWS_UPDATED used with declared variable
- @Test public void testCreateUpdateProcedure11() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable INPUT used with declared variable
- @Test public void testCreateUpdateProcedure12() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable CHANGING used with declared variable
- @Test public void testCreateUpdateProcedure14() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(CHANGING.e1 = 'true')\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable CHANGING and INPUT used in compound criteria
- @Test public void testCreateUpdateProcedure15() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(CHANGING.e1='false' and INPUT.e1=1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable CHANGING and INPUT used in compound criteria, with declared variables
- @Test public void testCreateUpdateProcedure16() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(CHANGING.e4 ='true' and INPUT.e2=1 or var1 < 30)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // special variable CHANGING compared against integer no implicit conversion available
- @Test public void testCreateUpdateProcedure17() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (boolean and date) and no implicit conversion is available: CHANGING.e4 = {d'2000-01-01'}"); //$NON-NLS-1$
- }
-
- // virtual group elements used in procedure(HAS CRITERIA)
- @Test public void testCreateUpdateProcedure18() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // virtual group elements used in procedure in if statement(HAS CRITERIA)
- @Test public void testCreateUpdateProcedure19() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // virtual group elements used in procedure(TRANSLATE CRITERIA)
- @Test public void testCreateUpdateProcedure20() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // virtual group elements used in procedure(TRANSLATE CRITERIA)
- @Test public void testCreateUpdateProcedure21() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using undefined variable should fail
- @Test public void testCreateUpdateProcedure22() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-// procedure = procedure + "DECLARE integer var1;\n";
- procedure = procedure + "var3 = var2+var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var2 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using undefined variable declared is of invalid datatype
- @Test public void testCreateUpdateProcedure23() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using declare variable that has parts
- @Test public void testCreateUpdateProcedure24() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using declare variable is qualified
- @Test public void testCreateUpdateProcedure26() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using declare variable is qualified but has more parts
- @Test public void testCreateUpdateProcedure27() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using a variable that has not been declared in an assignment stmt
- @Test public void testCreateUpdateProcedure28() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using a variable that has not been declared in an assignment stmt
- @Test public void testCreateUpdateProcedure29() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using invalid function in assignment expr
- @Test public void testCreateUpdateProcedure30() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using invalid function in assignment expr
- @Test public void testCreateUpdateProcedure31() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // using a variable being used inside a subcomand
- @Test public void testCreateUpdateProcedure32() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select var1 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution, variables declared in different blocks local variables
- // should override, outer block variables still valid afetr inner block is declared
- // fails as variable being compared against incorrect type
- @Test public void testCreateUpdateProcedure33() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE timestamp var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e2;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = var1 +1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // physical elements used on criteria of the if statement
- @Test public void testCreateUpdateProcedure34() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
- }
-
- // virtual elements used on criteria of the if statement
- @Test public void testCreateUpdateProcedure35() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1) and var1=1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // physical elements used on criteria of the if statement
- @Test public void testCreateUpdateProcedure36() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // TranslateCriteria on criteria of the if statement
- @Test public void testCreateUpdateProcedure37() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(TRANSLATE CRITERIA ON (vm1.g1.e1) WITH (vm1.g1.e1 = 1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // validating Translate CRITERIA, elements on it should be virtual group elements
- // but can use variables
- @Test public void testCreateUpdateProcedure38() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (pm1.g1.e2 = var1);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // physical elements used on criteria of the if statement
- @Test public void testCreateUpdateProcedure39() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // TranslateCriteria on criteria of the if statement
- @Test public void testCreateUpdateProcedure40() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // TranslateCriteria on criteria of the if statement
- @Test public void testCreateUpdateProcedure41() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // TranslateCriteria on criteria of the if statement
- @Test public void testCreateUpdateProcedure42() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // TranslateCriteria on criteria of the if statement
- @Test public void testCreateUpdateProcedure43() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
-// procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n";
-// procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n";
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
-
- Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
- GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
- virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
- Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);
- QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
- }
-
- // special variable CHANGING compared against integer no implicit conversion available
- @Test public void testCreateUpdateProcedure44() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "if(INPUT.e1 = 10)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.INSERT_PROCEDURE);
- }
-
- // special variable CHANGING compared against integer no implicit conversion available
- @Test public void testCreateUpdateProcedure45() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "if(INPUT.e1 = 10)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);
-
- GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
- virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-
- Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);
- QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
- }
-
- // special variable CHANGING compared against integer no implicit conversion available
- @Test public void testCreateUpdateProcedure46() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
-
- GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
- virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-
- Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);
- QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
- }
-
- // TranslateCriteria on criteria of the if statement
- @Test public void testCreateUpdateProcedure47() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (vm1.g1.e1 = pm1.g1.e1);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // validating Translate CRITERIA, elements(left elements on on it should be virtual group elements
- @Test public void testCreateUpdateProcedure48() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, INPUT.e2 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // resolving Translate CRITERIA, right element should be present on the command
- @Test public void testCreateUpdateProcedure49() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
- @Test public void testCreateUpdateProcedure50() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.E1, vm1.g1.e1, INPUT.e1))\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
- @Test public void testCreateUpdateProcedure51() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1=1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e2 = var1+vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // validating Translate CRITERIA, elements on it should be virtual group elements
- // but can use variables, gut left exprs should always be virtual elements
- @Test public void testCreateUpdateProcedure52() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (var1 = vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // resolving AssignmentStatement, variable type and assigned type
- // do not match and no implicit conversion available
- @Test public void testCreateUpdateProcedure53() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = INPUT.e4;"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // resolving AssignmentStatement, variable type and assigned type
- // do not match, but implicit conversion available
- @Test public void testCreateUpdateProcedure54() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // resolving AssignmentStatement, variable type and assigned type
- // do not match, but implicit conversion available
- @Test public void testCreateUpdateProcedure55() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // no user command provided - should throw resolver exception
- @Test public void testCreateUpdateProcedure56() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- TestResolver.helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
- }
-
- @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
- // Tests that the function params are resolved before the function for assignment statements
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = badFunction(badElement);"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
- }
-
- // addresses Cases 4624. Before change to UpdateProcedureResolver,
- // this case failed with assertion exception.
- @Test public void testCase4624() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
- procedure = procedure + "IF(var1 = {b 'true'})\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "SELECT Rack_ID, RACK_MDT_TYPE INTO #racks FROM Bert_MAP.BERT3.RACK;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: Bert_MAP.BERT3.RACK"); //$NON-NLS-1$
- }
-
- // addresses Cases 5474.
- @Test public void testCase5474() throws Exception {
- String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
- procedure = procedure + "VARIABLES.NLEVELS = SELECT COUNT(*) FROM (SELECT oi.e1 AS Col1, oi.e2 AS Col2, oi.e3 FROM pm1.g2 AS oi) AS TOBJ, pm2.g2 AS TModel WHERE TModel.e3 = TOBJ.e3;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
- }
-
- @Test public void testIssue174102() throws Exception {
- String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
- procedure = procedure + "CREATE LOCAL TEMPORARY TABLE #TTable (e1 string);"; //$NON-NLS-1$
- procedure = procedure + "EXECUTE STRING ('SELECT e1 FROM pm1.sq2 ' || crit ) AS e1 string INTO #TTable;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
- }
-
- // Address Issue 174519.
- // Expected result is resolver failure, but with different error.
- @Test public void testIssue174519() throws Exception {
- String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
- procedure = procedure + "INSERT INTO #temp \n"; //$NON-NLS-1$
- procedure = procedure + "SELECT pm1.sq3.e1 FROM pm1.sq3 WHERE pm1.sq3.in = VARIABLES.l_in;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
- helpResolveException("EXEC pm1.sq1(1)", metadata, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified. This statement has 0 elements and 0 values."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /*@Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
- String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
- procedure = procedure + "insert into pm1.g1 values (null, null, null, null);"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
- Command command = helpResolve(helpParse("exec pm1.sq1(1)"), metadata, null); //$NON-NLS-1$
-
- assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
- }*/
-
- //baseline test to ensure that a declare assignment cannot contain the declared variable
- @Test public void testDeclareStatement() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testDynamicIntoInProc() throws Exception {
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n") //$NON-NLS-1$
- .append("select e1 from #myTempTable;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
- helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testDynamicStatement() throws Exception {
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2';\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
- helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testDynamicStatementType() {
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("DECLARE object VARIABLES.X = null;\n") //$NON-NLS-1$
- .append("execute string VARIABLES.X;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
- helpFailUpdateProcedure(procedure.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution
- @Test public void testCreateUpdateProcedure1() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable resolution, variable used in if statement
- @Test public void testCreateUpdateProcedure3() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testSelectIntoInProc() throws Exception {
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
-
- procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
- helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testSelectIntoInProcNoFrom() throws Exception {
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
-
- procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
- helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- /*@Test public void testCommandUpdating3() throws Exception{
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("INSERT INTO pm1.g1 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
- .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- Command command = helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- assertEquals(2, command.updatingModelCount(metadata));
- }*/
-
- /*@Test public void testCommandUpdatingCount6() throws Exception{
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "if(INPUT.e1 = 10)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES (Input.e2);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
-
- Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.INSERT_PROCEDURE);
- assertEquals(2, command.updatingModelCount(metadata));
- }*/
-
- // variable declared is of special type ROWS_RETURNED
- @Test public void testDeclareRowsUpdated() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable rows_updated was previously declared."); //$NON-NLS-1$
- }
-
- // validating INPUT element assigned
- @Test public void testAssignInput() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "INPUT.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"INPUT.e1\" cannot be assigned a value. Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
- }
-
- // validating CHANGING element assigned
- @Test public void testAssignChanging() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "CHANGING.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"CHANGING.e1\" cannot be assigned a value. Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
- }
-
- // variables cannot be used among insert elements
- @Test public void testVariableInInsert() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1, 2);\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userQuery,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
- }
-
- // variables cannot be used among insert elements
- @Test public void testVariableInInsert2() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUT.x) values (1, 2);\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userQuery,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUT.x': Symbol INPUT.x is specified with an unknown group context]"); //$NON-NLS-1$
- }
-
- //should resolve first to the table's column
- @Test public void testVariableInInsert3() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
- procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userQuery,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testAmbigousInput() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "select e1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
- }
-
- @Test public void testLoopRedefinition() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n declare string var1;") //$NON-NLS-1$
- .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
- .append("\n BEGIN") //$NON-NLS-1$
- .append("\n LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor") //$NON-NLS-1$
- .append("\n BEGIN") //$NON-NLS-1$
- .append("\n var1 = CONCAT(var1, CONCAT(' ', loopCursor.e1));") //$NON-NLS-1$
- .append("\n END") //$NON-NLS-1$
- .append("\n END") //$NON-NLS-1$
- .append("\n END"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(proc.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
- }
-
- @Test public void testTempGroupElementShouldNotBeResolable() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n select 1 as a into #temp;") //$NON-NLS-1$
- .append("\n select #temp.a from pm1.g1;") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(proc.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
- }
-
- @Test public void testTempGroupElementShouldNotBeResolable1() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n select 1 as a into #temp;") //$NON-NLS-1$
- .append("\n insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(proc.toString(), userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
- }
-
- @Test public void testProcedureCreate() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
- .append("\n select e1 from t1;") //$NON-NLS-1$
- .append("\n create local temporary table t1 (e1 string, e2 integer);") //$NON-NLS-1$
- .append("\n select e2 from t1;") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- /**
- * it is not ok to redefine the loopCursor
- */
- @Test public void testProcedureCreate1() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
- .append("\n BEGIN") //$NON-NLS-1$
- .append("\n create local temporary table loopCursor (e1 string);") //$NON-NLS-1$
- .append("\nEND") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
- }
-
- @Test public void testProcedureCreateDrop() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n drop table t1;") //$NON-NLS-1$
- .append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
- }
-
- @Test public void testProcedureCreateDrop1() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
- .append("\n drop table t1;") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testCreateAfterImplicitTempTable() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n select e1 into #temp from pm1.g1;") //$NON-NLS-1$
- .append("\n create local temporary table #temp (e1 string);") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- @Test public void testInsertAfterCreate() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
- .append("\n insert into #temp (e1) values ('a');") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- /**
- * delete procedures should not reference input or changing vars.
- */
- @Test public void testDefect16451() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure += "BEGIN\n"; //$NON-NLS-1$
- procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = input.e1;\n"; //$NON-NLS-1$
- procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
- procedure += "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol input.e1 is specified with an unknown group context"); //$NON-NLS-1$
- }
-
- @Test public void testInvalidVirtualProcedure3() throws Exception {
- helpResolveException("EXEC pm1.vsp18()", FakeMetadataFactory.example1Cached(), "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // variable resolution, variable compared against
- // different datatype element for which there is no implicit transformation)
- @Test public void testCreateUpdateProcedure2() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure += "BEGIN\n"; //$NON-NLS-1$
- procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
- procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e4 = convert(var1, string), pm1.g1.e1 = var1;\n"; //$NON-NLS-1$
- procedure += "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e4' with expected type double to expression 'convert(var1, string)'"); //$NON-NLS-1$
- }
-
- // special variable INPUT compared against invalid type
- @Test public void testInvalidInputInUpdate() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure += "BEGIN\n"; //$NON-NLS-1$
- procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure += "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
- procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e1;\n"; //$NON-NLS-1$
- procedure += "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUT.e1'"); //$NON-NLS-1$
- }
-
- @Test public void testVirtualProcedure() throws Exception {
- helpResolve("EXEC pm1.vsp1()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testVirtualProcedure2() throws Exception {
- helpResolve("EXEC pm1.vsp14()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testVirtualProcedurePartialParameterReference() throws Exception {
- helpResolve("EXEC pm1.vsp58(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- //cursor starts with "#" Defect14924
- @Test public void testVirtualProcedureInvalid1() throws Exception {
- helpResolveException("EXEC pm1.vsp32()",FakeMetadataFactory.example1Cached(), "Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testVirtualProcedureWithOrderBy() throws Exception {
- helpResolve("EXEC pm1.vsp29()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testVirtualProcedureWithTempTableAndOrderBy() throws Exception {
- helpResolve("EXEC pm1.vsp33()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testVirtualProcedureWithConstAndOrderBy() throws Exception {
- helpResolve("EXEC pm1.vsp34()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testVirtualProcedureWithNoFromAndOrderBy() throws Exception {
- helpResolve("EXEC pm1.vsp28()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testInvalidVirtualProcedure2() throws Exception {
- helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLoopRedefinition2() throws Exception {
- helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testVariableResolutionWithIntervening() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
- .append("\nBEGIN") //$NON-NLS-1$
- .append("\n declare string x;") //$NON-NLS-1$
- .append("\n x = '1';") //$NON-NLS-1$
- .append("\n declare string y;") //$NON-NLS-1$
- .append("\n y = '1';") //$NON-NLS-1$
- .append("\nEND"); //$NON-NLS-1$
-
- TestResolver.helpResolve(proc.toString(), FakeMetadataFactory.example1Cached(), null);
- }
-
-}
Copied: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,1620 @@
+/*
+ * 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.query.resolver;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataStore;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.sql.ProcedureReservedWords;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.GroupContext;
+import com.metamatrix.query.sql.lang.Insert;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
+import com.metamatrix.query.sql.proc.AssignmentStatement;
+import com.metamatrix.query.sql.proc.Block;
+import com.metamatrix.query.sql.proc.CommandStatement;
+import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
+import com.metamatrix.query.sql.proc.LoopStatement;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.FakeMetadataObject;
+
+public class TestProcedureResolving {
+
+ private QueryMetadataInterface exampleStoredProcedure(String procedure) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+
+ FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
+ FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
+ FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+ QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure); //$NON-NLS-1$
+ FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
+
+ metadata.getStore().addObject(rs2);
+ metadata.getStore().addObject(sq1);
+
+ return metadata;
+ }
+
+ private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
+ helpFailUpdateProcedure(procedure, userUpdateStr, procedureType, null);
+ }
+
+ private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType, String msg) {
+ // resolve
+ try {
+ helpResolveUpdateProcedure(procedure, userUpdateStr, procedureType);
+ fail("Expected a QueryResolverException but got none."); //$NON-NLS-1$
+ } catch(QueryResolverException ex) {
+ if (msg != null) {
+ assertEquals(msg, ex.getMessage());
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new RuntimeException(e);
+ } catch (QueryParserException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
+ throws QueryMetadataException, MetaMatrixComponentException {
+ Map externalMetadata = new HashMap();
+
+ //TODO: it doesn't seem like these should be in the
+ List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(virtualGroup, metadata);
+ externalMetadata.put(virtualGroup, elements);
+
+ TempMetadataStore tms = new TempMetadataStore();
+
+ TempMetadataAdapter tma = new TempMetadataAdapter(metadata, tms);
+
+ GroupContext gc = ProcedureContainerResolver.createChildMetadata(tms, metadata, virtualGroup);
+
+ for (GroupSymbol symbol : gc.getAllGroups()) {
+ externalMetadata.put(symbol, ResolverUtil.resolveElementsInGroup(symbol, tma));
+ }
+
+ return externalMetadata;
+ }
+
+ @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\nDECLARE string var1;") //$NON-NLS-1$
+ .append("\nvar1 = '';") //$NON-NLS-1$
+ .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ .append("\n LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor2") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ .append("\n var1 = CONCAT(var1, CONCAT(' ', loopCursor2.e1));") //$NON-NLS-1$
+ .append("\n END") //$NON-NLS-1$
+ .append("\n END") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ Command command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ Map tempIDs = command.getTemporaryMetadata();
+ assertNotNull(tempIDs);
+ assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+ assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+
+ Command subCommand = command.getSubCommands().get(0);
+ tempIDs = subCommand.getTemporaryMetadata();
+ assertNotNull(tempIDs);
+ assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+ assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+
+ subCommand = command.getSubCommands().get(1);
+ tempIDs = subCommand.getTemporaryMetadata();
+ assertNotNull(tempIDs);
+ assertNotNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+ assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+ }
+
+ private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
+ return resolveProcedure(userUpdateStr, metadata);
+ }
+
+ private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
+ QueryMetadataInterface metadata) throws QueryParserException,
+ QueryResolverException, MetaMatrixComponentException,
+ QueryMetadataException {
+ ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
+ QueryResolver.resolveCommand(userCommand, metadata);
+ metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(userCommand.getTemporaryMetadata()));
+ return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
+ }
+
+ private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, MetaMatrixComponentException {
+ try {
+ helpResolve(userUpdateStr, metadata);
+ } catch (QueryResolverException e) {
+ assertEquals(msg, e.getMessage());
+ }
+ }
+
+ private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ return resolveProcedure(userUpdateStr, metadata);
+ }
+
+ /**
+ * Constants will now auto resolve if they are consistently representable in the target type
+ */
+ @Test public void testDefect23257() throws Exception{
+ CreateUpdateProcedureCommand command = helpResolve("EXEC pm5.vsp59()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+
+ CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1);
+
+ Insert insert = (Insert)cs.getCommand();
+
+ assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
+ }
+
+ @Test public void testProcedureScoping() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ //note that this declare takes presedense over the proc INPUTS.e1 and CHANGING.e1 variables
+ .append("\n declare integer e1 = 1;") //$NON-NLS-1$
+ .append("\n e1 = e1;") //$NON-NLS-1$
+ .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
+ .append("\n variables.e1 = convert(e1, integer);") //$NON-NLS-1$
+ .append("\n END") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+
+ Block block = command.getBlock();
+
+ AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
+ assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
+ assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
+
+ Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
+
+ assStmt = (AssignmentStatement)inner.getStatements().get(0);
+
+ ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
+
+ assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
+ }
+
+ // variable resolution, variable used in if statement, variable compared against
+ // different datatype element
+ @Test public void testCreateUpdateProcedure4() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1);\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution, variable used in if statement, invalid operation on variable
+ @Test public void testCreateUpdateProcedure5() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = var1 + var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 whwre var1 = var1+var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution, variables declared in different blocks local variables
+ // should not override
+ @Test public void testCreateUpdateProcedure6() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable var1 was previously declared."); //$NON-NLS-1$
+ }
+
+ // variable resolution, variables declared in different blocks local variables
+ // inner block using outer block variables
+ @Test public void testCreateUpdateProcedure7() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE boolean var2;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution, variables declared in different blocks local variables
+ // outer block cannot use inner block variables
+ @Test public void testCreateUpdateProcedure8() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var2;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "var2 = 1\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution, variables declared in different blocks local variables
+ // should override, outer block variables still valid afetr inner block is declared
+ @Test public void testCreateUpdateProcedure9() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = var1 +1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable ROWS_UPDATED resolution
+ @Test public void testCreateUpdateProcedure10() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable ROWS_UPDATED used with declared variable
+ @Test public void testCreateUpdateProcedure11() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable INPUT used with declared variable
+ @Test public void testCreateUpdateProcedure12() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable CHANGING used with declared variable
+ @Test public void testCreateUpdateProcedure14() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(CHANGING.e1 = 'true')\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable CHANGING and INPUT used in compound criteria
+ @Test public void testCreateUpdateProcedure15() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(CHANGING.e1='false' and INPUTS.e1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable CHANGING and INPUT used in compound criteria, with declared variables
+ @Test public void testCreateUpdateProcedure16() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(CHANGING.e4 ='true' and INPUTS.e2=1 or var1 < 30)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // special variable CHANGING compared against integer no implicit conversion available
+ @Test public void testCreateUpdateProcedure17() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (boolean and date) and no implicit conversion is available: CHANGING.e4 = {d'2000-01-01'}"); //$NON-NLS-1$
+ }
+
+ // virtual group elements used in procedure(HAS CRITERIA)
+ @Test public void testCreateUpdateProcedure18() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // virtual group elements used in procedure in if statement(HAS CRITERIA)
+ @Test public void testCreateUpdateProcedure19() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // virtual group elements used in procedure(TRANSLATE CRITERIA)
+ @Test public void testCreateUpdateProcedure20() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // virtual group elements used in procedure(TRANSLATE CRITERIA)
+ @Test public void testCreateUpdateProcedure21() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using undefined variable should fail
+ @Test public void testCreateUpdateProcedure22() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+// procedure = procedure + "DECLARE integer var1;\n";
+ procedure = procedure + "var3 = var2+var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var2 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using undefined variable declared is of invalid datatype
+ @Test public void testCreateUpdateProcedure23() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using declare variable that has parts
+ @Test public void testCreateUpdateProcedure24() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using declare variable is qualified
+ @Test public void testCreateUpdateProcedure26() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using declare variable is qualified but has more parts
+ @Test public void testCreateUpdateProcedure27() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using a variable that has not been declared in an assignment stmt
+ @Test public void testCreateUpdateProcedure28() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using a variable that has not been declared in an assignment stmt
+ @Test public void testCreateUpdateProcedure29() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using invalid function in assignment expr
+ @Test public void testCreateUpdateProcedure30() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using invalid function in assignment expr
+ @Test public void testCreateUpdateProcedure31() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // using a variable being used inside a subcomand
+ @Test public void testCreateUpdateProcedure32() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select var1 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution, variables declared in different blocks local variables
+ // should override, outer block variables still valid afetr inner block is declared
+ // fails as variable being compared against incorrect type
+ @Test public void testCreateUpdateProcedure33() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE timestamp var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = var1 +1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // physical elements used on criteria of the if statement
+ @Test public void testCreateUpdateProcedure34() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
+ }
+
+ // virtual elements used on criteria of the if statement
+ @Test public void testCreateUpdateProcedure35() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1) and var1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // physical elements used on criteria of the if statement
+ @Test public void testCreateUpdateProcedure36() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // TranslateCriteria on criteria of the if statement
+ @Test public void testCreateUpdateProcedure37() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(TRANSLATE CRITERIA ON (vm1.g1.e1) WITH (vm1.g1.e1 = 1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // validating Translate CRITERIA, elements on it should be virtual group elements
+ // but can use variables
+ @Test public void testCreateUpdateProcedure38() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (pm1.g1.e2 = var1);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // physical elements used on criteria of the if statement
+ @Test public void testCreateUpdateProcedure39() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // TranslateCriteria on criteria of the if statement
+ @Test public void testCreateUpdateProcedure40() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // TranslateCriteria on criteria of the if statement
+ @Test public void testCreateUpdateProcedure41() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // TranslateCriteria on criteria of the if statement
+ @Test public void testCreateUpdateProcedure42() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // TranslateCriteria on criteria of the if statement
+ @Test public void testCreateUpdateProcedure43() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+// procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n";
+// procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n";
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
+
+ Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+ GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+ virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+ Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);
+ QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+ }
+
+ // special variable CHANGING compared against integer no implicit conversion available
+ @Test public void testCreateUpdateProcedure44() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "if(INPUTS.e1 = 10)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.INSERT_PROCEDURE);
+ }
+
+ // special variable CHANGING compared against integer no implicit conversion available
+ @Test public void testCreateUpdateProcedure45() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "if(INPUTS.e1 = 10)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);
+
+ GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+ virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+
+ Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);
+ QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+ }
+
+ // special variable CHANGING compared against integer no implicit conversion available
+ @Test public void testCreateUpdateProcedure46() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
+
+ GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+ virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+
+ Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);
+ QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+ }
+
+ // TranslateCriteria on criteria of the if statement
+ @Test public void testCreateUpdateProcedure47() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (vm1.g1.e1 = pm1.g1.e1);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // validating Translate CRITERIA, elements(left elements on on it should be virtual group elements
+ @Test public void testCreateUpdateProcedure48() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, INPUTS.e2 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // resolving Translate CRITERIA, right element should be present on the command
+ @Test public void testCreateUpdateProcedure49() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
+ @Test public void testCreateUpdateProcedure50() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.E1, vm1.g1.e1, INPUTS.e1))\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
+ @Test public void testCreateUpdateProcedure51() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1=1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e2 = var1+vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // validating Translate CRITERIA, elements on it should be virtual group elements
+ // but can use variables, gut left exprs should always be virtual elements
+ @Test public void testCreateUpdateProcedure52() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (var1 = vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // resolving AssignmentStatement, variable type and assigned type
+ // do not match and no implicit conversion available
+ @Test public void testCreateUpdateProcedure53() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = INPUTS.e4;"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // resolving AssignmentStatement, variable type and assigned type
+ // do not match, but implicit conversion available
+ @Test public void testCreateUpdateProcedure54() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // resolving AssignmentStatement, variable type and assigned type
+ // do not match, but implicit conversion available
+ @Test public void testCreateUpdateProcedure55() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // no user command provided - should throw resolver exception
+ @Test public void testCreateUpdateProcedure56() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ TestResolver.helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
+ // Tests that the function params are resolved before the function for assignment statements
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = badFunction(badElement);"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
+ }
+
+ // addresses Cases 4624. Before change to UpdateProcedureResolver,
+ // this case failed with assertion exception.
+ @Test public void testCase4624() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
+ procedure = procedure + "IF(var1 = {b 'true'})\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "SELECT Rack_ID, RACK_MDT_TYPE INTO #racks FROM Bert_MAP.BERT3.RACK;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: Bert_MAP.BERT3.RACK"); //$NON-NLS-1$
+ }
+
+ // addresses Cases 5474.
+ @Test public void testCase5474() throws Exception {
+ String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
+ procedure = procedure + "VARIABLES.NLEVELS = SELECT COUNT(*) FROM (SELECT oi.e1 AS Col1, oi.e2 AS Col2, oi.e3 FROM pm1.g2 AS oi) AS TOBJ, pm2.g2 AS TModel WHERE TModel.e3 = TOBJ.e3;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
+ }
+
+ @Test public void testIssue174102() throws Exception {
+ String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
+ procedure = procedure + "CREATE LOCAL TEMPORARY TABLE #TTable (e1 string);"; //$NON-NLS-1$
+ procedure = procedure + "EXECUTE STRING ('SELECT e1 FROM pm1.sq2 ' || crit ) AS e1 string INTO #TTable;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
+ }
+
+ // Address Issue 174519.
+ // Expected result is resolver failure, but with different error.
+ @Test public void testIssue174519() throws Exception {
+ String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
+ procedure = procedure + "INSERT INTO #temp \n"; //$NON-NLS-1$
+ procedure = procedure + "SELECT pm1.sq3.e1 FROM pm1.sq3 WHERE pm1.sq3.in = VARIABLES.l_in;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
+ helpResolveException("EXEC pm1.sq1(1)", metadata, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified. This statement has 0 elements and 0 values."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*@Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
+ String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
+ procedure = procedure + "insert into pm1.g1 values (null, null, null, null);"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
+ Command command = helpResolve(helpParse("exec pm1.sq1(1)"), metadata, null); //$NON-NLS-1$
+
+ assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
+ }*/
+
+ //baseline test to ensure that a declare assignment cannot contain the declared variable
+ @Test public void testDeclareStatement() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testDynamicIntoInProc() throws Exception {
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n") //$NON-NLS-1$
+ .append("select e1 from #myTempTable;\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+ helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testDynamicStatement() throws Exception {
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2';\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+ helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testDynamicStatementType() {
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("DECLARE object VARIABLES.X = null;\n") //$NON-NLS-1$
+ .append("execute string VARIABLES.X;\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+ helpFailUpdateProcedure(procedure.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution
+ @Test public void testCreateUpdateProcedure1() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ // variable resolution, variable used in if statement
+ @Test public void testCreateUpdateProcedure3() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testSelectIntoInProc() throws Exception {
+ StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+
+ procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+ helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testSelectIntoInProcNoFrom() throws Exception {
+ StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+
+ procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable;\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+ helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ /*@Test public void testCommandUpdating3() throws Exception{
+ StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("INSERT INTO pm1.g1 (e1) VALUES (INPUTS.e1);\n") //$NON-NLS-1$
+ .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (INPUTS.e1);\n") //$NON-NLS-1$
+ .append("END\n"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ Command command = helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ assertEquals(2, command.updatingModelCount(metadata));
+ }*/
+
+ /*@Test public void testCommandUpdatingCount6() throws Exception{
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "if(INPUTS.e1 = 10)\n"; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES (INPUTS.e2);\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
+
+ Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.INSERT_PROCEDURE);
+ assertEquals(2, command.updatingModelCount(metadata));
+ }*/
+
+ // variable declared is of special type ROWS_RETURNED
+ @Test public void testDeclareRowsUpdated() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable rows_updated was previously declared."); //$NON-NLS-1$
+ }
+
+ // validating INPUT element assigned
+ @Test public void testAssignInput() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "INPUTS.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"INPUTS.e1\" cannot be assigned a value. Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
+ }
+
+ // validating CHANGING element assigned
+ @Test public void testAssignChanging() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "CHANGING.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"CHANGING.e1\" cannot be assigned a value. Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
+ }
+
+ // variables cannot be used among insert elements
+ @Test public void testVariableInInsert() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1, 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userQuery,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
+ }
+
+ // variables cannot be used among insert elements
+ @Test public void testVariableInInsert2() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUTS.x) values (1, 2);\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userQuery,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUTS.x': Symbol INPUTS.x is specified with an unknown group context]"); //$NON-NLS-1$
+ }
+
+ //should resolve first to the table's column
+ @Test public void testVariableInInsert3() throws Exception {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(procedure, userQuery,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testAmbigousInput() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+ procedure = procedure + "select e1;\n"; //$NON-NLS-1$
+ procedure = procedure + "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
+ }
+
+ @Test public void testLoopRedefinition() {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n declare string var1;") //$NON-NLS-1$
+ .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ .append("\n LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ .append("\n var1 = CONCAT(var1, CONCAT(' ', loopCursor.e1));") //$NON-NLS-1$
+ .append("\n END") //$NON-NLS-1$
+ .append("\n END") //$NON-NLS-1$
+ .append("\n END"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
+ }
+
+ @Test public void testTempGroupElementShouldNotBeResolable() {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n select 1 as a into #temp;") //$NON-NLS-1$
+ .append("\n select #temp.a from pm1.g1;") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+ }
+
+ @Test public void testTempGroupElementShouldNotBeResolable1() {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n select 1 as a into #temp;") //$NON-NLS-1$
+ .append("\n insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+ }
+
+ @Test public void testProcedureCreate() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
+ .append("\n select e1 from t1;") //$NON-NLS-1$
+ .append("\n create local temporary table t1 (e1 string, e2 integer);") //$NON-NLS-1$
+ .append("\n select e2 from t1;") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ /**
+ * it is not ok to redefine the loopCursor
+ */
+ @Test public void testProcedureCreate1() {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ .append("\n create local temporary table loopCursor (e1 string);") //$NON-NLS-1$
+ .append("\nEND") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
+ }
+
+ @Test public void testProcedureCreateDrop() {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n drop table t1;") //$NON-NLS-1$
+ .append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
+ }
+
+ @Test public void testProcedureCreateDrop1() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
+ .append("\n drop table t1;") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testCreateAfterImplicitTempTable() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n select e1 into #temp from pm1.g1;") //$NON-NLS-1$
+ .append("\n create local temporary table #temp (e1 string);") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ @Test public void testInsertAfterCreate() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
+ .append("\n insert into #temp (e1) values ('a');") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+ }
+
+ /**
+ * delete procedures should not reference input or changing vars.
+ */
+ @Test public void testDefect16451() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure += "BEGIN\n"; //$NON-NLS-1$
+ procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = INPUTS.e1;\n"; //$NON-NLS-1$
+ procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
+ procedure += "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol INPUTS.e1 is specified with an unknown group context"); //$NON-NLS-1$
+ }
+
+ @Test public void testInvalidVirtualProcedure3() throws Exception {
+ helpResolveException("EXEC pm1.vsp18()", FakeMetadataFactory.example1Cached(), "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // variable resolution, variable compared against
+ // different datatype element for which there is no implicit transformation)
+ @Test public void testCreateUpdateProcedure2() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure += "BEGIN\n"; //$NON-NLS-1$
+ procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
+ procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e4 = convert(var1, string), pm1.g1.e1 = var1;\n"; //$NON-NLS-1$
+ procedure += "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e4' with expected type double to expression 'convert(var1, string)'"); //$NON-NLS-1$
+ }
+
+ // special variable INPUT compared against invalid type
+ @Test public void testInvalidInputInUpdate() {
+ String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ procedure += "BEGIN\n"; //$NON-NLS-1$
+ procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
+ procedure += "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e1;\n"; //$NON-NLS-1$
+ procedure += "END\n"; //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpFailUpdateProcedure(procedure, userUpdateStr,
+ FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUTS.e1'"); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualProcedure() throws Exception {
+ helpResolve("EXEC pm1.vsp1()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualProcedure2() throws Exception {
+ helpResolve("EXEC pm1.vsp14()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualProcedurePartialParameterReference() throws Exception {
+ helpResolve("EXEC pm1.vsp58(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ //cursor starts with "#" Defect14924
+ @Test public void testVirtualProcedureInvalid1() throws Exception {
+ helpResolveException("EXEC pm1.vsp32()",FakeMetadataFactory.example1Cached(), "Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testVirtualProcedureWithOrderBy() throws Exception {
+ helpResolve("EXEC pm1.vsp29()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualProcedureWithTempTableAndOrderBy() throws Exception {
+ helpResolve("EXEC pm1.vsp33()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualProcedureWithConstAndOrderBy() throws Exception {
+ helpResolve("EXEC pm1.vsp34()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualProcedureWithNoFromAndOrderBy() throws Exception {
+ helpResolve("EXEC pm1.vsp28()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testInvalidVirtualProcedure2() throws Exception {
+ helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLoopRedefinition2() throws Exception {
+ helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testVariableResolutionWithIntervening() throws Exception {
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ .append("\n declare string x;") //$NON-NLS-1$
+ .append("\n x = '1';") //$NON-NLS-1$
+ .append("\n declare string y;") //$NON-NLS-1$
+ .append("\n y = '1';") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ TestResolver.helpResolve(proc.toString(), FakeMetadataFactory.example1Cached(), null);
+ }
+
+}
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -49,7 +49,7 @@
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -1396,7 +1396,7 @@
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
- FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
+ FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
@@ -1432,7 +1432,7 @@
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
- FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
+ FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
@@ -1882,7 +1882,7 @@
//String sql = "select intkey from SmallA where user() = 'bqt2'";
// Expected left expression
- FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
+ FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.USER, new Class[] { });
Function user = new Function(fd.getName(), new Expression[] {});
user.setFunctionDescriptor(fd);
@@ -1938,7 +1938,7 @@
@Test public void testDefect10809(){
String sql = "select * from LOB_TESTING_ONE where CLOB_COLUMN LIKE '%fff%'"; //$NON-NLS-1$
- helpResolve(helpParse(sql), FakeMetadataFactory.exampleLOB(), AnalysisRecord.createNonRecordingRecord());
+ helpResolve(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), AnalysisRecord.createNonRecordingRecord());
}
@Test public void testNonAutoConversionOfLiteralIntegerToShort() throws Exception {
@@ -2270,23 +2270,10 @@
}
- @Test public void testUnionInSubquery() {
+ @Test public void testUnionInSubquery() throws Exception {
String sql = "SELECT StringKey FROM (SELECT BQT2.SmallB.StringKey FROM BQT2.SmallB union SELECT convert(BQT2.SmallB.FloatNum, string) FROM BQT2.SmallB) x"; //$NON-NLS-1$
-
- // parse
- Command command = null;
- try {
- command = QueryParser.getQueryParser().parseCommand(sql);
- } catch(MetaMatrixException e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // resolve
- try {
- QueryResolver.resolveCommand(command, FakeMetadataFactory.exampleBQT());
- } catch(MetaMatrixException e) {
- fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ Command command = QueryParser.getQueryParser().parseCommand(sql);
+ QueryResolver.resolveCommand(command, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testCommandUpdatingCount1() throws Exception{
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -118,7 +118,7 @@
Criteria actual = null;
// rewrite
try {
- actual = QueryRewriter.rewriteCriteria(origCrit, null, null, null);
+ actual = QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
assertEquals("Did not rewrite correctly: ", expectedCrit, actual); //$NON-NLS-1$
} catch(QueryValidatorException e) {
throw new RuntimeException(e);
@@ -1491,11 +1491,12 @@
QueryParser parser = new QueryParser();
Command command = parser.parseCommand("exec pm1.sp4(5)"); //$NON-NLS-1$
- // resolve
- QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
+ // resolve
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+ QueryResolver.resolveCommand(command, metadata);
// rewrite
- Command rewriteCommand = QueryRewriter.rewrite(command, null, null);
+ Command rewriteCommand = QueryRewriter.rewrite(command, metadata, null);
List<SPParameter> parameters = ((StoredProcedure)rewriteCommand).getParameters();
@@ -1512,7 +1513,7 @@
// rewrite
try {
- QueryRewriter.rewriteCriteria(origCrit, null, null, null);
+ QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
fail("Expected QueryValidatorException due to divide by 0"); //$NON-NLS-1$
} catch(QueryValidatorException e) {
// looks like message is being wrapped with another exception with same message
@@ -1526,7 +1527,7 @@
// rewrite
try {
- QueryRewriter.rewriteCriteria(origCrit, null, null, null);
+ QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
fail("Expected QueryValidatorException due to invalid string"); //$NON-NLS-1$
} catch(QueryValidatorException e) {
assertEquals("Error Code:ERR.015.009.0004 Message:Unable to convert 'x' of type [string] to the expected type [integer].", e.getMessage()); //$NON-NLS-1$
@@ -1735,7 +1736,7 @@
Properties props = new Properties();
props.setProperty(ContextProperties.SESSION_ID, "1"); //$NON-NLS-1$
context.setEnvironmentProperties(props);
- Command rewriteCommand = QueryRewriter.rewrite(command, null, context);
+ Command rewriteCommand = QueryRewriter.rewrite(command, FakeMetadataFactory.example1Cached(), context);
assertEquals("EXEC pm1.sq2('1')", rewriteCommand.toString()); //$NON-NLS-1$
}
@@ -2232,20 +2233,19 @@
@Test public void testRewriteParseDate() {
String original = "parsedate(BQT1.SmallA.stringkey, 'yymmdd') = {d'1970-01-01'}"; //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
helpTestRewriteCriteria(original, parseCriteria("convert(parsetimestamp(BQT1.SmallA.stringkey, 'yymmdd'), date) = {d'1970-01-01'}", metadata), metadata); //$NON-NLS-1$
}
@Test public void testRewriteFormatTime() {
String original = "formattime(BQT1.SmallA.timevalue, 'hh:mm') = '08:02'"; //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
helpTestRewriteCriteria(original, parseCriteria("formattimestamp(convert(BQT1.SmallA.timevalue, timestamp), 'hh:mm') = '08:02'", metadata), metadata); //$NON-NLS-1$
}
@Test public void testRewriteTimestampAdd() {
String original = "timestampadd(SQL_TSI_SECOND, 1, BQT1.SmallA.timevalue) = {t'08:02:00'}"; //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
helpTestRewriteCriteria(original, parseCriteria("convert(timestampadd(SQL_TSI_SECOND, 1, convert(BQT1.SmallA.timevalue, timestamp)), time) = {t'08:02:00'}", metadata), metadata); //$NON-NLS-1$
}
-
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,11 @@
package com.metamatrix.query.sql.symbol;
+import org.teiid.connector.language.SQLReservedWords;
+
import junit.framework.TestCase;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.ReservedWords;
public class TestAggregateSymbol extends TestCase {
@@ -70,105 +71,105 @@
// ################################## ACTUAL TESTS ################################
public void testParser1() {
- AggregateSymbol as = new AggregateSymbol("count", ReservedWords.COUNT, false, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol as = new AggregateSymbol("count", SQLReservedWords.COUNT, false, sampleElement()); //$NON-NLS-1$
helpParser(as, "COUNT(m.g.c)"); //$NON-NLS-1$
}
public void testParser2() {
- AggregateSymbol as = new AggregateSymbol("count", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol as = new AggregateSymbol("count", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
helpParser(as, "COUNT(DISTINCT m.g.c)"); //$NON-NLS-1$
}
public void testParser3() {
- AggregateSymbol as = new AggregateSymbol("x", ReservedWords.MIN, false, sampleConstant()); //$NON-NLS-1$
+ AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.MIN, false, sampleConstant()); //$NON-NLS-1$
helpParser(as, "MIN(5)"); //$NON-NLS-1$
}
public void testParser4() {
- AggregateSymbol as = new AggregateSymbol("x", ReservedWords.MAX, false, sampleFunction()); //$NON-NLS-1$
+ AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.MAX, false, sampleFunction()); //$NON-NLS-1$
helpParser(as, "MAX((m.g.c + 5))"); //$NON-NLS-1$
}
public void testParser5() {
- AggregateSymbol as = new AggregateSymbol("x", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
helpParser(as, "COUNT(*)"); //$NON-NLS-1$
}
public void testEquals1() {
- AggregateSymbol as = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
helpEquals(as, as, true);
}
public void testEquals2() {
- AggregateSymbol as1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol as1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
AggregateSymbol as2 = (AggregateSymbol) as1.clone();
helpEquals(as1, as2, true);
}
//just changing the name of an aggregatesymbol doesn't matter
public void testEquals3() {
- AggregateSymbol as1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol as2 = new AggregateSymbol("y", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol as1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol as2 = new AggregateSymbol("y", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
helpEquals(as1, as2, true);
}
public void testEquals4() {
- AggregateSymbol as1 = new AggregateSymbol("count", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol as1 = new AggregateSymbol("count", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
AggregateSymbol as2 = (AggregateSymbol) as1.clone();
helpEquals(as1, as2, true);
}
public void testSelfEquivalence(){
- AggregateSymbol test = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, test, test);
}
public void testEquivalence(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
public void testEquivalenceCountStar(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, false, null); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
public void testEquivalenceCaseInsens(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("X", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("X", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
public void testNonEquivalenceUsingDiffElements(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("X", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("X", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
public void testNonEquivalence(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("y", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("y", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
public void testNonEquivalence1(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
public void testNonEquivalence2(){
- AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.MAX, true, sampleElement()); //$NON-NLS-1$
- AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+ AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.MAX, true, sampleElement()); //$NON-NLS-1$
+ AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -178,7 +178,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUT.a, INPUT.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUTS.a, INPUTS.e2);\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand2(){ //put a constant in select statement
@@ -186,7 +186,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, 5 from pm1.g1 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1) VALUES (INPUT.a);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1) VALUES (INPUTS.a);\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand3(){
@@ -194,7 +194,7 @@
"vm1.g2", //$NON-NLS-1$
"select * from pm1.g2 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUT.e1, INPUT.e2, INPUT.e3, INPUT.e4);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3, INPUTS.e4);\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand4(){ //test group alias
@@ -202,7 +202,7 @@
"vm1.g2", //$NON-NLS-1$
"select * from pm1.g2 as g_alias", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUT.e1, INPUT.e2, INPUT.e3, INPUT.e4);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3, INPUTS.e4);\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand5(){
@@ -210,7 +210,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 as g_alias where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUT.a, INPUT.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUTS.a, INPUTS.e2);\nEND"); //$NON-NLS-1$
}
public void testCreateUpdateCommand(){
@@ -218,7 +218,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e1 = INPUT.a, e2 = INPUT.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e1 = INPUTS.a, e2 = INPUTS.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
}
public void testCreateDeleteCommand(){
@@ -339,7 +339,7 @@
"vm1.g3", //$NON-NLS-1$
"SELECT e1, e2 FROM pm1.g3", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e2) VALUES (INPUT.e1, INPUT.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e2) VALUES (INPUTS.e1, INPUTS.e2);\nEND"); //$NON-NLS-1$
}
// Check that e2 is not required (it is auto-incremented)
@@ -348,7 +348,7 @@
"vm1.g4", //$NON-NLS-1$
"SELECT e1, e3 FROM pm1.g3", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e3) VALUES (INPUT.e1, INPUT.e3);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e3) VALUES (INPUTS.e1, INPUTS.e3);\nEND"); //$NON-NLS-1$
}
// Check that e1 is required (it is not-nullable, not auto-incrementable, and has no default value)
@@ -366,7 +366,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(false),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e2 = INPUT.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e2 = INPUTS.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
}
// Verify that elements that are not updateable are exlcluded from update and delete procedures
@@ -375,7 +375,7 @@
"vm1.g1", //$NON-NLS-1$
"SELECT e1, e2 FROM pm1.g1", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(false),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e2) VALUES (INPUT.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e2) VALUES (INPUTS.e2);\nEND"); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -32,9 +32,9 @@
import org.junit.Test;
import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.SQLReservedWords;
import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetCriteria;
@@ -196,10 +196,10 @@
*/
@Test public void testRecursionDetection() {
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
- AggregateSymbol a1 = new AggregateSymbol("x", ReservedWords.SUM, false, e1); //$NON-NLS-1$
+ AggregateSymbol a1 = new AggregateSymbol("x", SQLReservedWords.SUM, false, e1); //$NON-NLS-1$
Function f = new Function(SourceSystemFunctions.ADD_OP, new Expression[] {a1, a1});
HashMap<AggregateSymbol, AggregateSymbol> map = new HashMap<AggregateSymbol, AggregateSymbol>();
- map.put(a1, new AggregateSymbol("x", ReservedWords.SUM, false, a1)); //$NON-NLS-1$
+ map.put(a1, new AggregateSymbol("x", SQLReservedWords.SUM, false, a1)); //$NON-NLS-1$
ExpressionMappingVisitor.mapExpressions(f, map);
assertEquals("(SUM(SUM(e1)) + SUM(SUM(e1)))", f.toString()); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,6 +27,8 @@
import java.util.Arrays;
import java.util.List;
+import org.teiid.connector.language.SQLReservedWords;
+
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
@@ -34,7 +36,6 @@
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.BetweenCriteria;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -1051,37 +1052,37 @@
}
public void testAggregateSymbol1() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
helpTest(agg, "COUNT('abc')"); //$NON-NLS-1$
}
public void testAggregateSymbol2() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
helpTest(agg, "COUNT(DISTINCT 'abc')"); //$NON-NLS-1$
}
public void testAggregateSymbol3() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
helpTest(agg, "COUNT(*)"); //$NON-NLS-1$
}
public void testAggregateSymbol4() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.AVG, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.AVG, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
helpTest(agg, "AVG('abc')"); //$NON-NLS-1$
}
public void testAggregateSymbol5() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.SUM, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.SUM, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
helpTest(agg, "SUM('abc')"); //$NON-NLS-1$
}
public void testAggregateSymbol6() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.MIN, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.MIN, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
helpTest(agg, "MIN('abc')"); //$NON-NLS-1$
}
public void testAggregateSymbol7() {
- AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.MAX, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+ AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.MAX, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
helpTest(agg, "MAX('abc')"); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -35,6 +35,8 @@
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingBaseNode;
import com.metamatrix.query.mapping.xml.MappingDocument;
@@ -51,10 +53,17 @@
public class FakeMetadataFacade extends BasicQueryMetadata {
private FakeMetadataStore store;
+ private FunctionLibrary functionLibrary;
public FakeMetadataFacade(FakeMetadataStore store) {
this.store = store;
+ this.functionLibrary = SystemFunctionManager.getSystemFunctionLibrary();
}
+
+ public FakeMetadataFacade(FakeMetadataStore store, FunctionLibrary funcLibrary) {
+ this.store = store;
+ this.functionLibrary = funcLibrary;
+ }
public FakeMetadataStore getStore() {
return this.store;
@@ -759,4 +768,9 @@
return object.getProperty(key);
}
}
+
+ @Override
+ public FunctionLibrary getFunctionLibrary() {
+ return this.functionLibrary;
+ }
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,13 +29,22 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+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.vdb.ModelType;
import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingAttribute;
import com.metamatrix.query.mapping.xml.MappingDocument;
import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
import com.metamatrix.query.mapping.xml.MappingSequenceNode;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -43,7 +52,6 @@
public class FakeMetadataFactory {
private static FakeMetadataFacade CACHED_EXAMPLE1 = example1();
- private static FakeMetadataFacade CACHED_BQT = exampleBQT();
private static FakeMetadataFacade CACHED_AGGREGATES = exampleAggregates();
private FakeMetadataFactory() { }
@@ -52,14 +60,38 @@
return CACHED_EXAMPLE1;
}
- public static FakeMetadataFacade exampleBQTCached() {
- return CACHED_BQT;
+ public static TransformationMetadata exampleBQTCached() {
+ return RealMetadataFactory.exampleBQTCached();
}
+ public static void setCardinality(String group, int cardinality, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ if (metadata instanceof TransformationMetadata) {
+ Table t = (Table)metadata.getGroupID(group);
+ t.setCardinality(cardinality);
+ } else if (metadata instanceof FakeMetadataFacade) {
+ FakeMetadataObject fmo = (FakeMetadataObject)metadata.getGroupID(group);
+ fmo.putProperty(FakeMetadataObject.Props.CARDINALITY, cardinality);
+ } else {
+ throw new RuntimeException("unknown metadata"); //$NON-NLS-1$
+ }
+
+ }
+
public static FakeMetadataFacade exampleAggregatesCached() {
return CACHED_AGGREGATES;
}
-
+
+ public static DQPWorkContext buildWorkContext(QueryMetadataInterface metadata, VDBMetaData vdb) {
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName(vdb.getName());
+ workContext.setVdbVersion(vdb.getVersion());
+ workContext.setSessionToken(new SessionToken(5, "foo")); //$NON-NLS-1$
+ workContext.setVdb(vdb);
+ workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
+ DQPWorkContext.setWorkContext(workContext);
+ return workContext;
+ }
+
public static FakeMetadataFacade exampleBitwise() {
FakeMetadataObject phys = createPhysicalModel("phys"); //$NON-NLS-1$
FakeMetadataObject t = createPhysicalGroup("phys.t", phys); //$NON-NLS-1$
@@ -99,6 +131,39 @@
}
+ public static VDBMetaData example1VDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("example1");
+ vdb.setVersion(1);
+ vdb.addModel(createModel("pm1", true));
+ vdb.addModel(createModel("pm2", true));
+ vdb.addModel(createModel("pm3", true));
+ vdb.addModel(createModel("pm4", true));
+ vdb.addModel(createModel("pm5", true));
+ vdb.addModel(createModel("pm6", true));
+ vdb.addModel(createModel("vm1", false));
+ vdb.addModel(createModel("vm2", false));
+ vdb.addModel(createModel("tm1", false));
+
+ return vdb;
+ }
+
+ public static ModelMetaData createModel(String name, boolean source) {
+ ModelMetaData model = new ModelMetaData();
+ model.setName(name);
+ if (source) {
+ model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+ }
+ else {
+ model.setModelType(ModelType.getString(ModelType.VIRTUAL));
+ }
+ model.setVisible(true);
+ model.setSupportsMultiSourceBindings(false);
+ model.addSourceMapping(name, null);
+
+ return model;
+ }
+
public static FakeMetadataFacade example1() {
// Create models
FakeMetadataObject pm1 = createPhysicalModel("pm1"); //$NON-NLS-1$
@@ -2049,673 +2114,27 @@
return new FakeMetadataFacade(store);
}
- public static FakeMetadataFacade exampleBQT() {
- // Create models
- FakeMetadataObject bqt1 = createPhysicalModel("BQT1"); //$NON-NLS-1$
- FakeMetadataObject bqt2 = createPhysicalModel("BQT2"); //$NON-NLS-1$
- FakeMetadataObject bqt3 = createPhysicalModel("BQT3"); //$NON-NLS-1$
- FakeMetadataObject lob = createPhysicalModel("LOB"); //$NON-NLS-1$
- FakeMetadataObject vqt = createVirtualModel("VQT"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject bqt1SmallA = createPhysicalGroup("BQT1.SmallA", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt1SmallB = createPhysicalGroup("BQT1.SmallB", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt1MediumA = createPhysicalGroup("BQT1.MediumA", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt1MediumB = createPhysicalGroup("BQT1.MediumB", bqt1); //$NON-NLS-1$
- FakeMetadataObject bqt2SmallA = createPhysicalGroup("BQT2.SmallA", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt2SmallB = createPhysicalGroup("BQT2.SmallB", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt2MediumA = createPhysicalGroup("BQT2.MediumA", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt2MediumB = createPhysicalGroup("BQT2.MediumB", bqt2); //$NON-NLS-1$
- FakeMetadataObject bqt3SmallA = createPhysicalGroup("BQT3.SmallA", bqt3); //$NON-NLS-1$
- FakeMetadataObject bqt3SmallB = createPhysicalGroup("BQT3.SmallB", bqt3); //$NON-NLS-1$
- FakeMetadataObject bqt3MediumA = createPhysicalGroup("BQT3.MediumA", bqt3); //$NON-NLS-1$
- FakeMetadataObject bqt3MediumB = createPhysicalGroup("BQT3.MediumB", bqt3); //$NON-NLS-1$
- FakeMetadataObject lobTable = createPhysicalGroup("LOB.LobTbl", lob); //$NON-NLS-1$
-
- // Create virtual groups
- QueryNode vqtn1 = new QueryNode("VQT.SmallA", "SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg1 = createUpdatableVirtualGroup("VQT.SmallA", vqt, vqtn1); //$NON-NLS-1$
-
- QueryNode vqtn2 = new QueryNode("VQT.SmallB", "SELECT Concat(stringKey, stringNum) as a12345 FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2 = createUpdatableVirtualGroup("VQT.SmallB", vqt, vqtn2); //$NON-NLS-1$
-
- // Case 2589
- QueryNode vqtn2589 = new QueryNode("VQT.SmallA_2589", "SELECT * FROM BQT1.SmallA WHERE StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589 = createVirtualGroup("VQT.SmallA_2589", vqt, vqtn2589); //$NON-NLS-1$
-
- QueryNode vqtn2589a = new QueryNode("VQT.SmallA_2589a", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.IntKey = SmallB.IntKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589a = createVirtualGroup("VQT.SmallA_2589a", vqt, vqtn2589a); //$NON-NLS-1$
-
- QueryNode vqtn2589b = new QueryNode("VQT.SmallA_2589b", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589b = createVirtualGroup("VQT.SmallA_2589b", vqt, vqtn2589b); //$NON-NLS-1$
-
- QueryNode vqtn2589c = new QueryNode("VQT.SmallA_2589c", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE concat(SmallA.StringNum, SmallB.StringNum) = '1010'"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589c = createVirtualGroup("VQT.SmallA_2589c", vqt, vqtn2589c); //$NON-NLS-1$
-
- QueryNode vqtn2589d = new QueryNode("VQT.SmallA_2589d", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallA.IntNum = 10"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589d = createVirtualGroup("VQT.SmallA_2589d", vqt, vqtn2589d); //$NON-NLS-1$
-
- QueryNode vqtn2589f = new QueryNode("VQT.SmallA_2589f", "SELECT * FROM VQT.SmallA_2589"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589f = createVirtualGroup("VQT.SmallA_2589f", vqt, vqtn2589f); //$NON-NLS-1$
-
- QueryNode vqtn2589g = new QueryNode("VQT.SmallA_2589g", "SELECT * FROM VQT.SmallA_2589b"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589g = createVirtualGroup("VQT.SmallA_2589g", vqt, vqtn2589g); //$NON-NLS-1$
-
- QueryNode vqtn2589h = new QueryNode("VQT.SmallA_2589h", "SELECT VQT.SmallA_2589.* FROM VQT.SmallA_2589 INNER JOIN BQT1.SmallB ON VQT.SmallA_2589.StringKey = SmallB.StringKey"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589h = createVirtualGroup("VQT.SmallA_2589h", vqt, vqtn2589h); //$NON-NLS-1$
-
- QueryNode vqtn2589i = new QueryNode("VQT.SmallA_2589i", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallB.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg2589i = createVirtualGroup("VQT.SmallA_2589i", vqt, vqtn2589i); //$NON-NLS-1$
-
- // defect 15355
- QueryNode vqtn15355 = new QueryNode("VQT.Defect15355", "SELECT convert(IntKey, string) as StringKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg15355 = createVirtualGroup("VQT.Defect15355", vqt, vqtn15355); //$NON-NLS-1$
- QueryNode vqtn15355a = new QueryNode("VQT.Defect15355a", "SELECT StringKey, StringNum, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, StringNum, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg15355a = createVirtualGroup("VQT.Defect15355a", vqt, vqtn15355a); //$NON-NLS-1$
- QueryNode vqtn15355b = new QueryNode("VQT.Defect15355b", "SELECT convert(IntKey, string) as IntKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vqtg15355b = createVirtualGroup("VQT.Defect15355b", vqt, vqtn15355b); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "IntKey", "StringKey", //$NON-NLS-1$ //$NON-NLS-2$
- "IntNum", "StringNum", //$NON-NLS-1$ //$NON-NLS-2$
- "FloatNum", "LongNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DoubleNum", "ByteNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DateValue", "TimeValue", //$NON-NLS-1$ //$NON-NLS-2$
- "TimestampValue", "BooleanValue", //$NON-NLS-1$ //$NON-NLS-2$
- "CharValue", "ShortValue", //$NON-NLS-1$ //$NON-NLS-2$
- "BigIntegerValue", "BigDecimalValue", //$NON-NLS-1$ //$NON-NLS-2$
- "ObjectValue" }; //$NON-NLS-1$
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG,
- DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE,
- DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME,
- DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT,
- DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
- DataTypeManager.DefaultDataTypes.OBJECT };
-
- List<FakeMetadataObject> bqt1SmallAe = createElements(bqt1SmallA, elemNames, elemTypes);
- bqt1SmallAe.get(1).putProperty(FakeMetadataObject.Props.NATIVE_TYPE, "char"); //$NON-NLS-1$
- List bqt1SmallBe = createElements(bqt1SmallB, elemNames, elemTypes);
- List bqt1MediumAe = createElements(bqt1MediumA, elemNames, elemTypes);
- List bqt1MediumBe = createElements(bqt1MediumB, elemNames, elemTypes);
- List bqt2SmallAe = createElements(bqt2SmallA, elemNames, elemTypes);
- List bqt2SmallBe = createElements(bqt2SmallB, elemNames, elemTypes);
- List bqt2MediumAe = createElements(bqt2MediumA, elemNames, elemTypes);
- List bqt2MediumBe = createElements(bqt2MediumB, elemNames, elemTypes);
- List bqt3SmallAe = createElements(bqt3SmallA, elemNames, elemTypes);
- List bqt3SmallBe = createElements(bqt3SmallB, elemNames, elemTypes);
- List bqt3MediumAe = createElements(bqt3MediumA, elemNames, elemTypes);
- List bqt3MediumBe = createElements(bqt3MediumB, elemNames, elemTypes);
- List lobTable_elem = createElements(lobTable, new String[] {"ClobValue"}, new String[] {DataTypeManager.DefaultDataTypes.CLOB}); //$NON-NLS-1$
-
- // Create virtual elements
- List vqtg1e = createElements(vqtg1, elemNames, elemTypes);
- List vqtg2e = createElements(vqtg2, new String[] {"a12345"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
- List vqtg15355e = createElements(vqtg15355, new String[] {"StringKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
- List vqtg15355ae = createElements(vqtg15355a, new String[] {"StringKey", "StringNum", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- List vqtg15355be = createElements(vqtg15355b, new String[] {"IntKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
- List vqtg2589e = createElements(vqtg2589, elemNames, elemTypes);
- List vqtg2589ae = createElements(vqtg2589a, elemNames, elemTypes);
- List vqtg2589be = createElements(vqtg2589b, elemNames, elemTypes);
- List vqtg2589ce = createElements(vqtg2589c, elemNames, elemTypes);
- List vqtg2589de = createElements(vqtg2589d, elemNames, elemTypes);
- List vqtg2589fe = createElements(vqtg2589f, elemNames, elemTypes);
- List vqtg2589ge = createElements(vqtg2589g, elemNames, elemTypes);
- List vqtg2589he = createElements(vqtg2589h, elemNames, elemTypes);
- List vqtg2589ie = createElements(vqtg2589i, elemNames, elemTypes);
-
- // Add stored procedure
- FakeMetadataObject pm1 = createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject rs1p1 = createParameter("intkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs1 = createResultSet("pm1.rs1", pm1, new String[] { "IntKey", "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FakeMetadataObject rs1p2 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
- FakeMetadataObject spTest5 = createStoredProcedure("spTest5", pm1, Arrays.asList(new FakeMetadataObject[] { rs1p1, rs1p2}), "spTest5"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FakeMetadataObject pm2 = createPhysicalModel("pm2"); //$NON-NLS-1$
- FakeMetadataObject rs2p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs2p2 = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs2 = createResultSet("pm2.rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FakeMetadataObject rs2p3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
- FakeMetadataObject spTest8 = createStoredProcedure("pm2.spTest8", pm2, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2, rs2p3}), "spTest8"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FakeMetadataObject spTest8a = createStoredProcedure("pm2.spTest8a", pm2, Arrays.asList(new FakeMetadataObject[] { rs2p2, rs2p3}), "spTest8a"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FakeMetadataObject pm4 = createPhysicalModel("pm4"); //$NON-NLS-1$
- FakeMetadataObject rs4p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs4p2 = createParameter("ret", 1, ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject spTest9 = createStoredProcedure("pm4.spTest9", pm4, Arrays.asList(new FakeMetadataObject[] { rs4p1, rs4p2}), "spTest9"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FakeMetadataObject pm3 = createPhysicalModel("pm3"); //$NON-NLS-1$
- FakeMetadataObject rs3p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs3p2 = createParameter("outkey", 3, ParameterInfo.INOUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs3 = createResultSet("pm3.rs3", pm3, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FakeMetadataObject rs3p3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3); //$NON-NLS-1$
- FakeMetadataObject spTest11 = createStoredProcedure("spTest11", pm3, Arrays.asList(new FakeMetadataObject[] { rs3p1, rs3p2, rs3p3}), "spTest11"); //$NON-NLS-1$ //$NON-NLS-2$
-
- //add virtual stored procedures
- FakeMetadataObject mmspTest1 = createVirtualModel("mmspTest1"); //$NON-NLS-1$
- FakeMetadataObject vsprs1 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vspp1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
- QueryNode vspqn1 = new QueryNode("vsp1", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vsp1 = createVirtualProcedure("mmspTest1.MMSP1", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn1); //$NON-NLS-1$
-
- QueryNode vspqn2 = new QueryNode("vsp2", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor1 BEGIN LOOP ON (SELECT intkey FROM bqt1.smallB) AS intKeyCursor2 BEGIN x= intKeyCursor1.intkey - intKeyCursor2.intkey; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vsp2 = createVirtualProcedure("mmspTest1.MMSP2", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn2); //$NON-NLS-1$
-
- QueryNode vspqn3 = new QueryNode("vsp3", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vsp3 = createVirtualProcedure("mmspTest1.MMSP3", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn3); //$NON-NLS-1$
-
- QueryNode vspqn4 = new QueryNode("vsp4", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; x=0; WHILE(x < 50) BEGIN x= x + 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vsp4 = createVirtualProcedure("mmspTest1.MMSP4", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn4); //$NON-NLS-1$
-
- FakeMetadataObject vsp5p1 = createParameter("param1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode vspqn5 = new QueryNode("vsp5", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 0; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vsp5 = createVirtualProcedure("mmspTest1.MMSP5", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1, vsp5p1 }), vspqn5); //$NON-NLS-1$
-
- FakeMetadataObject vsp6p1 = createParameter("p1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 1; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vsp6 = createVirtualProcedure("mmspTest1.MMSP6", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1, vsp6p1 }), vspqn6); //$NON-NLS-1$
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(bqt1);
- store.addObject(bqt1SmallA);
- store.addObjects(bqt1SmallAe);
- store.addObject(bqt1SmallB);
- store.addObjects(bqt1SmallBe);
- store.addObject(bqt1MediumA);
- store.addObjects(bqt1MediumAe);
- store.addObject(bqt1MediumB);
- store.addObjects(bqt1MediumBe);
-
- store.addObject(bqt2);
- store.addObject(bqt2SmallA);
- store.addObjects(bqt2SmallAe);
- store.addObject(bqt2SmallB);
- store.addObjects(bqt2SmallBe);
- store.addObject(bqt2MediumA);
- store.addObjects(bqt2MediumAe);
- store.addObject(bqt2MediumB);
- store.addObjects(bqt2MediumBe);
-
- store.addObject(bqt3);
- store.addObject(bqt3SmallA);
- store.addObjects(bqt3SmallAe);
- store.addObject(bqt3SmallB);
- store.addObjects(bqt3SmallBe);
- store.addObject(bqt3MediumA);
- store.addObjects(bqt3MediumAe);
- store.addObject(bqt3MediumB);
- store.addObjects(bqt3MediumBe);
-
- store.addObject(lob);
- store.addObject(lobTable);
- store.addObjects(lobTable_elem);
-
- store.addObject(vqtg1);
- store.addObjects(vqtg1e);
-
- store.addObject(vqtg2);
- store.addObjects(vqtg2e);
-
- store.addObject(vqtg15355);
- store.addObjects(vqtg15355e);
- store.addObject(vqtg15355a);
- store.addObjects(vqtg15355ae);
- store.addObject(vqtg15355b);
- store.addObjects(vqtg15355be);
-
- store.addObject(vqtg2589);
- store.addObjects(vqtg2589e);
- store.addObject(vqtg2589a);
- store.addObjects(vqtg2589ae);
- store.addObject(vqtg2589b);
- store.addObjects(vqtg2589be);
- store.addObject(vqtg2589c);
- store.addObjects(vqtg2589ce);
- store.addObject(vqtg2589d);
- store.addObjects(vqtg2589de);
- store.addObject(vqtg2589f);
- store.addObjects(vqtg2589fe);
- store.addObject(vqtg2589g);
- store.addObjects(vqtg2589ge);
- store.addObject(vqtg2589h);
- store.addObjects(vqtg2589he);
- store.addObject(vqtg2589i);
- store.addObjects(vqtg2589ie);
-
- store.addObject(vqtg2);
- store.addObjects(vqtg2e);
-
- store.addObject(pm1);
- store.addObject(spTest5);
- store.addObject(rs1);
-
- store.addObject(pm2);
- store.addObject(spTest8);
- store.addObject(spTest8a);
- store.addObject(rs2);
-
- store.addObject(pm4);
- store.addObject(spTest9);
-
- store.addObject(pm3);
- store.addObject(spTest11);
- store.addObject(rs3);
-
- store.addObject(vsp1);
- store.addObject(vsp2);
- store.addObject(vsp3);
- store.addObject(vsp4);
- store.addObject(vsp5);
- store.addObject(vsp6);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
+ public static VDBMetaData exampleBQTVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("example1");
+ vdb.setVersion(1);
+ vdb.addModel(createModel("BQT1", true));
+ vdb.addModel(createModel("BQT2", true));
+ vdb.addModel(createModel("BQT3", true));
+ vdb.addModel(createModel("LOB", true));
+ vdb.addModel(createModel("VQT", false));
+ vdb.addModel(createModel("pm1", true));
+ vdb.addModel(createModel("pm2", true));
+ vdb.addModel(createModel("pm3", true));
+ vdb.addModel(createModel("pm4", true));
+
+ return vdb;
}
-
- public static FakeMetadataFacade exampleUQT() {
- // Create models
- FakeMetadataObject uqt2 = createPhysicalModel("UQT2"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject uqt2UpdateA = createPhysicalGroup("UQT2.UpdateA", uqt2); //$NON-NLS-1$
- FakeMetadataObject uqt2UpdateB = createPhysicalGroup("UQT2.UpdateB", uqt2); //$NON-NLS-1$
- FakeMetadataObject uqt2BlobTable = createPhysicalGroup("UQT2.BlobTable", uqt2); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "IntKey", "StringKey", //$NON-NLS-1$ //$NON-NLS-2$
- "IntNum", "StringNum", //$NON-NLS-1$ //$NON-NLS-2$
- "FloatNum", "LongNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DoubleNum", "ByteNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DateValue", "TimeValue", //$NON-NLS-1$ //$NON-NLS-2$
- "TimestampValue", "BooleanValue", //$NON-NLS-1$ //$NON-NLS-2$
- "CharValue", "ShortValue", //$NON-NLS-1$ //$NON-NLS-2$
- "BigIntegerValue", "BigDecimalValue", //$NON-NLS-1$ //$NON-NLS-2$
- "ObjectValue" }; //$NON-NLS-1$
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG,
- DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE,
- DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME,
- DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT,
- DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
- DataTypeManager.DefaultDataTypes.OBJECT };
-
- String[] blobElemNames = new String[] {
- "id", "BlobValue" //$NON-NLS-1$ //$NON-NLS-2$
- };
- String[] blobElemTypes = new String[] {DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BLOB
- };
-
- List uqt2UpdateAe = createElements(uqt2UpdateA, elemNames, elemTypes);
- List uqt2UpdateBe = createElements(uqt2UpdateB, elemNames, elemTypes);
- List uqt2BlobTablee = createElements(uqt2BlobTable, blobElemNames, blobElemTypes);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(uqt2);
- store.addObject(uqt2UpdateA);
- store.addObjects(uqt2UpdateAe);
- store.addObject(uqt2UpdateB);
- store.addObjects(uqt2UpdateBe);
- store.addObject(uqt2BlobTable);
- store.addObjects(uqt2BlobTablee);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleLOB() {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = createPhysicalGroup("LOB_TESTING_ONE", lib, true); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB,
- DataTypeManager.DefaultDataTypes.INTEGER };
-
- List libe1 = createElements( library, elemNames, elemTypes, true);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleStream(boolean isStream) {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = null;
- if (isStream) {
- library = createPhysicalGroup("STREAMEXAMPLE", lib, true); //$NON-NLS-1$
- } else {
- library = createPhysicalGroup("READEREAMPLE", lib, true); //$NON-NLS-1$
- }
- // Create physical elements
- String[] elemNames = new String[] {
- "KEY_EMULATOR", "DATA"}; //$NON-NLS-1$ //$NON-NLS-2$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.OBJECT};
-
- List libe1 = createElements( library, elemNames, elemTypes, true);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleBytes() {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = createPhysicalGroup("BYTE_EXAMPLE", lib, true); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "KEY_EMULATOR", "DATA"}; //$NON-NLS-1$ //$NON-NLS-2$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.OBJECT};
-
- List libe1 = createElements( library, elemNames, elemTypes, true);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleText() {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Text"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = createPhysicalGroup("Text.Library", lib, true); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "ID", "PDate", "Author" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DATE,
- DataTypeManager.DefaultDataTypes.STRING };
-
- List libe1 = createElements( library, elemNames, elemTypes, false);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
- public static FakeMetadataFacade exampleXQT() {
- FakeMetadataStore store = new FakeMetadataStore();
- FakeMetadataFacade facade = new FakeMetadataFacade(store);
-
- // Create models
- FakeMetadataObject xqt = FakeMetadataFactory.createPhysicalModel("XQT"); //$NON-NLS-1$
- FakeMetadataObject xqttest = FakeMetadataFactory.createVirtualModel("xqttest"); //$NON-NLS-1$
-
- // Create physical groups
- //FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("xqt.data", xqt);
- FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", xqt); //$NON-NLS-1$
-
-
- // Create physical elements
- List xqtData = FakeMetadataFactory.createElements(xqtGroup,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- // Create virtual groups
- QueryNode rsQuery = new QueryNode("xqttest.data", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey=13"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs = FakeMetadataFactory.createVirtualGroup("xqttest.data", xqttest, rsQuery); //$NON-NLS-1$
-
- QueryNode rsQuery2 = new QueryNode("xqttest.data2", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery2.addBinding("xqttest.data.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs2 = FakeMetadataFactory.createVirtualGroup("xqttest.data2", xqttest, rsQuery2); //$NON-NLS-1$
-
- QueryNode rsQuery3 = new QueryNode("xqttest.data3", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery3.addBinding("xqttest.data2.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs3 = FakeMetadataFactory.createVirtualGroup("xqttest.data3", xqttest, rsQuery3); //$NON-NLS-1$
-
- QueryNode rsQuery4 = new QueryNode("xqttest.data4", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery4.addBinding("xqttest.data.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs4 = FakeMetadataFactory.createVirtualGroup("xqttest.data4", xqttest, rsQuery4); //$NON-NLS-1$
-
- QueryNode rsQuery5 = new QueryNode("xqttest.data5", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery5.addBinding("xqttest.data4.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs5 = FakeMetadataFactory.createVirtualGroup("xqttest.data5", xqttest, rsQuery5); //$NON-NLS-1$
-
- QueryNode rsQuery6 = new QueryNode("xqttest.data6", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery6.addBinding("xqttest.data5.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs6 = FakeMetadataFactory.createVirtualGroup("xqttest.data6", xqttest, rsQuery6); //$NON-NLS-1$
-
-
- QueryNode rsQuery7 = new QueryNode("xqttest.data7", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs7 = FakeMetadataFactory.createVirtualGroup("xqttest.data7", xqttest, rsQuery7); //$NON-NLS-1$
-
- QueryNode rsQuery8 = new QueryNode("xqttest.data8", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey < ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery8.addBinding("xqttest.data7.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs8 = FakeMetadataFactory.createVirtualGroup("xqttest.data8", xqttest, rsQuery8); //$NON-NLS-1$
-
- // Create virtual elements
- List rsElements = FakeMetadataFactory.createElements(rs,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements2 = FakeMetadataFactory.createElements(rs2,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements3 = FakeMetadataFactory.createElements(rs3,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements4 = FakeMetadataFactory.createElements(rs4,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements5 = FakeMetadataFactory.createElements(rs5,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements6 = FakeMetadataFactory.createElements(rs6,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements7 = FakeMetadataFactory.createElements(rs7,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements8 = FakeMetadataFactory.createElements(rs8,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-
- FakeMetadataObject doc1 = FakeMetadataFactory.createVirtualGroup("xqttest.doc1", xqttest, createXQTPlanRecursive_5988()); //$NON-NLS-1$
- FakeMetadataObject doc1a = FakeMetadataFactory.createVirtualGroup("xqttest.doc1a", xqttest, createXQTPlanRecursive1a_5988()); //$NON-NLS-1$
-// FakeMetadataObject doc2 = FakeMetadataFactory.createVirtualGroup("xqttest.doc2", xqttest, createXQTPlanRecursiveSiblings());
-// FakeMetadataObject doc3 = FakeMetadataFactory.createVirtualGroup("xqttest.doc3", xqttest, createXQTPlanRecursive3_5988());
-// FakeMetadataObject doc4 = FakeMetadataFactory.createVirtualGroup("xqttest.doc4", xqttest, createXQTPlanChoice_6796());
-
- store.addObject(xqt);
- store.addObject(xqtGroup);
- store.addObjects(xqtData);
-
- store.addObject(xqttest);
- store.addObject(rs);
- store.addObject(rs2);
- store.addObject(rs3);
- store.addObject(rs4);
- store.addObject(rs5);
- store.addObject(rs6);
- store.addObject(rs7);
- store.addObject(rs8);
- store.addObjects(rsElements);
- store.addObjects(rsElements2);
- store.addObjects(rsElements3);
- store.addObjects(rsElements4);
- store.addObjects(rsElements5);
- store.addObjects(rsElements6);
- store.addObjects(rsElements7);
- store.addObjects(rsElements8);
-
- store.addObject(doc1);
- store.addObject(doc1a);
-// store.addObject(doc2);
-// store.addObject(doc3);
-// store.addObject(doc4);
-
- return facade;
+ public static TransformationMetadata exampleBQT() {
+ return RealMetadataFactory.exampleBQT();
}
- public static FakeMetadataFacade exampleXQT1() {
- FakeMetadataStore store = new FakeMetadataStore();
- FakeMetadataFacade facade = new FakeMetadataFacade(store);
-
- // Create models
- FakeMetadataObject xqt = FakeMetadataFactory.createPhysicalModel("XQT"); //$NON-NLS-1$
- FakeMetadataObject xqttest = FakeMetadataFactory.createVirtualModel("xqttest"); //$NON-NLS-1$
-
- // Create physical groups
- //FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("xqt.data", xqt);
- FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", xqt); //$NON-NLS-1$
-
- // Create physical elements
- List xqtData = FakeMetadataFactory.createElements(xqtGroup,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- // Create virtual groups
- QueryNode rsQuery = new QueryNode("xqttest.data", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey=13"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs = FakeMetadataFactory.createVirtualGroup("xqttest.data", xqttest, rsQuery); //$NON-NLS-1$
-
- // Create virtual elements
- List rsElements = FakeMetadataFactory.createElements(rs,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject doc1 = FakeMetadataFactory.createVirtualGroup("xqttest.doc1", xqttest, createBQTDocTest_Plan()); //$NON-NLS-1$
-
- store.addObject(xqt);
- store.addObject(xqtGroup);
- store.addObjects(xqtData);
-
- store.addObject(xqttest);
- store.addObject(rs);
- store.addObjects(rsElements);
- store.addObject(doc1);
-
- return facade;
- }
-
- /**
- * Method createXQTPlanRecursive.
- * @return Object
- */
- private static MappingDocument createXQTPlanRecursive_5988() {
- MappingDocument doc = new MappingDocument(true);
- MappingElement root = doc.addChildElement(new MappingElement("recursiveTest")); //$NON-NLS-1$
-
- MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
- src1.setSource("xqttest.data");//$NON-NLS-1$
-
- MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
- seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement src2 = seq1.addChildElement(new MappingElement("srcNested")); //$NON-NLS-1$
- src2.setSource("xqttest.data2");//$NON-NLS-1$
-
- MappingSequenceNode seq2 = src2.addSequenceNode(new MappingSequenceNode());
- seq2.addChildElement(new MappingElement("key", "xqttest.data2.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq2.addChildElement(new MappingElement("data", "xqttest.data2.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement recursive = seq2.addChildElement(new MappingRecursiveElement("srcNestedRecursive", "xqttest.data2")); //$NON-NLS-1$ //$NON-NLS-2$
- recursive.setSource("xqttest.data3");//$NON-NLS-1$
-
- return doc;
- }
-
- /**
- * Method createXQTPlanRecursive.
- * @return Object
- */
- private static MappingDocument createXQTPlanRecursive1a_5988() {
-
- MappingDocument doc = new MappingDocument(true);
- MappingElement root = doc.addChildElement(new MappingElement("recursiveTest")); //$NON-NLS-1$
-
- MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
- src1.setSource("xqttest.data");//$NON-NLS-1$
-
- MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
- seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement src2 = seq1.addChildElement(new MappingElement("srcNested")); //$NON-NLS-1$
- src2.setSource("xqttest.data2");//$NON-NLS-1$
-
- MappingSequenceNode seq2 = src2.addSequenceNode(new MappingSequenceNode());
- seq2.addChildElement(new MappingElement("key", "xqttest.data2.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq2.addChildElement(new MappingElement("data", "xqttest.data2.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement recursive = seq2.addChildElement(new MappingRecursiveElement("srcRecursive", "xqttest.data2")); //$NON-NLS-1$ //$NON-NLS-2$
- recursive.setSource("xqttest.data3");//$NON-NLS-1$
-
- // was not being used
-// MappingRecursiveElement src4 = new MappingRecursiveElement("srcRecursive", "xqttest.data"); //$NON-NLS-1$ //$NON-NLS-2$
-// src4.setSource("xqttest.data4"); //$NON-NLS-1$
- return doc;
- }
-
- /**
- * Method createXQTPlanRecursive.
- * @return Object
- */
- private static MappingDocument createBQTDocTest_Plan() {
- MappingDocument doc = new MappingDocument(false);
- MappingElement root = doc.addChildElement(new MappingElement("BQTDocTest")); //$NON-NLS-1$
-
- MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
- src1.setSource("xqttest.data");//$NON-NLS-1$
-
- MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
- seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
- return doc;
- }
-
public static FakeMetadataFacade exampleSymphony() {
// Create models
FakeMetadataObject model = createPhysicalModel("COMPLEX"); //$NON-NLS-1$
@@ -2750,489 +2169,6 @@
return new FakeMetadataFacade(store);
}
- public static FakeMetadataFacade exampleSystemPhysical() {
- // Create models
- FakeMetadataObject systemPhysical = createPhysicalModel("SystemPhysical"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject rtVirtualDbs = createPhysicalGroup("SystemPhysical.RT_VIRTUAL_DBS", systemPhysical); //$NON-NLS-1$
- List rtVirtualDbsEl = createElements(rtVirtualDbs,
- new String[] {
- "VDB_UID", //$NON-NLS-1$
- "VDB_VERSION", //$NON-NLS-1$
- "VDB_NM", //$NON-NLS-1$
- "DESCRIPTION", //$NON-NLS-1$
- "PROJECT_GUID", //$NON-NLS-1$
- "VDB_STATUS", //$NON-NLS-1$
- "VERSION_BY", //$NON-NLS-1$
- "VERSION_DATE", //$NON-NLS-1$
- "CREATED_BY", //$NON-NLS-1$
- "CREATED_DATE" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject rtVdbMdls = createPhysicalGroup("SystemPhysical.RT_VDB_MDLS", systemPhysical); //$NON-NLS-1$
- List rtVdbMdlsEl = createElements(rtVdbMdls,
- new String[] {
- "VDB_UID", //$NON-NLS-1$
- "MDL_UID", //$NON-NLS-1$
- "CNCTR_BNDNG_NM", //$NON-NLS-1$
- "VISIBILITY" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- FakeMetadataObject rtMdls = createPhysicalGroup("SystemPhysical.RT_MDLS", systemPhysical); //$NON-NLS-1$
- List rtMdlsEl = createElements(rtMdls,
- new String[] {
- "MDL_UID", //$NON-NLS-1$
- "MDL_NM", //$NON-NLS-1$
- "MDL_VERSION", //$NON-NLS-1$
- "DESCRIPTION", //$NON-NLS-1$
- "IS_PHYSICAL", //$NON-NLS-1$
- "SUP_AND", //$NON-NLS-1$
- "SUP_OR", //$NON-NLS-1$
- "SUP_SET", //$NON-NLS-1$
- "SUP_AGGREGATE", //$NON-NLS-1$
- "SUP_WHERE_ALL", //$NON-NLS-1$
- "SUP_SELECT_ALL", //$NON-NLS-1$
- "SUP_ORDER_BY", //$NON-NLS-1$
- "SUP_GRP_BY", //$NON-NLS-1$
- "SUP_JOIN", //$NON-NLS-1$
- "SUP_DISTINCT", //$NON-NLS-1$
- "SUP_OUTER_JOIN", //$NON-NLS-1$
- "SUP_TRANSACTION", //$NON-NLS-1$
- "SUP_SUBSCRIPTION", //$NON-NLS-1$
- "MAX_SET_SIZE", //$NON-NLS-1$
- "MAX_RESULT_SIZE", //$NON-NLS-1$
- "MDL_UUID" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject rtGrps = createPhysicalGroup("SystemPhysical.RT_GRPS", systemPhysical); //$NON-NLS-1$
- List rtGrpsEl = createElements(rtGrps,
- new String[] {
- "GRP_UID", //$NON-NLS-1$
- "GRP_NM", //$NON-NLS-1$
- "GRP_UPPR_NM", //$NON-NLS-1$
- "MDL_UID", //$NON-NLS-1$
- "DESCRIPTION", //$NON-NLS-1$
- "ALIAS", //$NON-NLS-1$
- "PATH_1", //$NON-NLS-1$
- "TABLE_TYPE", //$NON-NLS-1$
- "IS_PHYSICAL", //$NON-NLS-1$
- "HAS_QUERY_PLAN", //$NON-NLS-1$
- "SUP_UPDATE" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN });
-
- FakeMetadataObject rtTableTypes = createPhysicalGroup("SystemPhysical.RT_TABLE_TYPES", systemPhysical); //$NON-NLS-1$
- List rtTableTypesEl = createElements(rtTableTypes,
- new String[] {
- "TABLE_TYPE_CODE", //$NON-NLS-1$
- "TABLE_TYPE_NM", //$NON-NLS-1$
- "DESCRIPTION" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject rtKyIdxes = createPhysicalGroup("SystemPhysical.RT_KY_IDXES", systemPhysical); //$NON-NLS-1$
- List rtKyIdxesEl = createElements(rtKyIdxes,
- new String[] {
- "KEY_UID", //$NON-NLS-1$
- "GRP_UID", //$NON-NLS-1$
- "KEY_NM", //$NON-NLS-1$
- "DESCRIPTION", //$NON-NLS-1$
- "ALIAS", //$NON-NLS-1$
- "KEY_TYPE", //$NON-NLS-1$
- "IS_INDEXED", //$NON-NLS-1$
- "REF_KEY_UID", //$NON-NLS-1$
- "MATCH_TYPE" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- FakeMetadataObject rtKeyTypes = createPhysicalGroup("SystemPhysical.RT_KEY_TYPES", systemPhysical); //$NON-NLS-1$
- List rtKeyTypesEl = createElements(rtKeyTypes,
- new String[] {
- "KEY_TYPE_CODE", //$NON-NLS-1$
- "KEY_TYPE_NM", //$NON-NLS-1$
- "DESCRIPTION" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject rtKyIdxElmnts = createPhysicalGroup("SystemPhysical.RT_KY_IDX_ELMNTS", systemPhysical); //$NON-NLS-1$
- List rtKyIdxElmntsEl = createElements(rtKyIdxElmnts,
- new String[] {
- "ELMNT_UID", //$NON-NLS-1$
- "KEY_UID", //$NON-NLS-1$
- "POSITION" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- FakeMetadataObject rtElmnts = createPhysicalGroup("SystemPhysical.RT_ELMNTS", systemPhysical); //$NON-NLS-1$
- List rtElmntsEl = createElements(rtElmnts,
- new String[] {
- "ELMNT_UID", //$NON-NLS-1$
- "ELMNT_NM", //$NON-NLS-1$
- "ELMNT_UPPR_NM", //$NON-NLS-1$
- "POSITION", //$NON-NLS-1$
- "GRP_UID", //$NON-NLS-1$
- "DESCRIPTION", //$NON-NLS-1$
- "ALIAS", //$NON-NLS-1$
- "LABEL", //$NON-NLS-1$
- "DT_UID", //$NON-NLS-1$
- "SCALE", //$NON-NLS-1$
- "LNGTH", //$NON-NLS-1$
- "PRCSN_LNGTH", //$NON-NLS-1$
- "RADIX", //$NON-NLS-1$
- "CHR_OCTCT_LNGTH", //$NON-NLS-1$
- "IS_PHYSICAL", //$NON-NLS-1$
- "IS_LENGTH_FIXED", //$NON-NLS-1$
- "NULL_TYPE", //$NON-NLS-1$
- "SUP_SELECT", //$NON-NLS-1$
- "SUP_SET", //$NON-NLS-1$
- "SUP_SUBSCRIPTION", //$NON-NLS-1$
- "SUP_UPDATE", //$NON-NLS-1$
- "IS_CASE_SENSITIVE", //$NON-NLS-1$
- "IS_SIGNED", //$NON-NLS-1$
- "IS_CURRENCY", //$NON-NLS-1$
- "IS_AUTOINCREMENT", //$NON-NLS-1$
- "MIN_RANGE", //$NON-NLS-1$
- "MAX_RANGE", //$NON-NLS-1$
- "SEARCH_TYPE", //$NON-NLS-1$
- "FORMAT", //$NON-NLS-1$
- "MULTIPLICITY", //$NON-NLS-1$
- "DEFAULT_VL" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING });
-
- // Create virtual groups
- FakeMetadataObject system = createVirtualModel("System"); //$NON-NLS-1$
- QueryNode node = new QueryNode("System.Models", //$NON-NLS-1$
- "SELECT RT_VIRTUAL_DBS.VDB_NM AS VDBName, RT_VIRTUAL_DBS.VDB_VERSION AS VDBVersion, RT_MDLS.MDL_NM AS Name, RT_MDLS.MDL_VERSION AS Version, RT_MDLS.DESCRIPTION, RT_MDLS.IS_PHYSICAL AS IsPhysical, RT_MDLS.SUP_AND AS SupportsAnd, RT_MDLS.SUP_OR AS SupportsOr, RT_MDLS.SUP_SET AS SupportsSetCriteria, RT_MDLS.SUP_AGGREGATE AS SupportsAggregates, RT_MDLS.SUP_WHERE_ALL AS SupportsWhereAll, RT_MDLS.SUP_SELECT_ALL AS SupportsSelectAll, RT_MDLS.SUP_ORDER_BY AS SupportsOrderBy, RT_MDLS.SUP_GRP_BY AS SupportsGroupBy, RT_MDLS.SUP_JOIN AS SupportsJoin, RT_MDLS.SUP_DISTINCT AS SupportsDistinct, RT_MDLS.SUP_OUTER_JOIN AS SupportsOuterJoin, RT_MDLS.SUP_TRANSACTION AS SupportsTransactions, RT_MDLS.SUP_SUBSCRIPTION AS SupportsSubscriptions, RT_MDLS.MAX_SET_SIZE AS MaxSetSize, RT_MDLS.MAX_RESULT_SIZE AS MaxResultSize, RT_MDLS.MDL_UID AS UID, RT_VIRTUAL_DBS.VDB_UID AS VDBUID " + //$NON-NLS-1$
- "FROM SystemPhysical.RT_VIRTUAL_DBS AS RT_VIRTUAL_DBS, SystemPhysical.RT_VDB_MDLS AS RT_VDB_MDLS, SystemPhysical.RT_MDLS AS RT_MDLS " + //$NON-NLS-1$
- "WHERE (RT_VIRTUAL_DBS.VDB_UID = RT_VDB_MDLS.VDB_UID) AND (RT_VDB_MDLS.MDL_UID = RT_MDLS.MDL_UID) AND (RT_VDB_MDLS.VISIBILITY = 0)"); //$NON-NLS-1$
- FakeMetadataObject models = createVirtualGroup("System.Models", system, node); //$NON-NLS-1$
- List modelsEl = createElements(models,
- new String[] {
- "VDBName", //$NON-NLS-1$
- "VDBVersion", //$NON-NLS-1$
- "Name", //$NON-NLS-1$
- "Version", //$NON-NLS-1$
- "Description", //$NON-NLS-1$
- "IsPhysical", //$NON-NLS-1$
- "SupportsAnd", //$NON-NLS-1$
- "SupportsOr", //$NON-NLS-1$
- "SupportsSetCriteria", //$NON-NLS-1$
- "SupportsAggregates", //$NON-NLS-1$
- "SupportsWhereAll", //$NON-NLS-1$
- "SupportsSelectAll", //$NON-NLS-1$
- "SupportsOrderBy", //$NON-NLS-1$
- "SupportsGroupBy", //$NON-NLS-1$
- "SupportsJoin", //$NON-NLS-1$
- "SupportsDistinct", //$NON-NLS-1$
- "SupportsOuterJoin", //$NON-NLS-1$
- "SupportsTransactions", //$NON-NLS-1$
- "SupportsSubscriptions", //$NON-NLS-1$
- "MaxSetSize", //$NON-NLS-1$
- "MaxResultSize", //$NON-NLS-1$
- "UID", //$NON-NLS-1$
- "VDBUID" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- node = new QueryNode("System.Groups", //$NON-NLS-1$
- "SELECT Models.VDBName, Models.VDBVersion, Models.Name AS ModelName, RT_GRPS.PATH_1 AS FullName, RT_GRPS.GRP_NM AS Name, RT_GRPS.DESCRIPTION, RT_TABLE_TYPES.TABLE_TYPE_NM AS Type, RT_GRPS.ALIAS AS NameInSource, RT_GRPS.IS_PHYSICAL AS IsPhysical, RT_GRPS.HAS_QUERY_PLAN AS HasQueryPlan, RT_GRPS.GRP_UPPR_NM AS UpperName, RT_GRPS.SUP_UPDATE AS SupportsUpdates, RT_GRPS.GRP_UID AS UID " + //$NON-NLS-1$
- "FROM SystemPhysical.RT_GRPS AS RT_GRPS, System.Models AS Models, SystemPhysical.RT_TABLE_TYPES AS RT_TABLE_TYPES " + //$NON-NLS-1$
- "WHERE (RT_GRPS.MDL_UID = Models.UID) AND (RT_GRPS.TABLE_TYPE = RT_TABLE_TYPES.TABLE_TYPE_CODE) AND (RT_GRPS.TABLE_TYPE <> 5)"); //$NON-NLS-1$
- FakeMetadataObject groups = createVirtualGroup("System.Groups", system, node); //$NON-NLS-1$
- List groupsEl = createElements(groups,
- new String[] {
- "VDBName", //$NON-NLS-1$
- "VDBVersion", //$NON-NLS-1$
- "ModelName", //$NON-NLS-1$
- "FullName", //$NON-NLS-1$
- "Name", //$NON-NLS-1$
- "Description", //$NON-NLS-1$
- "Type", //$NON-NLS-1$
- "NameInSource", //$NON-NLS-1$
- "IsPhysical", //$NON-NLS-1$
- "HasQueryPlan", //$NON-NLS-1$
- "UpperName", //$NON-NLS-1$
- "SupportsUpdates", //$NON-NLS-1$
- "UID" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- node = new QueryNode("System.Keys", //$NON-NLS-1$
- "SELECT GROUPS.VDBName, GROUPS.VDBVersion, GROUPS.ModelName, GROUPS.FullName AS GroupFullName, RT_KY_IDXES.KEY_NM AS Name, RT_KY_IDXES.DESCRIPTION, RT_KY_IDXES.ALIAS AS NameInSource, RT_KEY_TYPES.KEY_TYPE_NM AS Type, RT_KY_IDXES.IS_INDEXED AS IsIndexed, RT_KY_IDXES.MATCH_TYPE AS MatchType, GROUPS.Name AS GroupName, GROUPS.UpperName AS GroupUpperName, RT_KY_IDXES.REF_KEY_UID AS RefKeyUID, RT_KY_IDXES.KEY_UID AS UID " + //$NON-NLS-1$
- "FROM SystemPhysical.RT_KY_IDXES AS RT_KY_IDXES, System.Groups AS GROUPS, SystemPhysical.RT_KEY_TYPES AS RT_KEY_TYPES " + //$NON-NLS-1$
- "WHERE (RT_KY_IDXES.GRP_UID = GROUPS.UID) AND (RT_KY_IDXES.KEY_TYPE = RT_KEY_TYPES.KEY_TYPE_CODE)"); //$NON-NLS-1$
- FakeMetadataObject keys = createVirtualGroup("System.Keys", system, node); //$NON-NLS-1$
- List keysEl = createElements(keys,
- new String[] {
- "VDBName", //$NON-NLS-1$
- "VDBVersion", //$NON-NLS-1$
- "ModelName", //$NON-NLS-1$
- "GroupFullName", //$NON-NLS-1$
- "Name", //$NON-NLS-1$
- "Description", //$NON-NLS-1$
- "NameInSource", //$NON-NLS-1$
- "Type", //$NON-NLS-1$
- "IsIndexed", //$NON-NLS-1$
- "MatchType", //$NON-NLS-1$
- "GroupName", //$NON-NLS-1$
- "GroupUpperName", //$NON-NLS-1$
- "RefKeyUID", //$NON-NLS-1$
- "UID" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- node = new QueryNode("System.KeyElements", //$NON-NLS-1$
- "SELECT KEYS.VDBName, KEYS.VDBVersion, KEYS.ModelName, KEYS.GroupFullName, RT_ELMNTS.ELMNT_NM AS Name, RT_KY_IDX_ELMNTS.POSITION, KEYS.Name AS KeyName, KEYS.Type AS KeyType, KEYS.GroupName, KEYS.GroupUpperName, KEYS.RefKeyUID, KEYS.UID " + //$NON-NLS-1$
- "FROM System.Keys AS KEYS LEFT OUTER JOIN SystemPhysical.RT_KY_IDX_ELMNTS AS RT_KY_IDX_ELMNTS ON RT_KY_IDX_ELMNTS.KEY_UID = KEYS.UID, SystemPhysical.RT_ELMNTS AS RT_ELMNTS " + //$NON-NLS-1$
- "WHERE RT_KY_IDX_ELMNTS.ELMNT_UID = RT_ELMNTS.ELMNT_UID"); //$NON-NLS-1$
- FakeMetadataObject keyElements = createVirtualGroup("System.KeyElements", system, node); //$NON-NLS-1$
- List keyElementsEl = createElements(keyElements,
- new String[] {
- "VDBName", //$NON-NLS-1$
- "VDBVersion", //$NON-NLS-1$
- "ModelName", //$NON-NLS-1$
- "GroupFullName", //$NON-NLS-1$
- "Name", //$NON-NLS-1$
- "Position", //$NON-NLS-1$
- "KeyName", //$NON-NLS-1$
- "KeyType", //$NON-NLS-1$
- "GroupName", //$NON-NLS-1$
- "GroupUpperName", //$NON-NLS-1$
- "RefKeyUID", //$NON-NLS-1$
- "UID" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.INTEGER });
-
- node = new QueryNode("System.ReferenceKeyElements", //$NON-NLS-1$
- "SELECT PK.VDBName, PK.VDBVersion, PK.ModelName, PK.GroupName AS PKGroupName, PK.GroupFullName AS PKGroupFullName, PK.Name AS PKElementName, FK.ModelName AS FKModelName, FK.GroupName AS FKGroupName, FK.GroupFullName AS FKGroupFullName, FK.Name AS FKElementName, FK.Position AS FKPosition, PK.KeyName AS PKKeyName, FK.KeyName AS FKKeyName, PK.KeyType AS PKKeyType, FK.KeyType AS FKKeyType, PK.GroupUpperName AS PKGroupUpperName, FK.GroupUpperName AS FKGroupUpperName " + //$NON-NLS-1$
- "FROM System.KeyElements AS PK, System.KeyElements AS FK " + //$NON-NLS-1$
- "WHERE (PK.UID = FK.RefKeyUID) AND (PK.Position = FK.Position)"); //$NON-NLS-1$
- FakeMetadataObject refKeyElements = createVirtualGroup("System.ReferenceKeyElements", system, node); //$NON-NLS-1$
- List refKeyElementsEl = createElements(refKeyElements,
- new String[] {
- "VDBName", //$NON-NLS-1$
- "VDBVersion", //$NON-NLS-1$
- "ModelName", //$NON-NLS-1$
- "PKGroupName", //$NON-NLS-1$
- "PKGroupFullName", //$NON-NLS-1$
- "PKElementName", //$NON-NLS-1$
- "FKModelName", //$NON-NLS-1$
- "FKGroupName", //$NON-NLS-1$
- "FKGroupFullName", //$NON-NLS-1$
- "FKElementName", //$NON-NLS-1$
- "FKPosition", //$NON-NLS-1$
- "PKKeyName", //$NON-NLS-1$
- "FKKeyName", //$NON-NLS-1$
- "PKKeyType", //$NON-NLS-1$
- "FKKeyType", //$NON-NLS-1$
- "PKGroupUpperName", //$NON-NLS-1$
- "FKGroupUpperName" }, //$NON-NLS-1$
- new String[] {
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.STRING });
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(systemPhysical);
- store.addObject(rtVirtualDbs);
- store.addObjects(rtVirtualDbsEl);
- store.addObject(rtVdbMdls);
- store.addObjects(rtVdbMdlsEl);
- store.addObject(rtMdls);
- store.addObjects(rtMdlsEl);
- store.addObject(rtGrps);
- store.addObjects(rtGrpsEl);
- store.addObject(rtTableTypes);
- store.addObjects(rtTableTypesEl);
- store.addObject(rtKyIdxes);
- store.addObjects(rtKyIdxesEl);
- store.addObject(rtKeyTypes);
- store.addObjects(rtKeyTypesEl);
- store.addObject(rtKyIdxElmnts);
- store.addObjects(rtKyIdxElmntsEl);
- store.addObject(rtElmnts);
- store.addObjects(rtElmntsEl);
-
- store.addObject(system);
- store.addObject(models);
- store.addObjects(modelsEl);
- store.addObject(groups);
- store.addObjects(groupsEl);
- store.addObject(keys);
- store.addObjects(keysEl);
- store.addObject(keyElements);
- store.addObjects(keyElementsEl);
- store.addObject(refKeyElements);
- store.addObjects(refKeyElementsEl);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
public static FakeMetadataFacade exampleYahoo() {
// Create models
FakeMetadataObject yahoo = createPhysicalModel("Yahoo"); //$NON-NLS-1$
@@ -3367,6 +2303,19 @@
return new FakeMetadataFacade(store);
}
+
+ public static VDBMetaData examplePrivatePhysicalModelVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("example1");
+ vdb.setVersion(1);
+ ModelMetaData m = createModel("pm1", true);
+ m.setVisible(false);
+ vdb.addModel(m);
+ vdb.addModel(createModel("vm1", false));
+
+ return vdb;
+ }
+
public static FakeMetadataFacade examplePrivatePhysicalModel() {
// Create models
FakeMetadataObject pm1 = createPhysicalModel("pm1"); //$NON-NLS-1$
@@ -3577,6 +2526,24 @@
store.addObjects(dealersElements);
}
+
+ public static VDBMetaData exampleMultiBindingVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("exampleMultiBinding");
+ vdb.setVersion(1);
+
+ ModelMetaData model = new ModelMetaData();
+ model.setName("MultiModel");
+ model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+ model.setVisible(true);
+
+ model.setSupportsMultiSourceBindings(true);
+ vdb.addModel(model);
+ vdb.addModel(createModel("Virt", false));
+
+ return vdb;
+ }
+
/**
* Metadata for Multi-Binding models
* @return example
@@ -3931,6 +2898,14 @@
return facade;
}
+ public static VDBMetaData exampleXQueryTransformationsVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("exampleXQueryTransformations");
+ vdb.setVersion(1);
+ vdb.addModel(createModel("m", true));
+ return vdb;
+ }
+
public static FakeMetadataFacade exampleXQueryTransformations() {
FakeMetadataObject model = FakeMetadataFactory.createPhysicalModel("m");//$NON-NLS-1$
Copied: trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,554 @@
+/*
+ * 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.query.unittest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.ColumnSet;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
+
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.sql.lang.SPParameter;
+
+public class RealMetadataFactory {
+
+ private static TransformationMetadata CACHED_BQT = exampleBQT();
+
+ private RealMetadataFactory() { }
+
+ public static TransformationMetadata exampleBQTCached() {
+ return CACHED_BQT;
+ }
+
+ public static TransformationMetadata exampleBQT() {
+ MetadataStore metadataStore = new MetadataStore();
+
+ Schema bqt1 = createPhysicalModel("BQT1", metadataStore); //$NON-NLS-1$
+ Schema bqt2 = createPhysicalModel("BQT2", metadataStore); //$NON-NLS-1$
+ Schema bqt3 = createPhysicalModel("BQT3", metadataStore); //$NON-NLS-1$
+ Schema lob = createPhysicalModel("LOB", metadataStore); //$NON-NLS-1$
+ Schema vqt = createVirtualModel("VQT", metadataStore); //$NON-NLS-1$
+ Schema bvqt = createVirtualModel("BQT_V", metadataStore); //$NON-NLS-1$
+ Schema bvqt2 = createVirtualModel("BQT2_V", metadataStore); //$NON-NLS-1$
+
+ // Create physical groups
+ Table bqt1SmallA = createPhysicalGroup("SmallA", bqt1); //$NON-NLS-1$
+ Table bqt1SmallB = createPhysicalGroup("SmallB", bqt1); //$NON-NLS-1$
+ Table bqt1MediumA = createPhysicalGroup("MediumA", bqt1); //$NON-NLS-1$
+ Table bqt1MediumB = createPhysicalGroup("MediumB", bqt1); //$NON-NLS-1$
+ Table bqt2SmallA = createPhysicalGroup("SmallA", bqt2); //$NON-NLS-1$
+ Table bqt2SmallB = createPhysicalGroup("SmallB", bqt2); //$NON-NLS-1$
+ Table bqt2MediumA = createPhysicalGroup("MediumA", bqt2); //$NON-NLS-1$
+ Table bqt2MediumB = createPhysicalGroup("MediumB", bqt2); //$NON-NLS-1$
+ Table bqt3SmallA = createPhysicalGroup("SmallA", bqt3); //$NON-NLS-1$
+ Table bqt3SmallB = createPhysicalGroup("SmallB", bqt3); //$NON-NLS-1$
+ Table bqt3MediumA = createPhysicalGroup("MediumA", bqt3); //$NON-NLS-1$
+ Table bqt3MediumB = createPhysicalGroup("MediumB", bqt3); //$NON-NLS-1$
+ Table lobTable = createPhysicalGroup("LobTbl", lob); //$NON-NLS-1$
+ Table library = createPhysicalGroup("LOB_TESTING_ONE", lob); //$NON-NLS-1$
+
+ createElements( library, new String[] { "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB, DataTypeManager.DefaultDataTypes.INTEGER });
+
+ // Create virtual groups
+ QueryNode vqtn1 = new QueryNode("VQT.SmallA", "SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg1 = createUpdatableVirtualGroup("SmallA", vqt, vqtn1); //$NON-NLS-1$
+
+ QueryNode vqtn2 = new QueryNode("VQT.SmallB", "SELECT Concat(stringKey, stringNum) as a12345 FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2 = createUpdatableVirtualGroup("SmallB", vqt, vqtn2); //$NON-NLS-1$
+
+ // Case 2589
+ QueryNode vqtn2589 = new QueryNode("VQT.SmallA_2589", "SELECT * FROM BQT1.SmallA WHERE StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589 = createVirtualGroup("SmallA_2589", vqt, vqtn2589); //$NON-NLS-1$
+
+ QueryNode vqtn2589a = new QueryNode("VQT.SmallA_2589a", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.IntKey = SmallB.IntKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589a = createVirtualGroup("SmallA_2589a", vqt, vqtn2589a); //$NON-NLS-1$
+
+ QueryNode vqtn2589b = new QueryNode("VQT.SmallA_2589b", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589b = createVirtualGroup("SmallA_2589b", vqt, vqtn2589b); //$NON-NLS-1$
+
+ QueryNode vqtn2589c = new QueryNode("VQT.SmallA_2589c", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE concat(SmallA.StringNum, SmallB.StringNum) = '1010'"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589c = createVirtualGroup("SmallA_2589c", vqt, vqtn2589c); //$NON-NLS-1$
+
+ QueryNode vqtn2589d = new QueryNode("VQT.SmallA_2589d", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallA.IntNum = 10"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589d = createVirtualGroup("SmallA_2589d", vqt, vqtn2589d); //$NON-NLS-1$
+
+ QueryNode vqtn2589f = new QueryNode("VQT.SmallA_2589f", "SELECT * FROM VQT.SmallA_2589"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589f = createVirtualGroup("SmallA_2589f", vqt, vqtn2589f); //$NON-NLS-1$
+
+ QueryNode vqtn2589g = new QueryNode("VQT.SmallA_2589g", "SELECT * FROM VQT.SmallA_2589b"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589g = createVirtualGroup("SmallA_2589g", vqt, vqtn2589g); //$NON-NLS-1$
+
+ QueryNode vqtn2589h = new QueryNode("VQT.SmallA_2589h", "SELECT VQT.SmallA_2589.* FROM VQT.SmallA_2589 INNER JOIN BQT1.SmallB ON VQT.SmallA_2589.StringKey = SmallB.StringKey"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589h = createVirtualGroup("SmallA_2589h", vqt, vqtn2589h); //$NON-NLS-1$
+
+ QueryNode vqtn2589i = new QueryNode("VQT.SmallA_2589i", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallB.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg2589i = createVirtualGroup("SmallA_2589i", vqt, vqtn2589i); //$NON-NLS-1$
+
+ // defect 15355
+ QueryNode vqtn15355 = new QueryNode("VQT.Defect15355", "SELECT convert(IntKey, string) as StringKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg15355 = createVirtualGroup("Defect15355", vqt, vqtn15355); //$NON-NLS-1$
+ QueryNode vqtn15355a = new QueryNode("VQT.Defect15355a", "SELECT StringKey, StringNum, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, StringNum, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg15355a = createVirtualGroup("Defect15355a", vqt, vqtn15355a); //$NON-NLS-1$
+ QueryNode vqtn15355b = new QueryNode("VQT.Defect15355b", "SELECT convert(IntKey, string) as IntKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vqtg15355b = createVirtualGroup("Defect15355b", vqt, vqtn15355b); //$NON-NLS-1$
+
+ QueryNode bvqtn1 = new QueryNode("BQT_V.BQT_V", "SELECT a.* FROM BQT1.SMALLA AS a WHERE a.INTNUM = (SELECT MIN(b.INTNUM) FROM BQT1.SMALLA AS b WHERE b.INTKEY = a.IntKey ) OPTION MAKEDEP a"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table bvqtg1 = createUpdatableVirtualGroup("BQT_V", bvqt, bvqtn1); //$NON-NLS-1$
+ QueryNode bvqt2n1 = new QueryNode("BQT2_V.BQT2_V", "SELECT BQT2.SmallA.* FROM BQT2.SmallA, BQT_V.BQT_V WHERE BQT2.SmallA.IntKey = BQT_V.BQT_V.IntKey"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table bvqt2g1 = createUpdatableVirtualGroup("BQT2_V", bvqt2, bvqt2n1); //$NON-NLS-1$
+
+ // Create physical elements
+ String[] elemNames = new String[] {
+ "IntKey", "StringKey", //$NON-NLS-1$ //$NON-NLS-2$
+ "IntNum", "StringNum", //$NON-NLS-1$ //$NON-NLS-2$
+ "FloatNum", "LongNum", //$NON-NLS-1$ //$NON-NLS-2$
+ "DoubleNum", "ByteNum", //$NON-NLS-1$ //$NON-NLS-2$
+ "DateValue", "TimeValue", //$NON-NLS-1$ //$NON-NLS-2$
+ "TimestampValue", "BooleanValue", //$NON-NLS-1$ //$NON-NLS-2$
+ "CharValue", "ShortValue", //$NON-NLS-1$ //$NON-NLS-2$
+ "BigIntegerValue", "BigDecimalValue", //$NON-NLS-1$ //$NON-NLS-2$
+ "ObjectValue" }; //$NON-NLS-1$
+ String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
+ DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
+ DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG,
+ DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE,
+ DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME,
+ DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN,
+ DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT,
+ DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
+ DataTypeManager.DefaultDataTypes.OBJECT };
+
+ List<Column> bqt1SmallAe = createElements(bqt1SmallA, elemNames, elemTypes);
+ bqt1SmallAe.get(1).setNativeType("char"); //$NON-NLS-1$
+ List bqt1SmallBe = createElements(bqt1SmallB, elemNames, elemTypes);
+ List bqt1MediumAe = createElements(bqt1MediumA, elemNames, elemTypes);
+ List bqt1MediumBe = createElements(bqt1MediumB, elemNames, elemTypes);
+ List bqt2SmallAe = createElements(bqt2SmallA, elemNames, elemTypes);
+ List bqt2SmallBe = createElements(bqt2SmallB, elemNames, elemTypes);
+ List bqt2MediumAe = createElements(bqt2MediumA, elemNames, elemTypes);
+ List bqt2MediumBe = createElements(bqt2MediumB, elemNames, elemTypes);
+ List bqt3SmallAe = createElements(bqt3SmallA, elemNames, elemTypes);
+ List bqt3SmallBe = createElements(bqt3SmallB, elemNames, elemTypes);
+ List bqt3MediumAe = createElements(bqt3MediumA, elemNames, elemTypes);
+ List bqt3MediumBe = createElements(bqt3MediumB, elemNames, elemTypes);
+ List lobTable_elem = createElements(lobTable, new String[] {"ClobValue"}, new String[] {DataTypeManager.DefaultDataTypes.CLOB}); //$NON-NLS-1$
+
+ // Create virtual elements
+ List vqtg1e = createElements(vqtg1, elemNames, elemTypes);
+ List vqtg2e = createElements(vqtg2, new String[] {"a12345"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+ List vqtg15355e = createElements(vqtg15355, new String[] {"StringKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
+ List vqtg15355ae = createElements(vqtg15355a, new String[] {"StringKey", "StringNum", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ List vqtg15355be = createElements(vqtg15355b, new String[] {"IntKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
+ List vqtg2589e = createElements(vqtg2589, elemNames, elemTypes);
+ List vqtg2589ae = createElements(vqtg2589a, elemNames, elemTypes);
+ List vqtg2589be = createElements(vqtg2589b, elemNames, elemTypes);
+ List vqtg2589ce = createElements(vqtg2589c, elemNames, elemTypes);
+ List vqtg2589de = createElements(vqtg2589d, elemNames, elemTypes);
+ List vqtg2589fe = createElements(vqtg2589f, elemNames, elemTypes);
+ List vqtg2589ge = createElements(vqtg2589g, elemNames, elemTypes);
+ List vqtg2589he = createElements(vqtg2589h, elemNames, elemTypes);
+ List vqtg2589ie = createElements(vqtg2589i, elemNames, elemTypes);
+ List bvqtg1e = createElements(bvqtg1, elemNames, elemTypes);
+ List bvqt2g1e = createElements(bvqt2g1, elemNames, elemTypes);
+
+ // Add stored procedure
+ Schema pm1 = createPhysicalModel("pm1", metadataStore); //$NON-NLS-1$
+ ProcedureParameter rs1p1 = createParameter("intkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ColumnSet<Procedure> rs1 = createResultSet("rs1", pm1, new String[] { "IntKey", "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest5 = createStoredProcedure("spTest5", pm1, Arrays.asList(rs1p1), "spTest5"); //$NON-NLS-1$ //$NON-NLS-2$
+ spTest5.setResultSet(rs1);
+
+ Schema pm2 = createPhysicalModel("pm2", metadataStore); //$NON-NLS-1$
+ ProcedureParameter rs2p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ProcedureParameter rs2p2 = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ColumnSet<Procedure> rs2 = createResultSet("rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest8 = createStoredProcedure("spTest8", pm2, Arrays.asList(rs2p1, rs2p2), "spTest8"); //$NON-NLS-1$ //$NON-NLS-2$
+ spTest8.setResultSet(rs2);
+
+ ProcedureParameter rs2p2a = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ColumnSet<Procedure> rs2a = createResultSet("rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest8a = createStoredProcedure("spTest8a", pm2, Arrays.asList(rs2p2a), "spTest8a"); //$NON-NLS-1$ //$NON-NLS-2$
+ spTest8a.setResultSet(rs2a);
+
+ Schema pm4 = createPhysicalModel("pm4", metadataStore); //$NON-NLS-1$
+ ProcedureParameter rs4p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ProcedureParameter rs4p2 = createParameter("ret", 1, ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ Procedure spTest9 = createStoredProcedure("spTest9", pm4, Arrays.asList(rs4p1, rs4p2), "spTest9"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Schema pm3 = createPhysicalModel("pm3", metadataStore); //$NON-NLS-1$
+ ProcedureParameter rs3p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ProcedureParameter rs3p2 = createParameter("outkey", 3, ParameterInfo.INOUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ ColumnSet<Procedure> rs3 = createResultSet("rs3", pm3, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest11 = createStoredProcedure("spTest11", pm3, Arrays.asList(rs3p1, rs3p2), "spTest11"); //$NON-NLS-1$ //$NON-NLS-2$
+ spTest11.setResultSet(rs3);
+
+ //add virtual stored procedures
+ Schema mmspTest1 = createVirtualModel("mmspTest1", metadataStore); //$NON-NLS-1$
+ ColumnSet<Procedure> vsprs1 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn1 = new QueryNode("vsp1", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp1 = createVirtualProcedure("MMSP1", mmspTest1, null, vspqn1); //$NON-NLS-1$
+ vsp1.setResultSet(vsprs1);
+
+ ColumnSet<Procedure> vsprs2 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn2 = new QueryNode("vsp2", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor1 BEGIN LOOP ON (SELECT intkey FROM bqt1.smallB) AS intKeyCursor2 BEGIN x= intKeyCursor1.intkey - intKeyCursor2.intkey; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp2 = createVirtualProcedure("MMSP2", mmspTest1, null, vspqn2); //$NON-NLS-1$
+ vsp2.setResultSet(vsprs2);
+
+ ColumnSet<Procedure> vsprs3 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn3 = new QueryNode("vsp3", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp3 = createVirtualProcedure("MMSP3", mmspTest1, null, vspqn3); //$NON-NLS-1$
+ vsp3.setResultSet(vsprs3);
+
+ ColumnSet<Procedure> vsprs4 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn4 = new QueryNode("vsp4", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; x=0; WHILE(x < 50) BEGIN x= x + 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp4 = createVirtualProcedure("MMSP4", mmspTest1, null, vspqn4); //$NON-NLS-1$
+ vsp4.setResultSet(vsprs4);
+
+ ColumnSet<Procedure> vsprs5 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ ProcedureParameter vsp5p1 = createParameter("param1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+ QueryNode vspqn5 = new QueryNode("vsp5", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 0; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp5 = createVirtualProcedure("MMSP5", mmspTest1, Arrays.asList(vsp5p1), vspqn5); //$NON-NLS-1$
+ vsp5.setResultSet(vsprs5);
+
+ ColumnSet<Procedure> vsprs6 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ ProcedureParameter vsp6p1 = createParameter("p1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+ QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 1; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp6 = createVirtualProcedure("MMSP6", mmspTest1, Arrays.asList(vsp6p1), vspqn6); //$NON-NLS-1$
+ vsp6.setResultSet(vsprs6);
+
+ CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
+ VDBMetaData vdbMetaData = new VDBMetaData();
+ vdbMetaData.setName("bqt"); //$NON-NLS-1$
+ vdbMetaData.setVersion(1);
+ for (Schema schema : metadataStore.getSchemas().values()) {
+ vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
+ }
+ return new TransformationMetadata(vdbMetaData, store, null, null);
+ }
+
+ /**
+ * Create a physical model with default settings.
+ */
+ public static Schema createPhysicalModel(String name, MetadataStore metadataStore) {
+ Schema schema = new Schema();
+ schema.setName(name);
+ metadataStore.addSchema(schema);
+ return schema;
+ }
+
+ /**
+ * Create a virtual model with default settings.
+ */
+ public static Schema createVirtualModel(String name, MetadataStore metadataStore) {
+ Schema schema = new Schema();
+ schema.setName(name);
+ schema.setPhysical(false);
+ metadataStore.addSchema(schema);
+ return schema;
+ }
+
+ /**
+ * Create a physical group with default settings.
+ * @param name Name of physical group, must match model name
+ * @param model Associated model
+ * @return FakeMetadataObject Metadata object for group
+ */
+ public static Table createPhysicalGroup(String name, Schema model, boolean fullyQualify) {
+ Table table = new Table();
+ table.setName(name);
+ model.addTable(table);
+ table.setSupportsUpdate(true);
+ table.setNameInSource((fullyQualify || name.lastIndexOf(".") == -1)? name : name.substring(name.lastIndexOf(".") + 1)); //$NON-NLS-1$ //$NON-NLS-2$
+ return table;
+ }
+
+ public static Table createPhysicalGroup(String name, Schema model) {
+ return createPhysicalGroup(name, model, false);
+ }
+
+ /**
+ * Create a virtual group with default settings.
+ */
+ public static Table createVirtualGroup(String name, Schema model, QueryNode plan) {
+ Table table = new Table();
+ table.setName(name);
+ model.addTable(table);
+ table.setVirtual(true);
+ table.setSelectTransformation(plan.getQuery());
+ return table;
+ }
+
+ /**
+ * Create a temp group with default settings.
+ * @param name Name of virtual group, must match model name
+ * @param model Associated model
+ * @param plan Appropriate query plan definition object for the temp group
+ * @return FakeMetadataObject Metadata object for group
+ */
+ public static FakeMetadataObject createTempGroup(String name, FakeMetadataObject model, Object plan) {
+ FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.GROUP);
+ obj.putProperty(FakeMetadataObject.Props.MODEL, model);
+ obj.putProperty(FakeMetadataObject.Props.IS_VIRTUAL, Boolean.FALSE);
+ obj.putProperty(FakeMetadataObject.Props.PLAN, plan);
+ obj.putProperty(FakeMetadataObject.Props.UPDATE, Boolean.FALSE);
+ obj.putProperty(FakeMetadataObject.Props.TEMP, Boolean.TRUE);
+ return obj;
+ }
+
+ /**
+ * Create a virtual group that allows updates with default settings.
+ */
+ public static Table createUpdatableVirtualGroup(String name, Schema model, QueryNode plan) {
+ return createUpdatableVirtualGroup(name, model, plan, null);
+ }
+
+ public static Table createUpdatableVirtualGroup(String name, Schema model, QueryNode plan, String updatePlan) {
+ Table table = createVirtualGroup(name, model, plan);
+ table.setUpdatePlan(updatePlan);
+ table.setSupportsUpdate(true);
+ return table;
+ }
+
+ public static Column createElement(String name, ColumnSet<?> group, String type) {
+ Column column = new Column();
+ column.setName(name);
+ group.addColumn(column);
+ column.setRuntimeType(type);
+ if(type.equals(DataTypeManager.DefaultDataTypes.STRING)) {
+ column.setSearchType(SearchType.Searchable);
+ } else if (DataTypeManager.isNonComparable(type)){
+ column.setSearchType(SearchType.Unsearchable);
+ } else {
+ column.setSearchType(SearchType.All_Except_Like);
+ }
+ column.setNullType(NullType.Nullable);
+ column.setPosition(group.getColumns().size()); //1 based indexing
+ column.setUpdatable(true);
+ column.setLength(100);
+ column.setNameInSource(name);
+ return column;
+ }
+
+ /**
+ * Create a set of elements in batch
+ */
+ public static List<Column> createElements(ColumnSet<?> group, String[] names, String[] types) {
+ return createElementsWithDefaults(group, names, types, new String[names.length]);
+ }
+
+ /**
+ * Create a set of elements in batch
+ */
+ public static List<Column> createElementsWithDefaults(ColumnSet<?> group, String[] names, String[] types, String[] defaults) {
+ List<Column> elements = new ArrayList<Column>();
+
+ for(int i=0; i<names.length; i++) {
+ Column element = createElement(names[i], group, types[i]);
+ element.setDefaultValue(defaults[i]);
+ elements.add(element);
+ }
+
+ return elements;
+ }
+
+ /**
+ * Create index. The name will be used as the Object metadataID.
+ * @param name String name of index
+ * @param group the group for the index
+ * @param elements the elements of the index (will be used as if they were
+ * metadata IDs)
+ * @return key metadata object
+ */
+ public static FakeMetadataObject createIndex(String name, FakeMetadataObject group, List elements) {
+ FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+ obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_INDEX);
+ obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+ Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+ if (keys == null){
+ keys = new ArrayList();
+ group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+ }
+ keys.add(obj);
+ return obj;
+ }
+
+ /**
+ * Create primary key. The name will be used as the Object metadataID.
+ * @param name String name of key
+ * @param group the group for the key
+ * @param elements the elements of the key (will be used as if they were
+ * metadata IDs)
+ * @return key metadata object
+ */
+ public static FakeMetadataObject createKey(String name, FakeMetadataObject group, List elements) {
+ FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+ obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_PRIMARY_KEY);
+ obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+ Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+ if (keys == null){
+ keys = new ArrayList();
+ group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+ }
+ keys.add(obj);
+ return obj;
+ }
+
+ /**
+ * Create foreign key. The name will be used as the Object metadataID.
+ * @param name String name of key
+ * @param group the group for the key
+ * @param elements the elements of the key (will be used as if they were
+ * @param primaryKey referenced by this foreign key
+ * metadata IDs)
+ * @return key metadata object
+ */
+ public static FakeMetadataObject createForeignKey(String name, FakeMetadataObject group, List elements, FakeMetadataObject primaryKey) {
+ FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+ obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_FOREIGN_KEY);
+ obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+ obj.putProperty(FakeMetadataObject.Props.REFERENCED_KEY, primaryKey);
+ Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+ if (keys == null){
+ keys = new ArrayList();
+ group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+ }
+ keys.add(obj);
+ return obj;
+ }
+
+ /**
+ * Create access pattern (currently an access pattern is implemented as a type of key). The name will
+ * be used as the Object metadataID.
+ * @param name String name of key
+ * @param group the group for the access pattern
+ * @param elements the elements of the access pattern (will be used as if they were
+ * metadata IDs)
+ * @return Access pattern metadata object
+ */
+ public static FakeMetadataObject createAccessPattern(String name, FakeMetadataObject group, List elements) {
+ FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+ obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_ACCESS_PATTERN);
+ obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+ Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+ if (keys == null){
+ keys = new ArrayList();
+ group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+ }
+ keys.add(obj);
+ return obj;
+ }
+
+ /**
+ * Create stored procedure parameter.
+ */
+ public static ProcedureParameter createParameter(String name, int index, int direction, String type, Object rs) {
+ ProcedureParameter param = new ProcedureParameter();
+ param.setName(name);
+ switch (direction) {
+ case SPParameter.IN:
+ param.setType(Type.In);
+ break;
+ case SPParameter.INOUT:
+ param.setType(Type.InOut);
+ break;
+ case SPParameter.OUT:
+ param.setType(Type.Out);
+ break;
+ case SPParameter.RESULT_SET:
+ throw new AssertionError("should not directly create a resultset param"); //$NON-NLS-1$
+ case SPParameter.RETURN_VALUE:
+ param.setType(Type.ReturnValue);
+ break;
+ }
+ param.setRuntimeType(type);
+ return param;
+ }
+
+ /**
+ * Create stored procedure.
+ * @param name Name of procedure, must match model name
+ * @param model Metadata object for the model
+ * @param params List of FakeMetadataObject that are the parameters for the procedure
+ * @param callableName Callable name of procedure, usually same as procedure name
+ * @return Metadata object for stored procedure
+ */
+ public static Procedure createStoredProcedure(String name, Schema model, List<ProcedureParameter> params, String callableName) {
+ Procedure proc = new Procedure();
+ proc.setName(name);
+ if (params != null) {
+ int index = 1;
+ for (ProcedureParameter procedureParameter : params) {
+ procedureParameter.setProcedure(proc);
+ procedureParameter.setPosition(index++);
+ }
+ proc.setParameters(params);
+ }
+ model.addProcedure(proc);
+ return proc;
+ }
+
+ /**
+ * Create virtual sotred procedure.
+ * @param name Name of stored query, must match model name
+ * @param model Metadata object for the model
+ * @param params List of FakeMetadataObject that are the parameters for the procedure
+ * @param queryPlan Object representing query plan
+ * @return Metadata object for stored procedure
+ */
+ public static Procedure createVirtualProcedure(String name, Schema model, List<ProcedureParameter> params, QueryNode queryPlan) {
+ Procedure proc = createStoredProcedure(name, model, params, null);
+ proc.setVirtual(true);
+ proc.setQueryPlan(queryPlan.getQuery());
+ return proc;
+ }
+
+ /**
+ * Create a result set.
+ */
+ public static ColumnSet<Procedure> createResultSet(String name, Object model, String[] colNames, String[] colTypes) {
+ ColumnSet<Procedure> rs = new ColumnSet<Procedure>();
+ rs.setName(name);
+ for(Column column : createElements(rs, colNames, colTypes)) {
+ column.setParent(rs);
+ }
+ return rs;
+ }
+
+}
Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1060,34 +1060,6 @@
helpValidate("EXEC pm1.sq1()", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
}
- // variable declared is of special type INPUT
- @Test public void testCreateUpdateProcedure1() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer INPUT;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
- // variable declared is of special type CHANGING
- @Test public void testCreateUpdateProcedure3() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer CHANGING;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpFailProcedure(procedure, userUpdateStr,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
// valid variable declared
@Test public void testCreateUpdateProcedure4() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
@@ -1744,7 +1716,7 @@
// Validate
ValidatorReport report = helpValidateInModeler("pm1.vsp36", sql, metadata); //$NON-NLS-1$
assertEquals(1, report.getItems().size());
- assertEquals("Elements cannot appear more than once in a SET or USING clause. The following elements are duplicated: [\"USING\".id]", report.toString()); //$NON-NLS-1$
+ assertEquals("Elements cannot appear more than once in a SET or USING clause. The following elements are duplicated: [DVARS.id]", report.toString()); //$NON-NLS-1$
}
@Test public void testValidateAssignmentWithFunctionOnParameter_InModeler() throws Exception{
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -21,16 +21,12 @@
*/
package org.teiid.dqp.internal.cache;
-import java.util.Properties;
-
import junit.framework.TestCase;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -40,17 +36,16 @@
@Override
protected void setUp() throws Exception {
- Properties p = new Properties();
- p.setProperty(DQPEmbeddedProperties.PROCESSNAME, "host-process"); //$NON-NLS-1$
- cacheContext = new DQPContextCache(p, new FakeCacheFactory());
-
+ cacheContext = new DQPContextCache();
+ cacheContext.setCacheFactory(new FakeCacheFactory());
+ cacheContext.setProcessName("host-process");
}
private DQPWorkContext getContext() {
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+ workContext.setVdbVersion(1); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
return workContext;
}
@@ -60,17 +55,17 @@
Cache cache = this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString());
cache.put("key", "request-value"); //$NON-NLS-1$ //$NON-NLS-2$
- cache = this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
+ cache = this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
cache.put("key", "session-value"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("request-value", this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
// close the request
this.cacheContext.removeRequestScopedCache(context.getRequestID(12L).toString());
assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$
- assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -97,7 +92,7 @@
assertEquals("request-value", this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("global-value", this.cacheContext.getGlobalScopedCache().get("key")); //$NON-NLS-1$ //$NON-NLS-2$
- this.cacheContext.shutdown();
+ this.cacheContext.stop();
assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$
// global only dies when the engine is shutdown
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,7 +25,7 @@
import java.util.Arrays;
import java.util.List;
-import javax.transaction.xa.XAResource;
+import junit.framework.Assert;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.ConnectorCapabilities;
@@ -40,17 +40,12 @@
import org.teiid.connector.basic.BasicConnector;
import org.teiid.connector.basic.BasicConnectorCapabilities;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.Command;
+import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.connector.xa.api.XAConnection;
-import org.teiid.connector.xa.api.XAConnector;
-import junit.framework.Assert;
-
-public class FakeConnector extends BasicConnector implements XAConnector {
+public class FakeConnector extends BasicConnector {
private static final int RESULT_SIZE = 5;
private boolean executeBlocks;
@@ -63,6 +58,8 @@
private int connectionCount;
private int executionCount;
+ private ConnectorEnvironment env;
+
public int getConnectionCount() {
return connectionCount;
}
@@ -71,31 +68,27 @@
return executionCount;
}
- @Override
- public Connection getConnection(org.teiid.connector.api.ExecutionContext context) throws ConnectorException {
- return new FakeConnection();
+ public ConnectorEnvironment getConnectorEnvironment() {
+ return this.env;
}
- @Override
- public void start(ConnectorEnvironment environment)
- throws ConnectorException {
-
+
+ public void setConnectorEnvironment(ConnectorEnvironment env) {
+ this.env = env;
}
+
@Override
- public void stop() {}
- @Override
- public XAConnection getXAConnection(ExecutionContext executionContext,
- TransactionContext transactionContext) throws ConnectorException {
- return new FakeConnection();
- }
+ public Connection getConnection() throws ConnectorException {
+ return new FakeConnection();
+ }
- private class FakeConnection extends BasicConnection implements XAConnection {
+ private class FakeConnection extends BasicConnection {
public FakeConnection() {
connectionCount++;
}
public boolean released = false;
- public Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+ public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
executionCount++;
return new FakeBlockingExecution(executionContext);
}
@@ -106,10 +99,6 @@
Assert.assertFalse("The connection should not be released more than once", released); //$NON-NLS-1$
released = true;
}
- @Override
- public XAResource getXAResource() throws ConnectorException {
- return null;
- }
}
private final class FakeBlockingExecution extends BasicExecution implements ResultSetExecution, UpdateExecution {
@@ -120,7 +109,7 @@
public FakeBlockingExecution(ExecutionContext ec) {
this.ec = ec;
}
- public void execute(IQueryCommand query, int maxBatchSize) throws ConnectorException {
+ public void execute(QueryExpression query, int maxBatchSize) throws ConnectorException {
if (executeBlocks) {
waitForCancel();
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -38,9 +38,7 @@
public FakeExecutionContextImpl(int unique) {
super("VDB" + unique, //$NON-NLS-1$
- "Version" + unique, //$NON-NLS-1$
- "User" + unique, //$NON-NLS-1$
- "Payload" + unique, //$NON-NLS-1$
+ unique,
"ExecutionPayload" + unique, //$NON-NLS-1$
"ConnectionID" + unique, //$NON-NLS-1$
"ConnectorID" + unique, //$NON-NLS-1$
@@ -50,8 +48,7 @@
}
public FakeExecutionContextImpl(ExecutionContext c) {
- super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(), c
- .getUser(), c.getTrustedPayload(), c.getExecutionPayload(), c
+ super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(), c.getExecutionPayload(), c
.getConnectionIdentifier(), c.getConnectorIdentifier(), c
.getRequestIdentifier(), c.getPartIdentifier(), c
.getExecutionCountIdentifier());
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,6 +24,7 @@
import org.teiid.dqp.internal.transaction.TransactionProvider;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.internal.transaction.XidFactory;
import com.metamatrix.core.util.SimpleMock;
@@ -31,6 +32,7 @@
public FakeTransactionService() {
this.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class));
+ this.setXidFactory(new XidFactory());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,217 +26,65 @@
*/
package org.teiid.dqp.internal.datamgr.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
-import org.teiid.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.cache.FakeCache;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
/**
* JUnit test for TestConnectorManagerImpl
*/
public final class TestConnectorManagerImpl {
- private Properties helpGetAppProps() {
- Properties appProperties = new Properties();
-
- appProperties.setProperty(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "AFakeConnectorBinding"); //$NON-NLS-1$
- appProperties.setProperty(ConnectorPropertyNames.MAX_RESULT_ROWS, "10"); //$NON-NLS-1$
- appProperties.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-
- return appProperties;
+
+ private ConnectorEnvironment helpGetAppProps() {
+ ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+ Mockito.stub(env.getMaxResultRows()).toReturn(10);
+ return env;
}
+
+ static ConnectorManager getConnectorManager(ConnectorEnvironment env) throws Exception {
+ final FakeConnector c = new FakeConnector();
+ c.setConnectorEnvironment(env);
+ ConnectorManager cm = new ConnectorManager("FakeConnector") {
+ Connector getConnector() {
+ return c;
+ }
+ };
+ cm.start();
+ return cm;
+ }
// =========================================================================
// T E S T C A S E S
// =========================================================================
- @Test public void testStartFailsWithNullRequiredProp() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- Properties appProperties = helpGetAppProps();
- // Remove required property
- appProperties.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, ""); //$NON-NLS-1$
-
- try {
- startConnectorManager(cm, appProperties);
- cm.stop();
- fail("Able to start ConnectorManager with null required props."); //$NON-NLS-1$
- } catch (ApplicationLifecycleException e) {
- assertEquals("Connector is missing required property ConnectorClass or wrong value supplied AFakeConnectorBinding<null> ", e.getMessage()); //$NON-NLS-1$
- }
- }
@Test public void testReceive() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- startConnectorManager(cm, helpGetAppProps());
-
+ ConnectorManager cm = getConnectorManager(helpGetAppProps());
AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
QueueResultsReceiver receiver = new QueueResultsReceiver();
- cm.executeRequest(receiver, request);
+ cm.executeRequest(new FakeWorkManager(), receiver, request);
assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
cm.stop();
}
- @Test public void testConnectorCapabilitiesOverride() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- startConnectorManager(cm, helpGetAppProps());
-
- AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-
- SourceCapabilities caps = cm.getCapabilities(request.getRequestID(), null, Mockito.mock(DQPWorkContext.class));
- assertFalse(caps.supportsCapability(Capability.CRITERIA_EXISTS));
- assertFalse(caps.supportsCapability(Capability.QUERY_EXCEPT));
-
-
- ConnectorManager cmnew = new ConnectorManager();
- Properties props = helpGetAppProps();
- props.setProperty("supportsExistsCriteria", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("supportsExcept", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- startConnectorManager(cmnew, props);
-
- SourceCapabilities capsnew = cmnew.getCapabilities(request.getRequestID(), null, Mockito.mock(DQPWorkContext.class));
- assertTrue(capsnew.supportsCapability(Capability.CRITERIA_EXISTS));
- assertTrue(capsnew.supportsCapability(Capability.QUERY_EXCEPT));
- }
-
- private void startConnectorManager(ConnectorManager cm, Properties props)
- throws ApplicationLifecycleException {
- cm.initialize(props);
- ApplicationEnvironment env = new ApplicationEnvironment();
- env.bindService(DQPServiceNames.METADATA_SERVICE, new FakeMetadataService());
- env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
- env.setCacheFactory(new FakeCache.FakeCacheFactory());
- cm.start(env);
- }
- @Test public void testIsXA() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- Properties props = new Properties();
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
- props.setProperty(ConnectorPropertyNames.IS_XA, Boolean.TRUE.toString());
- startConnectorManager(cm, props);
- assertTrue(cm.isXa());
- cm.stop();
- }
-
- @Test public void testIsXA_Failure() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- Properties props = new Properties();
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeSourceConnectionFactory.class.getName());
- props.setProperty(ConnectorPropertyNames.IS_XA, Boolean.TRUE.toString());
- try {
- startConnectorManager(cm, props);
- } catch (ApplicationLifecycleException e) {
- assertEquals("Connector \"Unknown_Binding_Name<null>\" was configured to support XA transactions, but the connector is not an XAConnector", e.getMessage()); //$NON-NLS-1$
- }
- cm.stop();
- }
-
@Test public void testDefect19049() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- Properties props = new Properties();
- final String connectorName = FakeConnector.class.getName();
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, connectorName);
- URLClassLoader cl = new URLClassLoader(new URL[0]);
- startConnectorManager(cm, props);
- ((FakeConnector)cm.getConnector().getActualConnector()).setClassloader(cl);
+ ConnectorManager cm = getConnectorManager(helpGetAppProps());
AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
QueueResultsReceiver receiver = new QueueResultsReceiver();
- cm.executeRequest(receiver, request);
+ cm.executeRequest(new FakeWorkManager(),receiver, request);
assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
cm.stop();
}
-
- @Test public void testConnectorStatus() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-
- Properties props = new Properties();
- Connector mockConnector = Mockito.mock(Connector.class);
- Connection mockConnection = Mockito.mock(Connection.class);
-
- Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toReturn(mockConnection);
-
- final String connectorName = mockConnector.getClass().getName();
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, connectorName);
- startConnectorManager(cm, props);
- cm.setConnector(new ConnectorWrapper(mockConnector)); // to make them same connector
-
- // no identity can be defined
- assertEquals(ConnectorStatus.UNABLE_TO_CHECK, cm.getStatus());
- }
-
- @Test public void testConnectorStatus_alive() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-
- Connector mockConnector = Mockito.mock(Connector.class);
- Connection mockConnection = Mockito.mock(Connection.class);
- ConnectorIdentity mockIdentity = Mockito.mock(ConnectorIdentity.class);
-
- Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toReturn(mockConnection);
- Mockito.stub(mockConnector.createIdentity(null)).toReturn(mockIdentity);
- Mockito.stub(mockConnection.isAlive()).toReturn(true);
-
- ConnectorWrapper wrapper = new ConnectorWrapper(mockConnector);
-
- wrapper.updateStatus();
- assertEquals(ConnectorStatus.OPEN, wrapper.getStatus());
- }
-
- @Test public void testConnectorStatus_unavailable() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-
- Connector mockConnector = Mockito.mock(Connector.class);
- Connection mockConnection = Mockito.mock(Connection.class);
- ConnectorIdentity mockIdentity = Mockito.mock(ConnectorIdentity.class);
-
- Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toReturn(mockConnection);
- Mockito.stub(mockConnector.createIdentity(null)).toReturn(mockIdentity);
- Mockito.stub(mockConnection.isAlive()).toReturn(false);
-
- ConnectorWrapper wrapper = new ConnectorWrapper(mockConnector);
-
- wrapper.updateStatus();
- assertEquals(ConnectorStatus.DATA_SOURCE_UNAVAILABLE, wrapper.getStatus());
- }
-
- @Test public void testConnectorStatus_exception() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-
- Connector mockConnector = Mockito.mock(Connector.class);
- ConnectorIdentity mockIdentity = Mockito.mock(ConnectorIdentity.class);
-
- Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toThrow(new ConnectorException());
- Mockito.stub(mockConnector.createIdentity(null)).toReturn(mockIdentity);
-
- ConnectorWrapper wrapper = new ConnectorWrapper(mockConnector);
-
- wrapper.updateStatus();
- assertEquals(ConnectorStatus.DATA_SOURCE_UNAVAILABLE, wrapper.getStatus());
- }
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,14 +31,13 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.mockito.Mockito;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
-
import junit.framework.TestCase;
-import com.metamatrix.common.queue.WorkerPool;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
+
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -63,19 +62,18 @@
protected void setUp() throws Exception {
super.setUp();
request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
- csm = new ConnectorManager();
- csm.setConnectorWorkerPool(Mockito.mock(WorkerPool.class));
- csm.setConnector(new ConnectorWrapper(new FakeConnector()));
- csm.setWorkItemFactory(new ConnectorWorkItemFactory(csm, true));
+ csm = TestConnectorManagerImpl.getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+ csm.workItemFactory = new ConnectorWorkItemFactory(csm, true);
}
- void helpAssureOneState() {
- csm.executeRequest(null, request);
+ void helpAssureOneState() throws Exception {
+ QueueResultsReceiver receiver = new QueueResultsReceiver();
+ csm.executeRequest(new FakeWorkManager(), receiver, request);
ConnectorWorkItem state = csm.getState(request.getAtomicRequestID());
assertEquals(state, csm.getState(request.getAtomicRequestID()));
}
- public void testCreateAndAddRequestState() {
+ public void testCreateAndAddRequestState() throws Exception {
helpAssureOneState();
assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
}
@@ -90,13 +88,13 @@
}
}
- public void testRemoveRequestState() {
+ public void testRemoveRequestState() throws Exception {
helpAssureOneState();
csm.removeState(request.getAtomicRequestID());
assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$
}
- public void testRemoveUnknownRequestState() {
+ public void testRemoveUnknownRequestState() throws Exception {
helpAssureOneState();
csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5)); //$NON-NLS-1$
@@ -107,7 +105,7 @@
List<ResultsFuture<AtomicResultsMessage>> futures = new ArrayList<ResultsFuture<AtomicResultsMessage>>();
for (int i=0; i<20; i++) {
ResultsFuture<AtomicResultsMessage> future = new ResultsFuture<AtomicResultsMessage>();
- csm.executeRequest(future.getResultsReceiver(), TestConnectorWorkItem.createNewAtomicRequestMessage(i, 1));
+ csm.executeRequest(new FakeWorkManager(),future.getResultsReceiver(), TestConnectorWorkItem.createNewAtomicRequestMessage(i, 1));
}
csm.stop();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,35 +22,36 @@
package org.teiid.dqp.internal.datamgr.impl;
+import static junit.framework.Assert.*;
+
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import javax.transaction.Transaction;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.Xid;
-import junit.framework.TestCase;
-
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorPropertyNames;
import org.teiid.connector.api.ProcedureExecution;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.connector.language.Call;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.FakeMetadataService;
+import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -58,13 +59,11 @@
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-public class TestConnectorWorkItem extends TestCase {
+public class TestConnectorWorkItem {
- private static final FakeMetadataFacade EXAMPLE_BQT = FakeMetadataFactory
- .exampleBQTCached();
+ private static final QueryMetadataInterface EXAMPLE_BQT = FakeMetadataFactory.exampleBQTCached();
private static Command helpGetCommand(String sql,
QueryMetadataInterface metadata) throws Exception {
@@ -73,38 +72,40 @@
return command;
}
- static ConnectorManager getConnectorManager() {
- ConnectorManager cm = new ConnectorManager();
- cm.setConnector(new ConnectorWrapper(new FakeConnector()));
- cm.setTransactionService(new FakeTransactionService());
- cm.setMetadataService(new FakeMetadataService());
+ static ConnectorManager getConnectorManager(ConnectorEnvironment env) {
+ final FakeConnector c = new FakeConnector();
+ c.setConnectorEnvironment(env);
+
+ ConnectorManager cm = new ConnectorManager("FakeConnector") {
+ Connector getConnector() {
+ return c;
+ }
+ };
return cm;
}
- static AtomicRequestMessage createNewAtomicRequestMessage(int requestid,
- int nodeid) throws Exception {
+ static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
RequestMessage rm = new RequestMessage();
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
- AtomicRequestMessage request = new AtomicRequestMessage(rm,
- workContext, nodeid);
- request.setCommand(helpGetCommand(
- "SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
+
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT, FakeMetadataFactory.exampleBQTVDB());
+ workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
+
+ AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
+ request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
request.setRequestID(new RequestID(requestid));
- request.setConnectorID(new ConnectorID("testing")); //$NON-NLS-1$
+ request.setConnectorName("testing"); //$NON-NLS-1$
request.setFetchSize(5);
return request;
}
- public void testProcedureBatching() throws Exception {
+ @Test public void testProcedureBatching() throws Exception {
ProcedureExecution exec = new FakeProcedureExecution(2, 1);
// this has two result set columns and 1 out parameter
int total_columns = 3;
StoredProcedure command = (StoredProcedure)helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT); //$NON-NLS-1$
command.getInputParameters().get(0).setExpression(new Constant(1));
- IProcedure proc = (IProcedure) new LanguageBridgeFactory(EXAMPLE_BQT)
- .translate(command);
+ Call proc = (Call)new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
ProcedureBatchHandler pbh = new ProcedureBatchHandler(proc, exec);
@@ -121,26 +122,24 @@
fail("Expected exception from resultset mismatch"); //$NON-NLS-1$
} catch (ConnectorException err) {
assertEquals(
- "Could not process stored procedure results for EXEC spTest8(, 1). Expected 2 result set columns, but was 1. Please update your models to allow for stored procedure results batching.", err.getMessage()); //$NON-NLS-1$
+ "Could not process stored procedure results for EXEC spTest8(1). Expected 2 result set columns, but was 1. Please update your models to allow for stored procedure results batching.", err.getMessage()); //$NON-NLS-1$
}
}
- public void testCancelBeforeNew() throws Exception {
+ @Test public void testCancelBeforeNew() throws Exception {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
// only one response is expected
+ FakeWorkManager wm = new FakeWorkManager();
ResultsFuture<AtomicResultsMessage> resultsFuture = new ResultsFuture<AtomicResultsMessage>();
- ConnectorWorkItem state = new SynchConnectorWorkItem(request,
- getConnectorManager(), resultsFuture
- .getResultsReceiver());
+ ConnectorWorkItem state = new SynchConnectorWorkItem(request,getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), resultsFuture.getResultsReceiver());
state.asynchCancel(); // cancel does not cause close, but the next
// processing will close
assertFalse(state.isDoneProcessing());
- state.run();
+ wm.doWork(state, 0, null, state);
- AtomicResultsMessage arm = resultsFuture.get(1000,
- TimeUnit.MILLISECONDS);
+ AtomicResultsMessage arm = resultsFuture.get(1000, TimeUnit.MILLISECONDS);
assertTrue(arm.isRequestClosed());
@@ -149,8 +148,8 @@
*/
try {
state.requestMore();
- } catch (IllegalStateException e) {
-
+ } catch (Throwable e) {
+ // catches the assertion error
}
}
@@ -169,8 +168,12 @@
switch (msgCount++) {
case 0:
// request more during delivery
- ((FakeConnector) manager.getConnector().getActualConnector()).setReturnsFinalBatch(true);
- workItem.requestMore();
+ try {
+ ((FakeConnector) manager.getConnector()).setReturnsFinalBatch(true);
+ workItem.requestMore();
+ } catch (ConnectorException e) {
+ exceptionOccurred(e);
+ }
break;
case 1:
if (results.isRequestClosed()) {
@@ -214,11 +217,10 @@
}
}
- public void testMoreAsynch() throws Throwable {
+ @Test public void testMoreAsynch() throws Throwable {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
- final ConnectorManager manager = getConnectorManager();
- AsynchMoreResultsReceiver receiver = new AsynchMoreResultsReceiver(
- manager);
+ final ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+ AsynchMoreResultsReceiver receiver = new AsynchMoreResultsReceiver(manager);
ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager,
receiver);
receiver.workItem = state;
@@ -230,9 +232,9 @@
}
}
- public void testSynchInterrupt() throws Exception {
+ @Test public void testSynchInterrupt() throws Exception {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
- final ConnectorManager manager = getConnectorManager();
+ final ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
QueueResultsReceiver receiver = new QueueResultsReceiver();
ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager, receiver);
Thread t = runRequest(state);
@@ -241,10 +243,10 @@
assertTrue(state.isCancelled());
}
- public void testImplicitClose() throws Exception {
+ @Test public void testImplicitClose() throws Exception {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
- ConnectorManager manager = getConnectorManager();
- FakeConnector connector = (FakeConnector) manager.getConnector().getActualConnector();
+ ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+ FakeConnector connector = (FakeConnector) manager.getConnector();
connector.setReturnsFinalBatch(true);
@@ -255,53 +257,55 @@
assertTrue(state.isDoneProcessing());
}
- public void testCloseBeforeNew() throws Exception {
+ @Test public void testCloseBeforeNew() throws Exception {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
+ FakeWorkManager wm = new FakeWorkManager();
ResultsFuture<AtomicResultsMessage> resultsFuture = new ResultsFuture<AtomicResultsMessage>();
- ConnectorWorkItem state = new SynchConnectorWorkItem(request,
- getConnectorManager(), resultsFuture.getResultsReceiver());
+ ConnectorWorkItem state = new SynchConnectorWorkItem(request,getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), resultsFuture.getResultsReceiver());
state.requestClose();
assertFalse(resultsFuture.isDone());
- state.run();
+
+ wm.doWork(state, 0, null, state);
AtomicResultsMessage arm = resultsFuture.get(1000,
TimeUnit.MILLISECONDS);
assertTrue(arm.isRequestClosed());
assertTrue(state.isDoneProcessing());
}
-
- public void testAsynchBasicMore() throws Exception {
+ @Test public void testAsynchBasicMore() throws Exception {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
- ConnectorManager manager = getConnectorManager();
- FakeConnector connector = (FakeConnector) manager.getConnector().getActualConnector();
+ FakeWorkManager wm = new FakeWorkManager();
+ ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+
+ FakeConnector connector = (FakeConnector) manager.getConnector();
QueueResultsReceiver resultsReceiver = new QueueResultsReceiver();
- FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(
- request, manager, resultsReceiver);
-
- state.run();
-
+
+ FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
+
+ wm.doWork(state, 0, null, state);
+
assertFalse(state.isDoneProcessing());
connector.setReturnsFinalBatch(true);
state.requestMore();
- state.run();
-
+ wm.doWork(state, 0, null, state);
+
assertTrue(state.isDoneProcessing());
assertEquals(3, resultsReceiver.results.size());
assertEquals(1, state.resumeCount);
}
- public void testAsynchKeepAlive() throws Exception {
+ @Test public void testAsynchKeepAlive() throws Exception {
AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
- ConnectorManager manager = getConnectorManager();
- FakeConnector connector = (FakeConnector) manager.getConnector().getActualConnector();
+ ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+ FakeConnector connector = (FakeConnector) manager.getConnector();
QueueResultsReceiver resultsReceiver = new QueueResultsReceiver();
- FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(
- request, manager, resultsReceiver);
+ FakeWorkManager wm = new FakeWorkManager();
+ FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
- state.run();
+ wm.doWork(state, 0, null, state);
assertFalse(state.isDoneProcessing());
@@ -317,7 +321,7 @@
assertEquals(1, state.resumeCount);
}
- public void testUpdateExecution() throws Throwable {
+ @Test public void testUpdateExecution() throws Throwable {
QueueResultsReceiver receiver = helpExecuteUpdate();
AtomicResultsMessage results = receiver.getResults().remove();
assertEquals(Integer.valueOf(1), results.getResults()[0].get(0));
@@ -329,7 +333,7 @@
AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
arm.setCommand(command);
QueueResultsReceiver receiver = new QueueResultsReceiver();
- SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(arm, getConnectorManager(), receiver);
+ SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(arm, getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), receiver);
synchConnectorWorkItem.run();
if (receiver.exception != null) {
throw receiver.exception;
@@ -337,14 +341,14 @@
return receiver;
}
- public void testExecutionWarning() throws Throwable {
+ @Test public void testExecutionWarning() throws Throwable {
QueueResultsReceiver receiver = helpExecuteUpdate();
AtomicResultsMessage results = receiver.getResults().remove();
assertEquals(1, results.getWarnings().size());
}
- public void testIsImmutablePropertySucceeds() throws Exception {
+ @Test public void testIsImmutablePropertySucceeds() throws Exception {
/*
* Setup:
* 1. requestMsg.isTransactional() must be TRUE
@@ -352,16 +356,10 @@
* 3. command must NOT be a SELECT
* 4. Then, set isImmutable to TRUE, we should SUCCEED
*/
- ConnectorManager cm = getConnectorManager();
- Properties props = new Properties();
+ ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+ Mockito.stub(env.isImmutable()).toReturn(true);
+ ConnectorManager cm = getConnectorManager(env);
- // to create an XA ConnectorManager
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-
- // to set IS_IMMUTABLE to true
- props.setProperty(ConnectorPropertyNames.IS_IMMUTABLE, "true"); //$NON-NLS-1$ //$NON-NLS-2$
- cm.initialize(props);
-
// command must not be a SELECT
Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
@@ -369,29 +367,9 @@
// To make the AtomicRequestMessage transactional, construct your own
requestMsg.setTransactionContext( new TransactionContext(){
-
@Override
- public Transaction getTransaction() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Scope getTransactionType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getTxnID() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isInTransaction() {
- // TODO Auto-generated method stub
- return true;
+ public Xid getXid() {
+ return Mockito.mock(Xid.class);
}} );
QueueResultsReceiver receiver = new QueueResultsReceiver();
@@ -407,7 +385,7 @@
}
}
- public void testIsImmutablePropertyFails() throws Exception {
+ @Test public void testIsImmutablePropertyFails() throws Exception {
/*
* Setup:
* 1. requestMsg.isTransactional() must be TRUE
@@ -415,15 +393,9 @@
* 3. command must NOT be a SELECT
* 4. Then, set isImmutable to FALSE, and we should FAIL
*/
- ConnectorManager cm = getConnectorManager();
- Properties props = new Properties();
-
- // to create an XA ConnectorManager
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-
- // to set IS_IMMUTABLE to false
- props.setProperty(ConnectorPropertyNames.IS_IMMUTABLE, "false"); //$NON-NLS-1$ //$NON-NLS-2$
- cm.initialize(props);
+ ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+ Mockito.stub(env.isImmutable()).toReturn(false);
+ ConnectorManager cm = getConnectorManager(env);
// command must not be a SELECT
Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
@@ -432,38 +404,18 @@
// To make the AtomicRequestMessage transactional, construct your own
requestMsg.setTransactionContext( new TransactionContext(){
-
@Override
- public Transaction getTransaction() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Scope getTransactionType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getTxnID() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isInTransaction() {
- // TODO Auto-generated method stub
- return true;
+ public Xid getXid() {
+ return Mockito.mock(Xid.class);
}} );
QueueResultsReceiver receiver = new QueueResultsReceiver();
- SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(requestMsg, cm, receiver);
// This is the test
try {
+ SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(requestMsg, cm, receiver);
synchConnectorWorkItem.run();
- this.assertNull("Connection should be null when IsImmutable is false", synchConnectorWorkItem.connection); //$NON-NLS-1$
+ assertNull("Connection should be null when IsImmutable is false", synchConnectorWorkItem.connection); //$NON-NLS-1$
} catch ( Exception e ) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, e.getMessage());
}
@@ -473,9 +425,8 @@
AsynchConnectorWorkItem {
int resumeCount;
- FakeQueuingAsynchConnectorWorkItem(AtomicRequestMessage message,
- ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
- super(message, manager, resultsReceiver);
+ FakeQueuingAsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver, WorkManager wm) throws ConnectorException {
+ super(message, manager, resultsReceiver, wm);
}
@Override
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -37,7 +37,7 @@
}
public ExecutionContextImpl createContext(String requestID, String partID) {
- return new ExecutionContextImpl("vdb", "1", "user", null, null, //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ return new ExecutionContextImpl("vdb", 1, null, //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
"Connection", "Connector", requestID, partID, "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,7 +24,7 @@
import java.sql.Clob;
-import org.teiid.dqp.internal.datamgr.impl.TypeFacilityImpl;
+import org.teiid.connector.basic.TypeFacilityImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,12 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.dqp.internal.datamgr.language.AggregateImpl;
-import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.SQLReservedWords;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Constant;
@@ -43,33 +43,33 @@
super(name);
}
- public static AggregateImpl example(String name, String functionName, boolean distinct, int value) throws Exception {
+ public static AggregateFunction example(String name, String functionName, boolean distinct, int value) throws Exception {
AggregateSymbol symbol = new AggregateSymbol(name,
functionName,
distinct,
new Constant(new Integer(value)));
- return (AggregateImpl)TstLanguageBridgeFactory.factory.translate(symbol);
+ return (AggregateFunction)TstLanguageBridgeFactory.factory.translate(symbol);
}
public void testGetName() throws Exception {
- assertEquals(IAggregate.COUNT, example("testName", ReservedWords.COUNT, true, 42).getName()); //$NON-NLS-1$
+ assertEquals(AggregateFunction.COUNT, example("testName", SQLReservedWords.COUNT, true, 42).getName()); //$NON-NLS-1$
}
public void testIsDistinct() throws Exception {
- assertTrue(example("testName", ReservedWords.COUNT, true, 42).isDistinct()); //$NON-NLS-1$
- assertFalse(example("testName", ReservedWords.COUNT, false, 42).isDistinct()); //$NON-NLS-1$
+ assertTrue(example("testName", SQLReservedWords.COUNT, true, 42).isDistinct()); //$NON-NLS-1$
+ assertFalse(example("testName", SQLReservedWords.COUNT, false, 42).isDistinct()); //$NON-NLS-1$
}
public void testGetExpression() throws Exception {
- AggregateImpl agg = example("testName", ReservedWords.COUNT, true, 42); //$NON-NLS-1$
+ AggregateFunction agg = example("testName", SQLReservedWords.COUNT, true, 42); //$NON-NLS-1$
assertNotNull(agg.getExpression());
- assertTrue(agg.getExpression() instanceof LiteralImpl);
- assertEquals(new Integer(42), ((LiteralImpl)agg.getExpression()).getValue());
+ assertTrue(agg.getExpression() instanceof Literal);
+ assertEquals(new Integer(42), ((Literal)agg.getExpression()).getValue());
}
public void testGetType() throws Exception {
- assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, example("x", ReservedWords.COUNT, true, 42).getType()); //$NON-NLS-1$
+ assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, example("x", SQLReservedWords.COUNT, true, 42).getType()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,10 +25,10 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.dqp.internal.datamgr.language.BatchedUpdatesImpl;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.Update;
import junit.framework.TestCase;
@@ -52,16 +52,16 @@
return new BatchedUpdateCommand(updates);
}
- public static BatchedUpdatesImpl example() throws Exception {
- return (BatchedUpdatesImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static BatchedUpdates example() throws Exception {
+ return (BatchedUpdates)TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetUpdateCommands() throws Exception {
List updates = example().getUpdateCommands();
assertEquals(3, updates.size());
- assertTrue(updates.get(0) instanceof IInsert);
- assertTrue(updates.get(1) instanceof IUpdate);
- assertTrue(updates.get(2) instanceof IDelete);
+ assertTrue(updates.get(0) instanceof Insert);
+ assertTrue(updates.get(1) instanceof Update);
+ assertTrue(updates.get(2) instanceof Delete);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,15 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-import org.teiid.dqp.internal.datamgr.language.CompareCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
+import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.CompareCriteria;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.Comparison.Operator;
+
+import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
import com.metamatrix.query.sql.symbol.Constant;
-import junit.framework.TestCase;
-
public class TestCompareCriteriaImpl extends TestCase {
/**
@@ -41,36 +41,37 @@
super(name);
}
- public static CompareCriteria helpExample(int operator, int leftVal, int rightVal) {
+ public static com.metamatrix.query.sql.lang.CompareCriteria helpExample(int operator, int leftVal, int rightVal) {
Constant left = new Constant(new Integer(leftVal));
Constant right = new Constant(new Integer(rightVal));
- return new CompareCriteria(left, operator, right);
+ return new com.metamatrix.query.sql.lang.CompareCriteria(left, operator, right);
}
- public static CompareCriteriaImpl example(int operator, int leftVal, int rightVal) throws Exception {
- return (CompareCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(operator, leftVal, rightVal));
+
+ public static Comparison example(int operator, int leftVal, int rightVal) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(operator, leftVal, rightVal));
}
public void testGetLeftExpression() throws Exception {
- CompareCriteriaImpl impl = example(CompareCriteria.GE, 200, 100);
+ Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
assertNotNull(impl.getLeftExpression());
- assertTrue(impl.getLeftExpression() instanceof LiteralImpl);
- assertEquals(new Integer(200), ((LiteralImpl)impl.getLeftExpression()).getValue());
+ assertTrue(impl.getLeftExpression() instanceof Literal);
+ assertEquals(new Integer(200), ((Literal)impl.getLeftExpression()).getValue());
}
public void testGetRightExpression() throws Exception {
- CompareCriteriaImpl impl = example(CompareCriteria.GE, 200, 100);
+ Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
assertNotNull(impl.getRightExpression());
- assertTrue(impl.getRightExpression() instanceof LiteralImpl);
- assertEquals(new Integer(100), ((LiteralImpl)impl.getRightExpression()).getValue());
+ assertTrue(impl.getRightExpression() instanceof Literal);
+ assertEquals(new Integer(100), ((Literal)impl.getRightExpression()).getValue());
}
public void testGetOperator() throws Exception {
- assertEquals(Operator.EQ, example(CompareCriteria.EQ, 200, 100).getOperator());
- assertEquals(Operator.GE, example(CompareCriteria.GE, 200, 100).getOperator());
- assertEquals(Operator.GT, example(CompareCriteria.GT, 200, 100).getOperator());
- assertEquals(Operator.LE, example(CompareCriteria.LE, 200, 100).getOperator());
- assertEquals(Operator.LT, example(CompareCriteria.LT, 200, 100).getOperator());
- assertEquals(Operator.NE, example(CompareCriteria.NE, 200, 100).getOperator());
+ assertEquals(Operator.EQ, example(AbstractCompareCriteria.EQ, 200, 100).getOperator());
+ assertEquals(Operator.GE, example(AbstractCompareCriteria.GE, 200, 100).getOperator());
+ assertEquals(Operator.GT, example(AbstractCompareCriteria.GT, 200, 100).getOperator());
+ assertEquals(Operator.LE, example(AbstractCompareCriteria.LE, 200, 100).getOperator());
+ assertEquals(Operator.LT, example(AbstractCompareCriteria.LT, 200, 100).getOperator());
+ assertEquals(Operator.NE, example(AbstractCompareCriteria.NE, 200, 100).getOperator());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,17 +22,14 @@
package org.teiid.dqp.internal.datamgr.language;
-import java.util.Iterator;
+import junit.framework.TestCase;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.ICompoundCriteria.Operator;
-import org.teiid.dqp.internal.datamgr.language.CompoundCriteriaImpl;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.AndOr.Operator;
import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import junit.framework.TestCase;
-
public class TestCompoundCriteriaImpl extends TestCase {
/**
@@ -43,28 +40,25 @@
super(name);
}
- public static CompoundCriteria helpExample(int operator) {
+ public static com.metamatrix.query.sql.lang.CompoundCriteria helpExample(int operator) {
CompareCriteria c1 = TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200);
CompareCriteria c2 = TestCompareCriteriaImpl.helpExample(CompareCriteria.LT, 500, 600);
- return new CompoundCriteria(operator, c1, c2);
+ return new com.metamatrix.query.sql.lang.CompoundCriteria(operator, c1, c2);
}
- public static CompoundCriteriaImpl example(int operator) throws Exception {
- return (CompoundCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(operator));
+ public static AndOr example(int operator) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(operator));
}
public void testGetOperator() throws Exception {
- assertEquals(Operator.AND, example(CompoundCriteria.AND).getOperator());
- assertEquals(Operator.OR, example(CompoundCriteria.OR).getOperator());
+ assertEquals(Operator.AND, example(com.metamatrix.query.sql.lang.CompoundCriteria.AND).getOperator());
+ assertEquals(Operator.OR, example(com.metamatrix.query.sql.lang.CompoundCriteria.OR).getOperator());
}
public void testGetCriteria() throws Exception {
- CompoundCriteriaImpl cc = example(CompoundCriteria.AND);
- assertNotNull(cc.getCriteria());
- assertEquals(2, cc.getCriteria().size());
- for (Iterator i = cc.getCriteria().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof ICriteria);
- }
+ AndOr cc = example(com.metamatrix.query.sql.lang.CompoundCriteria.AND);
+ assertTrue(cc.getLeftCondition() instanceof Comparison);
+ assertTrue(cc.getRightCondition() instanceof Comparison);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,13 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.DeleteImpl;
+import junit.framework.TestCase;
+
+import org.teiid.connector.language.Delete;
+
import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Delete;
-import junit.framework.TestCase;
-
public class TestDeleteImpl extends TestCase {
/**
@@ -39,21 +39,21 @@
super(name);
}
- public static Delete helpExample() {
- return new Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
+ public static com.metamatrix.query.sql.lang.Delete helpExample() {
+ return new com.metamatrix.query.sql.lang.Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND));
}
- public static DeleteImpl example() throws Exception {
- return (DeleteImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static Delete example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetGroup() throws Exception {
- assertNotNull(example().getGroup());
+ assertNotNull(example().getTable());
}
public void testGetCriteria() throws Exception {
- assertNotNull(example().getCriteria());
+ assertNotNull(example().getWhere());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,13 +24,10 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.metadata.runtime.Element;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.NamedTable;
-import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.unittest.FakeMetadataObject;
public class TestElementImpl extends TestCase {
@@ -75,12 +72,12 @@
return symbol;
}
- public static ElementImpl example(String groupName, String elementName) throws Exception {
- return (ElementImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName));
+ public static ColumnReference example(String groupName, String elementName) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName));
}
- public static ElementImpl example(String groupName, String elementName, Object metadataID) throws Exception {
- return (ElementImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName, metadataID));
+ public static ColumnReference example(String groupName, String elementName, Object metadataID) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName, metadataID));
}
public void testGetName() throws Exception {
@@ -90,30 +87,15 @@
public void testGetGroup() throws Exception {
Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
- assertNotNull(example("pm1.g1", "e1", metadataID).getGroup()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull(example("pm1.g1", "e1", metadataID).getTable()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testGetMetadataID() throws Exception {
- FakeMetadataObject group = FakeMetadataFactory.createPhysicalGroup("pm1.g1", FakeMetadataFactory.createPhysicalModel("pm1.g1")); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject metadataID = FakeMetadataFactory.createElement("e", group, DataTypeManager.DefaultDataTypes.STRING, 0); //$NON-NLS-1$
- assertNotNull(example("pm1.g1", "e", metadataID).getMetadataObject()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
public void testGetType() throws Exception {
Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e2"); //$NON-NLS-1$
assertTrue(example("pm1.g1", "e2", metadataID).getType().equals(Integer.class)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSetMetadataID() throws Exception {
- Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
- ElementImpl element = example("pm1.g1", "e1", metadataID); //$NON-NLS-1$ //$NON-NLS-2$
- Element elem = TstLanguageBridgeFactory.metadataFactory.getElement(metadataID);
- element.setMetadataObject(elem);
- assertNotNull(element.getMetadataObject());
- assertEquals(elem, element.getMetadataObject());
- }
-
- public void helpTestEquals(IElement e1, IElement e2, boolean equal) {
+ public void helpTestEquals(ColumnReference e1, ColumnReference e2, boolean equal) {
boolean actual = e1.equals(e2);
boolean actual2 = e2.equals(e1);
@@ -121,53 +103,12 @@
assertEquals("Did not get expected equal value", equal, actual); //$NON-NLS-1$
}
- public IGroup createGroup(String context, String definition) {
- return new GroupImpl(context, definition, null);
+ public NamedTable createGroup(String context, String definition) {
+ return new NamedTable(context, definition, null);
}
- public IElement createElement(IGroup group, String name) {
- return new ElementImpl(group, name, null, String.class);
+ public ColumnReference createElement(NamedTable group, String name) {
+ return new ColumnReference(group, name, null, String.class);
}
-
- public void testEquals1() {
- IElement e1 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestEquals(e1, e1, true);
- }
-
- public void testEquals2() {
- IElement e1 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IElement e2 = createElement(createGroup("a", "m.g"), "e2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestEquals(e1, e2, false);
- }
-
- public void testEquals3() {
- IElement e1 = createElement(createGroup("a", "m.g1"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IElement e2 = createElement(createGroup("a", "m.g2"), "e2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestEquals(e1, e2, false);
- }
-
- public void testEquals4() {
- IElement e1 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IElement e2 = createElement(createGroup("b", "m.g"), "e2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestEquals(e1, e2, false);
- }
-
- public void testEquals5() {
- IElement e1 = createElement(createGroup("m.g1", null), "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- IElement e2 = createElement(createGroup("m.g1", null), "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- helpTestEquals(e1, e2, true);
- }
-
- public void testEquals6() {
- IElement e1 = createElement(createGroup("a", "M.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IElement e2 = createElement(createGroup("a", "m.G"), "E1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestEquals(e1, e2, true);
- }
-
- public void testEquals7() {
- IElement e1 = createElement(createGroup("a", "m.g"), "m.g.e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IElement e2 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestEquals(e1, e2, true);
- }
-
+
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.ExistsCriteriaImpl;
+import org.teiid.connector.language.Exists;
+
import com.metamatrix.query.sql.lang.ExistsCriteria;
import junit.framework.TestCase;
@@ -41,16 +42,16 @@
}
public static ExistsCriteria helpExample() {
- ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample());
+ ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample(true));
return crit;
}
- public static ExistsCriteriaImpl example() throws Exception {
- return (ExistsCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static Exists example() throws Exception {
+ return (Exists)TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetQuery() throws Exception {
- assertNotNull(example().getQuery());
+ assertNotNull(example().getSubquery());
}
}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.IFromItem;
-import org.teiid.dqp.internal.datamgr.language.FromImpl;
-
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-
-import junit.framework.TestCase;
-
-public class TestFromImpl extends TestCase {
-
- /**
- * Constructor for TestFromImpl.
- * @param name
- */
- public TestFromImpl(String name) {
- super(name);
- }
-
- public static From helpExample() {
- List clauses = new ArrayList();
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
- return new From(clauses);
- }
-
- public static FromImpl example() throws Exception {
- return (FromImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
- }
-
- public void testGetItems() throws Exception {
- FromImpl from = example();
- assertNotNull(from.getItems());
- assertEquals(4, from.getItems().size());
- for (Iterator i = from.getItems().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IFromItem);
- }
- }
-
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,15 +24,13 @@
import java.util.List;
-import org.teiid.connector.language.IExpression;
-import org.teiid.dqp.internal.datamgr.language.FunctionImpl;
+import junit.framework.TestCase;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.Function;
+
import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import junit.framework.TestCase;
-
public class TestFunctionImpl extends TestCase {
/**
@@ -43,16 +41,16 @@
super(name);
}
- public static Function helpExample(String name) {
+ public static com.metamatrix.query.sql.symbol.Function helpExample(String name) {
Constant c1 = new Constant(new Integer(100));
Constant c2 = new Constant(new Integer(200));
- Function f = new Function(name, new Expression [] {c1, c2});
+ com.metamatrix.query.sql.symbol.Function f = new com.metamatrix.query.sql.symbol.Function(name, new com.metamatrix.query.sql.symbol.Expression[] {c1, c2});
f.setType(Integer.class);
return f;
}
- public static FunctionImpl example(String name) throws Exception {
- return (FunctionImpl)TstLanguageBridgeFactory.factory.translate(helpExample(name));
+ public static Function example(String name) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(name));
}
public void testGetName() throws Exception {
@@ -60,7 +58,7 @@
}
public void testGetParameters() throws Exception {
- List<IExpression> params = example("testFunction").getParameters(); //$NON-NLS-1$
+ List<Expression> params = example("testFunction").getParameters(); //$NON-NLS-1$
assertNotNull(params);
assertEquals(2, params.size());
for (int i = 0; i < params.size(); i++) {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,16 +26,15 @@
import java.util.Iterator;
import java.util.List;
-import org.teiid.connector.language.IElement;
-import org.teiid.dqp.internal.datamgr.language.GroupByImpl;
+import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.GroupBy;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.GroupBy;
+
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Function;
-import junit.framework.TestCase;
-
public class TestGroupByImpl extends TestCase {
/**
@@ -46,37 +45,37 @@
super(name);
}
- public static GroupBy helpExample() {
- List symbols = new ArrayList();
+ public static com.metamatrix.query.sql.lang.GroupBy helpExample() {
+ List<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
- return new GroupBy(symbols);
+ return new com.metamatrix.query.sql.lang.GroupBy(symbols);
}
- public static GroupBy helpExampleWithFunctions() {
- List symbols = new ArrayList();
+ public static com.metamatrix.query.sql.lang.GroupBy helpExampleWithFunctions() {
+ List<Expression> symbols = new ArrayList<Expression>();
ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1");//$NON-NLS-1$ //$NON-NLS-2$
Function f = new Function("length", new Expression[] { e1 } );//$NON-NLS-1$
symbols.add(e1);
symbols.add(f);
- return new GroupBy(symbols);
+ return new com.metamatrix.query.sql.lang.GroupBy(symbols);
}
- public static GroupByImpl example() throws Exception {
- return (GroupByImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static GroupBy example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetElements() throws Exception {
- GroupByImpl gb = example();
+ GroupBy gb = example();
assertNotNull(gb.getElements());
assertEquals(4, gb.getElements().size());
for (Iterator i = gb.getElements().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IElement);
+ assertTrue(i.next() instanceof ColumnReference);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.GroupImpl;
+import org.teiid.connector.language.NamedTable;
+
import junit.framework.TestCase;
import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -58,74 +59,26 @@
return symbol;
}
- public static GroupImpl example(String groupName) throws Exception {
+ public static NamedTable example(String groupName) throws Exception {
return example(groupName, null);
}
- public static GroupImpl example(String groupName, String definition) throws Exception {
- return (GroupImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition));
+ public static NamedTable example(String groupName, String definition) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition));
}
- public static GroupImpl example(String groupName, String definition, Object metadataID) throws Exception {
- return (GroupImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition, metadataID));
+ public static NamedTable example(String groupName, String definition, Object metadataID) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition, metadataID));
}
public void testGetContext() throws Exception {
Object metadataID = TstLanguageBridgeFactory.metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- assertEquals("x", example("x", "pm1.g1", metadataID).getContext()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("x", example("x", "pm1.g1", metadataID).getCorrelationName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testGetDefinition() throws Exception {
Object metadataID = TstLanguageBridgeFactory.metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- assertEquals("pm1.g1", example("x", "pm1.g1", metadataID).getDefinition()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("pm1.g1", example("x", "pm1.g1", metadataID).getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testEquals1() throws Exception {
- GroupImpl g1 = new GroupImpl("alias", "pm1.g1", null); //$NON-NLS-1$ //$NON-NLS-2$
- GroupImpl g2 = new GroupImpl("alias", "pm1.g1", null); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertEquals(g1,g2);
- }
-
- public void testEquals2() throws Exception {
- GroupImpl g1 = new GroupImpl("alias", "model.group1", null); //$NON-NLS-1$ //$NON-NLS-2$
- GroupImpl g2 = new GroupImpl("alias", "model.group2", null); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertEquals(g1,g2);
- }
-
- public void testEquals3() {
- GroupImpl g1 = new GroupImpl("alias1", "model.group", null); //$NON-NLS-1$ //$NON-NLS-2$
- GroupImpl g2 = new GroupImpl("alias2", "model.group", null); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue(! g1.equals(g2));
- }
-
- public void testEquals4() {
- GroupImpl g1 = new GroupImpl("alias1", "model.group", null); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertEquals(g1, g1);
- }
-
- public void testEquals5() {
- GroupImpl g1 = new GroupImpl("model.group", null, null); //$NON-NLS-1$
- GroupImpl g2 = new GroupImpl("model.group", null, null); //$NON-NLS-1$
-
- assertEquals(g1, g2);
- }
-
- public void testEquals6() {
- GroupImpl g1 = new GroupImpl("model.gRoUp", null, null); //$NON-NLS-1$
- GroupImpl g2 = new GroupImpl("MoDeL.group", null, null); //$NON-NLS-1$
-
- assertEquals(g1, g2);
- }
-
- public void testEquals7() {
- GroupImpl g1 = new GroupImpl("model.gRoUp", "alias", null); //$NON-NLS-1$ //$NON-NLS-2$
- GroupImpl g2 = new GroupImpl("MoDeL.group", null, null); //$NON-NLS-1$
-
- assertTrue(! g1.equals(g2));
- }
-
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,9 +26,9 @@
import java.util.Iterator;
import java.util.List;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.dqp.internal.datamgr.language.InCriteriaImpl;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.In;
import com.metamatrix.query.sql.lang.SetCriteria;
@@ -55,15 +55,15 @@
return crit;
}
- public static InCriteriaImpl example(boolean negated) throws Exception {
- return (InCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
+ public static In example(boolean negated) throws Exception {
+ return (In)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
}
public void testGetLeftExpression() throws Exception {
- InCriteriaImpl inCriteria = example(false);
+ In inCriteria = example(false);
assertNotNull(inCriteria.getLeftExpression());
- assertTrue(inCriteria.getLeftExpression() instanceof ILiteral);
- assertEquals(new Integer(300), ((ILiteral)inCriteria.getLeftExpression()).getValue());
+ assertTrue(inCriteria.getLeftExpression() instanceof Literal);
+ assertEquals(new Integer(300), ((Literal)inCriteria.getLeftExpression()).getValue());
}
public void testGetRightExpressions() throws Exception {
@@ -71,7 +71,7 @@
assertNotNull(values);
assertEquals(4, values.size());
for (Iterator i = values.iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IExpression);
+ assertTrue(i.next() instanceof Expression);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.InlineViewImpl;
+import org.teiid.connector.language.DerivedTable;
+
import com.metamatrix.query.sql.lang.SubqueryFromClause;
import junit.framework.TestCase;
@@ -35,19 +36,19 @@
}
public static SubqueryFromClause helpExample() {
- return new SubqueryFromClause("xyz", TestQueryImpl.helpExample()); //$NON-NLS-1$
+ return new SubqueryFromClause("xyz", TestQueryImpl.helpExample(true)); //$NON-NLS-1$
}
- public static InlineViewImpl example() throws Exception {
- return (InlineViewImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static DerivedTable example() throws Exception {
+ return (DerivedTable)TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetName() throws Exception {
- assertEquals("xyz", example().getName()); //$NON-NLS-1$
+ assertEquals("xyz", example().getCorrelationName()); //$NON-NLS-1$
}
public void testGetQuery() throws Exception {
- assertEquals("SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE (100 >= 200) AND (500 < 600) GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING (100 >= 200) AND (500 < 600) ORDER BY e1, e2 DESC, e3, e4 DESC", example().getQuery().toString()); //$NON-NLS-1$
+ assertEquals("SELECT DISTINCT vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 FROM vm1.g1, vm1.g2 AS myAlias, vm1.g3, vm1.g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC", example().getQuery().toString()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,16 +25,17 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.dqp.internal.datamgr.language.InsertImpl;
+import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.Insert;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.Insert;
+
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import junit.framework.TestCase;
-
public class TestInsertImpl extends TestCase {
/**
@@ -45,26 +46,26 @@
super(name);
}
- public static Insert helpExample(String groupName) {
+ public static com.metamatrix.query.sql.lang.Insert helpExample(String groupName) {
GroupSymbol group = TestGroupImpl.helpExample(groupName);
- ArrayList elements = new ArrayList();
+ ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e2")); //$NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e3")); //$NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e4")); //$NON-NLS-1$
- ArrayList values = new ArrayList();
+ ArrayList<Constant> values = new ArrayList<Constant>();
values.add(TestLiteralImpl.helpExample(1));
values.add(TestLiteralImpl.helpExample(2));
values.add(TestLiteralImpl.helpExample(3));
values.add(TestLiteralImpl.helpExample(4));
- return new Insert(group,
+ return new com.metamatrix.query.sql.lang.Insert(group,
elements,
values);
}
- public static Insert helpExample2(String groupName) {
+ public static com.metamatrix.query.sql.lang.Insert helpExample2(String groupName) {
GroupSymbol group = TestGroupImpl.helpExample(groupName);
ArrayList elements = new ArrayList();
elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
@@ -72,56 +73,56 @@
ArrayList values = new ArrayList();
values.add(TestSearchedCaseExpressionImpl.helpExample());
- return new Insert(group,
+ return new com.metamatrix.query.sql.lang.Insert(group,
elements,
values);
}
- public static InsertImpl example(String groupName) throws Exception {
- return (InsertImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName));
+ public static Insert example(String groupName) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(groupName));
}
- public static InsertImpl example2(String groupName) throws Exception {
- return (InsertImpl)TstLanguageBridgeFactory.factory.translate(helpExample2(groupName));
+ public static Insert example2(String groupName) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample2(groupName));
}
public void testGetGroup() throws Exception {
- assertNotNull(example("a.b").getGroup()); //$NON-NLS-1$
+ assertNotNull(example("a.b").getTable()); //$NON-NLS-1$
}
public void testGetElements() throws Exception {
- InsertImpl insert = example("a.b"); //$NON-NLS-1$
- assertNotNull(insert.getElements());
- assertEquals(4, insert.getElements().size());
- for (Iterator i = insert.getElements().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IElement);
+ Insert insert = example("a.b"); //$NON-NLS-1$
+ assertNotNull(insert.getColumns());
+ assertEquals(4, insert.getColumns().size());
+ for (Iterator i = insert.getColumns().iterator(); i.hasNext();) {
+ assertTrue(i.next() instanceof ColumnReference);
}
// verify that elements are not qualified by group
String sInsertSQL = insert.toString();
- assertTrue(sInsertSQL.indexOf( '.') == -1 );
+ assertTrue(sInsertSQL.substring(sInsertSQL.indexOf('(')).indexOf( '.') == -1 );
}
public void testGetValues() throws Exception {
- InsertImpl insert = example("a.b"); //$NON-NLS-1$
+ Insert insert = example("a.b"); //$NON-NLS-1$
assertNotNull(insert.getValueSource());
- assertEquals(4, ((IInsertExpressionValueSource)insert.getValueSource()).getValues().size());
- for (Iterator i = ((IInsertExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IExpression);
+ assertEquals(4, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
+ for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
+ assertTrue(i.next() instanceof Expression);
}
}
public void testExpressionsInInsert() throws Exception {
- InsertImpl insert = example2("a.b"); //$NON-NLS-1$
- assertNotNull(insert.getElements());
- assertEquals(1, insert.getElements().size());
- for (Iterator i = insert.getElements().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IElement);
+ Insert insert = example2("a.b"); //$NON-NLS-1$
+ assertNotNull(insert.getColumns());
+ assertEquals(1, insert.getColumns().size());
+ for (Iterator i = insert.getColumns().iterator(); i.hasNext();) {
+ assertTrue(i.next() instanceof ColumnReference);
}
assertNotNull(insert.getValueSource());
- assertEquals(1, ((IInsertExpressionValueSource)insert.getValueSource()).getValues().size());
- for (Iterator i = ((IInsertExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IExpression);
+ assertEquals(1, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
+ for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
+ assertTrue(i.next() instanceof Expression);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.IsNullCriteriaImpl;
+import org.teiid.connector.language.IsNull;
+
import com.metamatrix.query.sql.lang.IsNullCriteria;
import junit.framework.TestCase;
@@ -39,13 +40,13 @@
}
public static IsNullCriteria helpExample(boolean negated) {
- IsNullCriteria crit = new IsNullCriteria(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
+ IsNullCriteria crit = new IsNullCriteria(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
crit.setNegated(negated);
return crit;
}
- public static IsNullCriteriaImpl example(boolean negated) throws Exception {
- return (IsNullCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
+ public static IsNull example(boolean negated) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(negated));
}
public void testGetExpression() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,19 +23,18 @@
package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
-import java.util.Iterator;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.dqp.internal.datamgr.language.JoinImpl;
+import junit.framework.TestCase;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Join;
+
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.JoinPredicate;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.UnaryFromClause;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import junit.framework.TestCase;
-
public class TestJoinImpl extends TestCase {
/**
@@ -57,8 +56,8 @@
criteria);
}
- public static JoinImpl example(JoinType type) throws Exception {
- return (JoinImpl)TstLanguageBridgeFactory.factory.translate(helpExample(type));
+ public static Join example(JoinType type) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(type));
}
public void testGetLeftItem() throws Exception {
@@ -70,20 +69,16 @@
}
public void testGetJoinType() throws Exception {
- assertEquals(org.teiid.connector.language.IJoin.JoinType.CROSS_JOIN, example(JoinType.JOIN_CROSS).getJoinType());
- assertEquals(org.teiid.connector.language.IJoin.JoinType.FULL_OUTER_JOIN, example(JoinType.JOIN_FULL_OUTER).getJoinType());
- assertEquals(org.teiid.connector.language.IJoin.JoinType.INNER_JOIN, example(JoinType.JOIN_INNER).getJoinType());
- assertEquals(org.teiid.connector.language.IJoin.JoinType.LEFT_OUTER_JOIN, example(JoinType.JOIN_LEFT_OUTER).getJoinType());
- assertEquals(org.teiid.connector.language.IJoin.JoinType.RIGHT_OUTER_JOIN, example(JoinType.JOIN_RIGHT_OUTER).getJoinType());
+ assertEquals(Join.JoinType.CROSS_JOIN, example(JoinType.JOIN_CROSS).getJoinType());
+ assertEquals(Join.JoinType.FULL_OUTER_JOIN, example(JoinType.JOIN_FULL_OUTER).getJoinType());
+ assertEquals(Join.JoinType.INNER_JOIN, example(JoinType.JOIN_INNER).getJoinType());
+ assertEquals(Join.JoinType.LEFT_OUTER_JOIN, example(JoinType.JOIN_LEFT_OUTER).getJoinType());
+ assertEquals(Join.JoinType.RIGHT_OUTER_JOIN, example(JoinType.JOIN_RIGHT_OUTER).getJoinType());
}
public void testGetCriteria() throws Exception {
- JoinImpl join = example(JoinType.JOIN_INNER);
- assertNotNull(join.getCriteria());
- assertEquals(1, join.getCriteria().size());
- for (Iterator i = join.getCriteria().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof ICriteria);
- }
+ Join join = example(JoinType.JOIN_INNER);
+ assertTrue(join.getCondition() instanceof Comparison);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,8 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.dqp.internal.datamgr.language.LikeCriteriaImpl;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.Like;
import com.metamatrix.query.sql.lang.MatchCriteria;
import com.metamatrix.query.sql.symbol.Constant;
@@ -48,8 +48,8 @@
return match;
}
- public static LikeCriteriaImpl example(String right, char escape, boolean negated) throws Exception {
- return (LikeCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(right, escape, negated));
+ public static Like example(String right, char escape, boolean negated) throws Exception {
+ return (Like)TstLanguageBridgeFactory.factory.translate(helpExample(right, escape, negated));
}
public void testGetLeftExpression() throws Exception {
@@ -57,10 +57,10 @@
}
public void testGetRightExpression() throws Exception {
- LikeCriteriaImpl like = example("abc", '.', false); //$NON-NLS-1$
+ Like like = example("abc", '.', false); //$NON-NLS-1$
assertNotNull(like.getRightExpression());
- assertTrue(like.getRightExpression() instanceof ILiteral);
- assertEquals("abc", ((ILiteral)like.getRightExpression()).getValue()); //$NON-NLS-1$
+ assertTrue(like.getRightExpression() instanceof Literal);
+ assertEquals("abc", ((Literal)like.getRightExpression()).getValue()); //$NON-NLS-1$
}
public void testGetEscapeCharacter() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
+import org.teiid.connector.language.Literal;
+
import com.metamatrix.query.sql.symbol.Constant;
import junit.framework.TestCase;
@@ -46,14 +47,14 @@
return new Constant(val);
}
- public static LiteralImpl example(int val) {
+ public static Literal example(int val) {
Constant c = helpExample(val);
- return new LiteralImpl(c.getValue(), c.getType());
+ return new Literal(c.getValue(), c.getType());
}
- public static LiteralImpl example(Object val) {
+ public static Literal example(Object val) {
Constant c = helpExample(val);
- return new LiteralImpl(c.getValue(), c.getType());
+ return new Literal(c.getValue(), c.getType());
}
public void testGetValue() {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.NotCriteriaImpl;
+import org.teiid.connector.language.Not;
+
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.NotCriteria;
@@ -43,8 +44,8 @@
return new NotCriteria(TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200));
}
- public static NotCriteriaImpl example() throws Exception {
- return (NotCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static Not example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetCriteria() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,13 +26,11 @@
import java.util.Iterator;
import java.util.List;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.dqp.internal.datamgr.language.OrderByImpl;
-
-import com.metamatrix.query.sql.lang.OrderBy;
-
import junit.framework.TestCase;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.SortSpecification;
+
public class TestOrderByImpl extends TestCase {
/**
@@ -43,7 +41,7 @@
super(name);
}
- public static OrderBy helpExample() {
+ public static com.metamatrix.query.sql.lang.OrderBy helpExample() {
ArrayList elements = new ArrayList();
elements.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
elements.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -55,19 +53,19 @@
types.add(Boolean.FALSE);
types.add(Boolean.TRUE);
types.add(Boolean.FALSE);
- return new OrderBy(elements, types);
+ return new com.metamatrix.query.sql.lang.OrderBy(elements, types);
}
- public static OrderByImpl example() throws Exception {
- return (OrderByImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static OrderBy example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetItems() throws Exception {
- List items = example().getItems();
+ List items = example().getSortSpecifications();
assertNotNull(items);
assertEquals(4, items.size());
for (Iterator i = items.iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IOrderByItem);
+ assertTrue(i.next() instanceof SortSpecification);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,12 @@
package org.teiid.dqp.internal.datamgr.language;
-import java.sql.ResultSet;
-
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.dqp.internal.datamgr.language.ParameterImpl;
-import org.teiid.dqp.internal.datamgr.language.ProcedureImpl;
-
-
import junit.framework.TestCase;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.Argument.Direction;
+
public class TestParameterImpl extends TestCase {
/**
@@ -41,48 +38,24 @@
super(name);
}
- public static ParameterImpl example(int index) throws Exception {
- ProcedureImpl procImpl = TestProcedureImpl.example();
- return (ParameterImpl) procImpl.getParameters().get(index);
+ public static Argument example(int index) throws Exception {
+ Call procImpl = TestProcedureImpl.example();
+ return procImpl.getArguments().get(index);
}
- public void testGetIndex() throws Exception {
- assertEquals(2, example(1).getIndex());
- }
-
public void testGetDirection() throws Exception {
- assertEquals(Direction.RESULT_SET, example(0).getDirection());
+ assertEquals(Direction.IN, example(0).getDirection());
assertEquals(Direction.IN, example(1).getDirection());
- assertEquals(Direction.IN, example(2).getDirection());
}
public void testGetType() throws Exception {
- assertTrue(example(0).getType().equals(ResultSet.class));
- assertTrue(example(1).getType().equals(String.class));
- assertTrue(example(2).getType().equals(Integer.class));
+ assertTrue(example(0).getType().equals(String.class));
+ assertTrue(example(1).getType().equals(Integer.class));
}
public void testGetValue() throws Exception {
- assertEquals("x", example(1).getValue()); //$NON-NLS-1$
- assertEquals(new Integer(1), example(2).getValue());
+ assertEquals("x", example(0).getArgumentValue().getValue()); //$NON-NLS-1$
+ assertEquals(new Integer(1), example(1).getArgumentValue().getValue());
}
- public void testGetValueSpecified() throws Exception {
- assertEquals(false, example(0).getValueSpecified());
-
- ParameterImpl param = new ParameterImpl(1, Direction.IN, null, String.class, null);
- // Test construction state (null value)
- assertEquals(false, param.getValueSpecified());
- // Test value specified not set on null
- param.setValue(null);
- assertEquals(false, param.getValueSpecified());
- // Test value specified is set on actual value
- param.setValue("RINGTAIL LEMUR"); //$NON-NLS-1$
- assertEquals(true, param.getValueSpecified());
- // Test value specified override
- param.setValueSpecified(false);
- assertEquals(false, param.getValueSpecified());
- }
-
-
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,18 +22,15 @@
package org.teiid.dqp.internal.datamgr.language;
-import java.util.Collections;
-import java.util.Iterator;
+import junit.framework.TestCase;
-import org.teiid.connector.language.IParameter;
-import org.teiid.dqp.internal.datamgr.language.ProcedureImpl;
+import org.teiid.connector.language.Call;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.*;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.StoredProcedure;
-import junit.framework.TestCase;
-
public class TestProcedureImpl extends TestCase {
/**
@@ -42,14 +39,13 @@
*/
public TestProcedureImpl(String name) {
super(name);
- System.setProperty("metamatrix.config.none", "true");
}
- public static ProcedureImpl example() throws Exception {
+ public static Call example() throws Exception {
String sql = "EXEC pm1.sq3('x', 1)"; //$NON-NLS-1$
Command command = new QueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, TstLanguageBridgeFactory.metadata);
- return (ProcedureImpl)TstLanguageBridgeFactory.factory.translate((StoredProcedure)command);
+ return TstLanguageBridgeFactory.factory.translate((StoredProcedure)command);
}
public void testGetProcedureName() throws Exception {
@@ -57,24 +53,9 @@
}
public void testGetParameters() throws Exception {
- ProcedureImpl exec = example();
- assertNotNull(exec.getParameters());
- assertEquals(3, exec.getParameters().size());
- for (Iterator i = exec.getParameters().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof IParameter);
- }
+ Call exec = example();
+ assertNotNull(exec.getArguments());
+ assertEquals(2, exec.getArguments().size());
}
- public void testEquals1() {
- ProcedureImpl proc1 = new ProcedureImpl("proc1", Collections.EMPTY_LIST, null); //$NON-NLS-1$
- ProcedureImpl proc2 = new ProcedureImpl("proc1", Collections.EMPTY_LIST, null); //$NON-NLS-1$
- assertEquals(proc1, proc2);
- }
-
- public void testEquals2() {
- ProcedureImpl proc1 = new ProcedureImpl("proc1", Collections.EMPTY_LIST, null); //$NON-NLS-1$
- ProcedureImpl proc2 = new ProcedureImpl("proc2", Collections.EMPTY_LIST, null); //$NON-NLS-1$
- assertTrue(! proc1.equals(proc2));
- }
-
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,14 +22,22 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.QueryImpl;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.Select;
+
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.UnaryFromClause;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
-import junit.framework.TestCase;
-
public class TestQueryImpl extends TestCase {
/**
@@ -39,10 +47,21 @@
public TestQueryImpl(String name) {
super(name);
}
+
+ public static com.metamatrix.query.sql.lang.Select helpExampleSelect(boolean distinct) {
+ ArrayList<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
+ com.metamatrix.query.sql.lang.Select sel = new com.metamatrix.query.sql.lang.Select(symbols);
+ sel.setDistinct(distinct);
+ return sel;
+ }
- public static Query helpExample() {
- return new Query(TestSelectImpl.helpExample(true),
- TestFromImpl.helpExample(),
+ public static Query helpExample(boolean distinct) {
+ return new Query(helpExampleSelect(distinct),
+ TestQueryImpl.helpExampleFrom(),
TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
TestGroupByImpl.helpExample(),
TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
@@ -50,44 +69,67 @@
null);
}
- public static QueryImpl example() throws Exception {
- return (QueryImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static Select example(boolean distinct) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
}
public void testGetSelect() throws Exception {
- assertNotNull(example().getSelect());
+ assertNotNull(example(true).getDerivedColumns());
}
public void testGetFrom() throws Exception {
- assertNotNull(example().getFrom());
+ assertNotNull(example(true).getFrom());
}
public void testGetWhere() throws Exception {
- assertNotNull(example().getWhere());
+ assertNotNull(example(true).getWhere());
}
public void testGetGroupBy() throws Exception {
- assertNotNull(example().getGroupBy());
+ assertNotNull(example(true).getGroupBy());
}
public void testGetHaving() throws Exception {
- assertNotNull(example().getHaving());
+ assertNotNull(example(true).getHaving());
}
public void testGetOrderBy() throws Exception {
- assertNotNull(example().getOrderBy());
+ assertNotNull(example(true).getOrderBy());
}
public void testGetColumnNames() throws Exception {
- String[] expected = {"e1", "e2", "e3", "e4"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- String[] names = example().getColumnNames();
+ String[] expected = new String[4];
+ String[] names = example(true).getColumnNames();
assertTrue(EquivalenceUtil.areEquivalent(expected, names));
}
public void testGetColumnTypes() throws Exception {
Class[] expected = {String.class, String.class, String.class, String.class};
- Class[] types = example().getColumnTypes();
+ Class[] types = example(true).getColumnTypes();
assertTrue(EquivalenceUtil.areEquivalent(expected, types));
}
+ public static com.metamatrix.query.sql.lang.From helpExampleFrom() {
+ List<UnaryFromClause> clauses = new ArrayList<UnaryFromClause>();
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
+ return new com.metamatrix.query.sql.lang.From(clauses);
+ }
+
+ public void testGetSelectSymbols() throws Exception {
+ List symbols = example(false).getDerivedColumns();
+ assertNotNull(symbols);
+ assertEquals(4, symbols.size());
+ for (Iterator i = symbols.iterator(); i.hasNext();) {
+ assertTrue(i.next() instanceof DerivedColumn);
+ }
+ }
+
+ public void testIsDistinct() throws Exception {
+ assertTrue(example(true).isDistinct());
+ assertFalse(example(false).isDistinct());
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,14 +22,12 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.dqp.internal.datamgr.language.ScalarSubqueryImpl;
-
import junit.framework.TestCase;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.ScalarSubquery;
+
import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
/**
@@ -44,24 +42,23 @@
super(name);
}
- public static ScalarSubquery helpExample() {
- Query query = TestQueryImpl.helpExample();
- ScalarSubquery ss = new ScalarSubquery(query);
+ public static com.metamatrix.query.sql.symbol.ScalarSubquery helpExample() {
+ Query query = TestQueryImpl.helpExample(true);
+ com.metamatrix.query.sql.symbol.ScalarSubquery ss = new com.metamatrix.query.sql.symbol.ScalarSubquery(query);
ss.setType(((SingleElementSymbol)query.getProjectedSymbols().get(0)).getType());
return ss;
}
- public static ScalarSubqueryImpl example() throws Exception {
- return (ScalarSubqueryImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static ScalarSubquery example() throws Exception {
+ return (ScalarSubquery)TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetQuery() throws Exception {
- assertNotNull(example().getQuery()); }
+ assertNotNull(example().getSubquery()); }
public void testGetType() throws Exception {
- IQuery query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample());
- Class firstSymbolType = ((ISelectSymbol) query.getSelect().getSelectSymbols().get(0)).getExpression().getType();
-
+ Select query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample(true));
+ Class<?> firstSymbolType = query.getDerivedColumns().get(0).getExpression().getType();
assertEquals("Got incorrect type", firstSymbolType, example().getType()); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,8 +25,9 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.dqp.internal.datamgr.language.SearchedCaseExpressionImpl;
+import org.teiid.connector.language.SearchedCase;
+
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -60,8 +61,8 @@
return caseExpr;
}
- public static SearchedCaseExpressionImpl example() throws Exception {
- return (SearchedCaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static SearchedCase example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetElseExpression() throws Exception {
@@ -72,19 +73,19 @@
}
public void testGetThenExpression() throws Exception {
- assertNotNull(example().getThenExpression(0));
- assertNotNull(example().getThenExpression(1));
- assertNotNull(example().getThenExpression(2));
+ assertNotNull(example().getCases().get(0));
+ assertNotNull(example().getCases().get(1));
+ assertNotNull(example().getCases().get(2));
}
public void testGetWhenCount() throws Exception {
- assertEquals(3, example().getWhenCount());
+ assertEquals(3, example().getCases().size());
}
public void testGetWhenCriteria() throws Exception {
- assertNotNull(example().getWhenCriteria(0));
- assertNotNull(example().getWhenCriteria(1));
- assertNotNull(example().getWhenCriteria(2));
+ assertNotNull(example().getCases().get(0));
+ assertNotNull(example().getCases().get(1));
+ assertNotNull(example().getCases().get(2));
}
}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.dqp.internal.datamgr.language.SelectImpl;
-
-import com.metamatrix.query.sql.lang.Select;
-
-import junit.framework.TestCase;
-
-public class TestSelectImpl extends TestCase {
-
- /**
- * Constructor for TestSelectImpl.
- * @param name
- */
- public TestSelectImpl(String name) {
- super(name);
- }
-
- public static Select helpExample(boolean distinct) {
- ArrayList symbols = new ArrayList();
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
- Select sel = new Select(symbols);
- sel.setDistinct(distinct);
- return sel;
- }
-
- public static SelectImpl example(boolean distinct) throws Exception {
- return (SelectImpl)TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
- }
-
- public void testGetSelectSymbols() throws Exception {
- List symbols = example(false).getSelectSymbols();
- assertNotNull(symbols);
- assertEquals(4, symbols.size());
- for (Iterator i = symbols.iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof ISelectSymbol);
- }
- }
-
- public void testIsDistinct() throws Exception {
- assertTrue(example(true).isDistinct());
- assertFalse(example(false).isDistinct());
- }
-
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,12 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.IExpression;
-import org.teiid.dqp.internal.datamgr.language.SelectSymbolImpl;
+import junit.framework.TestCase;
-import com.metamatrix.query.sql.symbol.*;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
-import junit.framework.TestCase;
+import com.metamatrix.common.types.DataTypeManager;
public class TestSelectSymbolImpl extends TestCase {
@@ -39,39 +39,18 @@
super(name);
}
- public static Expression helpExample(String name, String alias) {
- SingleElementSymbol symbol = TestElementImpl.helpExample("vm1.g1", name); //$NON-NLS-1$
-
- if (alias != null) {
- return new AliasSymbol(alias, symbol);
- }
- return symbol;
- }
-
- public static SelectSymbolImpl example(String symbolName, String alias) throws Exception {
- Expression expr = helpExample(symbolName, alias);
- IExpression iExp = TstLanguageBridgeFactory.factory.translate(expr);
- String name = null;
- if (expr instanceof Function) {
- name = ((Function)expr).getName();
- }else if (expr instanceof SingleElementSymbol) {
- name = ((SingleElementSymbol)expr).getName();
- }
- SelectSymbolImpl selectSymbol = new SelectSymbolImpl(name, iExp);
- if(expr instanceof AliasSymbol){
- selectSymbol.setAlias(true);
- }
+ public static DerivedColumn example(String symbolName, String alias) throws Exception {
+ DerivedColumn selectSymbol = new DerivedColumn(alias, new ColumnReference(null, symbolName, null, DataTypeManager.DefaultDataClasses.INTEGER));
return selectSymbol;
}
public void testHasAlias() throws Exception {
- assertTrue(example("testName", "testAlias").hasAlias()); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse(example("testName", null).hasAlias()); //$NON-NLS-1$
+ assertNotNull(example("testName", "testAlias").getAlias()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNull(example("testName", null).getAlias()); //$NON-NLS-1$
}
public void testGetOutputName() throws Exception {
- assertEquals("testName", example("testName", null).getOutputName()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("testAlias", example("testName", "testAlias").getOutputName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("testAlias", example("testName", "testAlias").getAlias()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testGetExpression() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,27 +25,17 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.dqp.internal.datamgr.language.ElementImpl;
-import org.teiid.dqp.internal.datamgr.language.FromImpl;
-import org.teiid.dqp.internal.datamgr.language.GroupImpl;
-import org.teiid.dqp.internal.datamgr.language.OrderByImpl;
-import org.teiid.dqp.internal.datamgr.language.OrderByItemImpl;
-import org.teiid.dqp.internal.datamgr.language.QueryImpl;
-import org.teiid.dqp.internal.datamgr.language.SelectImpl;
-import org.teiid.dqp.internal.datamgr.language.SelectSymbolImpl;
-import org.teiid.dqp.internal.datamgr.language.SetQueryImpl;
-
import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetQuery;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SortSpecification.Ordering;
+
import com.metamatrix.query.sql.lang.SetQuery.Operation;
@@ -54,57 +44,43 @@
*/
public class TestSetQueryImpl extends TestCase {
- public static Query helpExampleQuery() {
- return new Query(TestSelectImpl.helpExample(true),
- TestFromImpl.helpExample(),
- TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
- TestGroupByImpl.helpExample(),
- TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
- TestOrderByImpl.helpExample(),
- null);
- }
-
- public static SetQuery helpExampleSetQuery() {
- SetQuery setQuery = new SetQuery(Operation.UNION);
+ public static com.metamatrix.query.sql.lang.SetQuery helpExampleSetQuery() {
+ com.metamatrix.query.sql.lang.SetQuery setQuery = new com.metamatrix.query.sql.lang.SetQuery(Operation.UNION);
setQuery.setAll(false);
- setQuery.setLeftQuery(helpExampleQuery());
- setQuery.setRightQuery(helpExampleQuery());
+ setQuery.setLeftQuery(TestQueryImpl.helpExample(true));
+ setQuery.setRightQuery(TestQueryImpl.helpExample(true));
setQuery.setOrderBy(TestOrderByImpl.helpExample());
return setQuery;
}
- public static SetQueryImpl example() throws Exception {
- return (SetQueryImpl)TstLanguageBridgeFactory.factory.translate(helpExampleSetQuery());
+ public static SetQuery example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExampleSetQuery());
}
- public static ISetQuery example2() throws Exception {
- IGroup group = new GroupImpl("ted", null, null); //$NON-NLS-1$
- IElement element = new ElementImpl(group, "nugent", null, String.class); //$NON-NLS-1$
- ISelectSymbol symbol = new SelectSymbolImpl("nugent",element); //$NON-NLS-1$
+ public static SetQuery example2() throws Exception {
+ NamedTable group = new NamedTable("ted", null, null); //$NON-NLS-1$
+ ColumnReference element = new ColumnReference(group, "nugent", null, String.class); //$NON-NLS-1$
+ DerivedColumn symbol = new DerivedColumn("nugent",element); //$NON-NLS-1$
List symbols = new ArrayList();
symbols.add(symbol);
- SelectImpl select = new SelectImpl(symbols, false);
List items = new ArrayList();
items.add(group);
- FromImpl from = new FromImpl(items);
- IGroup group2 = new GroupImpl("dave", null, null); //$NON-NLS-1$
- IElement element2 = new ElementImpl(group2, "barry", null, String.class); //$NON-NLS-1$
- ISelectSymbol symbol2 = new SelectSymbolImpl("barry", element2); //$NON-NLS-1$
+ NamedTable group2 = new NamedTable("dave", null, null); //$NON-NLS-1$
+ ColumnReference element2 = new ColumnReference(group2, "barry", null, String.class); //$NON-NLS-1$
+ DerivedColumn symbol2 = new DerivedColumn("barry", element2); //$NON-NLS-1$
List symbols2 = new ArrayList();
symbols2.add(symbol2);
- SelectImpl select2 = new SelectImpl(symbols2, false);
List items2 = new ArrayList();
items2.add(group2);
- FromImpl from2 = new FromImpl(items2);
- IQuery secondQuery = new QueryImpl(select2, from2, null, null, null, null);
+ Select secondQuery = new Select(symbols2, false, items2, null, null, null, null);
- IQuery query = new QueryImpl(select, from, null, null, null, null);
+ Select query = new Select(symbols, false, items, null, null, null, null);
- ISetQuery setQuery = new SetQueryImpl();
- setQuery.setOperation(ISetQuery.Operation.UNION);
+ SetQuery setQuery = new SetQuery();
+ setQuery.setOperation(SetQuery.Operation.UNION);
setQuery.setAll(true);
setQuery.setLeftQuery(query);
setQuery.setRightQuery(secondQuery);
@@ -112,27 +88,28 @@
return setQuery;
}
- public static ISetQuery example3() throws Exception {
- ISetQuery union = example2();
+ public static SetQuery example3() throws Exception {
+ SetQuery union = example2();
- List items = new ArrayList();
- IElement element = (IElement) ((ISelectSymbol) union.getProjectedQuery().getSelect().getSelectSymbols().get(0)).getExpression();
- items.add(new OrderByItemImpl("ted.nugent", IOrderByItem.ASC, element)); //$NON-NLS-1$
- OrderByImpl orderBy = new OrderByImpl(items);
+ List<SortSpecification> items = new ArrayList<SortSpecification>();
+ ColumnReference element = (ColumnReference) (union.getProjectedQuery().getDerivedColumns().get(0)).getExpression();
+ items.add(new SortSpecification(Ordering.ASC, element));
+ OrderBy orderBy = new OrderBy(items);
union.setOrderBy(orderBy);
return union;
}
public void testNestedSetQuery() throws Exception {
- SetQuery query = new SetQuery(SetQuery.Operation.EXCEPT, true, helpExampleQuery(), helpExampleQuery());
+ com.metamatrix.query.sql.lang.SetQuery query = new com.metamatrix.query.sql.lang.SetQuery(com.metamatrix.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleSetQuery(), helpExampleSetQuery());
- ISetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
-
+ SetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
+ assertTrue(setQuery.getLeftQuery() instanceof SetQuery);
+ assertTrue(setQuery.getRightQuery() instanceof SetQuery);
}
public void testGetSelect() throws Exception {
- assertNotNull(example().getProjectedQuery().getSelect());
+ assertNotNull(example().getProjectedQuery().getDerivedColumns());
}
public void testGetFrom() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,13 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ISubqueryCompareCriteria.Quantifier;
-import org.teiid.dqp.internal.datamgr.language.SubqueryCompareCriteriaImpl;
-
import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.CompareCriteria;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryComparison.Quantifier;
+
+import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -47,13 +47,13 @@
public static SubqueryCompareCriteria helpExample() {
ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- Query query = TestQueryImpl.helpExample();
- SubqueryCompareCriteria scc = new SubqueryCompareCriteria(element, query, CompareCriteria.GT, SubqueryCompareCriteria.ANY);
+ Query query = TestQueryImpl.helpExample(true);
+ SubqueryCompareCriteria scc = new SubqueryCompareCriteria(element, query, AbstractCompareCriteria.GT, SubqueryCompareCriteria.ANY);
return scc;
}
- public static SubqueryCompareCriteriaImpl example() throws Exception {
- return (SubqueryCompareCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static SubqueryComparison example() throws Exception {
+ return (SubqueryComparison)TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetExpression() throws Exception {
@@ -61,11 +61,11 @@
}
public void testGetQuery() throws Exception {
- assertNotNull(example().getQuery());
+ assertNotNull(example().getSubquery());
}
public void testOperator() throws Exception {
- assertEquals("Wrong operator", ICompareCriteria.Operator.GT, example().getOperator()); //$NON-NLS-1$
+ assertEquals("Wrong operator", Comparison.Operator.GT, example().getOperator()); //$NON-NLS-1$
}
public void testQuantifier() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.SubqueryInCriteriaImpl;
+import org.teiid.connector.language.SubqueryIn;
+
import junit.framework.TestCase;
import com.metamatrix.query.sql.lang.Query;
@@ -44,14 +45,14 @@
public static SubquerySetCriteria helpExample() {
ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- Query query = TestQueryImpl.helpExample();
+ Query query = TestQueryImpl.helpExample(true);
SubquerySetCriteria ssc = new SubquerySetCriteria(element, query);
ssc.setNegated(true);
return ssc;
}
- public static SubqueryInCriteriaImpl example() throws Exception {
- return (SubqueryInCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static SubqueryIn example() throws Exception {
+ return (SubqueryIn)TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetExpression() throws Exception {
@@ -59,7 +60,7 @@
}
public void testGetQuery() throws Exception {
- assertNotNull(example().getQuery());
+ assertNotNull(example().getSubquery());
}
public void testIsNegated() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,12 +24,11 @@
import java.util.List;
-import org.teiid.dqp.internal.datamgr.language.UpdateImpl;
-
import junit.framework.TestCase;
+import org.teiid.connector.language.Update;
+
import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Update;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -43,9 +42,9 @@
super(name);
}
- public static Update helpExample() {
+ public static com.metamatrix.query.sql.lang.Update helpExample() {
GroupSymbol group = TestGroupImpl.helpExample("vm1.g1"); //$NON-NLS-1$
- Update result = new Update();
+ com.metamatrix.query.sql.lang.Update result = new com.metamatrix.query.sql.lang.Update();
result.setGroup(group);
result.addChange(TestElementImpl.helpExample("vm1.g1", "e1"), new Constant(new Integer(1)));
result.addChange(TestElementImpl.helpExample("vm1.g1", "e2"), new Constant(new Integer(1)));
@@ -55,22 +54,22 @@
return result;
}
- public static UpdateImpl example() throws Exception {
- return (UpdateImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static Update example() throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample());
}
public void testGetGroup() throws Exception {
- assertNotNull(example().getGroup());
+ assertNotNull(example().getTable());
}
public void testGetChanges() throws Exception {
- List changes = example().getChanges().getClauses();
+ List changes = example().getChanges();
assertNotNull(changes);
assertEquals(4, changes.size());
}
public void testGetCriteria() throws Exception {
- assertNotNull(example().getCriteria());
+ assertNotNull(example().getWhere());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,7 +22,6 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.query.unittest.FakeMetadataFacade;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -37,7 +37,6 @@
public class TestMetadataFactory extends TestCase {
private RuntimeMetadataImpl metadataFactory;
private FakeMetadataObject pm1g1;
- private FakeMetadataObject pm1g1e1;
public TestMetadataFactory(String name) {
super(name);
@@ -49,38 +48,11 @@
List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- pm1g1e1 = (FakeMetadataObject)pm1g1e.get(0);
store.addObject(pm1g1);
store.addObjects(pm1g1e);
metadataFactory = new RuntimeMetadataImpl(new FakeMetadataFacade(store));
}
- //tests
-
- public void testCreateMetadataID() throws Exception {
- //test create MetadataID for Group
- GroupImpl gID = metadataFactory.getGroup(pm1g1);
- assertEquals(gID.getActualID(), pm1g1);
- assertEquals(((ElementImpl)gID.getChildren().get(0)).getActualID(), pm1g1e1);
-
- //test create MetadataID for Element
- ElementImpl eID = metadataFactory.getElement(pm1g1e1);
- assertEquals(eID.getActualID(), pm1g1e1);
- assertEquals(((GroupImpl)eID.getParent()).getActualID(), pm1g1);
- }
-
- public void testRuntimeMetadata() throws Exception {
- GroupImpl group = metadataFactory.getGroup(pm1g1);
- assertEquals(group.getNameInSource(), "g1"); //$NON-NLS-1$
- assertEquals(group.getActualID(), pm1g1);
-
- ElementImpl element = metadataFactory.getElement(pm1g1e1);
- assertEquals(element.getLength(), 100);
- assertEquals(element.getJavaType(), DataTypeManager.DefaultDataClasses.STRING);
- assertEquals("e1", element.getNameInSource()); //$NON-NLS-1$
- assertEquals(element.getActualID(), pm1g1e1);
- }
-
public void testGetVDBResourcePaths() throws Exception {
String[] expectedPaths = new String[] {"my/resource/path"}; //$NON-NLS-1$
String[] mfPaths = metadataFactory.getVDBResourcePaths();
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.pooling.connector;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.Execution;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.basic.BasicConnection;
-import org.teiid.connector.basic.BasicConnector;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-
-/**
- */
-public class FakeSourceConnectionFactory extends BasicConnector {
- static int connCnt;
-
- static boolean alive = true;
-
- class FakeSourceConnection extends BasicConnection {
- int id;
-
- FakeSourceConnection(int id){
- FakeSourceConnection.this.id = id;
- }
-
- public boolean isAlive() {
- return alive;
- }
-
- public boolean equals(Object other){
- return this.id == ((FakeSourceConnection)other).id;
- }
-
- public String toString(){
- return "Connection " + id; //$NON-NLS-1$
- }
-
- @Override
- public Execution createExecution(ICommand command,
- ExecutionContext executionContext, RuntimeMetadata metadata)
- throws ConnectorException {
- return null;
- }
-
- @Override
- public ConnectorCapabilities getCapabilities() {
- return null;
- }
-
- @Override
- public void close() {
-
- }
-
- }
-
- @Override
- public Connection getConnection(ExecutionContext context)
- throws ConnectorException {
- return new FakeSourceConnection(connCnt++);
- }
-
- @Override
- public void start(ConnectorEnvironment environment) throws ConnectorException {
- }
-
- @Override
- public void stop() {
- }
-
- @Override
- public ConnectorCapabilities getCapabilities() {
- return null;
- }
-
-}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.pooling.connector;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-
-/**
- */
-public class FakeUserIdentityConnectionFactory extends FakeSourceConnectionFactory {
-
- /*
- * @see com.metamatrix.data.pool.SourceConnectionFactory#createIdentity(com.metamatrix.data.SecurityContext)
- */
- public ConnectorIdentity createIdentity(ExecutionContext context) throws ConnectorException {
- if (context == null) {
- return null;
- }
- //use user name for now
- return new MappedUserIdentity(context.getUser(), null, null);
- }
-
-}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,389 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
-
-
-public class TestConnectionPool {
- private ConnectionPool userIDPool;
- private ConnectionPool singleIDPool;
- private static ArrayList<Exception> EXCEPTIONS = new ArrayList<Exception>();
- private static WorkerPool pool = WorkerPoolFactory.newWorkerPool(TestConnectionPool.class.getSimpleName(), 1);
-
- @AfterClass public static void tearDownOnce() {
- pool.shutdownNow();
- }
-
- @Before public void setUp() throws Exception{
- FakeSourceConnectionFactory.alive = true;
-
- singleIDPool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
- userIDPool = new ConnectionPool(new ConnectorWrapper(new FakeUserIdentityConnectionFactory()));
-
- Properties poolProperties = new Properties();
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "10"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "5"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
- ConnectorEnvironment env = createConnectorEnvironment(poolProperties);
- singleIDPool.initialize(env);
- userIDPool.initialize(env);
- }
-
- private ConnectorEnvironment createConnectorEnvironment(
- Properties poolProperties) {
- ConnectorEnvironment env = new ConnectorEnvironmentImpl(poolProperties, Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment(), pool);
- return env;
- }
-
- public void tearDown() throws Exception{
- singleIDPool.shutDown();
- userIDPool.shutDown();
- }
-
- public static ExecutionContext createContext(final String user, boolean userIdentity) {
- ExecutionContextImpl context = new ExecutionContextImpl(null, null, user, null, null, null, null, null, null, null);
- if (userIdentity) {
- context.setConnectorIdentity(new MappedUserIdentity(context.getUser(), null, null));
- }
- return context;
- }
-
- //=== tests ===//
- @Test public void testPoolUsingSingleIdentity() throws Exception {
- ExecutionContext context = createContext("x", false);//$NON-NLS-1$
-
- ConnectionWrapper conn1 = singleIDPool.obtain(context);
- ConnectionWrapper conn2 = singleIDPool.obtain(context);
- ConnectionWrapper conn3 = singleIDPool.obtain(context);
- ConnectionWrapper conn4 = singleIDPool.obtain(context);
-
- assertEquals(4, singleIDPool.getTotalCreatedConnectionCount());
- assertEquals(4, singleIDPool.getTotalConnectionCount());
- assertEquals(4, singleIDPool.getNumberOfConnectionsInUse());
- assertEquals(0, singleIDPool.getNumberOfConnectinsWaiting());
- assertEquals(0, singleIDPool.getTotalDestroyedConnectionCount());
-
-
-
-
- singleIDPool.release(conn2, false);
- singleIDPool.release(conn4, true);
-
- // only 1 has been closed/destroyed #4
- assertEquals(3, singleIDPool.getTotalConnectionCount());
- assertEquals(1, singleIDPool.getTotalDestroyedConnectionCount());
- assertEquals(1, singleIDPool.getNumberOfConnectinsWaiting());
- assertEquals(4, singleIDPool.getTotalCreatedConnectionCount());
- assertEquals(2, singleIDPool.getNumberOfConnectionsInUse());
-
-
- List unusedConns = singleIDPool.getUnusedConnections(conn1);
- assertEquals(1, unusedConns.size());
- assertTrue(unusedConns.contains(conn2));
- List usedConns = singleIDPool.getUsedConnections(conn2);
- assertEquals(2, usedConns.size());
- assertTrue(usedConns.contains(conn1));
- assertTrue(usedConns.contains(conn3));
- assertEquals(3, singleIDPool.getTotalConnectionCount());
- }
-
- @Test public void testMaxConnectionTest() throws Exception {
- ConnectionPool pool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-
- Properties poolProperties = new Properties();
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "0"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "5"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-
- try {
- pool.initialize(createConnectorEnvironment(poolProperties));
- fail("should have failed to use 0 as max connections"); //$NON-NLS-1$
- }catch (ConnectionPoolException e) {
- // pass
- }
- }
-
- @Test public void testMaxConnectionTest1() throws Exception {
- ConnectionPool pool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-
- Properties poolProperties = new Properties();
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "-1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "5"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-
- try {
- pool.initialize(createConnectorEnvironment(poolProperties));
- fail("should have failed to use 0 as max connections"); //$NON-NLS-1$
- }catch (ConnectionPoolException e) {
- // pass
- }
- }
-
- @Test public void testMaxConnectionTest2() throws Exception {
- ConnectionPool pool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-
- Properties poolProperties = new Properties();
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "10"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "0"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-
- try {
- pool.initialize(createConnectorEnvironment(poolProperties));
- fail("should have failed to use 0 as max connections"); //$NON-NLS-1$
- }catch (ConnectionPoolException e) {
- // pass
- }
- }
-
- @Test public void testMessageWhenPoolMaxedOutPerIdentity() throws Exception {
- ExecutionContext context = createContext("x", false);//$NON-NLS-1$
-
- // Max out the pool - 5 connections for same ID
- for(int i=0; i<5; i++) {
- singleIDPool.obtain(context);
- }
-
- // Ask for one more - this should time out
- try {
- singleIDPool.obtain(context);
- fail("No exception received when maxing out the pool"); //$NON-NLS-1$
- } catch(ConnectionPoolException e) {
- assertEquals("The connection pool for identity \"SingleIdentity\" is at the maximum connection count \"5\" and no connection became available in the timeout period. Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
- }
- }
-
- @Test public void testMessageWhenPoolTimedOut() throws Exception {
- FakeSourceConnectionFactory.alive = true;
-
- singleIDPool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
- Properties poolProperties = new Properties();
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.ENABLE_SHRINKING, Boolean.FALSE.toString());
- poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
- singleIDPool.initialize(createConnectorEnvironment(poolProperties));
-
- ExecutionContext context = createContext("x", false);//$NON-NLS-1$
-
- singleIDPool.obtain(context);
-
- try {
- // Ask for a connection... should time out.
- singleIDPool.obtain(context);
-
- fail("No exception received on pool timeout"); //$NON-NLS-1$
- } catch (ConnectionPoolException e) {
- assertEquals("The connection pool for identity \"SingleIdentity\" exceeded wait time for connection, \"1\" ms, and no connection became available in the timeout period. Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
- }
- }
-
- @Test public void testPoolUsingUserIdentity() throws Exception {
- ExecutionContext context1 = createContext("Jack", true); //$NON-NLS-1$
- ExecutionContext context2 = createContext("Tom", true); //$NON-NLS-1$
- userIDPool.obtain(context1);
- ConnectionWrapper conn2 = userIDPool.obtain(context1);
- ConnectionWrapper conn3 = userIDPool.obtain(context2);
- ConnectionWrapper conn4 = userIDPool.obtain(context2);
-
- assertEquals(4, userIDPool.getTotalCreatedConnectionCount());
- assertEquals(4, userIDPool.getTotalConnectionCount());
- assertEquals(4, userIDPool.getNumberOfConnectionsInUse());
- assertEquals(0, userIDPool.getNumberOfConnectinsWaiting());
- assertEquals(0, userIDPool.getTotalDestroyedConnectionCount());
-
-
-
- userIDPool.release(conn2, false);
- userIDPool.release(conn4, true);
-
- // only 1 has been closed/destroyed #4
- assertEquals(3, userIDPool.getTotalConnectionCount());
- assertEquals(1, userIDPool.getTotalDestroyedConnectionCount());
- assertEquals(1, userIDPool.getNumberOfConnectinsWaiting());
- assertEquals(4, userIDPool.getTotalCreatedConnectionCount());
- assertEquals(2, userIDPool.getNumberOfConnectionsInUse());
-
-
- List unusedConns = userIDPool.getUnusedConnections(conn2);
- assertEquals(1, unusedConns.size());
- assertTrue(unusedConns.contains(conn2));
- List usedConns = userIDPool.getUsedConnections(conn3);
- assertEquals(1, usedConns.size());
- assertTrue(usedConns.contains(conn3));
- assertEquals(3, userIDPool.getTotalConnectionCount());
- }
-
- @Test public void testPoolCleanUp() throws Exception {
- ExecutionContext context = createContext("x", false); //$NON-NLS-1$
-
- ConnectionWrapper conn1 = singleIDPool.obtain(context);
- ConnectionWrapper conn2 = singleIDPool.obtain(context);
- ConnectionWrapper conn3 = singleIDPool.obtain(context);
- ConnectionWrapper conn4 = singleIDPool.obtain(context);
- singleIDPool.release(conn2, false);
- singleIDPool.release(conn4, true);
-
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- }
-
- List unusedConns = singleIDPool.getUnusedConnections(conn1);
- assertEquals(0, unusedConns.size());
- List usedConns = singleIDPool.getUsedConnections(conn1);
- assertEquals(2, usedConns.size());
- assertTrue(usedConns.contains(conn1));
- assertTrue(usedConns.contains(conn3));
- assertEquals(2, singleIDPool.getTotalConnectionCount());
- }
-
- @Test public void testMultiThreading() throws Exception {
- EXCEPTIONS.clear();
- int runnerNumber = 20;
- int connPerRunner = 20;
-
- LoadRunner runner[] = new LoadRunner[runnerNumber];
- for(int i=0; i< runnerNumber; i++){
- runner[i] = new LoadRunner(userIDPool, connPerRunner);
- }
-
- for(int i=0; i< runnerNumber; i++){
- runner[i].start();
- }
-
- for(int i=0; i< runnerNumber; i++){
- try {
- runner[i].join();
- } catch (InterruptedException e) {
- }
- }
-
- assertEquals(EXCEPTIONS.toString(), 0, EXCEPTIONS.size());
-
- ExecutionContext context1 = createContext("Jack", true); //$NON-NLS-1$
- ExecutionContext context2 = createContext("Tom", true); //$NON-NLS-1$
-
- //List unusedConns1 = pool.getUnusedConneections(id1);
- List usedConns1 = userIDPool.getUsedConnections(userIDPool.obtain(context1));
-
- assertEquals(1, usedConns1.size());
- //List unusedConns2 = pool.getUnusedConneections(id2);
- List usedConns2 = userIDPool.getUsedConnections(userIDPool.obtain(context2));
- assertEquals(1, usedConns2.size());
- }
-
- static class LoadRunner extends Thread {
- ConnectionPool pool;
- private int n;
-
- LoadRunner(ConnectionPool pool, int connPerRunner){
- n = connPerRunner;
- this.pool = pool;
- }
-
- public void run(){
- ExecutionContext context1 = createContext("Jack", true); //$NON-NLS-1$
- ExecutionContext context2 = createContext("Tom", true); //$NON-NLS-1$
- try {
- ConnectionWrapper conn = null;
-
- for(int i=0; i<n; i++) {
- if(Math.random() < .5) {
- conn = pool.obtain(context1);
- } else {
- conn = pool.obtain(context2);
- }
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- //ignore
- }
- pool.release(conn, false);
- }
- } catch (ConnectionPoolException e) {
- TestConnectionPool.EXCEPTIONS.add(e);
- }
- }
- }
-
- @Test public void testMaxWithUserPool() throws Exception {
- userIDPool = new ConnectionPool(new ConnectorWrapper(new FakeUserIdentityConnectionFactory()));
- Properties poolProperties = new Properties();
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1000"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "1"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1000"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.ENABLE_SHRINKING, "false"); //$NON-NLS-1$
- poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
- userIDPool.initialize(createConnectorEnvironment(poolProperties));
-
- ConnectionWrapper conn = userIDPool.obtain(createContext("x", true)); //$NON-NLS-1$
- userIDPool.release(conn,false);
-
- assertEquals(1, userIDPool.getTotalConnectionCount());
-
- userIDPool.obtain(createContext("y", true)); //$NON-NLS-1$
-
- assertEquals(1, userIDPool.getTotalConnectionCount());
- }
-
-}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.connector.basic.BasicConnection;
-import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
-import org.teiid.dqp.internal.pooling.connector.ConnectionWrapper;
-
-
-public class TestConnectionWrapper extends TestCase {
-
- public void testIdleTime() throws Exception {
- ConnectionWrapper wrapper = new ConnectionWrapper(Mockito.mock(BasicConnection.class), Mockito.mock(ConnectionPool.class), 1);
- long time = wrapper.getTimeReturnedToPool();
- Thread.sleep(50);
- wrapper.close();
- assertTrue(wrapper.getTimeReturnedToPool() - time > 0);
- }
-
- public void testIsAliveTestInterval() throws Exception {
- BasicConnection connection = Mockito.mock(BasicConnection.class);
- Mockito.stub(connection.isAlive()).toReturn(Boolean.TRUE);
- ConnectionWrapper wrapper = new ConnectionWrapper(connection, Mockito.mock(ConnectionPool.class), 1);
- wrapper.setTestInterval(-1); //trigger an actual call.
- for (int i = 0; i < 10; i++) {
- wrapper.isAlive();
- wrapper.setTestInterval(60000);
- }
- Mockito.verify(connection, Mockito.times(1)).isAlive();
- }
-}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-import org.teiid.connector.basic.BasicConnector;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-
-/**
- */
-public class TestPerUserPool extends TestCase {
-
- public TestPerUserPool(String name) {
- super(name);
- }
-
- private Connector getTestConnector(ConnectorEnvironment env) throws ConnectorException {
- BasicConnector con = new BasicConnector() {
-
- @Override
- public ConnectorCapabilities getCapabilities() {
- return null;
- }
-
- @Override
- public Connection getConnection(ExecutionContext context)
- throws ConnectorException {
- assertTrue(context.getConnectorIdentity() instanceof MappedUserIdentity);
- return null;
- }
-
- @Override
- public void start(ConnectorEnvironment environment)
- throws ConnectorException {
-
- }
-
- @Override
- public void stop() {
-
- }
-
- };
- con.setUseCredentialMap(true);
- con.setAdminConnectionsAllowed(false);
- con.setConnectorName("oracle system");
- con.start(env);
- return con;
- }
-
- public void testWrongCredentials() throws Exception {
- ConnectorEnvironment env = initConnectorEnvironment();
- Connector factory = getTestConnector(env);
- try {
- ExecutionContext ctx = createSecurityContext("pw1", false, factory); //$NON-NLS-1$
- factory.getConnection(ctx);
- fail("expected failure"); //$NON-NLS-1$
- } catch (ConnectorException e) {
- assertEquals("Unable to extract credentials from command payload or trusted session payload for per-user connection.", e.getMessage()); //$NON-NLS-1$
- }
- }
-
- private ConnectorEnvironment initConnectorEnvironment() throws Exception {
- final Properties connProps = new Properties();
- connProps.put(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "oracle system"); //$NON-NLS-1$
- return new ConnectorEnvironmentImpl(connProps, Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment());
- }
-
- private ExecutionContext createSecurityContext(String credentialsStr, boolean useMap, Connector factory) throws Exception {
- Serializable credentials = credentialsStr;
- if (useMap) {
- credentials = CredentialMap.parseCredentials(credentialsStr);
- }
-
- // session payload
- ExecutionContextImpl impl = new ExecutionContextImpl(null, null, null, credentials, null, null, null, null, null, null);
- impl.setConnectorIdentity(factory.createIdentity(impl));
- return impl;
- }
-
- public void testCredentialMapInSessionPayload() throws Exception {
- ConnectorEnvironment env = initConnectorEnvironment();
- Connector factory = getTestConnector(env);
- ExecutionContext ctx = createSecurityContext("(system=oracle system,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
- factory.getConnection(ctx);
- }
-
- public void testCredentialMapMissingSystem() throws Exception {
- ConnectorEnvironment env = initConnectorEnvironment();
- Connector factory = getTestConnector(env);
-
- // Set system to "x" instead of "oracle system" which will cause no credentials to be found
- try {
- ExecutionContext ctx = createSecurityContext("(system=x,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
- factory.getConnection(ctx);
- fail("Expected exception when creating connection with missing system credentials"); //$NON-NLS-1$
- } catch(Exception e) {
- // expected
- assertEquals("Payload missing credentials for oracle system", e.getMessage()); //$NON-NLS-1$
- }
- }
-
-}
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-import java.util.Properties;
-
-import javax.transaction.Transaction;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.connector.xa.api.XAConnector;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-
-import com.metamatrix.admin.objects.MMConnectionPool;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.dqp.service.TransactionService;
-
-public class TestPooledConnector {
-
- @Test public void testGetXAConnection() throws Exception {
- XAConnector connector = Mockito.mock(XAConnector.class);
- PooledConnector pc = new PooledConnector("foo", connector, Mockito.mock(TransactionService.class)); //$NON-NLS-1$
- pc.start(new ConnectorEnvironmentImpl(new Properties(), Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment()));
- TransactionContext tc = Mockito.mock(TransactionContext.class);
- Mockito.stub(tc.getTransaction()).toReturn(Mockito.mock(Transaction.class));
- Mockito.stub(tc.getTxnID()).toReturn("1"); //$NON-NLS-1$
- Connection conn = pc.getConnection(Mockito.mock(ExecutionContext.class), tc);
- conn.close();
- Connection conn1 = pc.getConnection(Mockito.mock(ExecutionContext.class), tc);
- assertSame(conn, conn1);
-
- List<MMConnectionPool> stats = pc.getConnectionPoolStats();
- assertEquals(2, stats.size());
- assertEquals(1, stats.get(1).getConnectionsCreated());
- conn1.close(); //this is still in a txn so it should still be in use
-
- stats = pc.getConnectionPoolStats();
- assertEquals(1, stats.get(1).getConnectionsInuse());
-
- pc.stop();
- }
-
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,7 +39,7 @@
String sql = "{? = call pm4.spTest9()}"; //$NON-NLS-1$
try {
- TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), FakeMetadataFactory.exampleBQTCached(), true);
+ TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
fail();
} catch (QueryResolverException e) {
assertEquals("Required parameter 'PM4.SPTEST9.INKEY' has no value was set or is an invalid parameter.", e.getMessage()); //$NON-NLS-1$
@@ -58,7 +58,7 @@
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("EXEC pm4.spTest9(1)", expected);
- TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
/**
@@ -77,7 +77,7 @@
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("EXEC pm4.spTest9(1)", expected);
- TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
public void testOutParameter() throws Exception {
@@ -92,7 +92,7 @@
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("EXEC pm2.spTest8(2)", expected);
- TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
public void testInputExpression() throws Exception {
@@ -104,7 +104,7 @@
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("EXEC pm2.spTest8(1)", expected);
- TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,8 +39,8 @@
*/
public class TestCodeTableCache extends TestCase {
- private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, "test", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, "test", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, "test", 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, "test", 2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
public TestCodeTableCache(String name) {
super(name);
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.process;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- */
-public class TestConnectorCapabilitiesFinder extends TestCase {
-
- /**
- * Constructor for TestConnectorCapabilitiesFinder.
- * @param name
- */
- public TestConnectorCapabilitiesFinder(String name) {
- super(name);
- }
-
- public void testFind() throws Exception {
- String vdbName = "myvdb"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
- String modelName = "model"; //$NON-NLS-1$
- String functionName = "fakeFunction"; //$NON-NLS-1$
-
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setFunctionSupport("fakeFunction", true); //$NON-NLS-1$
- RequestMessage request = new RequestMessage(null);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(vdbName);
- workContext.setVdbVersion(vdbVersion);
-
- VDBService vdbService = Mockito.mock(VDBService.class);
- Mockito.stub(vdbService.getConnectorBindingNames(vdbName, vdbVersion, modelName)).toReturn(Arrays.asList(modelName));
- DataService dataService = Mockito.mock(DataService.class);
- BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
- basicSourceCapabilities.setFunctionSupport(functionName, true);
- Mockito.stub(dataService.getCapabilities(request, workContext, modelName)).toReturn(basicSourceCapabilities);
-
- CachedFinder finder = new CachedFinder(dataService, request, workContext);
-
- // Test
- SourceCapabilities actual = finder.findCapabilities(modelName);
- assertEquals("Did not get expected capabilities", true, actual.supportsFunction(functionName)); //$NON-NLS-1$
- }
-
-}
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java (from rev 1900, branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,80 @@
+/*
+ * 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.dqp.internal.process;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+
+/**
+ */
+public class TestConnectorCapabilitiesFinder extends TestCase {
+
+ /**
+ * Constructor for TestConnectorCapabilitiesFinder.
+ * @param name
+ */
+ public TestConnectorCapabilitiesFinder(String name) {
+ super(name);
+ }
+
+ public void testFind() throws Exception {
+ String modelName = "model"; //$NON-NLS-1$
+ String functionName = "fakeFunction"; //$NON-NLS-1$
+
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setFunctionSupport("fakeFunction", true); //$NON-NLS-1$
+
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add(modelName);
+
+ VDBMetaData vdb = Mockito.mock(VDBMetaData.class);
+ ModelMetaData model = Mockito.mock(ModelMetaData.class);
+ Mockito.stub(vdb.getModel(modelName)).toReturn(model);
+ Mockito.stub(model.getSourceNames()).toReturn(bindings);
+
+ BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
+ basicSourceCapabilities.setFunctionSupport(functionName, true);
+
+ ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+ ConnectorManager cm = Mockito.mock(ConnectorManager.class);
+ Mockito.stub(cm.getCapabilities()).toReturn(basicSourceCapabilities);
+ Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(cm);
+
+ CachedFinder finder = new CachedFinder(repo, vdb);
+
+ // Test
+ SourceCapabilities actual = finder.findCapabilities(modelName);
+ assertEquals("Did not get expected capabilities", true, actual.supportsFunction(functionName)); //$NON-NLS-1$
+ }
+
+}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,7 +25,6 @@
import static org.junit.Assert.*;
import java.sql.ResultSet;
-import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -33,56 +32,38 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-
public class TestDQPCore {
private DQPCore core;
@Before public void setUp() throws Exception {
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("bqt"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
- DQPWorkContext.setWorkContext(workContext);
-
- String vdbName = "bqt"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
-
- final ApplicationEnvironment env = new ApplicationEnvironment();
- env.bindService(DQPServiceNames.BUFFER_SERVICE, new FakeBufferService());
- FakeMetadataService mdSvc = new FakeMetadataService();
- mdSvc.addVdb(vdbName, vdbVersion, FakeMetadataFactory.exampleBQTCached());
- env.bindService(DQPServiceNames.METADATA_SERVICE, mdSvc);
- env.bindService(DQPServiceNames.DATA_SERVICE, new AutoGenDataService());
- env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.setDefaultPrivate(true);
- vdbService.addBinding(vdbName, vdbVersion, "BQT1", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addBinding(vdbName, vdbVersion, "BQT3", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addModel(vdbName, vdbVersion, "BQT3", ModelInfo.PRIVATE, false); //$NON-NLS-1$
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
+ DQPWorkContext context = FakeMetadataFactory.buildWorkContext(FakeMetadataFactory.exampleBQTCached(), FakeMetadataFactory.exampleBQTVDB());
+ context.getVDB().getModel("BQT3").setVisible(false); //$NON-NLS-1$
+ ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+ Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+
core = new DQPCore();
- core.setEnvironment(env);
- core.start(new Properties());
+ core.setWorkManager(new FakeWorkManager());
+ core.setBufferService(new FakeBufferService());
+ core.setConnectorManagerRepository(repo);
+ core.setTransactionService(new FakeTransactionService());
+
+ core.start(new DQPConfiguration());
}
@After public void tearDown() throws Exception {
@@ -92,7 +73,6 @@
public RequestMessage exampleRequestMessage(String sql) {
RequestMessage msg = new RequestMessage(sql);
- msg.setCallableStatement(false);
msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
msg.setFetchSize(10);
msg.setPartialResults(false);
@@ -204,14 +184,14 @@
}
@Test public void testCancel() throws Exception {
- assertFalse(this.core.cancelRequest(new RequestID(1)));
+ assertFalse(this.core.cancelRequest(1L));
}
public void helpTestVisibilityFails(String sql) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_OFF);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+ ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
}
@@ -233,13 +213,13 @@
private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(sessionid), userName));
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(sessionid, userName));
if (txnAutoWrap) {
reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
}
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+ ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
if (results.getException() != null) {
throw results.getException();
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,33 +28,32 @@
import junit.framework.TestCase;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
import org.teiid.dqp.internal.process.DQPCore.ClientState;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.server.serverapi.RequestInfo;
/**
*/
public class TestDQPCoreRequestHandling extends TestCase {
- private static final String SESSION_STRING = new MetaMatrixSessionID(2).toString();
+ private static final String SESSION_STRING = "2";
public TestDQPCoreRequestHandling(String name) {
super(name);
}
- private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestInfo> reqs2) {
+ private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestMetadata> reqs2) {
Set reqIDs2 = new HashSet();
- for (RequestInfo requestInfo : reqs2) {
- reqIDs2.add(requestInfo.getRequestID());
+ for (RequestMetadata requestInfo : reqs2) {
+ reqIDs2.add(new RequestID(requestInfo.getSessionId(), requestInfo.getExecutionId()));
}
assertEquals("Collections of request infos are not the same: ", new HashSet(reqs1), reqIDs2); //$NON-NLS-1$
@@ -66,7 +65,7 @@
public void testGetRequestsSessionToken1() {
DQPCore rm = new DQPCore();
Set reqs = new HashSet();
- Collection actualReqs = rm.getRequestsByClient("foo");
+ Collection actualReqs = rm.getRequestsForSession(2);
compareReqInfos(reqs, actualReqs);
}
@@ -75,11 +74,12 @@
*/
public void testGetRequestsSessionToken2() {
DQPCore rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
Set reqs = new HashSet();
RequestID id = addRequest(rm, SESSION_STRING, 1);
reqs.add(id);
- Collection<RequestInfo> actualReqs = rm.getRequestsByClient(SESSION_STRING);
+ Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(2);
compareReqInfos(reqs, actualReqs);
}
@@ -95,13 +95,14 @@
*/
public void testGetRequestsSessionToken3() {
DQPCore rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
Set reqs = new HashSet();
reqs.add(addRequest(rm, SESSION_STRING, 0));
reqs.add(addRequest(rm, SESSION_STRING, 1));
reqs.add(addRequest(rm, SESSION_STRING, 2));
- Collection actualReqs = rm.getRequestsByClient(SESSION_STRING);
+ Collection actualReqs = rm.getRequestsForSession(2);
compareReqInfos(reqs, actualReqs);
}
@@ -111,6 +112,7 @@
public void testAddRequest() {
DQPCore rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
addRequest(rm, r0, requestID, null, null);
@@ -118,6 +120,7 @@
public void testWarnings1() {
DQPCore rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
@@ -138,7 +141,7 @@
if (workContext == null) {
workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(Long.valueOf(id.getConnectionID())), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(Long.valueOf(id.getConnectionID()), "foo")); //$NON-NLS-1$
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
workItem.setOriginalCommand(originalCommand);
@@ -149,12 +152,13 @@
public void testGetConnectorInfo() {
DQPCore rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
- DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
+ DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, "connID", workItem); //$NON-NLS-1$
workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
@@ -163,12 +167,13 @@
public void testRemoveConnectorInfo() {
DQPCore rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
- DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
+ DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null,"connID", workItem); //$NON-NLS-1$
workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
workItem.closeAtomicRequest(atomicReq.getAtomicRequestID());
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,9 @@
package org.teiid.dqp.internal.process;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
import junit.framework.TestCase;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestDQPWorkContext extends TestCase {
@@ -43,11 +40,10 @@
public static DQPWorkContext example() {
DQPWorkContext message = new DQPWorkContext();
- message.setTrustedPayload("myTrustedPayload"); //$NON-NLS-1$
message.setVdbName("vdbName"); //$NON-NLS-1$
- message.setVdbVersion("vdbVersion"); //$NON-NLS-1$
+ message.setVdbVersion(1); //$NON-NLS-1$
message.setAppName("querybuilder"); //$NON-NLS-1$
- message.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "userName")); //$NON-NLS-1$
+ message.setSessionToken(new SessionToken(5, "userName")); //$NON-NLS-1$
return message;
}
@@ -55,10 +51,9 @@
DQPWorkContext copy = UnitTestUtil.helpSerialize(example());
assertEquals("5", copy.getConnectionID()); //$NON-NLS-1$
- assertEquals("myTrustedPayload", copy.getTrustedPayload()); //$NON-NLS-1$
assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
- assertEquals("vdbVersion", copy.getVdbVersion()); //$NON-NLS-1$
+ assertEquals(1, copy.getVdbVersion()); //$NON-NLS-1$
assertEquals("querybuilder", copy.getAppName()); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,35 +22,27 @@
package org.teiid.dqp.internal.process;
-import java.util.Collection;
import java.util.List;
-import java.util.Properties;
+import javax.resource.spi.work.WorkManager;
+
import junit.framework.TestCase;
-import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -71,7 +63,7 @@
private Command command;
private DataTierTupleSource info;
private int executeRequestFailOnCall = 10000;
- private FakeDataService dataService;
+ private FakeConnectorManager connectorManager;
private RequestWorkItem workItem;
public TestDataTierManager(String name) {
@@ -90,21 +82,22 @@
private void helpSetup(String sql, int nodeId) throws Exception {
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.exampleBQTVDB());
- dataService = new FakeDataService(executeRequestFailOnCall);
-// dataService.addResults("SELECT StringKey, IntKey FROM BQT1.SmallA", helpCreateFakeCodeTableResults(1, 50)); //$NON-NLS-1$
+ connectorManager = new FakeConnectorManager("FakeConnectorID", executeRequestFailOnCall);
rm = new DQPCore();
+ rm.setTransactionService(new FakeTransactionService());
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addBinding("MyVDB", "1", "BQT1", "mmuuid:binding", "bindingName"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
FakeBufferService bs = new FakeBufferService();
+
+ ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+ Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(connectorManager);
+
dtm = new DataTierManagerImpl(rm,
- dataService,
- vdbService,
+ repo,
bs,
- new FakeMetadataService(),
+ new FakeWorkManager(),
20,
1000,
1000);
@@ -113,24 +106,20 @@
RequestMessage original = new RequestMessage();
original.setExecutionId(1);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
RequestID requestID = workContext.getRequestID(original.getExecutionId());
context = new CommandContext();
context.setProcessorID(requestID);
context.setVdbName("test"); //$NON-NLS-1$
- context.setVdbVersion("1"); //$NON-NLS-1$
+ context.setVdbVersion(1); //$NON-NLS-1$
context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
request = new AtomicRequestMessage(original, workContext, nodeId);
request.setCommand(command);
- request.setConnectorID(new ConnectorID("FakeConnectorID")); //$NON-NLS-1$
+ request.setConnectorName("FakeConnectorID"); //$NON-NLS-1$
- info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorID(), workItem);
+ info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorName(), workItem);
workItem.addConnectorRequest(request.getAtomicRequestID(), info);
}
@@ -215,7 +204,7 @@
DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
connRequest.closeSource();
- assertFalse(this.dataService.closed);
+ assertFalse(this.connectorManager.closed);
assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
@@ -244,7 +233,7 @@
DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
connRequest.closeSource();
- assertTrue(this.dataService.closed);
+ assertTrue(this.connectorManager.closed);
assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
@@ -262,14 +251,14 @@
results.setSupportsImplicitClose(false);
info.receiveResults(results);
- assertFalse(this.dataService.closed);
+ assertFalse(this.connectorManager.closed);
assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
// now implicitly close the request then check to make sure it is not gone
connRequest.closeSource();
- assertFalse(this.dataService.closed);
+ assertFalse(this.connectorManager.closed);
assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
}
@@ -283,7 +272,7 @@
public void testCodeTableResponseException() throws Exception {
helpSetup(3);
- this.dataService.throwExceptionOnExecute = true;
+ this.connectorManager.throwExceptionOnExecute = true;
try {
dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -298,7 +287,7 @@
AtomicResultsMessage results = helpSetup("SELECT * FROM BQT1.SmallA", true, false, -1); //$NON-NLS-1$
- this.dataService.results = results;
+ this.connectorManager.results = results;
try {
dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -308,22 +297,22 @@
}
}
- private static class FakeDataService implements DataService {
+ private static class FakeConnectorManager extends ConnectorManager {
private int failOnCall = 10000;
private int calls = 0;
private boolean closed = false;
boolean throwExceptionOnExecute;
AtomicResultsMessage results;
- private FakeDataService(int failOnCallNumber) {
+ private FakeConnectorManager(String name, int failOnCallNumber) {
+ super(name);
this.failOnCall = failOnCallNumber;
}
- public void executeRequest(AtomicRequestMessage request,
- ConnectorID connector,
- ResultsReceiver<AtomicResultsMessage> resultListener)
- throws MetaMatrixComponentException {
+ @Override
+ public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> resultListener, AtomicRequestMessage request)
+ throws ConnectorException {
if (closed) {
- throw new MetaMatrixComponentException("Already closed"); //$NON-NLS-1$
+ throw new ConnectorException("Already closed"); //$NON-NLS-1$
}
if (throwExceptionOnExecute) {
resultListener.exceptionOccurred(new RuntimeException("Connector Exception")); //$NON-NLS-1$
@@ -331,50 +320,22 @@
resultListener.receiveResults(results);
}
}
- public ConnectorID selectConnector(String connectorBindingID) {
- if (connectorBindingID.equals("mmuuid:binding")) { //$NON-NLS-1$
- return new ConnectorID("FakeConnectorID"); //$NON-NLS-1$
- }
- return null;
- }
- public void initialize(Properties props) throws ApplicationInitializationException {}
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {}
- public void stop() throws ApplicationLifecycleException {}
- public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
- public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
- public List getConnectorBindings() throws ComponentNotFoundException {return null;}
- public ConnectorStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {return null;}
- public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {return null;}
- public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {return null;}
- public Collection getConnectionPoolStatistics(String connectorBindingName) throws MetaMatrixComponentException { return null; }
-
- public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {}
-
- public void cancelRequest(AtomicRequestID request,
- ConnectorID connectorId) throws MetaMatrixComponentException {
- }
- public void closeRequest(AtomicRequestID request,
- ConnectorID connectorId) throws MetaMatrixComponentException {
+
+ @Override
+ public void closeRequest(AtomicRequestID request) {
closed = true;
}
+
@Override
- public SourceCapabilities getCapabilities(RequestMessage request,
- DQPWorkContext dqpWorkContext, String modelName)
- throws MetaMatrixComponentException {
+ public SourceCapabilities getCapabilities() throws ConnectorException{
return null;
}
- public void requestBatch(AtomicRequestID request,
- ConnectorID connectorId) throws MetaMatrixComponentException {
+ @Override
+ public void requstMore(AtomicRequestID requestId) throws ConnectorException {
calls++;
if (calls == failOnCall) {
- throw new MetaMatrixComponentException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
+ throw new ConnectorException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
}
}
- @Override
- public MetadataStore getConnectorMetadata(String vdbName,
- String vdbVersion, String modelName, Properties importProperties)
- throws MetaMatrixComponentException {
- throw new UnsupportedOperationException();
- }
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,20 +29,14 @@
import junit.framework.TestCase;
-import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -58,92 +52,75 @@
super(name);
}
- public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata) throws Exception {
+ public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata, VDBMetaData vdb) throws Exception {
// Prepare sql
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
// Create components
- MetadataService mdSvc = Mockito.mock(MetadataService.class);
- Mockito.stub(mdSvc.lookupMetadata(Mockito.anyString(), Mockito.anyString())).toReturn(metadata);
SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
DQPCore requestMgr = new DQPCore();
+ requestMgr.setTransactionService(new FakeTransactionService());
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
// Initialize components
RequestID requestID = workContext.getRequestID(1);
RequestMessage requestMsg = new RequestMessage(sql);
TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null);
- ApplicationEnvironment env = new ApplicationEnvironment();
- FakeVDBService vdbService = new FakeVDBService();
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, "MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ MetaDataProcessor mdProc = new MetaDataProcessor(requestMgr, prepPlanCache, "MyVDB", 1);
return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
}
public void testSimpleQuery() throws Exception {
- Map[] metadata = helpGetMetadata("SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ Map[] metadata = helpGetMetadata("SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNotNull(metadata);
assertEquals(1, metadata.length);
}
public void testSimpleUpdate() throws Exception {
- Map[] metadata = helpGetMetadata("INSERT INTO pm1.g1 (e1) VALUES ('x')", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ Map[] metadata = helpGetMetadata("INSERT INTO pm1.g1 (e1) VALUES ('x')", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNull(metadata);
- metadata = helpGetMetadata("DELETE FROM pm1.g1 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ metadata = helpGetMetadata("DELETE FROM pm1.g1 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNull(metadata);
- metadata = helpGetMetadata("UPDATE pm1.g1 SET e1='y' WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ metadata = helpGetMetadata("UPDATE pm1.g1 SET e1='y' WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNull(metadata);
- metadata = helpGetMetadata("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ metadata = helpGetMetadata("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm1.g1", FakeMetadataFactory.example1Cached(),FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNull(metadata);
}
public void testElementLabel() throws Exception {
- Map[] metadata = helpGetMetadata("SELECT E2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ Map[] metadata = helpGetMetadata("SELECT E2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNotNull(metadata);
assertEquals(1, metadata.length);
assertEquals("E2", metadata[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$
}
public void testSimpleExec() throws Exception {
- Map[] metadata = helpGetMetadata("EXEC pm1.sq1()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ Map[] metadata = helpGetMetadata("EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNotNull(metadata);
assertEquals(2, metadata.length);
}
public void testExecNoResultColumns() throws Exception {
- Map[] metadata = helpGetMetadata("EXEC pm1.sp5()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ Map[] metadata = helpGetMetadata("EXEC pm1.sp5()", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
assertNotNull(metadata);
assertEquals(0, metadata.length);
}
- private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql) throws Exception {
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addModel("MyVDB", "1", "pm1", ModelInfo.PRIVATE, false); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-
+ private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql, VDBMetaData vdb) throws Exception {
// Create components
- MetadataService mdSvc = Mockito.mock(MetadataService.class);
- Mockito.stub(mdSvc.lookupMetadata(Mockito.anyString(), Mockito.anyString())).toReturn(metadata);
SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Initialize components
- ApplicationEnvironment env = new ApplicationEnvironment();
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env, "MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ MetaDataProcessor mdProc = new MetaDataProcessor(new DQPCore(), prepPlanCache, "MyVDB", 1);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
return mdProc.processMessage(workContext.getRequestID(1), workContext, sql, true);
}
@@ -159,7 +136,7 @@
QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel();
String sql = "SELECT e1 FROM pm1.g2"; //$NON-NLS-1$
- MetadataResult response = helpTestQuery(metadata, sql);
+ MetadataResult response = helpTestQuery(metadata, sql, FakeMetadataFactory.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
}
@@ -168,7 +145,7 @@
QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel();
String sql = "SELECT min(e1), max(e1), sum(e1), avg(e1) FROM pm1.g2"; //$NON-NLS-1$
- MetadataResult response = helpTestQuery(metadata, sql);
+ MetadataResult response = helpTestQuery(metadata, sql, FakeMetadataFactory.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
helpCheckNumericAttributes(response, 1, 21, 19, 4);
helpCheckNumericAttributes(response, 2, 22, 20, 0);
@@ -182,7 +159,7 @@
while(iter.hasNext()) {
String type = (String) iter.next();
Class typeClass = DataTypeManager.getDataTypeClass(type);
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, "vdb", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, "vdb", 1);
Map columnMetadata = processor.getDefaultColumn("t", "c", typeClass); //$NON-NLS-1$ //$NON-NLS-2$
verifyColumn(columnMetadata, type);
}
@@ -214,7 +191,7 @@
verifyAttribute(column, ResultsMetadataConstants.SIGNED, false, Boolean.class, dataType);
verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, false, String.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, false, String.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, false, Integer.class, dataType);
verifyAttribute(column, ResultsMetadataConstants.WRITABLE, false, Boolean.class, dataType);
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -49,9 +49,9 @@
@BeforeClass public static void setUpOnce() {
token.setVdbName("foo"); //$NON-NLS-1$
- token.setVdbVersion("1"); //$NON-NLS-1$
+ token.setVdbVersion(1); //$NON-NLS-1$
token2.setVdbName("foo"); //$NON-NLS-1$
- token2.setVdbVersion("2"); //$NON-NLS-1$
+ token2.setVdbVersion(2); //$NON-NLS-1$
}
//====Tests====//
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,14 +22,18 @@
package org.teiid.dqp.internal.process;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
-import org.teiid.dqp.internal.process.TestRequest.FakeApplicationEnvironment;
+import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
@@ -38,7 +42,8 @@
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
+import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer;
@@ -60,15 +65,16 @@
private static boolean DEBUG = false;
- static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement) throws Exception {
- helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement, false);
+
+ static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, VDBMetaData vdb) throws Exception {
+ helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement, false, vdb);
}
- static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, boolean isSessionSpecific) throws Exception {
- helpTestProcessing(preparedSql, values, expected, dataManager, (CapabilitiesFinder)null, metadata, null, callableStatement, isSessionSpecific, /* isAlreadyCached */false);
+ static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, boolean isSessionSpecific, VDBMetaData vdb) throws Exception {
+ helpTestProcessing(preparedSql, values, expected, dataManager, (CapabilitiesFinder)null, metadata, null, callableStatement, isSessionSpecific, /* isAlreadyCached */false, vdb);
}
- static public void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, boolean callableStatement, boolean isSessionSpecific, boolean isAlreadyCached) throws Exception {
+ static public void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, boolean callableStatement, boolean isSessionSpecific, boolean isAlreadyCached, VDBMetaData vdb) throws Exception {
if ( dataManager == null ) {
// Construct data manager with data
dataManager = new FakeDataManager();
@@ -98,13 +104,13 @@
}
//Create plan or used cache plan if isPlanCached
- PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false);
+ PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false, vdb);
// Run query
TestProcessor.doProcess(plan.processPlan, dataManager, expected, plan.context);
//test cached plan
- plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false);
+ plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false,vdb);
//make sure the plan is only created once
assertEquals("should reuse the plan", exHitCount, prepPlanCache.getCacheHitCount()); //$NON-NLS-1$
@@ -126,7 +132,7 @@
}
//get the plan again with a new connection
- assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, 7, callableStatement, false));
+ assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, 7, callableStatement, false, vdb));
/*
* If the command is not specific to a session we expect
@@ -152,7 +158,7 @@
values.add(new Short((short)0));
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
- helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false);
+ helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, FakeMetadataFactory.example1VDB());
}
@Test public void testSessionSpecificFunction() throws Exception {
@@ -169,7 +175,7 @@
values.add(new Short((short)0));
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
- helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, true);
+ helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, true, FakeMetadataFactory.example1VDB());
}
@Test public void testFunctionWithReferencePushDown() throws Exception {
@@ -197,7 +203,7 @@
List values = Arrays.asList(0);
- PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new SessionAwareCache<PreparedPlan>(), SESSION_ID, false, false);
+ PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new SessionAwareCache<PreparedPlan>(), SESSION_ID, false, false,FakeMetadataFactory.example1VDB());
TestOptimizer.checkNodeTypes(plan.processPlan, TestOptimizer.FULL_PUSHDOWN);
}
@@ -206,7 +212,7 @@
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
- return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false);
+ return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false, FakeMetadataFactory.example1VDB());
}
static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
@@ -216,31 +222,33 @@
QueryPlannerException {
return helpGetProcessorPlan(preparedSql, values,
new DefaultCapabilitiesFinder(), FakeMetadataFactory
- .example1Cached(), prepPlanCache, conn, false, false);
+ .example1Cached(), prepPlanCache, conn, false, false, FakeMetadataFactory.example1VDB());
}
static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
- CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults)
+ CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
//Create Request
RequestMessage request = new RequestMessage(preparedSql);
- request.setPreparedStatement(true);
- request.setCallableStatement(callableStatement);
+ if (callableStatement) {
+ request.setStatementType(StatementType.CALLABLE);
+ } else {
+ request.setStatementType(StatementType.PREPARED);
+ }
request.setParameterValues(values);
if (values != null && values.size() > 0 && values.get(0) instanceof List) {
- request.setPreparedBatchUpdate(true);
+ request.setBatchedUpdate(true);
}
if (limitResults) {
request.setRowLimit(1);
}
-
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("example1"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(conn), "foo")); //$NON-NLS-1$
+
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
+ workContext.setSessionToken(new SessionToken(conn, "foo")); //$NON-NLS-1$
+
PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
@Override
protected void createProcessor(Command processingCommand)
@@ -248,8 +256,12 @@
}
};
- FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata, "example1", "1", "pm1", "1", "BINDING"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- serverRequest.initialize(request, env, BufferManagerFactory.getStandaloneBufferManager(), null, null, DEBUG, null, workContext, 101024);
+
+ ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+ Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+
+ serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, null, null, DEBUG, null, workContext, 101024,repo);
+
serverRequest.setMetadata(capFinder, metadata, null);
serverRequest.processRequest();
@@ -367,9 +379,9 @@
SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>();
- helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
+ helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, FakeMetadataFactory.example1VDB());
- helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
+ helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, FakeMetadataFactory.example1VDB());
//make sure the plan wasn't reused
assertEquals(0, planCache.getCacheHitCount());
}
@@ -384,7 +396,7 @@
List<String> values = Arrays.asList("aa "); //$NON-NLS-1$
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData2b(dataManager);
- helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+ helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false, FakeMetadataFactory.example1VDB());
}
@Test(expected=QueryValidatorException.class) public void testLimitValidation() throws Exception {
@@ -392,7 +404,7 @@
List values = Arrays.asList(-1);
FakeDataManager dataManager = new FakeDataManager();
- helpTestProcessing(preparedSql, values, null, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+ helpTestProcessing(preparedSql, values, null, dataManager, FakeMetadataFactory.example1Cached(), false, false, FakeMetadataFactory.example1VDB());
}
@Test public void testExecParam() throws Exception {
@@ -405,7 +417,7 @@
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
- helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+ helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false, FakeMetadataFactory.example1VDB());
}
@Test public void testLimitParam() throws Exception {
@@ -418,7 +430,7 @@
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
- helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+ helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false,FakeMetadataFactory.example1VDB());
}
@Test public void testXQueryParam() throws Exception {
@@ -431,7 +443,7 @@
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
- helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.exampleXQueryTransformations(), false, false);
+ helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.exampleXQueryTransformations(), false, false, FakeMetadataFactory.exampleXQueryTransformationsVDB());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -73,7 +73,7 @@
};
// Create the plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false,FakeMetadataFactory.example1VDB());
Update update = (Update)dataManager.getCommandHistory().iterator().next();
assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
}
@@ -147,7 +147,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
// Create the plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false,FakeMetadataFactory.example1VDB());
// Repeat with different number of commands in batch
// Create expected results
@@ -167,7 +167,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
// Use the cached plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true,FakeMetadataFactory.example1VDB());
// Verify all the queries that were run
assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
@@ -241,7 +241,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 1 WHERE pm1.g1.e1 = 'b'")); //$NON-NLS-1$
// Create the plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false, FakeMetadataFactory.example1VDB());
// Repeat
expected = new List[] {
@@ -259,7 +259,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 3 WHERE pm1.g1.e1 = 'd'")); //$NON-NLS-1$
// Use the cached plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true,FakeMetadataFactory.example1VDB());
// Verify all the queries that were run
assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
@@ -336,7 +336,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
// Create the plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false, FakeMetadataFactory.example1VDB());
// Repeat with different number of commands in batch
// Create expected results
@@ -353,7 +353,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
// Use the cached plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true, FakeMetadataFactory.example1VDB());
// Repeat with different number of commands in batch
// Create expected results
@@ -381,7 +381,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = TRUE WHERE pm1.g1.e2 = 4")); //$NON-NLS-1$
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true, FakeMetadataFactory.example1VDB());
// Verify all the queries that were run
assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
@@ -457,7 +457,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
// Create the plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false, FakeMetadataFactory.example1VDB());
// Repeat with different number of commands in batch
expected = new List[] {
@@ -472,7 +472,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
// Use the cached plan and process the query
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true, FakeMetadataFactory.example1VDB());
// Repeat with different number of commands in batch
expected = new List[] {
@@ -495,7 +495,7 @@
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'f', e3 = TRUE WHERE pm1.g1.e2 = 2")); //$NON-NLS-1$
finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'g', e3 = TRUE WHERE pm1.g1.e2 = 3")); //$NON-NLS-1$
- TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true,FakeMetadataFactory.example1VDB());
// Verify all the queries that were run
assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -30,24 +30,17 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryPlannerException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeAuthorizationService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -67,7 +60,7 @@
private final static String QUERY = "SELECT * FROM pm1.g1"; //$NON-NLS-1$
private final static String VDB = "VDB"; //$NON-NLS-1$
- private final static String VDB_VERSION = "1"; //$NON-NLS-1$
+ private final static int VDB_VERSION = 1; //$NON-NLS-1$
private final static String MODEL = "pm1"; //$NON-NLS-1$
private final static String BINDING_ID = "1"; //$NON-NLS-1$
private final static String BINDING_NAME = "BINDING"; //$NON-NLS-1$
@@ -87,13 +80,8 @@
doc1.putProperty(FakeMetadataObject.Props.XML_SCHEMAS, schemas);
RequestMessage message = new RequestMessage("select * from xmltest.doc1"); //$NON-NLS-1$
message.setValidationMode(true);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
- Request request = helpProcessMessage(environment, message, null, workContext);
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
+ Request request = helpProcessMessage(message, null, workContext);
assertEquals(schemas, request.schemas);
}
@@ -113,15 +101,14 @@
Command command = QueryParser.getQueryParser().parseCommand(QUERY);
QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
+ ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+ Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+
+
RequestMessage message = new RequestMessage();
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
- request.initialize(message, environment, null, null, null, false, null, workContext, 101024);
+ request.initialize(message, null, null, null,null,false, null, workContext, 101024, repo);
request.initMetadata();
request.validateAccess(command);
}
@@ -137,46 +124,32 @@
public void testProcessRequest() throws Exception {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
-
-
//Try before plan is cached.
//If this doesn't throw an exception, assume it was successful.
RequestMessage message = new RequestMessage(QUERY);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
- helpProcessMessage(environment, message, null, workContext);
+ helpProcessMessage(message, null, workContext);
//Try again, now that plan is already cached.
//If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
- helpProcessMessage(environment, message, null, workContext);
+ helpProcessMessage(message, null, workContext);
}
public void testCommandContext() throws Exception {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
-
-
//Try before plan is cached.
//If this doesn't throw an exception, assume it was successful.
RequestMessage message = new RequestMessage(QUERY);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
- Request request = helpProcessMessage(environment, message, null, workContext);
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
+
+ Request request = helpProcessMessage(message, null, workContext);
assertEquals("5", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
}
- private Request helpProcessMessage(FakeApplicationEnvironment environment,
- RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws QueryValidatorException,
+ private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws QueryValidatorException,
QueryParserException,
QueryResolverException,
MetaMatrixComponentException,
@@ -187,10 +160,14 @@
} else {
request = new Request();
}
- request.initialize(message, environment, Mockito.mock(BufferManager.class),
- new FakeDataManager(), null, false, null, workContext,
- 101024);
+ ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+ Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+
+ request.initialize(message, Mockito.mock(BufferManager.class),
+ new FakeDataManager(), null, null, false, null, workContext,
+ 101024, repo);
+
request.processRequest();
return request;
}
@@ -207,66 +184,24 @@
public void testProcessRequestPreparedStatement() throws Exception {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>();
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
//Try before plan is cached.
//If this doesn't throw an exception, assume it was successful.
RequestMessage message = new RequestMessage(QUERY);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
- message.setPreparedStatement(true);
+ DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
+
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(new ArrayList());
- helpProcessMessage(environment, message, cache, workContext);
+ helpProcessMessage(message, cache, workContext);
//Try again, now that plan is already cached.
//If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
- message.setPreparedStatement(true);
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(new ArrayList());
- helpProcessMessage(environment, message, cache, workContext);
+ helpProcessMessage(message, cache, workContext);
}
-
-
- /**Fake ApplicationEnvironment that always returns the same metadata*/
- public static final class FakeApplicationEnvironment extends ApplicationEnvironment {
- private QueryMetadataInterface metadata;
-
- private FakeVDBService fakeVDBService;
-
- public FakeApplicationEnvironment(QueryMetadataInterface metadata, String vdbname, String version, String model,
- String bindingID, String bindingName) {
- this.metadata = metadata;
-
- fakeVDBService = new FakeVDBService();
- fakeVDBService.addModel(vdbname, version, model, ModelInfo.PUBLIC, false);
- fakeVDBService.addBinding(vdbname, version, model, bindingID, bindingName);
- }
-
- public ApplicationService findService(String type) {
- if (type == DQPServiceNames.METADATA_SERVICE) {
- MetadataService mdSvc = Mockito.mock(MetadataService.class);
- try {
- Mockito.stub(mdSvc.lookupMetadata(Mockito.anyString(), Mockito.anyString())).toReturn(metadata);
- } catch (MetaMatrixComponentException e) {
- throw new RuntimeException(e);
- }
- return mdSvc;
- } else if (type == DQPServiceNames.VDB_SERVICE) {
- return fakeVDBService;
- } else if (type == DQPServiceNames.DATA_SERVICE) {
- return new AutoGenDataService();
- } else if (type == DQPServiceNames.AUTHORIZATION_SERVICE) {
- return new FakeAuthorizationService(true);
- }
-
- return null;
- }
- }
-
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -85,7 +85,15 @@
private void assertDoneState() {
checkState(ThreadState.DONE);
}
-
+
+ @Override
+ protected boolean assosiateSecurityContext() {
+ return false;
+ }
+
+ @Override
+ protected void clearSecurityContext() {
+ }
}
public TestWorkItemState(String name) {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,11 @@
package org.teiid.dqp.internal.process.multisource;
-import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
-import org.teiid.dqp.internal.process.multisource.MultiSourceElementReplacementVisitor;
-import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-
import junit.framework.TestCase;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
@@ -45,13 +41,10 @@
public class TestMultiSourceElementReplacementVisitor extends TestCase {
public QueryMetadataInterface getMetadata() throws Exception {
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addModel("MyVDB", "1", "MultiModel", ModelInfo.PUBLIC, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addBinding("MyVDB", "1", "MultiModel", "mmuuid:blahblahblah", "x"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- vdbService.addBinding("MyVDB", "1", "MultiModel", "mmuuid:foofoofoo", "y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
- Collection multiSourceModels = vdbService.getMultiSourceModels("MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ Set<String> multiSourceModels = new HashSet<String>();
+ multiSourceModels.add("MultiModel");
MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
return wrapper;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,18 +22,13 @@
package org.teiid.dqp.internal.process.multisource;
-import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Properties;
-import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
-import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -43,12 +38,8 @@
public class TestMultiSourceMetadataWrapper extends TestCase {
public void testMultiSourcePseudoElement() throws Exception {
- String vdbName = "My Cool VDB"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
-
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addModel(vdbName, vdbVersion, "BQT1", ModelInfo.PUBLIC, true); //$NON-NLS-1$
- Collection multiSourceModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
+ HashSet<String> multiSourceModels = new HashSet<String>();
+ multiSourceModels.add("BQT1");
MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(FakeMetadataFactory.exampleBQTCached(), multiSourceModels);
Object groupID = wrapper.getGroupID("BQT1.SmallA"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,26 +22,23 @@
package org.teiid.dqp.internal.process.multisource;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
-import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
-import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
-import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
+import org.junit.Test;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.process.DQPWorkContext;
-import junit.framework.TestCase;
-
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.QueryOptimizer;
@@ -68,7 +65,7 @@
*
* @since 4.2
*/
-public class TestMultiSourcePlanToProcessConverter extends TestCase {
+public class TestMultiSourcePlanToProcessConverter {
private final class MultiSourceDataManager extends HardcodedDataManager {
@@ -93,19 +90,21 @@
private static final boolean DEBUG = false;
- public void helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List[] expectedResults) throws Exception {
- final String vdbName = "MyVDB"; //$NON-NLS-1$
- final String vdbVersion = "1"; //$NON-NLS-1$
-
- // Set up metadata and other dependencies
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addModel(vdbName, vdbVersion, multiModel, ModelInfo.PUBLIC, true);
+ public void helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List[] expectedResults, VDBMetaData vdb) throws Exception {
- char sourceID = 'a';
- for(int i=0; i<sourceCount; i++, sourceID++) {
- vdbService.addBinding(vdbName, vdbVersion, multiModel, "mmuuid:source_" + sourceID, "" + sourceID); //$NON-NLS-1$ //$NON-NLS-2$
+ DQPWorkContext dqpContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
+
+ Set<String> multiSourceModels = vdb.getMultiSourceModelNames();
+ for (String model:multiSourceModels) {
+ char sourceID = 'a';
+ // by default every model has one binding associated, but for multi-source there were none assigned.
+ ModelMetaData m = vdb.getModel(model);
+ int x = m.getSourceNames().size();
+ for(int i=x; i<sourceCount; i++, sourceID++) {
+ m.addSourceMapping("" + sourceID, null);
+ }
}
- Set<String> multiSourceModels = new HashSet<String>(vdbService.getMultiSourceModels(vdbName, vdbVersion));
+
MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
AnalysisRecord analysis = new AnalysisRecord(false, false, DEBUG);
@@ -122,8 +121,8 @@
idGenerator.setDefaultFactory(new IntegerIDFactory());
Properties props = new Properties();
- CommandContext context = new CommandContext("0", "test", "user", null, vdbName, vdbVersion, props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, vdbName, vdbService, vdbVersion, context));
+ CommandContext context = new CommandContext("0", "test", "user", null, vdb.getName(), vdb.getVersion(), props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, dqpContext, context));
ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);
@@ -135,7 +134,7 @@
TestProcessor.helpProcess(plan, context, dataMgr, expectedResults);
}
- public void testNoReplacement() throws Exception {
+ @Test public void testNoReplacement() throws Exception {
final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "SELECT * FROM MultiModel.Phys WHERE SOURCE_NAME = 'bogus'"; //$NON-NLS-1$
final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -143,10 +142,10 @@
final List[] expected =
new List[0];
final ProcessorDataManager dataMgr = new MultiSourceDataManager();
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
- public void testSingleReplacement() throws Exception {
+ @Test public void testSingleReplacement() throws Exception {
final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "SELECT * FROM MultiModel.Phys WHERE SOURCE_NAME = 'a'"; //$NON-NLS-1$
final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -155,10 +154,10 @@
new List[] { Arrays.asList(new Object[] { null, null, null}) };
final HardcodedDataManager dataMgr = new MultiSourceDataManager();
dataMgr.setMustRegisterCommands(false);
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
- public void testMultiReplacement() throws Exception {
+ @Test public void testMultiReplacement() throws Exception {
final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "SELECT * FROM MultiModel.Phys"; //$NON-NLS-1$
final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -168,10 +167,10 @@
Arrays.asList(new Object[] { null, null, null}),
Arrays.asList(new Object[] { null, null, null})};
final ProcessorDataManager dataMgr = new MultiSourceDataManager();
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
- public void testMultiReplacementWithOrderBy() throws Exception {
+ @Test public void testMultiReplacementWithOrderBy() throws Exception {
FakeMetadataFacade metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "SELECT * FROM MultiModel.Phys order by a"; //$NON-NLS-1$
@@ -192,10 +191,10 @@
new List[] {
Arrays.asList("e", "z", "b"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList("f", "z", "b")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
- public void testMultiReplacementWithLimit() throws Exception {
+ @Test public void testMultiReplacementWithLimit() throws Exception {
final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "SELECT distinct * FROM MultiModel.Phys order by a limit 1"; //$NON-NLS-1$
final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -212,10 +211,10 @@
new List[] {
Arrays.asList("e", "z", "b"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList("f", "z", "b")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
- public void testMultiDependentJoin() throws Exception {
+ @Test public void testMultiDependentJoin() throws Exception {
FakeMetadataFacade metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "SELECT a.a FROM MultiModel.Phys a inner join MultiModel.Phys b makedep on (a.a = b.a) order by a"; //$NON-NLS-1$
@@ -238,17 +237,17 @@
dataMgr.addData("SELECT g_0.a FROM MultiModel.Phys AS g_0 WHERE g_0.a IN ('x', 'y')", //$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { "x" }), //$NON-NLS-1$
Arrays.asList(new Object[] { "y" })}); //$NON-NLS-1$
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
- public void testSingleReplacementInDynamicCommand() throws Exception {
+ @Test public void testSingleReplacementInDynamicCommand() throws Exception {
final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "exec Virt.sq1('a')"; //$NON-NLS-1$
final String multiModel = "MultiModel"; //$NON-NLS-1$
final int sources = 3;
final List[] expected = new List[] { Arrays.asList(new Object[] { null, null}), };
final ProcessorDataManager dataMgr = new MultiSourceDataManager();
- helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,21 +27,18 @@
import java.util.Iterator;
import java.util.Set;
+import junit.framework.TestCase;
+
import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.process.Request;
-import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
-import junit.framework.TestCase;
-
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.FakeAuthorizationService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
@@ -68,40 +65,40 @@
FakeAuthorizationService svc = new FakeAuthorizationService(false);
// pm1.g1
- svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_READ, "pm1.g1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_READ, "pm1.g1.e1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_READ, "pm1.g1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_READ, "pm1.g1.e1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e2"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e3"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e4"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e3"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e4"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1.e2"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1.e3"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1.e4"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1.e2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1.e3"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1.e4"); //$NON-NLS-1$
// pm1.g2
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2.e2"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2.e3"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2.e4"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2.e2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2.e3"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2.e4"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2.e2"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2.e3"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2.e4"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2.e2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2.e3"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2.e4"); //$NON-NLS-1$
// pm1.g4
- svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g4"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g4.e1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g4.e2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g4"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g4.e1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g4.e2"); //$NON-NLS-1$
// pm1.sq2
- svc.addResource(CONN_ID, AuthorizationService.ACTION_READ, "pm1.sq1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.ACTION_READ, "pm1.sq1"); //$NON-NLS-1$
return svc;
}
@@ -111,21 +108,23 @@
FakeAuthorizationService svc = new FakeAuthorizationService(true);
// pm2.g2
- svc.addResource(CONN_ID, AuthorizationService.CONTEXT_INSERT, "pm2.g2.e1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.CONTEXT_INSERT, "pm2.g2.e1"); //$NON-NLS-1$
// pm3.g2
- svc.addResource(CONN_ID, AuthorizationService.CONTEXT_INSERT, "pm3.g2.e1"); //$NON-NLS-1$
- svc.addResource(CONN_ID, AuthorizationService.CONTEXT_INSERT, "pm3.g2.e2"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.CONTEXT_INSERT, "pm3.g2.e1"); //$NON-NLS-1$
+ svc.addResource(AuthorizationService.CONTEXT_INSERT, "pm3.g2.e2"); //$NON-NLS-1$
return svc;
}
- private void helpTest(AuthorizationService svc, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ private void helpTest(AuthorizationService svc, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(CONN_ID, svc, Mockito.mock(VDBService.class), "foo", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ vdb.addAttchment(QueryMetadataInterface.class, metadata);
+
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(svc, vdb);
ValidatorReport report = Validator.validate(command, metadata, visitor);
if(report.hasItems()) {
ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
@@ -146,109 +145,107 @@
}
public void testEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testEverythingAccessible1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testEverythingAccessible2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testInaccesibleElement() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testInaccesibleElement2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testInsertInaccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testUpdateCriteriaInaccessibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testUpdateElementInaccessibleForUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDelete() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testDeleteCriteriaInaccesibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDeleteInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g3"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testProc() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testProcInaccesible() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testSelectIntoEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm2.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm2.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm3.g2.e1", "pm3.g2.e2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm3.g2.e1", "pm3.g2.e2"},FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testTempTableSelectInto() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testTempTableSelectInto1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTempTableInsert() throws Exception {
- helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testXMLAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+ helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
public void testXMLInAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, MetaMatrixComponentException {
- FakeVDBService vdbService = new FakeVDBService();
- String vdbName = "foo"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
- String modelName = "pm1"; //$NON-NLS-1$
- vdbService.addModel(vdbName, vdbVersion, modelName, visible?ModelInfo.PUBLIC:ModelInfo.PRIVATE, false);
- AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(CONN_ID, Mockito.mock(AuthorizationService.class), vdbService, vdbName, vdbVersion);
-
+ VDBMetaData vdb = FakeMetadataFactory.example1VDB();
+ if (!visible) {
+ vdb.getModel("pm1").setVisible(false);
+ }
+ AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(Mockito.mock(AuthorizationService.class), vdb);
String sql = "select lookup('pm1.g1', 'e1', 'e2', 1)"; //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(sql);
Request.validateWithVisitor(mvvv, FakeMetadataFactory.example1Cached(), command);
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.transaction;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.xa.XAResource;
-
-import org.teiid.dqp.internal.transaction.TransactionContextImpl;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.UnitTestUtil;
-
-public class TestTransactionContextImpl extends TestCase {
-
- public void testSerialization() throws Exception {
- TransactionContextImpl context = new TransactionContextImpl();
-
- UnitTestUtil.helpSerialize(context);
-
- context.setTransaction(new Transaction() {
-
- public void commit() throws RollbackException,
- HeuristicMixedException,
- HeuristicRollbackException,
- SecurityException,
- IllegalStateException,
- SystemException {
- }
-
- public boolean delistResource(XAResource arg0,
- int arg1) throws IllegalStateException,
- SystemException {
- return false;
- }
-
- public boolean enlistResource(XAResource arg0) throws RollbackException,
- IllegalStateException,
- SystemException {
- return false;
- }
-
- public int getStatus() throws SystemException {
- return 0;
- }
-
- public void registerSynchronization(Synchronization arg0) throws RollbackException,
- IllegalStateException,
- SystemException {
- }
-
- public void rollback() throws IllegalStateException,
- SystemException {
- }
-
- public void setRollbackOnly() throws IllegalStateException,
- SystemException {
- }
-
- }, "foo"); //$NON-NLS-1$
-
- try {
- UnitTestUtil.helpSerialize(context);
- fail("expected exception"); //$NON-NLS-1$
- } catch (MetaMatrixRuntimeException e) {
-
- }
- }
-
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,20 +22,23 @@
package org.teiid.dqp.internal.transaction;
+import javax.resource.spi.XATerminator;
import javax.transaction.xa.XAResource;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.adminapi.Transaction;
-import junit.framework.TestCase;
-
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.util.SimpleMock;
+import com.metamatrix.dqp.service.TransactionContext;
public class TestTransactionServer extends TestCase {
private TransactionServerImpl server;
-
+ private XATerminator xaTerminator;
+
private static final String THREAD1 = "1"; //$NON-NLS-1$
private static final String THREAD2 = "2"; //$NON-NLS-1$
@@ -51,7 +54,11 @@
*/
protected void setUp() throws Exception {
server = new TransactionServerImpl();
- server.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class));
+ TransactionProvider provider = Mockito.mock(TransactionProvider.class);
+ xaTerminator = Mockito.mock(XATerminator.class);
+ Mockito.stub(provider.getXATerminator()).toReturn(xaTerminator);
+ server.setTransactionProvider(provider);
+ server.setXidFactory(new XidFactory());
}
/**
@@ -61,7 +68,7 @@
server.begin(THREAD1);
try {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
assertEquals("Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$
@@ -73,7 +80,7 @@
* once in a global, cannot start a local
*/
public void testTransactionExclusion1() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
try {
server.begin(THREAD1);
@@ -88,13 +95,13 @@
* global can only be started once
*/
public void testTransactionExclusion2() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
try {
- server.start(THREAD2, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD2, XID1, XAResource.TMNOFLAGS, 100,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
- assertEquals("Global transaction MMXid global:1 branch:null format:0 already exists.", ex.getMessage()); //$NON-NLS-1$
+ assertEquals("Global transaction Teiid-Xid global:1 branch:null format:0 already exists.", ex.getMessage()); //$NON-NLS-1$
}
}
@@ -102,10 +109,10 @@
* global cannot be nested
*/
public void testTransactionExclusion3() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
try {
- server.start(THREAD1, XID2, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID2, XAResource.TMNOFLAGS, 100,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
assertEquals("Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$
@@ -132,12 +139,12 @@
* global cannot be nested
*/
public void testTransactionExclusion5() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
- server.start(THREAD2, XID2, XAResource.TMNOFLAGS, 100);
- server.end(THREAD2, XID2, XAResource.TMSUCCESS);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ server.start(THREAD2, XID2, XAResource.TMNOFLAGS, 100,false);
+ server.end(THREAD2, XID2, XAResource.TMSUCCESS,false);
try {
- server.start(THREAD1, XID2, XAResource.TMJOIN, 100);
+ server.start(THREAD1, XID2, XAResource.TMJOIN, 100,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
assertEquals("Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$
@@ -156,10 +163,49 @@
}
}
+ public void testLocalSetRollback() throws Exception {
+ TransactionContext tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("s1");
+ tc.setRollbackOnly();
+
+ server.commit(THREAD1);
+
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+ }
+
+ public void testSinglePhaseCommit() throws Exception {
+ TransactionContext tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("S1");
+
+ server.commit(THREAD1);
+
+ Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+
+ tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("S1");
+ tc.incrementPartcipatingSourceCount("S1");
+
+ server.commit(THREAD1);
+
+ Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+ }
+
+ public void testTwoPhaseCommit() throws Exception {
+ TransactionContext tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("S1");
+ tc.incrementPartcipatingSourceCount("S2");
+
+ server.commit(THREAD1);
+
+ Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+ }
+
public void testLocalRollback() throws Exception {
- server.begin(THREAD1);
+ TransactionContext tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("s1");
server.rollback(THREAD1);
-
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+
try {
server.rollback(THREAD1);
} catch (XATransactionException e) {
@@ -168,46 +214,46 @@
}
public void testConcurrentEnlistment() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
try {
- server.start(THREAD1, XID1, XAResource.TMJOIN, 100);
+ server.start(THREAD1, XID1, XAResource.TMJOIN, 100,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
- assertEquals("Concurrent enlistment in global transaction MMXid global:1 branch:null format:0 is not supported.", //$NON-NLS-1$
+ assertEquals("Concurrent enlistment in global transaction Teiid-Xid global:1 branch:null format:0 is not supported.", //$NON-NLS-1$
ex.getMessage());
}
}
public void testSuspend() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
- server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
try {
- server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+ server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
- assertEquals("Client is not currently enlisted in transaction MMXid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
+ assertEquals("Client is not currently enlisted in transaction Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
}
}
public void testSuspendResume() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
- server.end(THREAD1, XID1, XAResource.TMSUSPEND);
- server.start(THREAD1, XID1, XAResource.TMRESUME, 100);
- server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
+ server.start(THREAD1, XID1, XAResource.TMRESUME, 100,false);
+ server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
try {
- server.start(THREAD2, XID1, XAResource.TMRESUME, 100);
+ server.start(THREAD2, XID1, XAResource.TMRESUME, 100,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
- assertEquals("Cannot resume, transaction MMXid global:1 branch:null format:0 was not suspended by client 2.", ex.getMessage()); //$NON-NLS-1$
+ assertEquals("Cannot resume, transaction Teiid-Xid global:1 branch:null format:0 was not suspended by client 2.", ex.getMessage()); //$NON-NLS-1$
}
}
public void testUnknownFlags() throws Exception {
try {
- server.start(THREAD1, XID1, Integer.MAX_VALUE, 100);
+ server.start(THREAD1, XID1, Integer.MAX_VALUE, 100,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
assertEquals("Unknown flags", ex.getMessage()); //$NON-NLS-1$
@@ -216,22 +262,22 @@
public void testUnknownGlobalTransaction() throws Exception {
try {
- server.end(THREAD1, XID1, XAResource.TMSUCCESS);
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
- assertEquals("No global transaction found for MMXid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
+ assertEquals("No global transaction found for Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
}
}
public void testPrepareWithSuspended() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
- server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
try {
- server.prepare(THREAD1, XID1);
+ server.prepare(THREAD1, XID1,false);
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException ex) {
- assertEquals("Suspended work still exists on transaction MMXid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
+ assertEquals("Suspended work still exists on transaction Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
}
}
@@ -240,7 +286,7 @@
}
public void testGetTransactions() throws Exception {
- server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
server.begin(THREAD2);
assertEquals(2, server.getTransactions().size());
@@ -249,7 +295,184 @@
assertEquals(1, server.getTransactions().size());
Transaction t = server.getTransactions().iterator().next();
- assertEquals(THREAD1, t.getAssociatedSession());
+ assertEquals(Long.parseLong(THREAD1), t.getAssociatedSession());
assertNotNull(t.getXid());
}
+
+ public void testGlobalPrepare() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+
+ server.prepare(THREAD1, XID1, false);
+
+ Mockito.verify(xaTerminator).prepare(tc.getXid());
+
+ server.commit(THREAD1, XID1, true, false);
+ }
+
+ public void testGlobalPrepareFail() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ server.end(THREAD1, XID1, XAResource.TMFAIL, false);
+
+ try {
+ server.prepare(THREAD1, XID1, false);
+ fail("should have failed to prepare as end resulted in TMFAIL");
+ } catch (Exception e) {
+ }
+
+ server.forget(THREAD1, XID1, false);
+ }
+
+ public void testGlobalOnePhaseCommit() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+
+ tc.incrementPartcipatingSourceCount("S1");
+
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+
+ server.prepare(THREAD1, XID1, false);
+
+
+ server.commit(THREAD1, XID1, true, false);
+
+ // since there are two sources the commit is not single phase
+ Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+ }
+
+ public void testGlobalOnePhaseCommit_force_prepare_through() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+
+ tc.incrementPartcipatingSourceCount("S1");
+
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+
+
+ server.commit(THREAD1, XID1, true, false);
+
+ // since there are two sources the commit is not single phase
+ Mockito.verify(xaTerminator, Mockito.times(0)).prepare(tc.getXid());
+ Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+ }
+
+ public void testGlobalOnePhaseCommit_force_prepare() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+
+ tc.incrementPartcipatingSourceCount("S1");
+ tc.incrementPartcipatingSourceCount("S2");
+
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+
+
+ server.commit(THREAD1, XID1, true, false);
+
+ // since there are two sources the commit is not single phase
+ Mockito.verify(xaTerminator).prepare(tc.getXid());
+ Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+ }
+
+
+ public void testGlobalOnePhase_teiid_multiple() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+
+ tc.incrementPartcipatingSourceCount("S1");
+ tc.incrementPartcipatingSourceCount("S2");
+
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+
+ server.prepare(THREAD1, XID1, false);
+
+
+ server.commit(THREAD1, XID1, true, false);
+
+ // since there are two sources the commit is not single phase
+ Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+ }
+
+ public void testGlobalOnePhaseRoolback() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+
+ tc.incrementPartcipatingSourceCount("S1");
+
+ server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+
+ server.prepare(THREAD1, XID1, false);
+
+
+ server.rollback(THREAD1, XID1, false);
+
+ // since there are two sources the commit is not single phase
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+ }
+
+ public void testLocalCommit_rollback() throws Exception {
+ TransactionContext tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("s1");
+ tc.setRollbackOnly();
+ server.commit(THREAD1);
+
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+ }
+
+ public void testLocalCommit_not_in_Tx() throws Exception {
+ TransactionContext tc = server.begin(THREAD1);
+ server.commit(THREAD1);
+
+ Mockito.verify(xaTerminator,Mockito.times(0)).commit(tc.getXid(), true);
+ }
+
+ public void testRequestCommit() throws Exception{
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+ server.start(tc);
+ tc.incrementPartcipatingSourceCount("s1");
+ server.commit(tc);
+ Mockito.verify(xaTerminator,Mockito.times(0)).prepare(tc.getXid());
+ Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+ }
+
+ public void testRequestCommit2() throws Exception{
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+ server.start(tc);
+ tc.incrementPartcipatingSourceCount("s1");
+ tc.incrementPartcipatingSourceCount("s2");
+ server.commit(tc);
+
+ Mockito.verify(xaTerminator).prepare(tc.getXid());
+ Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+ }
+
+ public void testRequestRollback() throws Exception{
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+ server.start(tc);
+ tc.incrementPartcipatingSourceCount("s1");
+ tc.incrementPartcipatingSourceCount("s2");
+
+ server.rollback(tc);
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+ }
+
+ public void testLocalCancel() throws Exception {
+ TransactionContext tc = server.begin(THREAD1);
+ tc.incrementPartcipatingSourceCount("S1");
+ tc.incrementPartcipatingSourceCount("S2");
+
+ server.cancelTransactions(THREAD1, false);
+
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+ }
+
+ public void testRequestCancel() throws Exception{
+ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+ server.start(tc);
+ tc.incrementPartcipatingSourceCount("s1");
+ tc.incrementPartcipatingSourceCount("s2");
+
+ server.cancelTransactions(THREAD1, true);
+ Mockito.verify(xaTerminator).rollback(tc.getXid());
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,15 +31,16 @@
import java.util.Properties;
import org.junit.Test;
-import org.mockito.Mockito;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
+import com.metamatrix.core.vdb.ModelType;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestTransformationMetadata {
@@ -50,8 +51,18 @@
mf.addProcedure("y"); //$NON-NLS-1$
MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
mf1.addProcedure("y"); //$NON-NLS-1$
- CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()), Mockito.mock(MetadataSource.class));
- TransformationMetadata tm = new TransformationMetadata(cms);
+ CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
+
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("vdb");
+ vdb.setVersion(1);
+
+ vdb.addModel(buildModel("x"));
+ vdb.addModel(buildModel("x1"));
+
+ TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
+ DQPWorkContext context = FakeMetadataFactory.buildWorkContext(tm, vdb);
+
try {
tm.getStoredProcedureInfoForProcedure("y"); //$NON-NLS-1$
fail("expected exception"); //$NON-NLS-1$
@@ -60,6 +71,14 @@
}
}
+ ModelMetaData buildModel(String name) {
+ ModelMetaData model = new ModelMetaData();
+ model.setName(name);
+ model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+ model.setVisible(true);
+ return model;
+ }
+
@Test public void testAmbiguousTableWithPrivateModel() throws Exception {
Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
@@ -67,20 +86,32 @@
mf.addTable("y"); //$NON-NLS-1$
MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
mf1.addTable("y"); //$NON-NLS-1$
- MetadataSource ms = Mockito.mock(MetadataSource.class);
- Mockito.stub(ms.getName()).toReturn("foo"); //$NON-NLS-1$
- CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()), ms);
- TransformationMetadata tm = new TransformationMetadata(cms);
+ CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
+
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("foo");
+ vdb.setVersion(1);
+
+ ModelMetaData model = new ModelMetaData();
+ model.setName("x1");
+ vdb.addModel(model);
+
+ ModelMetaData model2 = new ModelMetaData();
+ model2.setName("x");
+ model2.setVisible(true);
+ vdb.addModel(model2);
+
+ TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(2, result.size());
-
- VDBService vdbService = Mockito.mock(VDBService.class);
- Mockito.stub(vdbService.getModelVisibility("foo", "1", "x1")).toReturn((int)ModelInfo.PRIVATE); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Mockito.stub(vdbService.getModelVisibility("foo", "1", "x")).toReturn((int)ModelInfo.PUBLIC); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- tm = new TransformationMetadata(cms, vdbService, "1"); //$NON-NLS-1$
+
+ FakeMetadataFactory.buildWorkContext(tm, vdb);
+
+ model.setVisible(false);
+
+ tm = new TransformationMetadata(vdb, cms, null, null);
result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(1, result.size());
-
}
}
14 years, 2 months
teiid SVN: r1915 - in trunk/engine/src/main/java/com/metamatrix/common/buffer: impl and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-05 09:18:19 -0500 (Fri, 05 Mar 2010)
New Revision: 1915
Modified:
trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
Log:
TEIID-833 committing JCA merge
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java 2010-03-05 14:14:05 UTC (rev 1914)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java 2010-03-05 14:18:19 UTC (rev 1915)
@@ -22,13 +22,11 @@
package com.metamatrix.common.buffer;
-import java.util.Properties;
-
import com.metamatrix.api.exception.MetaMatrixComponentException;
public interface StorageManager {
- void initialize(Properties props) throws MetaMatrixComponentException;
+ void initialize() throws MetaMatrixComponentException;
FileStore createFileStore(String name);
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-03-05 14:14:05 UTC (rev 1914)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-03-05 14:18:19 UTC (rev 1915)
@@ -32,7 +32,6 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -59,7 +58,6 @@
import com.metamatrix.common.types.StandardXMLTranslator;
import com.metamatrix.common.types.Streamable;
import com.metamatrix.common.types.XMLType;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
@@ -367,8 +365,7 @@
}
@Override
- public void initialize(Properties props) throws MetaMatrixComponentException {
- PropertiesUtils.setBeanProperties(this, props, "org.teiid.buffer"); //$NON-NLS-1$
+ public void initialize() throws MetaMatrixComponentException {
DataTypeManager.addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
@Override
public XMLType transform(Source value) {
14 years, 2 months
teiid SVN: r1914 - trunk/engine/src/main/java/com/metamatrix/common/buffer/impl.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-05 09:14:05 -0500 (Fri, 05 Mar 2010)
New Revision: 1914
Modified:
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java
Log:
TEIID-833 committing JCA merge
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java 2010-03-04 20:47:34 UTC (rev 1913)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java 2010-03-05 14:14:05 UTC (rev 1914)
@@ -23,7 +23,6 @@
package com.metamatrix.common.buffer.impl;
import java.nio.ByteBuffer;
-import java.util.Properties;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.FileStore;
@@ -31,10 +30,7 @@
public class MemoryStorageManager implements StorageManager {
- /**
- * @see StorageManager#initialize(Properties)
- */
- public void initialize(Properties props) throws MetaMatrixComponentException {
+ public void initialize() {
}
@Override
14 years, 2 months
teiid SVN: r1913 - in trunk/connector-api: src/main/java/org/teiid/connector/api and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-04 15:47:34 -0500 (Thu, 04 Mar 2010)
New Revision: 1913
Added:
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectionContext.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicResourceAdapter.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/ConnectionRequestInfoWrapper.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/TypeFacilityImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnector.java
trunk/connector-api/src/main/java/org/teiid/connector/language/AggregateFunction.java
trunk/connector-api/src/main/java/org/teiid/connector/language/AndOr.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Argument.java
trunk/connector-api/src/main/java/org/teiid/connector/language/BaseInCondition.java
trunk/connector-api/src/main/java/org/teiid/connector/language/BaseLanguageObject.java
trunk/connector-api/src/main/java/org/teiid/connector/language/BatchedUpdates.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Call.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ColumnReference.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Command.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Comparison.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Condition.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Delete.java
trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedColumn.java
trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedTable.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Exists.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Expression.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ExpressionValueSource.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Function.java
trunk/connector-api/src/main/java/org/teiid/connector/language/GroupBy.java
trunk/connector-api/src/main/java/org/teiid/connector/language/In.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Insert.java
trunk/connector-api/src/main/java/org/teiid/connector/language/InsertValueSource.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IsNull.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Join.java
trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageObject.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Like.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Limit.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Literal.java
trunk/connector-api/src/main/java/org/teiid/connector/language/MetadataReference.java
trunk/connector-api/src/main/java/org/teiid/connector/language/NamedTable.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Not.java
trunk/connector-api/src/main/java/org/teiid/connector/language/OrderBy.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Predicate.java
trunk/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SQLReservedWords.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedWhenClause.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Select.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SetClause.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SortSpecification.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryComparison.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryContainer.java
trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryIn.java
trunk/connector-api/src/main/java/org/teiid/connector/language/TableReference.java
trunk/connector-api/src/main/java/org/teiid/connector/language/Update.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java
trunk/connector-api/src/test/java/org/teiid/connector/TestWrappedConnector.java
Removed:
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorIdentity.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorPropertyNames.java
trunk/connector-api/src/main/java/org/teiid/connector/api/CredentialMap.java
trunk/connector-api/src/main/java/org/teiid/connector/api/MappedUserIdentity.java
trunk/connector-api/src/main/java/org/teiid/connector/api/SingleIdentity.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IAggregate.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IBaseInCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IBatchedUpdates.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ICommand.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ICompareCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ICompoundCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ICriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IDelete.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IElement.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IExistsCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IExpression.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IFrom.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IFromItem.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IFunction.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IGroup.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IGroupBy.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IInCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IInlineView.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IInsert.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertExpressionValueSource.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertValueSource.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IIsNullCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IJoin.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageObject.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ILikeCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ILimit.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ILiteral.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ILogicalCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IMetadataReference.java
trunk/connector-api/src/main/java/org/teiid/connector/language/INotCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderBy.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderByItem.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IParameter.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IPredicateCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IProcedure.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IQuery.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IQueryCommand.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IScalarSubquery.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISearchedCaseExpression.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISelect.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISelectSymbol.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClause.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClauseList.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISetQuery.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryCompareCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryContainer.java
trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryInCriteria.java
trunk/connector-api/src/main/java/org/teiid/connector/language/IUpdate.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Element.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Group.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataObject.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Parameter.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TypeModel.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java
trunk/connector-api/src/main/java/org/teiid/connector/xa/api/
trunk/connector-api/src/test/java/org/teiid/connector/TestCredentialMap.java
Modified:
trunk/connector-api/pom.xml
trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java
trunk/connector-api/src/main/java/org/teiid/connector/api/Connector.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorException.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorLogger.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ProcedureExecution.java
trunk/connector-api/src/main/java/org/teiid/connector/api/ResultSetExecution.java
trunk/connector-api/src/main/java/org/teiid/connector/api/UpdateExecution.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnection.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageUtil.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
Log:
TEIID-833 committing JCA merge
Modified: trunk/connector-api/pom.xml
===================================================================
--- trunk/connector-api/pom.xml 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/pom.xml 2010-03-04 20:47:34 UTC (rev 1913)
@@ -16,6 +16,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -26,17 +27,11 @@
</dependency>
<dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-internal</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
</dependency>
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- </dependency>
-
</dependencies>
<build>
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,15 +22,16 @@
package org.teiid.connector.api;
-import org.teiid.connector.language.ICommand;
+import javax.resource.spi.LocalTransaction;
+import javax.transaction.xa.XAResource;
+
+import org.teiid.connector.language.Command;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
/**
* <p>Represents a connection to this connector. A connection will be obtained
* from the connector for every query that is executed, then closed after the query has completed.
* </p>
- * <p>If pooling is enabled, see {@link PoolAwareConnection} to optionally implement pooling specific behavior.
- * </p>
*/
public interface Connection {
@@ -39,20 +40,20 @@
* queries (and other commands) will be sent to the connector.
* @return Connector capabilities, may return null if the Connector returns globally scoped capabilities {@link Connector#getCapabilities()}
*/
- ConnectorCapabilities getCapabilities();
+ ConnectorCapabilities getCapabilities() throws ConnectorException;
/**
* Create an execution object for the specified command
* @param command the command
* @param executionContext Provides information about the context that this command is
- * executing within, such as the identifiers for the MetaMatrix command being executed
+ * executing within, such as the identifiers for the command being executed
* @param metadata Access to runtime metadata if needed to translate the command
- * @return An execution object that MetaMatrix can use to execute the command
+ * @return An execution object that can use to execute the command
*/
- Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata ) throws ConnectorException;
+ Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata ) throws ConnectorException;
/**
- * Release the connection. This will be called when MetaMatrix has completed
+ * Release the connection. This will be called when system has completed
* using the connection for an execution.
*/
void close();
@@ -62,20 +63,17 @@
* @return true if open, false if there is a source error.
*/
boolean isAlive();
+
+ /**
+ * Get the local transaction for the connector.
+ * @return null if local transactions are not supported
+ */
+ LocalTransaction getLocalTransaction() throws ConnectorException;
- /**
- * Called by the pool when an existing connection is leased so that the underlying
- * Connection may have it's identity switched to a different user.
- * @param identity
- * @throws ConnectorException
- */
- void setConnectorIdentity(ConnectorIdentity context)
- throws ConnectorException;
-
/**
- * Called by the pool to indicate that the connection was returned to the pool.
- * The actual close call will be made when the pool wants to purge this connection.
+ * If Connector supports participating in XA Connections, return the XAResurce associated with this connection.
+ * @return null if not supported
*/
- void closeCalled();
+ XAResource getXAResource() throws ConnectorException;
}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectionContext.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/api/ConnectionContext.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectionContext.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectionContext.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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.connector.api;
+
+import javax.security.auth.Subject;
+
+/**
+ * Thread local class to access the Subject in the Connector code. This is set just before the
+ * connector connection is created.
+ */
+public class ConnectionContext {
+ private static ThreadLocal<Subject> SUBJECT = new ThreadLocal<Subject>() {
+ protected Subject initialValue() {
+ return null;
+ }
+ };
+
+ public static Subject getSubject() {
+ return SUBJECT.get();
+ }
+
+ public static void setSubject(Subject subject) {
+ SUBJECT.set(subject);
+ }
+}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/Connector.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/Connector.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/Connector.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,67 +22,49 @@
package org.teiid.connector.api;
+import javax.security.auth.Subject;
+
/**
* <p>The primary entry point for a Connector. This interface should be implemented
* by the connector writer.</p>
*
- * <p>The Connector Manager will instantiate the implementation
- * of this class by reflection in an isolated classloader. Once the class has been
+ * <p>The JCA Container will instantiate the implementation of this class. Once the class has been
* instantiated, the {@link #initialize(ConnectorEnvironment)} method will be called
- * with all necessary connector properties. The {@link #start()} and {@link #stop()}
- * methods are lifecycle methods called when starting or stopping the connector.</p>
+ * with all necessary connector properties. </p>
*/
public interface Connector {
+ /**
+ * Initialize the connector with supplied configuration
+ * @param config
+ */
+ void initialize(ConnectorEnvironment config) throws ConnectorException;
+
/**
- * Start the connector with the connector environment. The environment
- * provides access to external resources the connector implementation may
- * need to use.
- * @param environment The connector environment, provided by the Connector Manager
- * @throws ConnectorException
- */
- void start(ConnectorEnvironment environment) throws ConnectorException;
-
- /**
- * Stop the connector. No commands will be executed on the connector when it is
- * stopped.
- */
- void stop();
-
- /**
* Obtain a connection with the connector. The connection typically is associated
- * with a particular security context. The connection is assumed to be pooled in
- * the underlying source if pooling is necessary - the connection will be closed
- * when execution has completed against it.
- * @param context The context of the current user that will be using this connection,
- * may be null if this connection is for an administrative operation.
+ * with a particular security context. The connection is assumed to be pooled by container
+ * if pooling is necessary - the connection will be closed when execution has completed against it.
+ *
+ * If you need to authenticate/authorize and need to get access to {{@link Subject}, then use
+ * {@link ConnectionContext}
+ *
* @return A Connection, created by the Connector
* @throws ConnectorException If an error occurred obtaining a connection
*/
- Connection getConnection( ExecutionContext context ) throws ConnectorException;
+ Connection getConnection() throws ConnectorException;
/**
* Get the capabilities of this connector. The capabilities affect what kinds of
* queries (and other commands) will be sent to the connector.
* @return ConnectorCapabilities, may return null if the Connector provides User scoped capabilities {@link Connection#getCapabilities()}
*/
- ConnectorCapabilities getCapabilities();
+ ConnectorCapabilities getCapabilities() throws ConnectorException;
- /**
- * Create an identity object based on a security context.
- *
- * If single identity is not supported then an exception should be thrown when a
- * null context is supplied.
- *
- * Implementors of this class may use a different implementation of the
- * {@link ConnectorIdentity} interface to similarly affect pooling.
- *
- * @param context The context provided by the Connector Manager
- * @return The associated connector identity
- * @throws ConnectorException If a null context is not accepted or an error occurs while creating the identity.
- */
- ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException;
-
+ /**
+ * Get the ConnectorEnvironment that this connector is initialized with.
+ * @return
+ * @throws ConnectorException
+ */
+ ConnectorEnvironment getConnectorEnvironment();
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -31,22 +31,8 @@
public class ConnectorAnnotations {
- /**
- * The Pooling Annotation can be used to enable/suppress automatic pooling.
- *
- * This is especially useful in situations where legacy ConnectionPool properties
- * are still in use and thus {@link ConnectorPropertyNames#CONNECTION_POOL_ENABLED}
- * is set to true or when a connector cannot possibly provide a proper implementation
- * of a {@link ConnectorIdentityFactory}.
- */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
- public @interface ConnectionPooling {
- boolean enabled() default true;
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.TYPE})
public @interface SynchronousWorkers {
boolean enabled() default true;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,8 +24,8 @@
import java.util.List;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ISetQuery;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.SetQuery;
/**
@@ -373,7 +373,7 @@
boolean requiresCriteria();
/**
- * Whether the source supports {@link IBatchedUpdates}
+ * Whether the source supports {@link BatchedUpdates}
* @since 6.0
*/
boolean supportsBatchedUpdates();
@@ -386,7 +386,7 @@
/**
* Support indicates that the connector can accept INSERTs with
- * values specified by an {@link ISetQuery}.
+ * values specified by an {@link SetQuery}.
* @since 6.1
*/
boolean supportsInsertWithQueryExpression();
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -23,12 +23,8 @@
package org.teiid.connector.api;
import java.util.Properties;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import org.teiid.connector.language.ILanguageFactory;
+import org.teiid.connector.language.LanguageFactory;
/**
@@ -36,24 +32,47 @@
* environment provides access to external resources the Connector writer may
* need.
*/
-public interface ConnectorEnvironment extends Executor {
+public interface ConnectorEnvironment {
- /**
- * Get all configuration properties provided in the Connector Binding
- * for this connector instance.
- * @return Properties for initializing the connector
- */
- Properties getProperties();
+ /**
+ * Capabilities Class Name
+ * @return
+ */
+ public String getCapabilitiesClass();
+
+ /**
+ * Defines if the Connector is read-only connector
+ * @return
+ */
+ public boolean isImmutable();
+
+ /**
+ * Throw exception if there are more rows in the result set than specified in the MaxResultRows setting.
+ * @return
+ */
+ public boolean isExceptionOnMaxRows();
+ /**
+ * Maximum result set rows to fetch
+ * @return
+ */
+ public int getMaxResultRows();
+
+ /**
+ * Shows the XA transaction capability of the Connector.
+ * @return
+ */
+ public boolean isXaCapable();
+
/**
- * Get the name of the connector binding, as exposed in the console.
- * @return Connector binding name
+ * Indicates whether the connector represents a pooled resource. If it does, then
+ * synchronous workers will be used.
*/
- String getConnectorName();
-
+ boolean isSynchWorkers();
+
/**
* Obtain a reference to the logger that can be used to add messages to the
- * MetaMatrix log files for debugging and error recovery.
+ * log files for debugging and error recovery.
* @return The {@link ConnectorLogger}
*/
ConnectorLogger getLogger();
@@ -63,7 +82,7 @@
* new language interface objects. This is typically needed when modifying the language
* objects passed to the connector or for testing when objects need to be created.
*/
- ILanguageFactory getLanguageFactory();
+ LanguageFactory getLanguageFactory();
/**
* Obtain a reference to the type facility, which can be used to perform many type
@@ -72,40 +91,8 @@
TypeFacility getTypeFacility();
/**
- * Schedule a command for repeated execution with the same contract as
- * {@link ScheduledThreadPoolExecutor#scheduleAtFixedRate(Runnable, long, long, TimeUnit)}
- * Executions will not happen concurrently. If an execution takes longer than a period,
- * the next execution will take place on the first period interval after completion.
- * @param command
- * @param initialDelay
- * @param period
- * @param unit
+ * Get the Override capabilities for the connector
* @return
*/
- ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
- long initialDelay,
- long period,
- TimeUnit unit);
-
-
- /**
- * Get the item from cache based on the scope provided; The required information like session-id, or vdb-name etc
- * are gleaned from runtime context. If such information is not available then error will be raised.
- * @param scope - scope of the cache; {@link CacheScope.REQUEST}, scope is not supported, as request information is not
- * visible. use ExecutionContext.
- * on {@link ExecutionContext}
- * @param key
- * @return
- */
- Object getFromCache(CacheScope scope, Object key);
-
- /**
- * Store the item in the cache based on the scope provided.The required information like session-id, or vdb-name etc
- * are gleaned from runtime context. If such information is not available then error will be raised.
- * @param scope - scope of the cache; {@link CacheScope.REQUEST}, scope is not supported.
- * on {@link ExecutionContext}
- * @param key
- * @param value
- */
- void storeInCache(CacheScope scope, Object key, Object value);
+ Properties getOverrideCapabilities() throws ConnectorException;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorException.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorException.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorException.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,13 +22,13 @@
package org.teiid.connector.api;
-import com.metamatrix.core.MetaMatrixCoreException;
+import javax.resource.ResourceException;
/**
* An exception the connector writer can return in case of an
* error while using the connector.
*/
-public class ConnectorException extends MetaMatrixCoreException{
+public class ConnectorException extends ResourceException{
private static final long serialVersionUID = -5980862789340592219L;
@@ -49,11 +49,11 @@
}
public ConnectorException( String errorCode, String message ) {
- super( errorCode, message );
+ super( message, errorCode);
}
public ConnectorException( int errorCode, String message ) {
- super( Integer.toString(errorCode), message );
+ super(message, Integer.toString(errorCode));
}
@@ -64,7 +64,7 @@
* @param e An exception to nest within this one
*/
public ConnectorException( Throwable e, String message ) {
- super( e, message );
+ super(message,e);
}
/**
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorIdentity.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorIdentity.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.api;
-
-
-/**
- * Represents the identity of a connection in the pool. Identities are
- * used to determine whether two connections can be put in the same pool.
- * Implementors must supply appropriate {@link java.lang.Object#equals(java.lang.Object)} and
- * {@link java.lang.Object#hashCode()} methods.
- */
-public interface ConnectorIdentity {
-
-}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorLogger.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorLogger.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorLogger.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -23,7 +23,7 @@
package org.teiid.connector.api;
/**
- * Provide access to write messages to the MetaMatrix logs.
+ * Provide access to write messages to the logs.
*/
public interface ConnectorLogger {
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorPropertyNames.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorPropertyNames.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorPropertyNames.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,114 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.api;
-
-public class ConnectorPropertyNames {
-
- /**
- * The property that specifies the class name of the custom connector class
- * that connects to the data source. This property is required.
- */
- public static final String CONNECTOR_CLASS = "ConnectorClass"; //$NON-NLS-1$
-
- /**
- * The environment property name whose value defines the maximum number
- * of processor threads. This property is required.
- */
- public static final String MAX_CONNECTIONS = "ConnectorMaxConnections"; //$NON-NLS-1$
-
- /**
- * This property can be used to specify the maximum number of rows to be returned
- * from the datasource of this connector. The connector should stop adding records
- * to the ResultsCollector when the rows collected is equal to this value. This
- * property is optional and if no value is specified, we should return all the rows.
- * @since 3.0
- */
- public static final String MAX_RESULT_ROWS = "MaxResultRows"; //$NON-NLS-1$
-
- /**
- * This property can be used to specify whether or not an exception should be thrown
- * if the number of rows for a query exceeds the value of MAX_RESULT_ROWS. If this
- * flag is set to false, then no more than MAX_RESULT_ROWS values will be returned but
- * no exception will be thrown.
- */
- public static final String EXCEPTION_ON_MAX_ROWS = "ExceptionOnMaxRows"; //$NON-NLS-1$
-
- /**
- * This property can be used to specify whether or not Connection Pooling is enabled.
- * If this flag is set to false, then connection pooling is disabled.
- */
- public static final String CONNECTION_POOL_ENABLED = "ConnectionPoolEnabled"; //$NON-NLS-1$
-
- /**
- * The environment property used to identify a <i>type</i> of connector binding.
- * This property is required and is a component used to uniquely identify a
- * connector instance.
- * @since 4.0
- */
- public static final String CONNECTOR_BINDING_NAME = "ConnectorBindingName"; //$NON-NLS-1$
-
- /**
- * The environment property used to identify a routing ID. This value should
- * be used to locate this particular connector from the DQP.
- * @since 4.0
- */
- public static final String CONNECTOR_ID = "ConnectorID"; //$NON-NLS-1$
-
- /**
- * The name of the VM where the connector is running on.
- * @since 4.0
- */
- public static final String CONNECTOR_VM_NAME = "ConnectorVMName"; //$NON-NLS-1$
-
- /**
- * Indicates whether the connector represents a pooled resource. If it does, then
- * synchronous workers will be used.
- */
- public static final String SYNCH_WORKERS = "SynchWorkers"; //$NON-NLS-1$
-
- public static final String USING_CUSTOM_CLASSLOADER = "UsingCustomClassloader"; //$NON-NLS-1$
-
- public static final String CONNECTOR_CLASSPATH = "ConnectorClassPath"; //$NON-NLS-1$
-
- public static final String CONNECTOR_TYPE_CLASSPATH = "ConnectorTypeClassPath"; //$NON-NLS-1$
-
- public static final String IS_XA = "IsXA"; //$NON-NLS-1$
-
- public static final String USE_CREDENTIALS_MAP = "UseCredentialMap"; //$NON-NLS-1$
-
- public static final String ADMIN_CONNECTIONS_ALLOWED = "AdminConnectionsAllowed"; //$NON-NLS-1$
-
- public static final String USE_RESULTSET_CACHE = "ResultSetCacheEnabled"; //$NON-NLS-1$
- public static final String MAX_RESULTSET_CACHE_SIZE = "ResultSetCacheMaxSize"; //$NON-NLS-1$
- public static final String MAX_RESULTSET_CACHE_AGE = "ResultSetCacheMaxAge"; //$NON-NLS-1$
- public static final String RESULTSET_CACHE_SCOPE = "ResultSetCacheScope"; //$NON-NLS-1$
-
- /**
- * This property can be used to bypass the normal logic that throws an exception when a command
- * is about to be executed by a non-XA compatible connector, but there is a global transaction.
- */
- public static final String IS_IMMUTABLE = "Immutable"; //$NON-NLS-1$
-
- public static final String USE_POST_DELEGATION = "UsePostDelegation"; //$NON-NLS-1$
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/api/CredentialMap.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/CredentialMap.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/CredentialMap.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,377 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.api;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.teiid.connector.DataPlugin;
-
-import com.metamatrix.core.util.StringUtil;
-
-/**
- * Allows credentials to be passed on a per user basis to a connector.
- *
- * A CredentialsMap object is produced based on information provided in the JDBC
- * URL. The static method parseCredentials() is used for this purpose.
- *
- * This CredentialMap serves as the session "trusted payload".
- *
- * It is the responsibility of a Connector to call
- * {@link ExecutionContext#getTrustedPayload()} to retrieve the CredentialMap.
- *
- * The system name should be the same as the Connector Binding Name retrieved from
- * {@link ConnectorEnvironment#getConnectorName()}.
- *
- * To get the keyword/value pairs use getSystemCredentials(systemName), this will
- * return a Map that contains the properties for the specified system.
- *
- * Specific user and password values can be retrieved with
- * getUser(systemName) and getPassword(systemName)
- */
-public class CredentialMap implements Serializable {
- //Parsing keywords for system, user, and password. Comparison is done
- //ignoring case.
- public final static String SYSTEM_KEYWORD = "system"; //$NON-NLS-1$
- public final static String USER_KEYWORD = "user"; //$NON-NLS-1$
- public final static String PASSWORD_KEYWORD = "password"; //$NON-NLS-1$
- public final static String ESCAPE_CHAR = "\\"; //$NON-NLS-1$
- public final static String DEFAULT_SYSTEM = "default"; //$NON-NLS-1$
-
- private final static String ESCAPE_SLASH = "ESCAPE_SLASH"; // forward slash //$NON-NLS-1$
- private final static String ESCAPE_COMMA = "ESCAPE_COMMA"; // comma //$NON-NLS-1$
- private final static String ESCAPE_EQUAL = "ESCAPE_EQUAL"; // equals //$NON-NLS-1$
-// private final static String ESCAPE_SEMI = "ESCAPE_SEMI"; // semicolon
-// private final static String ESCAPE_CLOSE_PAREN = "ESCAPE_CLOSE_PAREN"; // closing paren
-
-
- private final static String[] escape_chars = {
- ESCAPE_CHAR + "/", // forward slash //$NON-NLS-1$
- ESCAPE_CHAR + ",", // comma //$NON-NLS-1$
- ESCAPE_CHAR + "="}; // equals //$NON-NLS-1$
-// ESCAPE_CHAR + ";", // semicolon
-// ESCAPE_CHAR + ")"}; // closing paren
-
- private final static String[] escape_strings = {
- ESCAPE_SLASH, // forward slash
- ESCAPE_COMMA, // comma
- ESCAPE_EQUAL }; // equals
-// ESCAPE_SEMI, // semicolon
-// ESCAPE_CLOSE_PAREN }; // closing paren
-
- /**
- * In this mode, the CredentialMap will ignore the default credentials
- * and only credentials set for a system will be exposed. This is the
- * default setting for the CredentialMap.
- */
- public static final short MODE_IGNORE_DEFAULTS = 0;
-
- /**
- * In this mode, the default credentials will be returned for any system,
- * overlaid with any system-specific credentials. If a system is unknown,
- * all default credentials are returned for that system.
- */
- public static final short MODE_USE_DEFAULTS_GLOBALLY = 1;
-
- /**
- * In this mode, the default credentials will be returned for any system,
- * overlaid with any system-specific credentials. If a system is unknown,
- * the default credentials are NOT used.
- */
- public static final short MODE_USE_DEFAULTS_ON_EXISTING = 2;
-
- /**
- * The map of map of credentials (keyed by system name, upper case).
- */
- private Map map = new HashMap();
-
- private short defaultCredentialMode = MODE_IGNORE_DEFAULTS;
- private Map defaultCredentials;
-
-
- /**
- * Method to parse a credentials substring extracted from a JDBC URL. The
- * presumed command line syntax is ...;credentials=(...);...
- * Only the substring starting and ending with the parentheses is passed to
- * this method. That is, the first non-blank character must be a '(' and the
- * last non-blank character must be a ')', or an exception will be thrown.
- *
- * Syntax is: (credentialspec1/credentialspec2/.../credentialspecn)
- *
- * Any number one or greater of credential specifications may be included,
- * separated by '/' characters.
- *
- * Each credentials spec will be specified in the following way:
- * Keyword-specified, order-independent name-value pairs of the form
- * keyword=value. The only required keyword is "system", which must be specified
- * for each credentials spec, and must have a value corresponding to the name of an EIS
- * already known to the system.
- *
- * Ex: system=sys1,user=sys1un,pass=sys1pw, whatever=somevalue.
- * Each of the keywords must be unique.
- *
- * All blank space is ignored, except within a keyword or value.
- *
- * Any syntax error will cause an Exception to be thrown.
- *
- * @param inputStr the string to be parsed; first non-blank must be a '(', last non-blank must be a ')'
- * @return a CredentialMap containing the input
- * @throws ConnectorException upon any syntax error; descriptive text included
- */
- public static CredentialMap parseCredentials(String inputStr) throws ConnectorException {
-
- for (int i = 0; i < escape_chars.length; i++) {
- inputStr = StringUtil.replaceAll(inputStr, escape_chars[i], escape_strings[i]);
- }
-
- if (inputStr == null) {
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Null_input")); //$NON-NLS-1$
- }
-
- inputStr = inputStr.trim();
-
- CredentialMap credentialMap = new CredentialMap(); // map of maps keyed on system
- int strLen = inputStr.length();
-
- //Check that not empty
-
- if (strLen == 0) {
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Empty_input")); //$NON-NLS-1$
- }
-
- //Check that first non-blank char is left paren
- if (!inputStr.startsWith("(")|| !inputStr.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Missing_parens")); //$NON-NLS-1$
- }
-
- // strip of ()'s
- inputStr = inputStr.substring(1, inputStr.length()-1);
-
- List credentials = StringUtil.getTokens(inputStr, "/"); //$NON-NLS-1$
- Iterator credentialIter = credentials.iterator();
-
- while (credentialIter.hasNext()) {
- String credential = (String) credentialIter.next();
-
- // Convert the escaped "/" since we already parsed on the "/"
- credential = StringUtil.replaceAll(credential, escape_strings[0], "/"); //$NON-NLS-1$
-
- Map newMap = getCredentialMap(credential.trim());
- String system = (String) newMap.get(SYSTEM_KEYWORD);
- if (system == null || system.length() == 0) {
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Missing_system_prop")); //$NON-NLS-1$
- }
- credentialMap.addSystemCredentials(system, newMap); // add to Map of Maps.
- }
- return credentialMap;
- }
-
-
- /**
- * Takes a string containing key/value pairs.
- * Example "propName1=propValue1,propName2,propValue2,....."
- * and returns a map of key/value pairs.
- */
- private static Map getCredentialMap(String credential) {
- List propList = StringUtil.getTokens(credential, ","); //$NON-NLS-1$
- Iterator propIter = propList.iterator();
- Map map = new HashMap();
- while (propIter.hasNext()) {
- String propVal = (String) propIter.next();
- List pvList = StringUtil.getTokens(propVal, "="); //$NON-NLS-1$
- String key = null;
- String val = null;
- if (pvList.size() > 0) {
- key = (String) pvList.get(0);
- key = key.trim();
- }
- if (pvList.size() > 1) {
- val = (String) pvList.get(1);
- val = val.trim();
- // put back the escaped "," and "=" since we already parsed on these.
- val = StringUtil.replaceAll(val, escape_strings[1], ","); //$NON-NLS-1$
- val = StringUtil.replaceAll(val, escape_strings[2], "="); //$NON-NLS-1$
- }
- map.put(key,val);
- }
- return map;
- }
-
- public CredentialMap() {
- super();
- }
-
- /**
- * Method to return an array of systems that have been added to this
- * CredentialMap.
- *
- * @return array of the systems that have been added using addSystemCredentials() - always uppercase
- */
- public String[] getSystems() {
- Set keySet = map.keySet();
- String[] keys = new String[keySet.size()];
- Iterator it = keySet.iterator();
- for (int i = 0; it.hasNext(); i++) {
- keys[i] = (String)it.next();
- }
- return keys;
- }
-
- /**
- * Method to add a user name and credentials (e.g. password) for a system
- *
- * @param system system name corresponding to the user and credentials
- * @param credentials Map containing name/val pairs
- */
- public void addSystemCredentials(String system, Map credentials) {
- map.put(system.toUpperCase(), credentials);
- }
-
- /**
- * Set the default credentials to use with this credential map. See the
- * various default credential modes to understand when and how these will
- * be returned.
- *
- * @param defaultCredentials Map of credentials
- * @since 4.3
- */
- public void setDefaultCredentials(Map defaultCredentials) {
- this.defaultCredentials = defaultCredentials;
- }
-
- /**
- * Set the default credential mode to determine when default credentials should
- * be returned.
- *
- * @param mode The mode
- * @see #MODE_IGNORE_DEFAULTS
- * @see #MODE_USE_DEFAULTS_GLOBALLY
- * @see #MODE_USE_DEFAULTS_ON_EXISTING
- * @since 4.3
- */
- public void setDefaultCredentialMode(short mode) {
- this.defaultCredentialMode = mode;
- }
-
- /**
- * Method to return the credentials map for a system
- *
- * @param systemName system name
- * @return Map
- */
- public Map getSystemCredentials(String systemName) {
- Map systemCredentials = (Map)map.get(systemName.toUpperCase());
-
- // If ignoring defaults, return just as is
- if(this.defaultCredentialMode == MODE_IGNORE_DEFAULTS) {
- return systemCredentials;
- }
-
- // Pre-load the credential set to return with the defaults if
- // 1. defaults exist
- // 2. AND using defaults globally
- // 3. OR (using defaults on existing AND system credentials exist)
- Map workingMap = null;
- if(this.defaultCredentials != null &&
- (this.defaultCredentialMode == MODE_USE_DEFAULTS_GLOBALLY ||
- (this.defaultCredentialMode == MODE_USE_DEFAULTS_ON_EXISTING &&
- systemCredentials != null))) {
-
- workingMap = new HashMap();
- workingMap.putAll(defaultCredentials);
- }
-
- // Apply system credentials over the top if they exist
- if(systemCredentials != null) {
- if(workingMap == null) {
- workingMap = new HashMap();
- }
- workingMap.putAll(systemCredentials);
- }
-
- return workingMap;
- }
-
- /**
- * Get the user property for the specified system, if it exists. The
- * user property is defined by the static constant {@link #USER_KEYWORD}.
- *
- * @param systemName The system to look up (case insensitive)
- * @return The user name for this system if the system was found and the system had a user property
- * @since 4.3
- */
- public String getUser(String systemName) {
- Map credentials = getSystemCredentials(systemName);
- if(credentials != null) {
- return (String) credentials.get(USER_KEYWORD);
- }
-
- return null;
- }
-
- /**
- * Get the password property for the specified system, if it exists. The
- * password property is defined by the static constant {@link #PASSWORD_KEYWORD}.
- *
- * @param systemName The system to look up (case insensitive)
- * @return The password for this system if the system was found and the system had a password property
- * @since 4.3
- */
- public String getPassword(String systemName) {
- Map credentials = getSystemCredentials(systemName);
- if(credentials != null) {
- return (String) credentials.get(PASSWORD_KEYWORD);
- }
-
- return null;
- }
-
- public String toString() {
- StringBuffer b = new StringBuffer();
- String[] systems = this.getSystems();
- for (int i=0; i < systems.length; i++) {
- String system = systems[i];
- Map map = this.getSystemCredentials(system);
- b.append("\n"); //$NON-NLS-1$
- b.append(system);
- b.append("\n"); //$NON-NLS-1$
- Iterator iter = map.keySet().iterator();
- while (iter.hasNext()) {
- Object key = iter.next();
- b.append("\t"); //$NON-NLS-1$
- b.append(key);
- b.append("="); //$NON-NLS-1$
- b.append(map.get(key));
- b.append("\n"); //$NON-NLS-1$
- }
- }
- return b.toString();
- }
-
-}//end CredentialMap
-
-
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,7 +24,9 @@
import java.io.Serializable;
+import javax.security.auth.Subject;
+
/**
* The security context provides information about the user context in which
* this query is being run.
@@ -37,25 +39,15 @@
public interface ExecutionContext {
/**
- * Get the {@link ConnectorIdentity} created by the Connector's {@link
- * ConnectorIdentityFactory}
- *
- * @return the {@link ConnectorIdentity} or {@link SingleIdentity} if the
- * Connector does not implement {@link ConnectorIdentityFactory}
- * @since 6.0
- */
- ConnectorIdentity getConnectorIdentity();
-
- /**
* Get the identifier for the current connector running the command
* @return Connector identifier; never null
*/
String getConnectorIdentifier();
/**
- * Get the identifier for the MetaMatrix command being executed. This can be
- * correlated back to identifiers exposed in other parts of the MetaMatrix system.
- * @return MetaMatrix command identifier
+ * Get the identifier for the command being executed. This can be
+ * correlated back to identifiers exposed in other parts of the system.
+ * @return command identifier
*/
String getRequestIdentifier();
@@ -67,7 +59,7 @@
/**
* Execution count defines an id; where every access to the connector from
- * the MetaMatrix server in a given command execution boundary is uniquely defined;
+ * the server in a given command execution boundary is uniquely defined;
* Like for example in the case of "batched execution" of commands, each execution of
* command gets new identifier.
*/
@@ -83,48 +75,32 @@
* Get the version of the VDB this query is being run against.
* @return VDB version, never null
*/
- String getVirtualDatabaseVersion();
+ int getVirtualDatabaseVersion();
/**
- * Get the user name for the user running this query.
- * @return User name, never null
+ * Get the user for the user running this query.
+ * @return User, never null
*/
- String getUser();
-
+ Subject getSubject();
+
/**
- * Get the trusted payload passed when the user connected. MetaMatrix has no
- * knowledge about what the payload contains - it is merely passed through
- * the system. It is most often used to pass security information such as
- * credentials. It is available in the connector, as is the Execution Payload,
- * for connector developers to utilize.
- * @return Trusted payload if one exists, otherwise null
- */
- Serializable getTrustedPayload();
-
- /**
* Get the trusted payload passed when the user statement was executed.
- * MetaMatrix has no knowledge about what the payload contains - it is merely
+ * Teiid has no knowledge about what the payload contains - it is merely
* passed through the system. It is most often used to pass security
* information such as credentials.
*
- * <p>The execution payload differs from the Trusted Payload in that it
- * is set on the Statement and so may not be constant over the Connection lifecycle
- * and may be changed upon each statement execution. The Execution Payload is
- * <em>not</em> authenticated or validated by the MetaMatrix system.</p>
+ * <p>Given that the Execution Payload is not authenticated by the Teiid
+ * system, connector writers are responsible for ensuring its validity. </p>
*
- * <p>Given that the Execution Payload is not authenticated by the MetaMatrix
- * system, connector writers are responsible for ensuring its validity. This
- * can possibly be accomplished by comparing it against the Trusted Payload.</p>
- *
* @return Trusted execution payload if one exists, otherwise null
* @since 4.2
*/
Serializable getExecutionPayload();
-
+
/**
* Get the identifier for the connection through which
* the command is being executed. This represents the original JDBC user
- * connection to the MetaMatrix system
+ * connection to the Teiid system
* @return Connection identifier
*/
String getConnectionIdentifier();
@@ -150,6 +126,10 @@
*/
void addWarning(Exception ex);
+ /**
+ * Flag indicates that the operation needs to be executed in a XA transaction.
+ * @return
+ */
boolean isTransactional();
/**
@@ -166,4 +146,21 @@
* @param value
*/
void put(Object key, Object value);
+
+ /**
+ * Get a item that has been placed previously from cache. If no such object then a null will be returned. The item looked
+ * up in the specified scope.
+ * @param scope
+ * @param key
+ * @return
+ */
+ Object getFromCache(CacheScope scope, Object key);
+
+ /**
+ * Place a item in the Cache in the given scope.
+ * @param scope
+ * @param key
+ * @param value
+ */
+ void storeInCache(CacheScope scope, Object key, Object value);
}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/api/MappedUserIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/MappedUserIdentity.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/MappedUserIdentity.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.api;
-
-
-/**
- * This class represents a ConnectorIdentity keyed on a username with
- * a mapped identity
- */
-public class MappedUserIdentity implements ConnectorIdentity {
- private String username;
- private String mappedUser;
- private String password;
-
- /**
- * Construct with a security context
- * @param context The context
- */
- public MappedUserIdentity(String username, String mappedUser, String password){
- this.username = username;
- this.mappedUser = mappedUser;
- this.password = password;
- }
-
- /**
- * Implement equals based on the case-insensitive user name.
- * @param obj Other identity object
- * @return True if other object is a UserIdentity with the same user name
- */
- public boolean equals(Object obj){
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof MappedUserIdentity) {
- MappedUserIdentity that = (MappedUserIdentity)obj;
- return username.equals(that.username);
- }
-
- return false;
- }
-
- /**
- * Get hash code, based on user name
- */
- public int hashCode(){
- return username.hashCode();
- }
-
- public String toString(){
- return "UserIdentity " + username; //$NON-NLS-1$
- }
-
- public String getMappedUser() {
- return mappedUser;
- }
-
- public String getPassword() {
- return password;
- }
-}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ProcedureExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ProcedureExecution.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ProcedureExecution.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,11 +24,11 @@
import java.util.List;
-import org.teiid.connector.language.IProcedure;
+import org.teiid.connector.language.Call;
/**
* The procedure execution represents the case where a connector can execute a
- * {@link IProcedure}. The output may include 0 or more output parameters and
+ * {@link Call}. The output may include 0 or more output parameters and
* optionally a result set.
*/
public interface ProcedureExecution extends ResultSetExecution {
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ResultSetExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ResultSetExecution.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ResultSetExecution.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,11 +24,11 @@
import java.util.List;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.QueryExpression;
/**
- * Defines an execution for {@link IQueryCommand}s and {@link IProcedure}s that
+ * Defines an execution for {@link QueryExpression}s and {@link Call}s that
* returns a resultset, which is represented through the iterator method
* {@link #next()}.
*/
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/api/SingleIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/SingleIdentity.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/SingleIdentity.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.api;
-
-
-/**
- * This class represents a single ConnectorIdentity. All the connections are treated the same.
- */
-public class SingleIdentity implements ConnectorIdentity {
-
- public SingleIdentity(){
- }
-
- /**
- * Return true for everything - all identities are identical.
- */
- public boolean equals(Object obj){
- return obj instanceof SingleIdentity;
- }
-
- public String toString(){
- return "SingleIdentity"; //$NON-NLS-1$
- }
-
- public int hashCode(){
- return 0;
- }
-}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/UpdateExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/UpdateExecution.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/UpdateExecution.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,15 +22,15 @@
package org.teiid.connector.api;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IUpdate;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.Update;
/**
* The update execution represents the case where a connector can
- * execute an {@link IInsert}, {@link IUpdate}, {@link IDelete}, or {@link IBatchedUpdates} command.
+ * execute an {@link Insert}, {@link Update}, {@link Delete}, or {@link BatchedUpdates} command.
*/
public interface UpdateExecution extends Execution {
Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnection.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnection.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,52 +22,55 @@
package org.teiid.connector.basic;
+import javax.resource.spi.LocalTransaction;
+import javax.transaction.xa.XAResource;
+
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
import org.teiid.connector.api.Execution;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ProcedureExecution;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.api.UpdateExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.Command;
+import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
/**
* Provides a default implementation of a {@link PoolAwareConnection} for a Connector
* that supports global capabilities. Extensions of this class should implement
- * {@link #createProcedureExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
- * {@link #createResultSetExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
- * {@link #createUpdateExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
+ * {@link #createProcedureExecution(Call, ExecutionContext, RuntimeMetadata)}
+ * {@link #createResultSetExecution(Call, ExecutionContext, RuntimeMetadata)}
+ * {@link #createUpdateExecution(Call, ExecutionContext, RuntimeMetadata)}
* as necessary.
*/
public abstract class BasicConnection implements Connection {
+
@Override
- public Execution createExecution(ICommand command,
+ public Execution createExecution(Command command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- if (command instanceof IQueryCommand) {
- return createResultSetExecution((IQueryCommand)command, executionContext, metadata);
+ if (command instanceof QueryExpression) {
+ return createResultSetExecution((QueryExpression)command, executionContext, metadata);
}
- if (command instanceof IProcedure) {
- return createProcedureExecution((IProcedure)command, executionContext, metadata);
+ if (command instanceof Call) {
+ return createProcedureExecution((Call)command, executionContext, metadata);
}
return createUpdateExecution(command, executionContext, metadata);
}
- public ResultSetExecution createResultSetExecution(IQueryCommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+ public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
throw new ConnectorException("Unsupported Execution");
}
- public ProcedureExecution createProcedureExecution(IProcedure command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+ public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
throw new ConnectorException("Unsupported Execution");
}
- public UpdateExecution createUpdateExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+ public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
throw new ConnectorException("Unsupported Execution");
}
@@ -82,14 +85,12 @@
}
@Override
- public void closeCalled() {
-
+ public LocalTransaction getLocalTransaction() {
+ return null;
}
@Override
- public void setConnectorIdentity(ConnectorIdentity context)
- throws ConnectorException {
-
+ public XAResource getXAResource() throws ConnectorException {
+ return null;
}
-
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,81 +1,36 @@
package org.teiid.connector.basic;
-import org.teiid.connector.DataPlugin;
import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-import org.teiid.connector.api.SingleIdentity;
-import com.metamatrix.common.util.PropertiesUtils;
-
public abstract class BasicConnector implements Connector {
- private boolean useCredentialMap;
- private boolean adminConnectionsAllowed = true;
- private String connectorName;
+ protected ConnectorEnvironment config;
+ protected ConnectorCapabilities capabilities;
@Override
- public void start(ConnectorEnvironment environment)
- throws ConnectorException {
- this.connectorName = environment.getConnectorName();
- this.adminConnectionsAllowed = PropertiesUtils.getBooleanProperty(environment.getProperties(), ConnectorPropertyNames.ADMIN_CONNECTIONS_ALLOWED, true);
- this.useCredentialMap = PropertiesUtils.getBooleanProperty(environment.getProperties(), ConnectorPropertyNames.USE_CREDENTIALS_MAP, false);
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.connector.api.Connector#createIdentity(com.metamatrix.connector.api.ExecutionContext)
- */
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- if (context == null) {
- if (adminConnectionsAllowed) {
- return new SingleIdentity();
- }
- throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.single_identity_not_supported")); //$NON-NLS-1$
- }
- Object payload = context.getTrustedPayload();
- if (!(payload instanceof CredentialMap)) {
- if (useCredentialMap) {
- throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.extraction_error")); //$NON-NLS-1$
- }
- return new SingleIdentity();
- }
- CredentialMap credMap = (CredentialMap)payload;
- String user = credMap.getUser(connectorName);
- String password = credMap.getPassword(connectorName);
- if (user == null || password == null) {
- throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.missing_credentials", connectorName)); //$NON-NLS-1$
- }
- return new MappedUserIdentity(context.getUser(), user, password);
- }
+ public void initialize(ConnectorEnvironment config) throws ConnectorException {
+ this.config = config;
+ }
- public String getConnectorName() {
- return connectorName;
+ @Override
+ public ConnectorEnvironment getConnectorEnvironment(){
+ return this.config;
}
- public void setConnectorName(String connectorName) {
- this.connectorName = connectorName;
- }
-
- public boolean useCredentialMap() {
- return useCredentialMap;
- }
-
- public void setUseCredentialMap(boolean useCredentialMap) {
- this.useCredentialMap = useCredentialMap;
- }
-
- public boolean areAdminConnectionsAllowed() {
- return adminConnectionsAllowed;
- }
-
- public void setAdminConnectionsAllowed(boolean adminConnectionsAllowed) {
- this.adminConnectionsAllowed = adminConnectionsAllowed;
- }
-
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return BasicConnectorCapabilities.class;
+ }
+
+ @Override
+ public ConnectorCapabilities getCapabilities() throws ConnectorException {
+ if (capabilities == null) {
+ // create Capabilities
+ capabilities = BasicManagedConnectionFactory.getInstance(ConnectorCapabilities.class, this.config.getCapabilitiesClass(), null, getDefaultCapabilities());
+ }
+ return capabilities;
+ }
+
}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,139 @@
+/*
+ * 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.basic;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+import org.teiid.connector.api.ConnectionContext;
+import org.teiid.connector.api.ConnectorException;
+
+public class BasicManagedConnection implements ManagedConnection {
+ protected PrintWriter log;
+ protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
+ protected WrappedConnection conn;
+ private BasicManagedConnectionFactory mcf;
+
+ public BasicManagedConnection(BasicManagedConnectionFactory mcf) {
+ this.mcf = mcf;
+ }
+
+ @Override
+ public void associateConnection(Object handle) throws ResourceException {
+ if (!(handle instanceof WrappedConnection)) {
+ throw new ConnectorException("Wrong connection supplied to assosiate");
+ }
+ this.conn = (WrappedConnection)handle;
+ this.conn.setManagedConnection(this);
+ }
+
+ @Override
+ public void cleanup() throws ResourceException {
+ if (this.conn != null) {
+ this.conn.close();
+ this.conn = null;
+ }
+ ConnectionContext.setSubject(null);
+ }
+
+ @Override
+ public void destroy() throws ResourceException {
+ cleanup();
+ }
+
+ @Override
+ public ManagedConnectionMetaData getMetaData() throws ResourceException {
+ return null;
+ }
+
+ @Override
+ public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
+ if(!(arg1 instanceof ConnectionRequestInfoWrapper)) {
+ throw new ConnectorException("Un recognized Connection Request Info object received");
+ }
+ ConnectionRequestInfoWrapper criw = (ConnectionRequestInfoWrapper)arg1;
+ ConnectionContext.setSubject(arg0);
+ this.conn = new WrappedConnection(criw.actualConnector.getConnection(), mcf);
+ this.conn.setManagedConnection(this);
+ return this.conn;
+ }
+
+ @Override
+ public LocalTransaction getLocalTransaction() throws ResourceException {
+ return this.conn.getLocalTransaction();
+ }
+
+ @Override
+ public XAResource getXAResource() throws ResourceException {
+ return this.conn.getXAResource();
+ }
+
+ @Override
+ public void addConnectionEventListener(ConnectionEventListener arg0) {
+ synchronized (this.listeners) {
+ this.listeners.add(arg0);
+ }
+ }
+
+ @Override
+ public void removeConnectionEventListener(ConnectionEventListener arg0) {
+ synchronized (this.listeners) {
+ this.listeners.remove(arg0);
+ }
+ }
+
+ @Override
+ public void setLogWriter(PrintWriter arg0) throws ResourceException {
+ this.log = arg0;
+ }
+
+ @Override
+ public PrintWriter getLogWriter() throws ResourceException {
+ return this.log;
+ }
+
+ // called by the wrapped connection to notify the close of the connection.
+ void connectionClosed() {
+ ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+ ce.setConnectionHandle(this.conn);
+
+ ArrayList<ConnectionEventListener> copy = null;
+ synchronized (this.listeners) {
+ copy = new ArrayList<ConnectionEventListener>(this.listeners);
+ }
+
+ for(ConnectionEventListener l: copy) {
+ l.connectionClosed(ce);
+ }
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,224 @@
+/*
+ * 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.basic;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+import javax.security.auth.Subject;
+
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.language.LanguageFactory;
+
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ReflectionHelper;
+
+public class BasicManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation, ConnectorEnvironment {
+
+ private static final long serialVersionUID = -7302713800883776790L;
+ private static final TypeFacility TYPE_FACILITY = new TypeFacilityImpl();
+ private ConnectorLogger logger = new DefaultConnectorLogger();
+ private PrintWriter log;
+ private BasicResourceAdapter ra;
+
+ // Properties set by ra.xml
+ private String connectorClass;
+ private String capabilitiesClass = BasicConnectorCapabilities.class.getName();
+ private boolean immutable = false;
+ private boolean exceptionOnMaxRows = false;
+ private int maxResultRows = -1;
+ private boolean xaCapable;
+
+ private boolean synchWorkers = true;
+ private String overrideCapabilitiesFile;
+
+ // derived
+ private Properties overrideCapabilities;
+
+ @Override
+ public Object createConnectionFactory() throws ResourceException {
+ return new ResourceException("Resource Adapter does not currently support running in a non-managed environment.");
+ }
+
+ @Override
+ public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
+ try {
+ Object o = ReflectionHelper.create(this.connectorClass, null, Thread.currentThread().getContextClassLoader());
+ if(!(o instanceof Connector)) {
+ throw new ConnectorException("Invalid Connector class specified="+this.connectorClass);
+ }
+ Connector connector = (Connector)o;
+ connector.initialize(this);
+ return new WrappedConnector(connector, arg0, this);
+ } catch (MetaMatrixCoreException e) {
+ throw new ResourceException(e);
+ }
+ }
+
+ @Override
+ public ManagedConnection createManagedConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
+ return new BasicManagedConnection(this);
+ }
+
+ @Override
+ public PrintWriter getLogWriter() throws ResourceException {
+ return this.log;
+ }
+
+ @Override
+ public ManagedConnection matchManagedConnections(Set arg0, Subject arg1, ConnectionRequestInfo arg2) throws ResourceException {
+ // rameshTODO: to manage per-user based pools the information in the request info needs to be used to filter.
+ return (ManagedConnection)arg0.iterator().next();
+ }
+
+ @Override
+ public void setLogWriter(PrintWriter arg0) throws ResourceException {
+ this.log = arg0;
+ }
+
+ @Override
+ public ResourceAdapter getResourceAdapter() {
+ return this.ra;
+ }
+
+ @Override
+ public void setResourceAdapter(ResourceAdapter arg0) throws ResourceException {
+ this.ra = (BasicResourceAdapter)arg0;
+ }
+
+ public void setConnectorClass(String arg0) {
+ this.connectorClass = arg0;
+ }
+
+ public void setCapabilitiesClass(String arg0) {
+ this.capabilitiesClass = arg0;
+ }
+
+ public void setImmutable(Boolean arg0) {
+ this.immutable = arg0.booleanValue();
+ }
+
+ public void setExceptionOnMaxRows(Boolean arg0) {
+ this.exceptionOnMaxRows = arg0.booleanValue();
+ }
+
+ public void setMaxResultRows(Integer arg0) {
+ this.maxResultRows = arg0.intValue();
+ }
+
+ public String getCapabilitiesClass() {
+ return capabilitiesClass;
+ }
+
+ public boolean isImmutable() {
+ return immutable;
+ }
+
+ public boolean isExceptionOnMaxRows() {
+ return exceptionOnMaxRows;
+ }
+
+ public int getMaxResultRows() {
+ return maxResultRows;
+ }
+
+ public boolean isXaCapable() {
+ return xaCapable;
+ }
+
+ public void setXaCapable(Boolean arg0) {
+ this.xaCapable = arg0.booleanValue();
+ }
+
+ @Override
+ public LanguageFactory getLanguageFactory() {
+ return LanguageFactory.INSTANCE;
+ }
+
+ @Override
+ public ConnectorLogger getLogger() {
+ return logger;
+ }
+
+ @Override
+ public TypeFacility getTypeFacility() {
+ return TYPE_FACILITY;
+ }
+
+ @Override
+ public boolean isSynchWorkers() {
+ return synchWorkers;
+ }
+
+ public void setSynchWorkers(Boolean arg0) {
+ this.synchWorkers = arg0.booleanValue();
+ }
+
+ @Override
+ public Properties getOverrideCapabilities() throws ConnectorException {
+ if (this.overrideCapabilities == null && this.overrideCapabilitiesFile != null) {
+ try {
+ this.overrideCapabilities = new Properties();
+ this.overrideCapabilities.loadFromXML(this.getClass().getResourceAsStream(this.overrideCapabilitiesFile));
+ } catch (IOException e) {
+ throw new ConnectorException(e);
+ }
+ }
+ return this.overrideCapabilities;
+ }
+
+ public void setOverrideCapabilitiesFile(String propsFile) {
+ this.overrideCapabilitiesFile = propsFile;
+ }
+
+ public static <T> T getInstance(Class<T> expectedType, String className, Collection ctorObjs, Class defaultClass) throws ConnectorException {
+ try {
+ if (className == null) {
+ if (defaultClass == null) {
+ throw new ConnectorException("Neither class name or default class specified to create an instance");
+ }
+ return expectedType.cast(defaultClass.newInstance());
+ }
+ return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
+ } catch (MetaMatrixCoreException e) {
+ throw new ConnectorException(e);
+ } catch (IllegalAccessException e) {
+ throw new ConnectorException(e);
+ } catch(InstantiationException e) {
+ throw new ConnectorException(e);
+ }
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicResourceAdapter.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicResourceAdapter.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicResourceAdapter.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicResourceAdapter.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.connector.basic;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.XAResource;
+
+public class BasicResourceAdapter implements ResourceAdapter {
+ BootstrapContext ctx;
+
+ @Override
+ public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ @Override
+ public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ @Override
+ public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
+ return new XAResource[0];
+ }
+
+ @Override
+ public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
+ this.ctx = ctx;
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ public WorkManager getWorkManager() {
+ return ctx.getWorkManager();
+ }
+
+ public XATerminator getXATerminator() {
+ return ctx.getXATerminator();
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/ConnectionRequestInfoWrapper.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/ConnectionRequestInfoWrapper.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/ConnectionRequestInfoWrapper.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/ConnectionRequestInfoWrapper.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,34 @@
+/*
+ * 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.basic;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+import org.teiid.connector.api.Connector;
+
+class ConnectionRequestInfoWrapper implements ConnectionRequestInfo {
+ Connector actualConnector;
+
+ public ConnectionRequestInfoWrapper(Connector connector) {
+ this.actualConnector = connector;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+/*
+ * Date: Sep 16, 2003
+ * Time: 11:23:00 AM
+ */
+package org.teiid.connector.basic;
+
+import org.teiid.connector.api.ConnectorLogger;
+
+/**
+ * DefaultConnectorLogger.
+ */
+public class DefaultConnectorLogger implements ConnectorLogger {
+ public static final String CTX_CONNECTOR = "CONNECTOR"; //$NON-NLS-1$
+ @Override
+ public void logError(String message) {
+ //LogManager.logError(CTX_CONNECTOR, message);
+ }
+ @Override
+ public void logError(String message, Throwable error) {
+ // LogManager.logError(CTX_CONNECTOR, error, message);
+ }
+ @Override
+ public void logWarning(String message) {
+ // LogManager.logWarning(CTX_CONNECTOR, message);
+ }
+ @Override
+ public void logInfo(String message) {
+ //LogManager.logInfo(CTX_CONNECTOR, message);
+ }
+ @Override
+ public void logDetail(String message) {
+ //LogManager.logDetail(CTX_CONNECTOR, message);
+ }
+
+ @Override
+ public void logTrace(String message) {
+ // LogManager.logTrace(CTX_CONNECTOR, message);
+ }
+
+ @Override
+ public boolean isDetailEnabled() {
+ //return LogManager.isMessageToBeRecorded(CTX_CONNECTOR, MessageLevel.DETAIL);
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ //return LogManager.isMessageToBeRecorded(CTX_CONNECTOR, MessageLevel.ERROR);
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ //return LogManager.isMessageToBeRecorded(CTX_CONNECTOR, MessageLevel.INFO);
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ //return LogManager.isMessageToBeRecorded(CTX_CONNECTOR, MessageLevel.TRACE);
+ return true;
+ }
+
+ @Override
+ public boolean isWarningEnabled() {
+ //return LogManager.isMessageToBeRecorded(CTX_CONNECTOR, MessageLevel.WARNING);
+ return true;
+ }
+
+ @Override
+ public void logDetail(String message, Throwable error) {
+ //LogManager.log(MessageLevel.DETAIL, CTX_CONNECTOR, error, message);
+ }
+
+ @Override
+ public void logInfo(String message, Throwable error) {
+ //LogManager.log(MessageLevel.INFO, CTX_CONNECTOR, error, message);
+ }
+
+ @Override
+ public void logTrace(String message, Throwable error) {
+ //LogManager.log(MessageLevel.TRACE, CTX_CONNECTOR, error, message);
+ }
+
+ @Override
+ public void logWarning(String message, Throwable error) {
+ //LogManager.log(MessageLevel.WARNING, CTX_CONNECTOR, error, message);
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/TypeFacilityImpl.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/TypeFacilityImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/TypeFacilityImpl.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/TypeFacilityImpl.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,52 @@
+/*
+ * 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.basic;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.teiid.connector.api.TypeFacility;
+
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.util.TimestampWithTimezone;
+
+/**
+ */
+public class TypeFacilityImpl extends TypeFacility {
+
+ public TypeFacilityImpl() {
+ }
+
+ @Override
+ public Object convertToRuntimeType(Object value) {
+ return DataTypeManager.convertToRuntimeType(value);
+ }
+
+ @Override
+ public Object convertDate(Date date, TimeZone initial, Calendar target,
+ Class targetType) {
+ return TimestampWithTimezone.create(date, initial, target, targetType);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,111 @@
+/*
+ * 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.basic;
+
+import java.lang.reflect.Proxy;
+
+import javax.resource.spi.LocalTransaction;
+import javax.transaction.xa.XAResource;
+
+import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.Execution;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.MetadataProvider;
+import org.teiid.connector.basic.WrappedConnector.CapabilitesOverloader;
+import org.teiid.connector.language.Command;
+import org.teiid.connector.metadata.runtime.MetadataFactory;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+
+public class WrappedConnection implements Connection, MetadataProvider {
+
+ private Connection conn;
+ private ConnectorEnvironment env;
+ private ConnectorCapabilities caps;
+ private BasicManagedConnection mc;
+ boolean closed = false;
+
+ public WrappedConnection(Connection conn, ConnectorEnvironment env) {
+ this.conn = conn;
+ this.env = env;
+ }
+
+ @Override
+ public void close() {
+ if (!this.closed && this.mc != null) {
+ this.closed = true;
+ this.conn.close();
+ this.mc.connectionClosed();
+ this.mc = null;
+ }
+ }
+
+ @Override
+ public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata)
+ throws ConnectorException {
+ return conn.createExecution(command, executionContext, metadata);
+ }
+
+ @Override
+ public ConnectorCapabilities getCapabilities() throws ConnectorException {
+ if (this.caps == null) {
+ ConnectorCapabilities caps = conn.getCapabilities();
+ if (caps != null && this.env.getOverrideCapabilities() != null) {
+ caps = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(caps, this.env.getOverrideCapabilities()));
+ }
+ this.caps = caps;
+ }
+ return this.caps;
+ }
+
+ @Override
+ public LocalTransaction getLocalTransaction() throws ConnectorException {
+ return conn.getLocalTransaction();
+ }
+
+ @Override
+ public boolean isAlive() {
+ return conn.isAlive();
+ }
+
+ @Override
+ public XAResource getXAResource() throws ConnectorException {
+ return conn.getXAResource();
+ }
+
+ @Override
+ public void getConnectorMetadata(MetadataFactory metadataFactory) throws ConnectorException {
+ if (this.conn instanceof MetadataProvider) {
+ ((MetadataProvider) this.conn).getConnectorMetadata(metadataFactory);
+ } else {
+ throw new ConnectorException("Connector is not capable of providing metadata. Extend connector with MetadataProvider interface");
+ }
+ }
+
+ // Called by managed connection for the connection management
+ void setManagedConnection(BasicManagedConnection mc) {
+ this.mc = mc;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnector.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnector.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnector.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnector.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,141 @@
+/*
+ * 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.basic;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ReflectionHelper;
+import com.metamatrix.core.util.StringUtil;
+
+public class WrappedConnector implements Connector, Referenceable, Serializable {
+
+ private static final long serialVersionUID = 5499157394014613035L;
+ private Connector delegate;
+ private ConnectionManager cm;
+ private BasicManagedConnectionFactory mcf;
+ private Reference reference;
+ ConnectorCapabilities caps;
+
+ public WrappedConnector(Connector delegate, ConnectionManager cm, BasicManagedConnectionFactory mcf) {
+ this.delegate = delegate;
+ this.cm = cm;
+ this.mcf = mcf;
+ }
+
+ @Override
+ public void initialize(ConnectorEnvironment config) throws ConnectorException {
+ this.delegate.initialize(config);
+ }
+
+ @Override
+ public ConnectorCapabilities getCapabilities() throws ConnectorException {
+ if (this.caps != null) {
+ return this.caps;
+ }
+
+ // see if enhanced capabilities are available from the connector.
+ this.caps = delegate.getCapabilities();
+
+ // if not use the default capabilities specified in the configuration.
+ if (this.caps == null) {
+ try {
+ Object o = ReflectionHelper.create(this.mcf.getCapabilitiesClass(), null, Thread.currentThread().getContextClassLoader());
+ if(!(o instanceof ConnectorCapabilities)) {
+ throw new ConnectorException("Invalid Connector Capabilities class specified="+this.mcf.getCapabilitiesClass());
+ }
+ this.caps = (ConnectorCapabilities)o;
+ } catch (MetaMatrixCoreException e) {
+ throw new ConnectorException(e);
+ }
+ }
+ // capabilities overload
+ ConnectorEnvironment env = getConnectorEnvironment();
+ if (this.caps != null && env.getOverrideCapabilities() != null) {
+ this.caps = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(this.caps, env.getOverrideCapabilities()));
+ }
+ return caps;
+ }
+
+ @Override
+ public Connection getConnection() throws ConnectorException {
+ try {
+ return (Connection)cm.allocateConnection(mcf, new ConnectionRequestInfoWrapper(this.delegate));
+ } catch (ResourceException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ @Override
+ public ConnectorEnvironment getConnectorEnvironment() {
+ return this.delegate.getConnectorEnvironment();
+ }
+
+ @Override
+ public void setReference(Reference arg0) {
+ this.reference = arg0;
+ }
+
+ @Override
+ public Reference getReference() throws NamingException {
+ return this.reference;
+ }
+
+
+ /**
+ * Overloads the connector capabilities with one defined in the connector binding properties
+ */
+ static final class CapabilitesOverloader implements InvocationHandler {
+ ConnectorCapabilities caps;
+ Properties properties;
+
+ CapabilitesOverloader(ConnectorCapabilities caps, Properties properties){
+ this.caps = caps;
+ this.properties = properties;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String value = this.properties.getProperty(method.getName());
+ if (value == null || value.trim().length() == 0 || (args != null && args.length != 0)) {
+ return method.invoke(this.caps, args);
+ }
+ return StringUtil.valueOf(value, method.getReturnType());
+ }
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/AggregateFunction.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/AggregateFunction.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/AggregateFunction.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/AggregateFunction.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,131 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an aggregate function.
+ */
+public class AggregateFunction extends BaseLanguageObject implements Expression {
+
+ public static final String COUNT = "COUNT"; //$NON-NLS-1$
+ public static final String AVG = "AVG"; //$NON-NLS-1$
+ public static final String SUM = "SUM"; //$NON-NLS-1$
+ public static final String MIN = "MIN"; //$NON-NLS-1$
+ public static final String MAX = "MAX"; //$NON-NLS-1$
+
+ private Expression expression;
+ private String aggName;
+ private boolean isDistinct;
+ private Class<?> type;
+
+ public AggregateFunction(String aggName, boolean isDistinct, Expression exp, Class<?> type) {
+ this.expression = exp;
+ this.aggName = aggName;
+ this.isDistinct = isDistinct;
+ this.type = type;
+ }
+
+ /**
+ * Get the name of the aggregate function. This will be one of the constants defined
+ * in this class.
+ * @see #COUNT
+ * @see #AVG
+ * @see #SUM
+ * @see #MIN
+ * @see #MAX
+ */
+ public String getName() {
+ return this.aggName;
+ }
+
+ /**
+ * Determine whether this function was executed with DISTINCT. Executing
+ * with DISTINCT will remove all duplicate values in a group when evaluating
+ * the aggregate function.
+ * @return True if DISTINCT mode is used
+ */
+ public boolean isDistinct() {
+ return this.isDistinct;
+ }
+
+ /**
+ * Get the expression within the aggregate function. The expression will be
+ * null for the special case COUNT(*). This is the only case where the
+ * expression will be null
+ * @return The expression or null for COUNT(*)
+ */
+ public Expression getExpression() {
+ return this.expression;
+ }
+
+ /**
+ * @see org.teiid.connector.language.LanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
+ */
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set the name of the aggregate function. This will be one of the constants defined
+ * in this class.
+ * @param name New aggregate function name
+ * @see #COUNT
+ * @see #AVG
+ * @see #SUM
+ * @see #MIN
+ * @see #MAX
+ */
+ public void setName(String name) {
+ this.aggName = name;
+ }
+
+ /**
+ * Set whether this function was executed with DISTINCT. Executing
+ * with DISTINCT will remove all duplicate values in a group when evaluating
+ * the aggregate function.
+ * @param isDistinct True if DISTINCT mode should be used
+ */
+ public void setDistinct(boolean isDistinct) {
+ this.isDistinct = isDistinct;
+ }
+
+ /**
+ * Set the expression within the aggregate function. The expression will be
+ * null for the special case COUNT(*).
+ * @param expression The new expression
+ */
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/AndOr.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/AndOr.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/AndOr.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/AndOr.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,83 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a logical criteria such as AND, OR, or NOT.
+ */
+public class AndOr extends Condition {
+
+ public enum Operator {
+ AND,
+ OR,
+ }
+
+ private Condition leftCondition;
+ private Condition rightCondition;
+ private Operator operator = Operator.AND;
+
+ public AndOr(Condition left, Condition right, Operator operator) {
+ this.leftCondition = left;
+ this.rightCondition = right;
+ this.operator = operator;
+ }
+
+ /**
+ * Get operator used to connect these criteria.
+ * @return Operator constant
+ */
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set operator used to connect these criteria.
+ * @param operator Operator constant
+ */
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ public Condition getLeftCondition() {
+ return leftCondition;
+ }
+
+ public Condition getRightCondition() {
+ return rightCondition;
+ }
+
+ public void setLeftCondition(Condition left) {
+ this.leftCondition = left;
+ }
+
+ public void setRightCondition(Condition right) {
+ this.rightCondition = right;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Argument.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Argument.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Argument.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Argument.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,89 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class Argument extends BaseLanguageObject implements MetadataReference<ProcedureParameter> {
+
+ public enum Direction {
+ IN,
+ OUT,
+ INOUT,
+ }
+
+ private Direction direction;
+ private Literal argumentValue;
+ private ProcedureParameter metadataObject;
+ private Class<?> type;
+
+ public Argument(Direction direction, Literal value, Class<?> type, ProcedureParameter metadataObject) {
+ this.direction = direction;
+ this.argumentValue = value;
+ this.metadataObject = metadataObject;
+ this.type = type;
+ }
+
+ public Direction getDirection() {
+ return this.direction;
+ }
+
+ /**
+ * Get the argument value
+ * @return the value or null if this is an out parameter
+ */
+ public Literal getArgumentValue() {
+ return this.argumentValue;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setDirection(Direction direction) {
+ this.direction = direction;
+ }
+
+ public void setArgumentValue(Literal value) {
+ this.argumentValue = value;
+ }
+
+ @Override
+ public ProcedureParameter getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public void setMetadataObject(ProcedureParameter metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/BaseInCondition.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/BaseInCondition.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/BaseInCondition.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/BaseInCondition.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,65 @@
+/*
+ * 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.language;
+
+public abstract class BaseInCondition extends Condition implements Predicate {
+
+ private Expression leftExpression;
+ private boolean negated;
+
+ public BaseInCondition(Expression leftExpression, boolean negated) {
+ this.leftExpression = leftExpression;
+ this.negated = negated;
+ }
+
+ /**
+ * Get left expression of IN criteria
+ * @return Left expression
+ */
+ public Expression getLeftExpression() {
+ return leftExpression;
+ }
+
+ /**
+ * Set left expression of IN criteria
+ */
+ public void setLeftExpression(Expression leftExpression) {
+ this.leftExpression = leftExpression;
+ }
+
+ /**
+ * Returns whether this criteria is negated.
+ * @return flag indicating whether this criteria contains a NOT
+ */
+ public boolean isNegated() {
+ return negated;
+ }
+
+ /**
+ * Sets whether this criteria is negated.
+ * @param negated Flag indicating whether this criteria contains a NOT
+ */
+ public void setNegated(boolean negated) {
+ this.negated = negated;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/BaseLanguageObject.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/BaseLanguageObject.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/BaseLanguageObject.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/BaseLanguageObject.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,33 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.util.SQLStringVisitor;
+
+public abstract class BaseLanguageObject implements LanguageObject {
+
+ public String toString() {
+ return SQLStringVisitor.getSQLString(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/BatchedUpdates.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/BatchedUpdates.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/BatchedUpdates.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/BatchedUpdates.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,51 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a batch of INSERT, UPDATE and DELETE commands to be executed together.
+ */
+public class BatchedUpdates extends BaseLanguageObject implements Command {
+
+ private List<Command> updateCommands;
+
+ public BatchedUpdates(List<Command> updateCommands) {
+ this.updateCommands = updateCommands;
+ }
+
+ /**
+ * @return a list of IInsert, IUpdate and IDelete commands in this batched update.
+ */
+ public List<Command> getUpdateCommands() {
+ return updateCommands;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Call.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Call.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Call.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Call.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,110 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.ColumnSet;
+import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a procedural execution (such as a stored procedure).
+ */
+public class Call extends BaseLanguageObject implements Command, MetadataReference<Procedure> {
+
+ private String name;
+ private List<Argument> arguments;
+ private Procedure metadataObject;
+ private Class<?> returnType;
+
+ public Call(String name, List<Argument> parameters, Procedure metadataObject) {
+ this.name = name;
+ this.arguments = parameters;
+ this.metadataObject = metadataObject;
+ }
+
+ /**
+ * Get the return type
+ * @return the return parameter type or null if not expecting a return value
+ */
+ public Class<?> getReturnType() {
+ return returnType;
+ }
+
+ public void setReturnType(Class<?> returnType) {
+ this.returnType = returnType;
+ }
+
+ public String getProcedureName() {
+ return this.name;
+ }
+
+ public List<Argument> getArguments() {
+ return arguments;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setProcedureName(String name) {
+ this.name = name;
+ }
+
+ public void setArguments(List<Argument> parameters) {
+ this.arguments = parameters;
+ }
+
+ @Override
+ public Procedure getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public ProcedureParameter getReturnParameter() {
+ for (ProcedureParameter param : this.metadataObject.getParameters()) {
+ if (param.getType() == Type.ReturnValue) {
+ return param;
+ }
+ }
+ return null;
+ }
+
+ public Class<?>[] getResultSetColumnTypes() {
+ ColumnSet<Procedure> resultSet = this.metadataObject.getResultSet();
+ if (resultSet == null) {
+ return new Class[0];
+ }
+ List<Column> columnMetadata = resultSet.getColumns();
+ int size = columnMetadata.size();
+ Class<?>[] coulmnDTs = new Class[size];
+ for(int i =0; i<size; i++ ){
+ coulmnDTs[i] = columnMetadata.get(i).getJavaType();
+ }
+ return coulmnDTs;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/ColumnReference.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ColumnReference.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ColumnReference.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ColumnReference.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,96 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an element in the language. An example of an element
+ * would be a column reference in a SELECT clause.
+ */
+public class ColumnReference extends BaseLanguageObject implements MetadataReference<Column>, Expression {
+
+ private NamedTable table;
+ private String name;
+ private Column metadataObject;
+ private Class<?> type;
+
+ public ColumnReference(NamedTable group, String name, Column metadataObject, Class<?> type) {
+ this.table = group;
+ this.name = name;
+ this.metadataObject = metadataObject;
+ this.type = type;
+ }
+
+ /**
+ * Gets the name of the element.
+ * @return the name of the element
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Return the table that contains this column. May be null.
+ * @return The group reference
+ */
+ public NamedTable getTable() {
+ return table;
+ }
+
+ @Override
+ public Column getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public void setMetadataObject(Column metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ /**
+ * Sets the name of the element.
+ * @param name The name of the element
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Command.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Command.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Command.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Command.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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.language;
+
+/**
+ * Represents a command in the language objects. A command is an instruction of
+ * something to execute sent to the connector. Typical commands perform
+ * SELECT, INSERT, UPDATE, DELETE, etc type operations.
+ */
+public interface Command extends LanguageObject {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Comparison.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Comparison.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Comparison.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Comparison.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,117 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.language.SQLReservedWords.Tokens;
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a comparison between two expressions connected with
+ * one of the following operators: =, <>, <, <=, >, >=.
+ */
+public class Comparison extends Condition implements Predicate {
+
+ public enum Operator {
+ EQ(Tokens.EQ),
+ NE(Tokens.NE),
+ LT(Tokens.LT),
+ LE(Tokens.LE),
+ GT(Tokens.GT),
+ GE(Tokens.GE);
+
+ private String toString;
+ Operator(String toString) {
+ this.toString = toString;
+ }
+ @Override
+ public String toString() {
+ return toString;
+ }
+ }
+
+ private Expression leftExpression;
+ private Expression rightExpression;
+ private Operator operator;
+
+ public Comparison(Expression left, Expression right, Operator operator) {
+ leftExpression = left;
+ rightExpression = right;
+ this.operator = operator;
+ }
+
+ /**
+ * Get left expression.
+ * @return Left expression
+ */
+ public Expression getLeftExpression() {
+ return leftExpression;
+ }
+
+ /**
+ * Get right expression.
+ * @return Right expression
+ */
+ public Expression getRightExpression() {
+ return rightExpression;
+ }
+
+ /**
+ * Get the operator
+ * @return Operator constant
+ * @see Operator
+ */
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ /**
+ * Set left expression of criteria
+ */
+ public void setLeftExpression(Expression expression) {
+ this.leftExpression = expression;
+ }
+
+ /**
+ * Set right expression of criteria
+ */
+ public void setRightExpression(Expression expression) {
+ this.rightExpression = expression;
+ }
+
+ /**
+ * Set the operator
+ * @see Operator
+ */
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ /**
+ * @see org.teiid.connector.language.LanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
+ */
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Condition.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Condition.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Condition.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Condition.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,37 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.api.TypeFacility;
+
+/**
+ * Represents criteria, which is also a boolean expression
+ */
+public abstract class Condition extends BaseLanguageObject implements Expression {
+
+ @Override
+ public Class<?> getType() {
+ return TypeFacility.RUNTIME_TYPES.BOOLEAN;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Delete.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Delete.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Delete.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Delete.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,76 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a DELETE command.
+ */
+public class Delete extends BaseLanguageObject implements Command {
+
+ private NamedTable table;
+ private Condition where;
+
+ public Delete(NamedTable group, Condition criteria) {
+ this.table = group;
+ this.where = criteria;
+ }
+
+ /**
+ * Get group that is being deleted from.
+ * @return Insert group
+ */
+ public NamedTable getTable() {
+ return table;
+ }
+
+ /**
+ * Get criteria that is being used with the delete - may be null
+ * @return Criteria, may be null
+ */
+ public Condition getWhere() {
+ return where;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set group that is being deleted from.
+ * @param group Insert group
+ */
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ /**
+ * Set criteria that is being used with the delete - may be null
+ * @param criteria Criteria, may be null
+ */
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedColumn.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/DerivedColumn.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedColumn.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedColumn.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,57 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class DerivedColumn extends BaseLanguageObject {
+
+ private String alias;
+ private Expression expression;
+
+ public DerivedColumn(String name, Expression expression) {
+ this.alias = name;
+ this.expression = expression;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setAlias(String name) {
+ this.alias = name;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedTable.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/DerivedTable.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedTable.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedTable.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,60 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a derived table or inline view in the from clause.
+ */
+public class DerivedTable extends BaseLanguageObject implements TableReference {
+
+ private String correlationName;
+ private QueryExpression query;
+
+ public DerivedTable(QueryExpression query, String name) {
+ this.query = query;
+ this.correlationName = name;
+ }
+
+ public String getCorrelationName() {
+ return this.correlationName;
+ }
+
+ public void setCorrelationName(String name) {
+ this.correlationName = name;
+ }
+
+ public QueryExpression getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(QueryExpression query) {
+ this.query = query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Exists.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Exists.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Exists.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Exists.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,51 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an EXISTS criteria that checks whether any results would be
+ * returned from a subquery.
+ */
+public class Exists extends Condition implements Predicate, SubqueryContainer {
+
+ private QueryExpression query;
+
+ public Exists(QueryExpression query) {
+ this.query = query;
+ }
+
+ public QueryExpression getSubquery() {
+ return query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Expression.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Expression.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Expression.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Expression.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,39 @@
+/*
+ * 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.language;
+
+/**
+ * Represents an expression in the language. Subinterfaces define specific
+ * types of expressions, such as literal values, element references, and
+ * functions.
+ */
+public interface Expression extends LanguageObject {
+
+ /**
+ * Determine the type returned by this expression.
+ *
+ * @return The type, as defined by a Java class
+ */
+ Class<?> getType();
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/ExpressionValueSource.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ExpressionValueSource.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ExpressionValueSource.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ExpressionValueSource.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,45 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class ExpressionValueSource extends BaseLanguageObject implements InsertValueSource {
+
+ private List<Expression> values;
+
+ public ExpressionValueSource(List<Expression> values) {
+ this.values = values;
+ }
+
+ public List<Expression> getValues() {
+ return values;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Function.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Function.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Function.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Function.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,86 @@
+/*
+ * 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.language;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a function. A function has a name and 0..n
+ * Expressions that are parameters.
+ */
+public class Function extends BaseLanguageObject implements Expression {
+
+ private String name;
+ private List<Expression> parameters;
+ private Class<?> type;
+
+ public Function(String name, List<? extends Expression> params, Class<?> type) {
+ this.name = name;
+ if (params == null) {
+ this.parameters = new ArrayList<Expression>(0);
+ } else {
+ this.parameters = new ArrayList<Expression>(params);
+ }
+ this.type = type;
+ }
+
+ /**
+ * Get name of the function
+ * @return Function name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Get the parameters used in this function.
+ * @return Array of IExpressions defining the parameters
+ */
+ public List<Expression> getParameters() {
+ return parameters;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set name of the function
+ * @param name Function name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/GroupBy.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/GroupBy.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/GroupBy.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/GroupBy.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,56 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a GROUP BY clause in a query.
+ */
+public class GroupBy extends BaseLanguageObject {
+
+ private List<Expression> elements;
+
+ public GroupBy(List<Expression> elements) {
+ this.elements = elements;
+ }
+
+ /**
+ * Get list of IExpression that the GROUP BY should be grouped on.
+ * @return List of IExpression
+ */
+ public List<Expression> getElements() {
+ return elements;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setElements(List<Expression> elements) {
+ this.elements = elements;
+ }
+
+}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IAggregate.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IAggregate.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IAggregate.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an expression in the SELECT clause. Anything
- * other than an aggregate symbol in the SELECT clause will
- * be referenced by an IExpressionSymbol.
- */
-public interface IAggregate extends IExpression {
-
- public static final String COUNT = "COUNT"; //$NON-NLS-1$
- public static final String AVG = "AVG"; //$NON-NLS-1$
- public static final String SUM = "SUM"; //$NON-NLS-1$
- public static final String MIN = "MIN"; //$NON-NLS-1$
- public static final String MAX = "MAX"; //$NON-NLS-1$
-
- /**
- * Get the name of the aggregate function. This will be one of the constants defined
- * in this interface.
- * @see #COUNT
- * @see #AVG
- * @see #SUM
- * @see #MIN
- * @see #MAX
- */
- String getName();
-
- /**
- * Set the name of the aggregate function. This will be one of the constants defined
- * in this interface.
- * @param name New aggregate function name
- * @see #COUNT
- * @see #AVG
- * @see #SUM
- * @see #MIN
- * @see #MAX
- */
- void setName(String name);
-
- /**
- * Determine whether this function was executed with DISTINCT. Executing
- * with DISTINCT will remove all duplicate values in a group when evaluating
- * the aggregate function.
- * @return True if DISTINCT mode is used
- */
- boolean isDistinct();
-
- /**
- * Set whether this function was executed with DISTINCT. Executing
- * with DISTINCT will remove all duplicate values in a group when evaluating
- * the aggregate function.
- * @param isDistinct True if DISTINCT mode should be used
- */
- void setDistinct(boolean isDistinct);
-
- /**
- * Get the expression within the aggregate function. The expression will be
- * null for the special case COUNT(*). This is the only case where the
- * expression will be null
- * @return The expression or null for COUNT(*)
- */
- IExpression getExpression();
-
- /**
- * Set the expression within the aggregate function. The expression will be
- * null for the special case COUNT(*).
- * @param expression The new expression
- */
- void setExpression(IExpression expression);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IBaseInCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IBaseInCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IBaseInCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- */
-public interface IBaseInCriteria extends IPredicateCriteria {
- /**
- * Get left expression of IN criteria
- * @return Left expression
- */
- IExpression getLeftExpression();
-
- /**
- * Set left expression of IN criteria
- * @return Left expression
- */
- void setLeftExpression(IExpression expression);
-
- /**
- * Returns whether this criteria is negated.
- * @return flag indicating whether this criteria contains a NOT
- */
- boolean isNegated();
-
- /**
- * Sets whether this criteria is negated.
- * @param negated Flag indicating whether this criteria contains a NOT
- */
- void setNegated(boolean negated);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IBatchedUpdates.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IBatchedUpdates.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IBatchedUpdates.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-
-/**
- * Represents a batch of INSERT, UPDATE and DELETE commands to be executed together.
- * @since 4.2
- */
-public interface IBatchedUpdates extends ICommand {
-
- /**
- *
- * @return a list of IInsert, IUpdate and IDelete commands in this batched update.
- * @since 4.2
- */
- List<ICommand> getUpdateCommands();
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ICommand.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ICommand.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ICommand.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a command in the language objects. A command is an instruction of
- * something to execute sent to the connector. Typical commands perform
- * SELECT, INSERT, UPDATE, DELETE, etc type operations.
- */
-public interface ICommand extends ILanguageObject {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ICompareCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ICompareCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ICompareCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a comparison between two expressions connected with
- * one of the following operators: =, <>, <, <=, >, >=.
- */
-public interface ICompareCriteria extends IPredicateCriteria {
-
- public enum Operator {
- EQ,
- NE,
- LT,
- LE,
- GT,
- GE
- }
-
- /**
- * Get left expression.
- * @return Left expression
- */
- IExpression getLeftExpression();
-
- /**
- * Set left expression of criteria
- * @return Left expression
- */
- void setLeftExpression(IExpression expression);
-
- /**
- * Get right expression.
- * @return Right expression
- */
- IExpression getRightExpression();
-
- /**
- * Set left expression of criteria
- * @return Right expression
- */
- void setRightExpression(IExpression expression);
-
- /**
- * Get operator from set defined in this interface.
- * @return Operator constant
- * @see Operator#EQ
- * @see Operator#NE
- * @see Operator#LT
- * @see Operator#LE
- * @see Operator#GT
- * @see Operator#GE
- */
- Operator getOperator();
-
- /**
- * Set operator from set defined in this interface.
- * @param operator Operator constant
- * @see Operator#EQ
- * @see Operator#NE
- * @see Operator#LT
- * @see Operator#LE
- * @see Operator#GT
- * @see Operator#GE
- */
- void setOperator(Operator operator);
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ICompoundCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ICompoundCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ICompoundCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents a compound logical criteria such as AND or OR.
- */
-public interface ICompoundCriteria extends ILogicalCriteria {
-
- public enum Operator {
- AND,
- OR
- }
-
- /**
- * Get operator used to connect these criteria.
- * @return Operator constant
- * @see Operator#AND
- * @see Operator#OR
- */
- Operator getOperator();
-
- /**
- * Set operator used to connect these criteria.
- * @param operator Operator constant
- * @see Operator#AND
- * @see Operator#OR
- */
- void setOperator(Operator operator);
-
- /**
- * Get list of ICriteria combined by this compound criteria.
- * @return List of ICriteria
- */
- List<ICriteria> getCriteria();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ICriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ICriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ICriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a criteria in the language objects.
- */
-public interface ICriteria extends ILanguageObject {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IDelete.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IDelete.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IDelete.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a DELETE command in the language objects.
- */
-public interface IDelete extends ICommand {
-
- /**
- * Get group that is being inserted into.
- * @return Insert group
- */
- IGroup getGroup();
-
- /**
- * Get criteria that is being used with the delete - may be null
- * @return Criteria, may be null
- */
- ICriteria getCriteria();
-
- /**
- * Set group that is being inserted into.
- * @param group Insert group
- */
- void setGroup(IGroup group);
-
- /**
- * Set criteria that is being used with the delete - may be null
- * @param criteria Criteria, may be null
- */
- void setCriteria(ICriteria criteria);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IElement.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IElement.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IElement.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import org.teiid.connector.metadata.runtime.Element;
-
-/**
- * Represents an element in the language. An example of an element
- * would be a column reference in a SELECT clause.
- */
-public interface IElement extends IMetadataReference<Element>, IExpression {
-
- /**
- * Gets the name of the element.
- * @return the name of the element
- */
- String getName();
-
- /**
- * Return the group that contains this element.
- * @return The group reference
- */
- IGroup getGroup();
-
- /**
- * Sets the name of the element.
- * @param name The name of the element
- */
- void setName(String name);
-
- /**
- * Set the group that contains this element.
- * @return The group reference
- */
- void setGroup(IGroup group);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IExistsCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IExistsCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IExistsCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an EXISTS criteria that checks whether any results would be
- * returned from a subquery.
- */
-public interface IExistsCriteria extends IPredicateCriteria, ISubqueryContainer {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IExpression.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IExpression.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IExpression.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an expression in the language. Subinterfaces define specific
- * types of expressions, such as literal values, element references, and
- * functions.
- */
-public interface IExpression extends ILanguageObject {
-
- /**
- * Determine the type returned by this expression.
- *
- * @return The type, as defined by a Java class
- */
- Class<?> getType();
-
- /**
- * Set the type returned by this expression.
- *
- * @param type The type, as defined by a Java class
- */
- void setType(Class<?> type);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IFrom.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IFrom.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IFrom.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents a FROM clause in a query.
- */
-public interface IFrom extends ILanguageObject {
-
- /**
- * Get a List of IFromItem in this FROM clause.
- * @return List of IFromItem
- */
- List<IFromItem> getItems();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IFromItem.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IFromItem.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IFromItem.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an item in the FROM clause - typically this is either a
- * group or a join, as represented by {@link IGroup or IJoin}.
- */
-public interface IFromItem extends ILanguageObject {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IFunction.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IFunction.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IFunction.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents a function in the language. A function has a name and 0..n
- * Expressions that are parameters.
- */
-public interface IFunction extends IExpression {
-
- /**
- * Get name of the function
- * @return Function name
- */
- String getName();
-
- /**
- * Get the parameters used in this function.
- * @return Array of IExpressions defining the parameters
- */
- List<IExpression> getParameters();
-
- /**
- * Set name of the function
- * @param name Function name
- */
- void setName(String name);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IGroup.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IGroup.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IGroup.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import org.teiid.connector.metadata.runtime.Group;
-
-/**
- * Represents a group in the language objects. An example of a group would
- * be a table reference in the FROM clause. An IGroup may have a context name
- * used in references to this group.
- */
-public interface IGroup extends IMetadataReference<Group>, IFromItem, ILanguageObject {
-
- /**
- * Get the name of the group as defined in the VDB. This is null if the
- * context is the same as the definition.
- * @return Actual group name
- */
- String getDefinition();
-
- /**
- * Get the aliased name this group uses for references in the command.
- * @return Context name
- */
- String getContext();
-
- /**
- * Set the name of the group as defined in the VDB. This is null if the
- * context is the same as the definition.
- * @param definition The definition
- */
- void setDefinition(String definition);
-
- /**
- * Set the aliased name this group uses for references in the command.
- * @param context Context name
- */
- void setContext(String context);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IGroupBy.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IGroupBy.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IGroupBy.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents a GROUP BY clause in a query.
- */
-public interface IGroupBy extends ILanguageObject {
-
- /**
- * Get list of IExpression that the GROUP BY should be grouped on.
- * @return List of IExpression
- */
- List<IExpression> getElements();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IInCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IInCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IInCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents an IN criteria.
- */
-public interface IInCriteria extends IBaseInCriteria {
-
- /**
- * Get List of IExpression in the set on the right side of the criteria.
- * @return List of IExpression
- */
- List<IExpression> getRightExpressions();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IInlineView.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IInlineView.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IInlineView.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-/**
- * An inline view represents a subquery in the FROM clause that defines a
- * query-able context for the outer query. An inline view must be named, which allows
- * them to be treated like aliased groups.
- *
- */
-public interface IInlineView extends IGroup, ISubqueryContainer {
-
- String getName();
-
- void setName(String name);
-
- /**
- * Sets the string that represents the query used within the inline view.
- *
- * @param output
- * @since 5.0
- */
- void setOutput(String output);
-
- /**
- * Gets the output for the subquery once it has been preprocessed.
- * Returns null if the subquery has not yet been converted to output form.
- *
- * @return
- * @since 4.3
- */
- String getOutput();
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IInsert.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IInsert.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IInsert.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents an INSERT command in the language objects.
- */
-public interface IInsert extends ICommand {
-
- /**
- * Get group that is being inserted into.
- * @return Insert group
- */
- IGroup getGroup();
-
- /**
- * Get list of elements being inserted into
- * @return List of IElement
- */
- List<IElement> getElements();
-
- /**
- * Get the IInsertValues
- * @return
- */
- IInsertValueSource getValueSource();
-
- /**
- * Set the IInsertValues
- * @param values
- */
- void setValueSource(IInsertValueSource values);
-
- /**
- * Set group that is being inserted into.
- * @param group Insert group
- */
- void setGroup(IGroup group);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertExpressionValueSource.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertExpressionValueSource.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertExpressionValueSource.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,9 +0,0 @@
-package org.teiid.connector.language;
-
-import java.util.List;
-
-public interface IInsertExpressionValueSource extends IInsertValueSource, ILanguageObject {
-
- List<IExpression> getValues();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertValueSource.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertValueSource.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IInsertValueSource.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,5 +0,0 @@
-package org.teiid.connector.language;
-
-public interface IInsertValueSource extends ILanguageObject {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IIsNullCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IIsNullCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IIsNullCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an IS NULL criteria.
- */
-public interface IIsNullCriteria extends IPredicateCriteria {
-
- /**
- * Get the expression being checked for null.
- * @return Expression being checked
- */
- IExpression getExpression();
-
- /**
- * Set expression of criteria
- * @return Expression
- */
- void setExpression(IExpression expression);
-
- /**
- * Returns whether this criteria is negated.
- * @return flag indicating whether this criteria contains a NOT
- */
- boolean isNegated();
-
- /**
- * Sets whether this criteria is negated.
- * @param negated Flag indicating whether this criteria contains a NOT
- */
- void setNegated(boolean negated);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IJoin.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IJoin.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IJoin.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents a join in the FROM clause. A join combines two IFromItems together
- * in a join.
- */
-public interface IJoin extends IFromItem {
-
- public enum JoinType {
- INNER_JOIN,
- CROSS_JOIN,
- LEFT_OUTER_JOIN,
- RIGHT_OUTER_JOIN,
- FULL_OUTER_JOIN
- }
-
- /**
- * Get the left IFromItem
- * @return From item
- */
- IFromItem getLeftItem();
-
- /**
- * Get the right IFromItem
- * @return From item
- */
- IFromItem getRightItem();
-
- /**
- * Get join type
- * @return Join type
- * @see JoinType#INNER_JOIN
- * @see JoinType#CROSS_JOIN
- * @see JoinType#LEFT_OUTER_JOIN
- * @see JoinType#RIGHT_OUTER_JOIN
- * @see JoinType#FULL_OUTER_JOIN
- */
- JoinType getJoinType();
-
- /**
- * Return List of CompareCriteria specifying join criteria.
- * @return List of CompareCriteria
- */
- List<ICriteria> getCriteria();
-
- /**
- * Set the left IFromItem
- * @param item From item
- */
- void setLeftItem(IFromItem item);
-
- /**
- * Set the right IFromItem
- * @param item From item
- */
- void setRightItem(IFromItem item);
-
- /**
- * Set join type
- * @param type Join type
- * @see JoinType#INNER_JOIN
- * @see JoinType#CROSS_JOIN
- * @see JoinType#LEFT_OUTER_JOIN
- * @see JoinType#RIGHT_OUTER_JOIN
- * @see JoinType#FULL_OUTER_JOIN
- */
- void setJoinType(JoinType type);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageFactory.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageFactory.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,337 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ICompoundCriteria.Operator;
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-
-/**
- * Factory for the construction of language objects that implement the language interfaces.
- * This factory is provided by the connector environment and can be used in modifying the language
- * interfaces if needed.
- */
-public interface ILanguageFactory {
-
- /**
- * Create aggregate function.
- * @param name Aggregate function name, as defined by constants in {@link IAggregate}
- * @param isDistinct True if aggregate function is DISTINCT, false otherwise
- * @param expression Inner expression of the aggregate function
- * @param type Data type
- * @return New IAggregate
- */
- IAggregate createAggregate(String name, boolean isDistinct, IExpression expression, Class type);
-
- /**
- * Create compare criteria.
- * @param operator Operator, as defined in constants in {@link ICompareCriteria}
- * @param leftExpression Left expression
- * @param rightExpression Right expression
- * @return New ICompareCriteria
- */
- ICompareCriteria createCompareCriteria(ICompareCriteria.Operator operator, IExpression leftExpression, IExpression rightExpression);
-
- /**
- * Create a new ICompoundCriteria
- * @param operator Operator, as defined by {@link Operator#AND} or
- * {@link Operator#OR}
- * @param innerCriteria List of ICriteria, typically containing two criteria
- * @return New ICompoundCriteria
- */
- ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List<? extends ICriteria> innerCriteria);
-
- /**
- * Create a new IDelete.
- * @param group The group to delete from
- * @param criteria The criteria (can be null)
- * @return New IDelete
- */
- IDelete createDelete(IGroup group, ICriteria criteria);
-
- /**
- * Create new element.
- * @param name Name of the element
- * @param group Group this element is in
- * @param metadataReference Metadata reference describing this element
- * @param type Data type
- * @return New IElement
- */
- IElement createElement(String name, IGroup group, Element metadataReference, Class type);
-
- /**
- * Create new exists criteria.
- * @param query Inner query
- * @return New IExists
- */
- IExistsCriteria createExistsCriteria(IQuery query);
-
- /**
- * Create new from clause
- * @param items List of IFromItem
- * @return New IFrom
- */
- IFrom createFrom(List<? extends IFromItem> items);
-
- /**
- * Create new function
- * @param functionName Name of the function
- * @param args Arguments, should never be null
- * @param type Data type returned
- * @return New IFunction
- */
- IFunction createFunction(String functionName, IExpression[] args, Class<?> type);
-
- /**
- * Create new function
- * @param functionName Name of the function
- * @param args Arguments, should never be null
- * @param type Data type returned
- * @return New IFunction
- */
- IFunction createFunction(String functionName, List<? extends IExpression> args, Class<?> type);
-
- /**
- * Create new group.
- * @param context Alias if it exists, or group name if no alias exists
- * @param definition Group name
- * @param metadataReference Reference to metadata identifier
- * @return New IGroup
- */
- IGroup createGroup(String context, String definition, Group metadataReference);
-
- /**
- * Create new group by.
- * @param items List of IGroupByItem
- * @return New IGroupBy
- */
- IGroupBy createGroupBy(List<? extends IExpression> items);
-
- /**
- * Create new IN criteria
- * @param leftExpression Left expression
- * @param rightExpressions List of right expressions
- * @param isNegated True if NOT IN, false for IN
- * @return New IInCriteria
- */
- IInCriteria createInCriteria(IExpression leftExpression, List<? extends IExpression> rightExpressions, boolean isNegated);
-
- /**
- * Create new inline view
- * @param query The query defining the inline view
- * @param name The name of the inline view
- * @return New IInLineView
- */
- IInlineView createInlineView(IQueryCommand query, String name);
-
- /**
- * Create new insert command
- * @param group Insert group
- * @param columns List of IElement being inserted into
- * @param values List of IExpression (usually ILiteral)
- * @return New IInsert
- */
- IInsert createInsert(IGroup group, List<IElement> columns, IInsertValueSource valueSource);
-
- /**
- * Create a new value source for an insert command
- * @param values
- * @return
- */
- IInsertExpressionValueSource createInsertExpressionValueSource(List<IExpression> values);
-
- /**
- * Create new IS NULL criteria
- * @param expression Expression
- * @param isNegated True if IS NOT NULL, false if IS NULL
- * @return New IIsNullCriteria
- */
- IIsNullCriteria createIsNullCriteria(IExpression expression, boolean isNegated);
-
- /**
- * Create new join predicate
- * @param joinType Join type as defined by constants in {@link IJoin}
- * @param leftItem Left from clause item
- * @param rightItem Right from clause item
- * @param criteria List of ICriteria (considered to be AND'ed together)
- * @return New IJoin
- */
- IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List<? extends ICriteria> criteria);
-
- /**
- * Create new LIKE criteria
- * @param leftExpression Left expression
- * @param rightExpression Right expression
- * @param escapeCharacter Escape character or null if none
- * @param isNegated True if NOT LIKE, false if LIKE
- * @return New ILikeCriteria
- */
- ILikeCriteria createLikeCriteria(IExpression leftExpression, IExpression rightExpression, Character escapeCharacter, boolean isNegated);
-
- /**
- * Create new literal value.
- * @param value The value, may be null
- * @param type The data type
- * @return New ILiteral
- */
- ILiteral createLiteral(Object value, Class type);
-
- /**
- * Create new NOT criteria
- * @param criteria Inner criteria
- * @return New INotCriteria
- */
- INotCriteria createNotCriteria(ICriteria criteria);
-
- /**
- * Create new ORDER BY clause
- * @param items List of IOrderByItem
- * @return New IOrderBy
- */
- IOrderBy createOrderBy(List<? extends IOrderByItem> items);
-
- /**
- * Create new ORDER BY item
- * @param name Name of item
- * @param element Associated element, if applicable
- * @param direction Direction, defined by constants in {@link IOrderByItem}
- * @return New IOrderByItem
- */
- IOrderByItem createOrderByItem(String name, IElement element, boolean direction);
-
- /**
- * Create new procedure parameter
- * @param index Index in the procedure call
- * @param direction Kind of parameter - IN, OUT, .... as defined in {@link IParameter}
- * @param value Value, may be null if not applicable
- * @param type Data type
- * @param metadataReference Metadata identifier reference
- * @return New IParameter
- */
- IParameter createParameter(int index, Direction direction, Object value, Class type, Parameter metadataReference);
-
- /**
- * Create new procedure
- * @param name Name of procedure
- * @param parameters List of IParameter
- * @param metadataReference Metadata identifier reference
- * @return New IProcedure
- */
- IProcedure createProcedure(String name, List<? extends IParameter> parameters, Procedure metadataReference);
-
- /**
- * Create new query
- * @param select SELECT clause
- * @param from FROM clause
- * @param where WHERE clause
- * @param groupBy GROUP BY clause
- * @param having HAVING clause
- * @param orderBy ORDER BY clause
- * @return New IQuery
- */
- IQuery createQuery(ISelect select, IFrom from, ICriteria where, IGroupBy groupBy, ICriteria having, IOrderBy orderBy);
-
- ISetQuery createSetOp(ISetQuery.Operation operation, boolean all, IQueryCommand leftQuery, IQueryCommand rightQuery, IOrderBy orderBy, ILimit limit);
-
- /**
- * Create new scalar subquery which can be used as an expression
- * @param query Subquery
- * @return New scalar subquery
- */
- IScalarSubquery createScalarSubquery(IQuery query);
-
- /**
- * Create searched case expression.
- * @param whenExpressions List of when expressions, should match thenExpressions
- * @param thenExpressions List of then expressions, should match whenExpressions
- * @param elseExpression Else expression, may be null
- * @param type Data type
- * @return New ICaseExpression
- */
- ISearchedCaseExpression createSearchedCaseExpression(List<? extends ICriteria> whenExpressions, List<? extends IExpression> thenExpressions, IExpression elseExpression, Class type);
-
- /**
- * Create new SELECT clause
- * @param isDistinct True if DISTINCT, false for ALL
- * @param selectSymbols List of ISelectSymbol
- * @return New ISelect
- */
- ISelect createSelect(boolean isDistinct, List<? extends ISelectSymbol> selectSymbols);
-
- /**
- * Create new select symbol
- * @param name Name of the symbol (which may be an alias)
- * @param expression Expression
- * @return New ISelectSymbol
- */
- ISelectSymbol createSelectSymbol(String name, IExpression expression);
-
- /**
- * Create new subquery compare criteria
- * @param leftExpression Left expression
- * @param operator Comparison operator, as defined in {@link ISubqueryCompareCriteria}
- * @param quantifier Quantification operator, as defined in {@link ISubqueryCompareCriteria}
- * @param subquery Right subquery
- * @return New ISubqueryCompareCriteria
- */
- ISubqueryCompareCriteria createSubqueryCompareCriteria(IExpression leftExpression, ICompareCriteria.Operator operator, ISubqueryCompareCriteria.Quantifier quantifier, IQuery subquery);
-
- /**
- * Create new subquery IN criteria
- * @param expression Left expression
- * @param subquery Right subquery
- * @param isNegated True if NOT IN, false if IN
- * @return New ISubqueryInCriteria
- */
- ISubqueryInCriteria createSubqueryInCriteria(IExpression expression, IQuery subquery, boolean isNegated);
-
- /**
- * Create new UPDATE command
- * @param group Group being updated
- * @param updates
- * @param criteria Criteria to use, may be null
- * @return New IUpdate
- */
- IUpdate createUpdate(IGroup group, ISetClauseList updates, ICriteria criteria);
-
- /**
- * Creates a new SetClauseList
- * @param clauses
- * @return
- */
- ISetClauseList createSetClauseList(List<ISetClause> clauses);
-
- /**
- * Creates a new SetClause
- * @param symbol
- * @param value
- * @return
- */
- ISetClause createSetClause(IElement symbol, IExpression value);
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageObject.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageObject.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ILanguageObject.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- * Root interface for all language object interfaces.
- */
-public interface ILanguageObject {
-
- void acceptVisitor(LanguageObjectVisitor visitor);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ILikeCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ILikeCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ILikeCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-/**
- * Represents a LIKE criteria in the language.
- */
-public interface ILikeCriteria extends IPredicateCriteria {
-
- /**
- * Get left expression.
- * @return Left expression
- */
- IExpression getLeftExpression();
-
- /**
- * Set left expression of criteria
- * @return Left expression
- */
- void setLeftExpression(IExpression expression);
-
- /**
- * Get right expression.
- * @return Right expression
- */
- IExpression getRightExpression();
-
- /**
- * Set left expression of criteria
- * @return Right expression
- */
- void setRightExpression(IExpression expression);
-
- /**
- * Get escape character, if one is defined.
- * @return Escape character or null if none is defined.
- */
- Character getEscapeCharacter();
-
- /**
- * Set escape character, if one is defined.
- * @param character Escape character or null if none is defined.
- */
- void setEscapeCharacter(Character character);
-
- /**
- * Returns whether this criteria is negated.
- * @return flag indicating whether this criteria contains a NOT
- */
- boolean isNegated();
-
- /**
- * Sets whether this criteria is negated.
- * @param negated Flag indicating whether this criteria contains a NOT
- */
- void setNegated(boolean negated);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ILimit.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ILimit.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ILimit.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-
-/**
- * Represents a LIMIT clause with row offset and row limit values to bound the resulting rows
- * @since 4.3
- */
-public interface ILimit extends ILanguageObject {
-
- /**
- * Get the max number of rows returned by the connector for this query .
- * @return the max number of rows returned by the connector for this query.
- * @since 5.0 SP1
- */
- int getRowLimit();
-
- /**
- * Gets the offset (relative to the starting row of the produced resultset) of the
- * first row returned by the connector. 0 or less indicates no offset.
- * @return
- * @since 5.0 SP1
- */
- int getRowOffset();
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ILiteral.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ILiteral.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ILiteral.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-/**
- * Represents a literal value that is used in
- * an expression. The value can be obtained and should match
- * the type specified by {@link ILiteral#getType}.
- */
-public interface ILiteral extends IExpression {
- /**
- * Get the value of the literal
- * @return Object of value
- */
- Object getValue();
-
- /**
- * Get the Java type of the literal
- * @return Java class name of type
- */
- Class<?> getType();
-
- /**
- * Set the value of the literal
- * @param value Object of value
- */
- void setValue(Object value);
-
- /**
- * Set the Java type of the literal
- * @param type Java class name of type
- */
- void setType(Class<?> type);
-
- /**
- * Returns true if this literal should be treated as a bind value
- */
- boolean isBindValue();
-
- /**
- * Set whether this literal should be treated as a bind value
- * @param bindValue
- */
- void setBindValue(boolean bindValue);
-
- /**
- * Returns true if the value for this literal is a list of values.
- * @return
- */
- boolean isMultiValued();
-
- /**
- * Set whether the value for this literal is a list of values.
- * @param multiValued
- */
- void setMultiValued(boolean multiValued);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ILogicalCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ILogicalCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ILogicalCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a logical criteria, which typically is used to bind
- * together {@link IPredicateCriteria}.
- */
-public interface ILogicalCriteria extends ICriteria {
-
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IMetadataReference.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IMetadataReference.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IMetadataReference.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import org.teiid.connector.metadata.runtime.MetadataObject;
-
-/**
- * This interface is used to mark language objects as having a
- * reference to a MetadataID.
- */
-public interface IMetadataReference<T extends MetadataObject> {
-
- T getMetadataObject();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/INotCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/INotCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/INotCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a NOT criteria, which is wrapped around another criteria.
- */
-public interface INotCriteria extends ILogicalCriteria {
-
- /**
- * The criteria wrapped by the NOT.
- * @return Criteria
- */
- ICriteria getCriteria();
-
- /**
- * The criteria wrapped by the NOT.
- * @param criteria Criteria
- */
- void setCriteria(ICriteria criteria);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderBy.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderBy.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderBy.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents an ORDER BY clause in a command. The ORDER BY is
- * conceptually executed on the results of the SELECT clause and thus
- * specifies the columns to order by based on the names of the
- * SELECT symbols. So, the IOrderBy does not work on IExpression, rather
- * it is a list of Strings matching to the values returned from
- * {@link ISelectSymbol#getOutputName()}.
- */
-public interface IOrderBy extends ILanguageObject {
-
- /**
- * Get list of {@link IOrderByItem}s specifying the ordering of the results.
- * @return List of IOrderByItem
- */
- List<IOrderByItem> getItems();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderByItem.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderByItem.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IOrderByItem.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-/**
- * Represents a single item in the ORDER BY clause.
- */
-public interface IOrderByItem extends ILanguageObject {
-
- public static final boolean ASC = true;
- public static final boolean DESC = false;
-
- /**
- * Get name of the output column to order by
- * @return Name of output column, as specified in {@link ISelectSymbol#getOutputName()}.
- */
- String getName();
-
- /**
- * Get direction of whether to sort ascending or descending.
- * @return {@link #ASC} for ascending or {@link #DESC} for descending
- */
- boolean getDirection();
-
- /**
- * Set name of the output column to order by
- * @param name Name of output column, as specified in {@link ISelectSymbol#getOutputName()}.
- */
- void setName(String name);
-
- /**
- * Set direction of whether to sort ascending or descending.
- * @param direction {@link #ASC} for ascending or {@link #DESC} for descending
- */
- void setDirection(boolean direction);
-
- /**
- * Get the element referred to by this item
- * @return The element, may be null
- */
- IElement getElement();
-
- /**
- * Set the new element for this order by
- * @param element New element
- */
- void setElement(IElement element);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IParameter.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IParameter.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IParameter.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import org.teiid.connector.metadata.runtime.Parameter;
-
-/**
- * Represents an execution parameter.
- */
-public interface IParameter extends ILanguageObject, IMetadataReference<Parameter> {
-
- public enum Direction {
- IN,
- OUT,
- INOUT,
- RETURN,
- RESULT_SET
- }
-
- /**
- * Get index of this parameter in the IExecution.
- * @return Index of the parameter
- */
- int getIndex();
-
- /**
- * Get direction of parameter
- * @return Direction
- * @see Direction#IN
- * @see Direction#OUT
- * @see Direction#INOUT
- * @see Direction#RETURN
- */
- Direction getDirection();
-
- /**
- * Get type of parameter, defined as a Java class. Output result sets will
- * return "java.sql.ResultSet".
- * @return Type of parameter
- */
- Class getType();
-
- /**
- * Get value of object if this is an IN parameter.
- * @return Value of IN parameter or null otherwise
- */
- Object getValue();
-
- /**
- * Determine whether a value was set for this parameter. This will only
- * return true if this parameter is an IN or INOUT parameter and a value was
- * set by the caller. If no value was set, then this parameter was determined
- * to be optional and has no default value. Connectors may deal with this
- * optional parameter as necessary, perhaps by using named parameters when
- * executing the procedure to avoid unspecified inputs.
- *
- * @return True if IN or INOUT and no value was set
- * @since 4.3.2
- */
- boolean getValueSpecified();
-
- /**
- * Set index of this parameter in the IExecution.
- * @param index Index of the parameter
- */
- void setIndex(int index);
-
- /**
- * Set direction of parameter
- * @param direction Direction
- * @see Direction#IN
- * @see Direction#OUT
- * @see Direction#INOUT
- * @see Direction#RETURN
- */
- void setDirection(Direction direction);
-
- /**
- * Set type of parameter, defined as a Java class. Output result sets will
- * return "java.sql.ResultSet".
- * @param type Type of parameter
- */
- void setType(Class type);
-
- /**
- * Set value of object if this is an IN parameter. If
- * value is non-null, the valueSpecified attribute will be
- * automatically set. If null, callers must also call {@link #setValueSpecified(boolean)}
- * to indicate whether the null was a missing or actual value.
- *
- * @param value Value of IN parameter or null otherwise
- */
- void setValue(Object value);
-
- /**
- * Indicate that a value was specified for this parameter. If no
- * value was specified, the connector must deal with the optional parameter
- * as necessary.
- *
- * @param specified True if value was specified
- * @since 4.3.2
- */
- void setValueSpecified(boolean specified);
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IPredicateCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IPredicateCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IPredicateCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a criteria that can occur at the leaf of a tree of
- * criteria.
- */
-public interface IPredicateCriteria extends ICriteria {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IProcedure.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IProcedure.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IProcedure.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-
-/**
- * Represents a procedural execution (such as a stored procedure).
- */
-public interface IProcedure extends ICommand, IMetadataReference<Procedure> {
-
- /**
- * Gets the name of the procedure.
- * @return the name of the procedure
- */
- String getProcedureName();
-
- /**
- * Returns list of the IParameter objects associated with this execution.
- * The parameters describe inputs and outputs.
- * @return List of IParameter
- */
- List<IParameter> getParameters();
-
- /**
- * Sets the name of the procedure.
- * @param name The name of the procedure
- */
- void setProcedureName(String name);
-
- /**
- * Get the procedure result set column types
- * @return an array containing the types or an empty array if there is no
- * result set parameter
- * @throws ConnectorException
- */
- Class<?>[] getResultSetColumnTypes() throws ConnectorException;
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IQuery.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IQuery.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IQuery.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a SELECT query in the language objects.
- */
-public interface IQuery extends IQueryCommand {
-
- /**
- * Get SELECT clause, should never be null.
- * @return Select clause object
- */
- ISelect getSelect();
-
- /**
- * Get FROM clause, should never be null.
- * @return From clause object
- */
- IFrom getFrom();
-
- /**
- * Get WHERE clause, may be null.
- * @return A criteria object
- */
- ICriteria getWhere();
-
- /**
- * Get GROUP BY clause, may be null.
- * @return A group by object
- */
- IGroupBy getGroupBy();
-
- /**
- * Get HAVING clause, may be null.
- * @return A criteria object
- */
- ICriteria getHaving();
-
- /**
- * Set SELECT clause, should never be null.
- * @param select Select clause object
- */
- void setSelect(ISelect select);
-
- /**
- * Set FROM clause, should never be null.
- * @param from From clause object
- */
- void setFrom(IFrom from);
-
- /**
- * Set WHERE clause, may be null.
- * @param criteria A criteria object
- */
- void setWhere(ICriteria criteria);
-
- /**
- * Set GROUP BY clause, may be null.
- * @param groupBy A group by object
- */
- void setGroupBy(IGroupBy groupBy);
-
- /**
- * Set HAVING clause, may be null.
- * @param criteria A criteria object
- */
- void setHaving(ICriteria criteria);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IQueryCommand.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IQueryCommand.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IQueryCommand.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-public interface IQueryCommand extends ICommand, IInsertValueSource {
-
- /**
- * Set ORDER BY clause, may be null.
- * @param orderBy An ORDER BY object
- */
- void setOrderBy(IOrderBy orderBy);
- /**
- * Set LIMIT clause, may be null.
- * @param limit A LIMIT object
- */
- void setLimit(ILimit limit);
-
- IQuery getProjectedQuery();
-
- /**
- * Get ORDER BY clause, may be null.
- * @return An ORDER BY object
- */
- IOrderBy getOrderBy();
-
- /**
- * Get LIMIT clause, may be null.
- * @return A LIMIT object
- */
- ILimit getLimit();
-
- /**
- * Get the column names of the output columns for this query
- * @return a String[] containing the column names
- * @since 4.3
- */
- String[] getColumnNames();
-
- /**
- * Get the column types of the output columns for this query
- * @return a Class[] containing the column names
- * @since 4.3
- */
- Class[] getColumnTypes();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IScalarSubquery.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IScalarSubquery.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IScalarSubquery.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a scalar subquery. That is, a query that is evaluated as a scalar
- * expression and returns a single value. The inner subquery must return exactly
- * 1 column as well.
- */
-public interface IScalarSubquery extends IExpression, ISubqueryContainer {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISearchedCaseExpression.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISearchedCaseExpression.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISearchedCaseExpression.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a non-searched CASE expression:
- * <br/> CASE WHEN criteria THEN expression ... END
- */
-public interface ISearchedCaseExpression extends IExpression {
-
- /**
- * Gets the number of WHEN and THEN clauses in the CASE expression
- * @return the number of WHEN ... THEN ... parts
- */
- int getWhenCount();
-
- /**
- * Gets the WHEN criteria at the specified index
- * @param index the 0-based index
- * @return the WHEN criteria at the index
- */
- ICriteria getWhenCriteria(int index);
-
- /**
- * Sets the WHEN criteria at the specified index
- * @param index the 0-based index
- * @param criteria The new WHEN criteria at the index
- */
- void setWhenCriteria(int index, ICriteria criteria);
-
- /**
- * Gets the THEN expression at the specified index
- * @param index the 0-based index
- * @return the THEN expression at the index
- */
- IExpression getThenExpression(int index);
-
- /**
- * Sets the THEN expression at the specified index
- * @param index the 0-based index
- * @param expression The new THEN expression at the index
- */
- void setThenExpression(int index, IExpression expression);
-
- /**
- * Gets the ELSE expression, if defined. Can be null.
- * @return the ELSE expression.
- */
- IExpression getElseExpression();
-
- /**
- * Sets the ELSE expression
- * @param expression The new ELSE expression
- */
- void setElseExpression(IExpression expression);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISelect.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISelect.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISelect.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-/**
- * Represents a SELECT clause in the language objects.
- */
-public interface ISelect extends ILanguageObject {
-
- /**
- * Get List of ISelectSymbol.
- * @return List of ISelectSymbol
- */
- List<ISelectSymbol> getSelectSymbols();
-
- /**
- * Determine whether the DISTINCT flag is used in this SELECT.
- * @return True if SELECT DISTINCT, false if SELECT ALL
- */
- boolean isDistinct();
-
- /**
- * Set whether the DISTINCT flag is used in this SELECT.
- * @param distinct True if SELECT DISTINCT, false if SELECT ALL
- */
- void setDistinct(boolean distinct);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISelectSymbol.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISelectSymbol.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISelectSymbol.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an item in the SELECT clause. Typically the SELECT clause
- * contains expressions which are optionally given an output name.
- */
-public interface ISelectSymbol extends ILanguageObject {
-
- /**
- * Determine whether this symbol is named with an alias.
- * @return True if an alias exists
- */
- boolean hasAlias();
-
- /**
- * Return output column name. This may be the alias name, a name
- * derived from the expression, or a default name assigned to an
- * expression.
- * @return Name of the output column
- */
- String getOutputName();
-
- /**
- * Get the expression referenced by this symbol.
- * @return The expression
- */
- IExpression getExpression();
-
- /**
- * Set whether this symbol is named with an alias.
- * @param alias True if an alias exists
- */
- void setAlias(boolean alias);
-
- /**
- * Set output column name. This may be the alias name, a name
- * derived from the expression, or a default name assigned to an
- * expression.
- * @param name Name of the output column
- */
- void setOutputName(String name);
-
- /**
- * Set the expression referenced by this symbol.
- * @param expression The expression
- */
- void setExpression(IExpression expression);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClause.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClause.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClause.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-public interface ISetClause extends ILanguageObject {
-
- IElement getSymbol();
-
- void setSymbol(IElement symbol);
-
- IExpression getValue();
-
- void setValue(IExpression value);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClauseList.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClauseList.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISetClauseList.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-import java.util.List;
-
-public interface ISetClauseList extends ILanguageObject {
-
- List<ISetClause> getClauses();
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISetQuery.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISetQuery.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISetQuery.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-public interface ISetQuery extends
- IQueryCommand {
-
- public enum Operation {
- /** Represents UNION of two queries */
- UNION,
- /** Represents intersection of two queries */
- INTERSECT,
- /** Represents set difference of two queries */
- EXCEPT
- }
-
- boolean isAll();
-
- void setAll(boolean all);
-
- Operation getOperation();
-
- void setOperation(Operation operation);
-
- IQueryCommand getLeftQuery();
-
- void setLeftQuery(IQueryCommand leftQuery);
-
- IQueryCommand getRightQuery();
-
- void setRightQuery(IQueryCommand rightQuery);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryCompareCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryCompareCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryCompareCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents a quantified comparison criteria. This criteria has an expression on the left,
- * a comparison operator (such as =, <, etc), a quantification operator (ALL, ANY),
- * and a subquery.
- */
-public interface ISubqueryCompareCriteria extends IPredicateCriteria, ISubqueryContainer {
-
- public enum Quantifier {
- SOME,
- ALL
- }
- /**
- * Get left expression.
- * @return Left expression
- */
- IExpression getLeftExpression();
-
- /**
- * Get operator from set defined in this interface.
- * @return Operator constant
- * @see #EQ
- * @see #NE
- * @see #LT
- * @see #LE
- * @see #GT
- * @see #GE
- */
- ICompareCriteria.Operator getOperator();
-
- /**
- * Get quantifier.
- * @return Quantifier constant
- * @see Quantifier#SOME
- * @see Quantifier#ALL
- */
- Quantifier getQuantifier();
-
- /**
- * Set left expression.
- * @param expression Left expression
- */
- void setLeftExpression(IExpression expression);
-
- /**
- * Set operator from set defined in this interface.
- * @param quantifier Operator constant
- * @see #EQ
- * @see #NE
- * @see #LT
- * @see #LE
- * @see #GT
- * @see #GE
- */
- void setOperator(ICompareCriteria.Operator operator);
-
- /**
- * Set quantifier.
- * @param quantifier Quantifier constant
- * @see Quantifier#SOME
- * @see Quantifier#ALL
- */
- void setQuantifier(Quantifier quantifier);
-
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryContainer.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryContainer.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryContainer.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * This is a marker interface for language interfaces that contain a subquery.
- */
-public interface ISubqueryContainer {
-
- /**
- * Get the inner subquery
- * @return Subquery
- */
- IQueryCommand getQuery();
-
- /**
- * Set the inner subquery
- * @param query Subquery
- */
- void setQuery(IQueryCommand query);
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryInCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryInCriteria.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ISubqueryInCriteria.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.language;
-
-/**
- * Represents an IN criteria that uses a subquery on the right side rather than a
- * list of values.
- */
-public interface ISubqueryInCriteria extends IBaseInCriteria, ISubqueryContainer {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/language/IUpdate.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IUpdate.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IUpdate.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
-
-
-/**
- * Represents an UPDATE command in the language objects.
- */
-public interface IUpdate extends ICommand {
-
- /**
- * Get group that is being inserted into.
- * @return Insert group
- */
- IGroup getGroup();
-
- /**
- * Get list of changes that should occur in the UPDATE - every
- * change is of the form "element = expression".
- * @return ISetClauseList
- */
- ISetClauseList getChanges();
-
- /**
- * Get criteria that is being used with the delete - may be null
- * @return Criteria, may be null
- */
- ICriteria getCriteria();
-
- /**
- * Set group that is being inserted into.
- * @param group Insert group
- */
- void setGroup(IGroup group);
-
- /**
- * Set list of changes that should occur in the UPDATE - every
- * change is of the form "element = expression".
- * @param changes
- */
- void setChanges(ISetClauseList changes);
-
- /**
- * Set criteria that is being used with the delete - may be null
- * @param criteria Criteria, may be null
- */
- void setCriteria(ICriteria criteria);
-
-}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/In.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/In.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/In.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/In.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,54 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class In extends BaseInCondition {
+
+ private List<Expression> rightExpressions;
+
+ public In(Expression left, List<Expression> right, boolean negated) {
+ super(left, negated);
+ rightExpressions = right;
+ }
+
+ /**
+ * Get List of IExpression in the set on the right side of the criteria.
+ * @return List of IExpression
+ */
+ public List<Expression> getRightExpressions() {
+ return rightExpressions;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setRightExpressions(List<Expression> expressions) {
+ this.rightExpressions = expressions;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Insert.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Insert.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Insert.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Insert.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,70 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+
+public class Insert extends BaseLanguageObject implements Command {
+
+ private NamedTable table;
+ private List<ColumnReference> columns;
+ private InsertValueSource valueSource;
+
+ public Insert(NamedTable group, List<ColumnReference> elements, InsertValueSource valueSource) {
+ this.table = group;
+ this.columns = elements;
+ this.valueSource = valueSource;
+ }
+
+ public NamedTable getTable() {
+ return table;
+ }
+
+ public List<ColumnReference> getColumns() {
+ return columns;
+ }
+
+ public InsertValueSource getValueSource() {
+ return valueSource;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ public void setColumns(List<ColumnReference> elements) {
+ this.columns = elements;
+ }
+
+ public void setValueSource(InsertValueSource values) {
+ this.valueSource = values;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/InsertValueSource.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/InsertValueSource.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/InsertValueSource.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/InsertValueSource.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,27 @@
+/*
+ * 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.language;
+
+public interface InsertValueSource extends LanguageObject {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/IsNull.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/IsNull.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/IsNull.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/IsNull.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,60 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an IS NULL predicate.
+ */
+public class IsNull extends Condition implements Predicate {
+
+ private Expression expression;
+ private boolean negated;
+
+ public IsNull(Expression expr, boolean isNegated) {
+ expression = expr;
+ this.negated = isNegated;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public boolean isNegated() {
+ return this.negated;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+ public void setNegated(boolean negated) {
+ this.negated = negated;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Join.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Join.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Join.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Join.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,85 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class Join extends BaseLanguageObject implements TableReference {
+
+ public enum JoinType {
+ INNER_JOIN,
+ CROSS_JOIN,
+ LEFT_OUTER_JOIN,
+ RIGHT_OUTER_JOIN,
+ FULL_OUTER_JOIN
+ }
+
+ private TableReference leftItem;
+ private TableReference rightItem;
+ private JoinType joinType;
+ private Condition condition;
+
+ public Join(TableReference left, TableReference right, JoinType joinType, Condition criteria) {
+ this.leftItem = left;
+ this.rightItem = right;
+ this.joinType = joinType;
+ this.condition = criteria;
+ }
+
+ public TableReference getLeftItem() {
+ return leftItem;
+ }
+
+ public TableReference getRightItem() {
+ return rightItem;
+ }
+
+ public JoinType getJoinType() {
+ return this.joinType;
+ }
+
+ public Condition getCondition() {
+ return condition;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setLeftItem(TableReference item) {
+ this.leftItem = item;
+ }
+
+ public void setRightItem(TableReference item) {
+ this.rightItem = item;
+ }
+
+ public void setJoinType(JoinType type) {
+ this.joinType = type;
+ }
+
+ public void setCondition(Condition criteria) {
+ this.condition = criteria;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,207 @@
+/*
+ * 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.language;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.connector.language.SortSpecification.Ordering;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.connector.metadata.runtime.Table;
+
+/**
+ * Factory for the construction of language objects that implement the language interfaces.
+ * This factory is provided by the connector environment and can be used in modifying the language
+ * interfaces if needed.
+ */
+public class LanguageFactory {
+
+ /**
+ * Public instance, holds no state so can be shared by everyone.
+ */
+ public static final LanguageFactory INSTANCE = new LanguageFactory();
+
+ public AggregateFunction createAggregate(String name, boolean isDistinct, Expression expression, Class<?> type) {
+ return new AggregateFunction(name, isDistinct, expression, type);
+ }
+
+ public Comparison createCompareCriteria(
+ Comparison.Operator operator,
+ Expression leftExpression,
+ Expression rightExpression) {
+ return new Comparison(leftExpression, rightExpression, operator);
+ }
+
+ public AndOr createAndOr(AndOr.Operator operator, Condition left, Condition right) {
+ return new AndOr(left, right, operator);
+ }
+
+ public Delete createDelete(NamedTable group, Condition where) {
+ return new Delete(group, where);
+ }
+
+ public ColumnReference createColumnReference(String name, NamedTable group, Column metadataReference, Class<?> type) {
+ return new ColumnReference(group, name, metadataReference, type);
+ }
+
+ public Exists createExists(Select query) {
+ return new Exists(query);
+ }
+
+ public Function createFunction(String functionName, Expression[] args, Class<?> type) {
+ return new Function(functionName, Arrays.asList(args), type);
+ }
+
+ public Function createFunction(String functionName, List<? extends Expression> args, Class<?> type) {
+ return new Function(functionName, args, type);
+ }
+
+ public NamedTable createNamedTable(String name, String correlationName, Table metadataReference) {
+ return new NamedTable(name, correlationName, metadataReference);
+ }
+
+ public GroupBy createGroupBy(List<Expression> items) {
+ return new GroupBy(items);
+ }
+
+ public In createIn(Expression leftExpression, List<Expression> rightExpressions, boolean isNegated) {
+ return new In(leftExpression, rightExpressions, isNegated);
+ }
+
+ public Insert createInsert(NamedTable group, List<ColumnReference> columns, InsertValueSource valueSource) {
+ return new Insert(group, columns, valueSource);
+ }
+
+ public ExpressionValueSource createInsertExpressionValueSource(List<Expression> values) {
+ return new ExpressionValueSource(values);
+ }
+
+ public IsNull createIsNullCriteria(Expression expression, boolean isNegated) {
+ return new IsNull(expression, isNegated);
+ }
+
+ public Join createJoin(Join.JoinType joinType, TableReference leftItem, TableReference rightItem, Condition condition) {
+ return new Join(leftItem, rightItem, joinType, condition);
+ }
+
+ public Like createLikeCriteria(
+ Expression leftExpression,
+ Expression rightExpression,
+ Character escapeCharacter,
+ boolean isNegated) {
+ return new Like(leftExpression, rightExpression, escapeCharacter, isNegated);
+ }
+
+ public Literal createLiteral(Object value, Class<?> type) {
+ return new Literal(value, type);
+ }
+
+ public Not createNot(Condition criteria) {
+ return new Not(criteria);
+ }
+
+ public OrderBy createOrderBy(List<SortSpecification> items) {
+ return new OrderBy(items);
+ }
+
+ public SortSpecification createOrderByItem(ColumnReference element, Ordering direction) {
+ return new SortSpecification(direction, element);
+ }
+
+ public Argument createArgument(Argument.Direction direction, Literal value, Class<?> type, ProcedureParameter metadataReference) {
+ return new Argument(direction, value, type, metadataReference);
+ }
+
+ public Call createCall(String name, List<Argument> parameters, Procedure metadataReference) {
+ return new Call(name, parameters, metadataReference);
+ }
+
+ public Select createQuery(
+ List<DerivedColumn> select,
+ boolean isDistinct,
+ List<TableReference> from,
+ Condition where,
+ GroupBy groupBy,
+ Condition having,
+ OrderBy orderBy) {
+ return new Select(select, isDistinct, from, where, groupBy, having, orderBy);
+ }
+
+ public ScalarSubquery createScalarSubquery(Select query) {
+ return new ScalarSubquery(query);
+ }
+
+ public SearchedCase createSearchedCaseExpression(
+ List<SearchedWhenClause> cases,
+ Expression elseExpression,
+ Class<?> type) {
+ return new SearchedCase(cases, elseExpression, type);
+ }
+
+ public SearchedWhenClause createSearchedWhenCondition(Condition condition, Expression result) {
+ return new SearchedWhenClause(condition, result);
+ }
+
+ public DerivedColumn createSelectSymbol(String name, Expression expression) {
+ return new DerivedColumn(name, expression);
+ }
+
+ public SubqueryComparison createSubqueryCompareCriteria(
+ Expression leftExpression,
+ Comparison.Operator operator,
+ SubqueryComparison.Quantifier quantifier,
+ Select subquery) {
+ return new SubqueryComparison(leftExpression, operator, quantifier, subquery);
+ }
+
+ public SubqueryIn createSubqueryInCriteria(Expression expression, Select subquery, boolean isNegated) {
+ return new SubqueryIn(expression, isNegated, subquery);
+ }
+
+ public Update createUpdate(NamedTable group, List<SetClause> updates, Condition criteria) {
+ return new Update(group, updates, criteria);
+ }
+
+ public DerivedTable createInlineView(QueryExpression query, String name) {
+ return new DerivedTable(query, name);
+ }
+
+ public SetQuery createSetOp(SetQuery.Operation operation, boolean all, QueryExpression leftQuery, QueryExpression rightQuery, OrderBy orderBy, Limit limit) {
+ SetQuery queryImpl = new SetQuery();
+ queryImpl.setOperation(operation);
+ queryImpl.setAll(all);
+ queryImpl.setLeftQuery(leftQuery);
+ queryImpl.setRightQuery(rightQuery);
+ queryImpl.setOrderBy(orderBy);
+ queryImpl.setLimit(limit);
+ return queryImpl;
+ }
+
+ public SetClause createSetClause(ColumnReference symbol, Expression value) {
+ return new SetClause(symbol, value);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageObject.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageObject.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageObject.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageObject.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,34 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Root interface for all language object interfaces.
+ */
+public interface LanguageObject {
+
+ void acceptVisitor(LanguageObjectVisitor visitor);
+
+}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageUtil.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageUtil.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageUtil.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,7 +24,7 @@
import java.util.*;
-import org.teiid.connector.language.ICompoundCriteria.Operator;
+import org.teiid.connector.language.AndOr.Operator;
/**
@@ -48,31 +48,28 @@
* @param criteria Criteria to break, may be null
* @return List of ICriteria, never null
*/
- public static final List separateCriteriaByAnd(ICriteria criteria) {
+ public static final List<Condition> separateCriteriaByAnd(Condition criteria) {
if(criteria == null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- List parts = new ArrayList();
+ List<Condition> parts = new ArrayList<Condition>();
separateCriteria(criteria, parts);
return parts;
}
/**
- * Helper method for {@link #separateCriteriaByAnd(ICriteria)} that
+ * Helper method for {@link #separateCriteriaByAnd(Condition)} that
* can be called recursively to collect parts.
* @param crit Crit to break apart
* @param parts List to add parts to
*/
- private static void separateCriteria(ICriteria crit, List parts) {
- if(crit instanceof ICompoundCriteria) {
- ICompoundCriteria compCrit = (ICompoundCriteria) crit;
+ private static void separateCriteria(Condition crit, List<Condition> parts) {
+ if(crit instanceof AndOr) {
+ AndOr compCrit = (AndOr) crit;
if(compCrit.getOperator() == Operator.AND) {
- List subCrits = compCrit.getCriteria();
- Iterator iter = subCrits.iterator();
- while(iter.hasNext()) {
- separateCriteria((ICriteria) iter.next(), parts);
- }
+ separateCriteria(compCrit.getLeftCondition(), parts);
+ separateCriteria(compCrit.getRightCondition(), parts);
} else {
parts.add(crit);
}
@@ -84,30 +81,19 @@
/**
* This utility method can be used to combine two criteria using an AND.
* If both criteria are null, then null will be returned. If either is null,
- * then the other will be returned. If neither is null and the primaryCrit is
- * an ICompoundCriteria, then the additionalCrit will be added to the primaryCrit
- * and the primaryCrit will be returned. If the primaryCrit is not compound, a new
- * ICompoundCriteria will be created and both criteria will be added to it.
+ * then the other will be returned.
* @param primaryCrit Primary criteria - may be modified
* @param additionalCrit Won't be modified, but will likely be attached to the returned crit
* @param languageFactory Will be used to construct new ICompoundCriteria if necessary
* @return Combined criteria
*/
- public static ICriteria combineCriteria(ICriteria primaryCrit, ICriteria additionalCrit, ILanguageFactory languageFactory) {
+ public static Condition combineCriteria(Condition primaryCrit, Condition additionalCrit, LanguageFactory languageFactory) {
if(primaryCrit == null) {
return additionalCrit;
} else if(additionalCrit == null) {
return primaryCrit;
- } else if((primaryCrit instanceof ICompoundCriteria) && ((ICompoundCriteria)primaryCrit).getOperator() == Operator.AND) {
- ICompoundCriteria primaryCompound = (ICompoundCriteria) primaryCrit;
- primaryCompound.getCriteria().add(additionalCrit);
- return primaryCrit;
} else {
- List crits = new ArrayList(2);
- crits.add(primaryCrit);
- crits.add(additionalCrit);
- ICompoundCriteria compCrit = languageFactory.createCompoundCriteria(Operator.AND, crits);
- return compCrit;
+ return languageFactory.createAndOr(Operator.AND, primaryCrit, additionalCrit);
}
}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Like.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Like.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Like.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Like.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,78 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class Like extends Condition implements Predicate {
+
+ private Expression leftExpression;
+ private Expression rightExpression;
+ private Character escapeCharacter;
+ private boolean isNegated;
+
+ public Like(Expression left, Expression right, Character escapeCharacter, boolean negated) {
+ leftExpression = left;
+ rightExpression = right;
+ this.escapeCharacter = escapeCharacter;
+ this.isNegated = negated;
+
+ }
+
+ public Expression getLeftExpression() {
+ return leftExpression;
+ }
+
+ public Expression getRightExpression() {
+ return rightExpression;
+ }
+
+ public Character getEscapeCharacter() {
+ return this.escapeCharacter;
+ }
+
+ public boolean isNegated() {
+ return this.isNegated;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setLeftExpression(Expression expression) {
+ this.leftExpression = expression;
+ }
+
+ public void setRightExpression(Expression expression) {
+ this.rightExpression = expression;
+ }
+
+ public void setEscapeCharacter(Character character) {
+ this.escapeCharacter = character;
+ }
+
+ public void setNegated(boolean negated) {
+ this.isNegated = negated;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Limit.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Limit.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Limit.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Limit.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,66 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a LIMIT clause with row offset and row limit values to bound the resulting rows
+ */
+public class Limit extends BaseLanguageObject {
+
+ private int rowOffset;
+ private int rowLimit;
+
+ public Limit(int offset, int rowLimit) {
+ this.rowOffset = offset;
+ this.rowLimit = rowLimit;
+ }
+
+ /**
+ * Get the max number of rows returned.
+ */
+ public int getRowLimit() {
+ return rowLimit;
+ }
+
+ /**
+ * Get the row offset at which to begin returning rows.
+ */
+ public int getRowOffset() {
+ return rowOffset;
+ }
+
+ public void setRowLimit(int rowLimit) {
+ this.rowLimit = rowLimit;
+ }
+
+ public void setRowOffset(int rowOffset) {
+ this.rowOffset = rowOffset;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Literal.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Literal.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Literal.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Literal.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,80 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a literal value that is used in
+ * an expression. The value can be obtained and should match
+ * the type specified by {@link #getType()}
+ */
+public class Literal extends BaseLanguageObject implements Expression {
+
+ private Object value;
+ private Class<?> type;
+ private boolean bindValue;
+ private boolean multiValued;
+
+ public Literal(Object value, Class<?> type) {
+ this.value = value;
+ this.type = type;
+ }
+
+ public Object getValue() {
+ return this.value;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public boolean isBindValue() {
+ return bindValue;
+ }
+
+ public void setBindValue(boolean bindValue) {
+ this.bindValue = bindValue;
+ }
+
+ public boolean isMultiValued() {
+ return multiValued;
+ }
+
+ public void setMultiValued(boolean multiValued) {
+ this.multiValued = multiValued;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/MetadataReference.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/MetadataReference.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/MetadataReference.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/MetadataReference.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,36 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+
+
+/**
+ * This interface is used to mark language objects as having a
+ * reference to a MetadataID.
+ */
+public interface MetadataReference<T extends AbstractMetadataRecord> {
+
+ T getMetadataObject();
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/NamedTable.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/NamedTable.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/NamedTable.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/NamedTable.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,77 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a table in the language objects. An example would
+ * be a table reference in the FROM clause.
+ */
+public class NamedTable extends BaseLanguageObject implements MetadataReference<Table>, TableReference {
+
+ private String correlationName;
+ private String name;
+ private Table metadataObject;
+
+ public NamedTable(String name, String correlationName, Table group) {
+ this.name = name;
+ this.correlationName = correlationName;
+ this.metadataObject = group;
+ }
+
+ public String getCorrelationName() {
+ return correlationName;
+ }
+
+ /**
+ * Gets the name of the table. Will typically match the name in the metadata.
+ * @return
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public Table getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public void setMetadataObject(Table metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setName(String definition) {
+ this.name = definition;
+ }
+
+ public void setCorrelationName(String context) {
+ this.correlationName = context;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Not.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Not.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Not.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Not.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class Not extends Condition {
+
+ private Condition criteria;
+
+ public Not(Condition criteria) {
+ this.criteria = criteria;
+ }
+
+ public Condition getCriteria() {
+ return criteria;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setCriteria(Condition criteria) {
+ this.criteria = criteria;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/OrderBy.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/OrderBy.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/OrderBy.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/OrderBy.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,52 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an ORDER BY clause in a command.
+ */
+public class OrderBy extends BaseLanguageObject {
+
+ private List<SortSpecification> sortSpecifications;
+
+ public OrderBy(List<SortSpecification> items) {
+ this.sortSpecifications = items;
+ }
+
+ public List<SortSpecification> getSortSpecifications() {
+ return sortSpecifications;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setSortSpecifications(List<SortSpecification> items) {
+ this.sortSpecifications = items;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Predicate.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Predicate.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Predicate.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Predicate.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,31 @@
+/*
+ * 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.language;
+
+/**
+ * Represents a criteria that can occur at the leaf of a tree of
+ * criteria.
+ */
+public interface Predicate {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,96 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+public abstract class QueryExpression extends BaseLanguageObject implements Command, InsertValueSource {
+
+ private OrderBy orderBy;
+ private Limit limit;
+
+ public abstract Select getProjectedQuery();
+
+ /**
+ * Get ORDER BY clause, may be null.
+ * @return An ORDER BY object
+ */
+ public OrderBy getOrderBy() {
+ return orderBy;
+ }
+
+ /**
+ * Get LIMIT clause, may be null.
+ * @return A LIMIT object
+ */
+ public Limit getLimit() {
+ return limit;
+ }
+
+ /**
+ * Get the derived column names. Note this only reports alias names.
+ * Any other names may not be consistent throughout the translation process.
+ * @return a String[] containing the column names
+ * @since 4.3
+ */
+ public String[] getColumnNames() {
+ List<DerivedColumn> selectSymbols = getProjectedQuery().getDerivedColumns();
+ String[] columnNames = new String[selectSymbols.size()];
+ int symbolIndex = 0;
+ for (DerivedColumn column : selectSymbols) {
+ columnNames[symbolIndex++] = column.getAlias();
+ }
+ return columnNames;
+ }
+
+ /**
+ * Get the column types of the output columns for this query
+ * @return a Class[] containing the column names
+ * @since 4.3
+ */
+ public Class<?>[] getColumnTypes() {
+ List<DerivedColumn> selectSymbols = getProjectedQuery().getDerivedColumns();
+ Class<?>[] columnTypes = new Class[selectSymbols.size()];
+ int symbolIndex = 0;
+ for (DerivedColumn column : selectSymbols) {
+ columnTypes[symbolIndex++] = column.getExpression().getType();
+ }
+ return columnTypes;
+ }
+
+ /**
+ * Set ORDER BY clause, may be null.
+ * @param orderBy An ORDER BY object
+ */
+ public void setOrderBy(OrderBy orderBy) {
+ this.orderBy = orderBy;
+ }
+
+ /**
+ * Set LIMIT clause, may be null.
+ * @param limit A LIMIT object
+ */
+ public void setLimit(Limit limit) {
+ this.limit = limit;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SQLReservedWords.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SQLReservedWords.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SQLReservedWords.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SQLReservedWords.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,354 @@
+/*
+ * 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.language;
+
+import java.lang.reflect.Field;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Reserved words for Teiid.
+ */
+public class SQLReservedWords {
+
+ public interface Tokens {
+ public static final String ALL_COLS = "*"; //$NON-NLS-1$
+ public static final String SPACE = " "; //$NON-NLS-1$
+ public static final String COMMA = ","; //$NON-NLS-1$
+ public static final String DOT = "."; //$NON-NLS-1$
+ public static final String QUOTE = "'"; //$NON-NLS-1$
+ public static final String EQ = "="; //$NON-NLS-1$
+ public static final String NE = "<>"; //$NON-NLS-1$
+ public static final String LT = "<"; //$NON-NLS-1$
+ public static final String GT = ">"; //$NON-NLS-1$
+ public static final String LE = "<="; //$NON-NLS-1$
+ public static final String GE = ">="; //$NON-NLS-1$
+ public static final String LPAREN = "("; //$NON-NLS-1$
+ public static final String RPAREN = ")"; //$NON-NLS-1$
+ }
+
+ public static final String ADD = "ADD"; //$NON-NLS-1$
+ public static final String ANY = "ANY"; //$NON-NLS-1$
+ public static final String ALL = "ALL"; //$NON-NLS-1$
+ public static final String ALTER = "ALTER"; //$NON-NLS-1$
+ public static final String AND = "AND"; //$NON-NLS-1$
+ public static final String ARRAY = "ARRAY"; //$NON-NLS-1$s
+ public static final String AS = "AS"; //$NON-NLS-1$
+ public static final String ASC = "ASC"; //$NON-NLS-1$
+ public static final String ATOMIC = "ATOMIC"; //$NON-NLS-1$
+ public static final String AUTHORIZATION = "autorization"; //$NON-NLS-1$
+ public static final String AVG = "AVG"; //$NON-NLS-1$
+ public static final String BEGIN = "BEGIN"; //$NON-NLS-1$
+ public static final String BETWEEN = "BETWEEN"; //$NON-NLS-1$
+ public static final String BIGDECIMAL = "BIGDECIMAL"; //$NON-NLS-1$
+ public static final String BIGINT = "BIGINT"; //$NON-NLS-1$
+ public static final String BIGINTEGER = "BIGINTEGER"; //$NON-NLS-1$
+ public static final String BINARY = "BINARY"; //$NON-NLS-1$
+ public static final String BLOB = "BLOB"; //$NON-NLS-1$
+ public static final String BOTH = "BOTH"; //$NON-NLS-1$
+ public static final String BREAK = "BREAK"; //$NON-NLS-1$
+ public static final String BY = "BY"; //$NON-NLS-1$
+ public static final String BYTE = "BYTE"; //$NON-NLS-1$
+ public static final String CALL = "CALL"; //$NON-NLS-1$
+ public static final String CALLED = "CALLED"; //$NON-NLS-1$
+ public static final String CASE = "CASE"; //$NON-NLS-1$
+ public static final String CAST = "CAST"; //$NON-NLS-1$
+ public static final String CASCADED = "CASCADED"; //$NON-NLS-1$
+ public static final String CHAR = "CHAR"; //$NON-NLS-1$
+ public static final String CHARACTER = "CHARACTER"; //$NON-NLS-1$
+ public static final String CHECK = "CHECK"; //$NON-NLS-1$
+ public static final String CLOB = "CLOB"; //$NON-NLS-1$
+ public static final String CLOSE = "CLOSE"; //$NON-NLS-1$
+ public static final String COLLATE = "COLLATE"; //$NON-NLS-1$
+ public static final String COLUMN = "COLUMN"; //$NON-NLS-1$
+ public static final String COMMIT = "COMMIT"; //$NON-NLS-1$
+ public static final String CONNECT = "CONNECT"; //$NON-NLS-1$
+ public static final String CONVERT = "CONVERT"; //$NON-NLS-1$
+ public static final String CONSTRAINT = "CONSTRAINT"; //$NON-NLS-1$
+ public static final String CONTINUE = "CONTINUE"; //$NON-NLS-1$
+ public static final String COUNT = "COUNT"; //$NON-NLS-1$
+ public static final String CORRESPONDING = "CORRESPONDING"; //$NON-NLS-1$
+ public static final String CRITERIA = "CRITERIA"; //$NON-NLS-1$
+ public static final String CREATE = "CREATE"; //$NON-NLS-1$
+ public static final String CROSS = "CROSS"; //$NON-NLS-1$
+ public static final String CURRENT_DATE = "CURRENT_DATE"; //$NON-NLS-1$
+ public static final String CURRENT_TIME = "CURRENT_TIME"; //$NON-NLS-1$
+ public static final String CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP"; //$NON-NLS-1$
+ public static final String CURRENT_USER = "CURRENT_USER"; //$NON-NLS-1$
+ public static final String CURSOR = "CURSOR"; //$NON-NLS-1$
+ public static final String DATE = "DATE"; //$NON-NLS-1$
+ public static final String DAY = "DAY"; //$NON-NLS-1$
+ public static final String DEALLOCATE = "DEALLOCATE"; //$NON-NLS-1$
+ public static final String DEBUG = "DEBUG"; //$NON-NLS-1$
+ public static final String DECIMAL = "DECIMAL"; //$NON-NLS-1$
+ public static final String DECLARE = "DECLARE"; //$NON-NLS-1$
+ public static final String DEFAULT = "DEFAULT"; //$NON-NLS-1$
+ public static final String DELETE = "DELETE"; //$NON-NLS-1$
+ public static final String DESC = "DESC"; //$NON-NLS-1$
+ public static final String DESCRIBE = "DESCRIBE"; //$NON-NLS-1$
+ public static final String DETERMINISTIC = "DETERMINISTIC"; //$NON-NLS-1$
+ public static final String DISCONNECT = "DISCONNECT"; //$NON-NLS-1$
+ public static final String DISTINCT = "DISTINCT"; //$NON-NLS-1$
+ public static final String DOUBLE = "DOUBLE"; //$NON-NLS-1$
+ public static final String DROP = "DROP"; //$NON-NLS-1$
+ public static final String EACH = "EACH"; //$NON-NLS-1$
+ public static final String ELSE = "ELSE"; //$NON-NLS-1$
+ public static final String END = "END"; //$NON-NLS-1$
+ public static final String ERROR = "ERROR"; //$NON-NLS-1$
+ public static final String ESCAPE = "ESCAPE"; //$NON-NLS-1$
+ public static final String EXCEPT = "EXCEPT"; //$NON-NLS-1$
+ public static final String EXEC = "EXEC"; //$NON-NLS-1$
+ public static final String EXECUTE = "EXECUTE"; //$NON-NLS-1$
+ public static final String EXISTS = "EXISTS"; //$NON-NLS-1$
+ public static final String EXTERNAL = "EXTERNAL"; //$NON-NLS-1$
+ public static final String FALSE = "FALSE"; //$NON-NLS-1$
+ public static final String FETCH = "FETCH"; //$NON-NLS-1$
+ public static final String FILTER = "FILTER"; //$NON-NLS-1$
+ public static final String FLOAT = "FLOAT"; //$NON-NLS-1$
+ public static final String FN = "FN"; //$NON-NLS-1$
+ public static final String FOR = "FOR"; //$NON-NLS-1$
+ public static final String FOREIGN = "FOREIGN"; //$NON-NLS-1$
+ public static final String FROM = "FROM"; //$NON-NLS-1$
+ public static final String FULL = "FULL"; //$NON-NLS-1$
+ public static final String FUNCTION = "FUNCTION"; //$NON-NLS-1$
+ public static final String GET = "GET"; //$NON-NLS-1$
+ public static final String GLOBAL = "GLOBAL"; //$NON-NLS-1$
+ public static final String GRANT = "GRANT"; //$NON-NLS-1$
+ public static final String GROUP = "GROUP"; //$NON-NLS-1$
+ public static final String GROUPING = "GROUPING"; //$NON-NLS-1$
+ public static final String HAS = "HAS"; //$NON-NLS-1$
+ public static final String HAVING = "HAVING"; //$NON-NLS-1$
+ public static final String HOLD = "HOLD"; //$NON-NLS-1$
+ public static final String HOUR = "HOUR"; //$NON-NLS-1$
+ public static final String IDENTITY = "IDENTITY"; //$NON-NLS-1$
+ public static final String INDICATOR = "INDICATOR"; //$NON-NLS-1$
+ public static final String IF = "IF"; //$NON-NLS-1$
+ public static final String IMMEDIATE = "IMMEDIATE"; //$NON-NLS-1$
+ public static final String IN = "IN"; //$NON-NLS-1$
+ public static final String INOUT = "INOUT"; //$NON-NLS-1$
+ public static final String INNER = "INNER"; //$NON-NLS-1$
+ public static final String INPUT = "INPUT"; //$NON-NLS-1$
+ public static final String INSENSITIVE = "INSENSITIVE"; //$NON-NLS-1$
+ public static final String INSERT = "INSERT"; //$NON-NLS-1$
+ public static final String INTEGER = "INTEGER"; //$NON-NLS-1$
+ public static final String INTERSECT = "INTERSECT"; //$NON-NLS-1$
+ public static final String INTERVAL = "INTERVAL"; //$NON-NLS-1$
+ public static final String INTO = "INTO"; //$NON-NLS-1$
+ public static final String IS = "IS"; //$NON-NLS-1$
+ public static final String ISOLATION = "ISOLATION"; //$NON-NLS-1$
+ public static final String JOIN = "JOIN"; //$NON-NLS-1$
+ public static final String LANGUAGE = "LANGUAGE"; //$NON-NLS-1$
+ public static final String LARGE = "LARGE"; //$NON-NLS-1$
+ public static final String LEADING = "LEADING"; //$NON-NLS-1$
+ public static final String LEFT = "LEFT"; //$NON-NLS-1$
+ public static final String LIKE = "LIKE"; //$NON-NLS-1$
+ public static final String LIMIT = "LIMIT"; //$NON-NLS-1$
+ public static final String LOCAL = "LOCAL"; //$NON-NLS-1$
+ public static final String LONG = "LONG"; //$NON-NLS-1$
+ public static final String LOOP = "LOOP"; //$NON-NLS-1$
+ public static final String MAKEDEP = "MAKEDEP"; //$NON-NLS-1$
+ public static final String MAKENOTDEP = "MAKENOTDEP"; //$NON-NLS-1$
+ public static final String MATCH = "MATCH"; //$NON-NLS-1$
+ public static final String MAX = "MAX"; //$NON-NLS-1$
+ public static final String MIN = "MIN"; //$NON-NLS-1$
+ public static final String MERGE = "MERGE"; //$NON-NLS-1$
+ public static final String METHOD = "METHOD"; //$NON-NLS-1$
+ public static final String MINUTE = "MINUTE"; //$NON-NLS-1$
+ public static final String MODIFIES = "MODIFIES"; //$NON-NLS-1$
+ public static final String MODULE = "MODULE"; //$NON-NLS-1$
+ public static final String MONTH = "MONTH"; //$NON-NLS-1$
+ public static final String NATURAL = "NATURAL"; //$NON-NLS-1$
+ public static final String NEW = "NEW"; //$NON-NLS-1$
+ public static final String NO = "NO"; //$NON-NLS-1$
+ public static final String NOCACHE = "NOCACHE"; //$NON-NLS-1$
+ public static final String NONE = "NONE"; //$NON-NLS-1$
+ public static final String NOT = "NOT"; //$NON-NLS-1$
+ public static final String NULL = "NULL"; //$NON-NLS-1$
+ public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
+ public static final String OF = "OF"; //$NON-NLS-1$
+ public static final String OJ = "OJ"; //$NON-NLS-1$
+ public static final String OLD = "OLD"; //$NON-NLS-1$
+ public static final String ON = "ON"; //$NON-NLS-1$
+ public static final String ONLY = "ONLY"; //$NON-NLS-1$
+ public static final String OPEN = "OPEN"; //$NON-NLS-1$
+ public static final String OR = "OR"; //$NON-NLS-1$
+ public static final String ORDER = "ORDER"; //$NON-NLS-1$
+ public static final String OUT = "OUT"; //$NON-NLS-1$
+ public static final String OUTER = "OUTER"; //$NON-NLS-1$
+ public static final String OUTPUT = "OUTPUT"; //$NON-NLS-1$
+ public static final String OPTION = "OPTION"; //$NON-NLS-1$
+ public static final String OVER = "OVER"; //$NON-NLS-1$
+ public static final String OVERLAPS = "OVERLAPS"; //$NON-NLS-1$
+ public static final String PARAMETER = "PARAMETER"; //$NON-NLS-1$
+ public static final String PARTITION = "PARTITION"; //$NON-NLS-1$
+ public static final String PRECISION = "PRECISION"; //$NON-NLS-1$
+ public static final String PREPARE = "PREPARE"; //$NON-NLS-1$
+ public static final String PRIMARY = "PRIMARY"; //$NON-NLS-1$
+ public static final String PROCEDURE = "PROCEDURE"; //$NON-NLS-1$
+ public static final String PLANONLY = "PLANONLY"; //$NON-NLS-1$
+ public static final String RANGE = "RANGE"; //$NON-NLS-1$
+ public static final String READS = "READS"; //$NON-NLS-1$
+ public static final String REAL = "REAL"; //$NON-NLS-1$
+ public static final String RECURSIVE = "RECURSIVE"; //$NON-NLS-1$
+ public static final String REFERENCES = "REFERENCES"; //$NON-NLS-1$
+ public static final String REFERENCING = "REFERENCING"; //$NON-NLS-1$
+ public static final String RETURN = "RETURN"; //$NON-NLS-1$
+ public static final String RETURNS = "RETURNS"; //$NON-NLS-1$
+ public static final String REVOKE = "REVOKE"; //$NON-NLS-1$
+ public static final String RIGHT = "RIGHT"; //$NON-NLS-1$
+ public static final String ROLLBACK = "ROLLBACK"; //$NON-NLS-1$
+ public static final String ROLLUP = "ROLLUP"; //$NON-NLS-1$
+ public static final String ROW = "ROW"; //$NON-NLS-1$
+ public static final String ROWS = "ROWS"; //$NON-NLS-1$
+ public static final String SAVEPOINT = "ROWS"; //$NON-NLS-1$
+ public static final String SCROLL = "ROWS"; //$NON-NLS-1$
+ public static final String SEARCH = "ROWS"; //$NON-NLS-1$
+ public static final String SECOND = "ROWS"; //$NON-NLS-1$
+ public static final String SELECT = "SELECT"; //$NON-NLS-1$
+ public static final String SENSITIVE = "ROWS"; //$NON-NLS-1$
+ public static final String SESSION_USER = "SESSION_USER"; //$NON-NLS-1$
+ public static final String SET = "SET"; //$NON-NLS-1$
+ public static final String SHORT = "SHORT"; //$NON-NLS-1$
+ public static final String SHOWPLAN = "SHOWPLAN"; //$NON-NLS-1$
+ public static final String SIILAR = "ROWS"; //$NON-NLS-1$
+ public static final String SMALLINT = "ROWS"; //$NON-NLS-1$
+ public static final String SOME = "SOME"; //$NON-NLS-1$
+ public static final String SPECIFIC = "ROWS"; //$NON-NLS-1$
+ public static final String SQL = "ROWS"; //$NON-NLS-1$
+ public static final String SQLEXCEPTION = "SQLEXCEPTION"; //$NON-NLS-1$
+ public static final String SQLSTATE = "SQLSTATE"; //$NON-NLS-1$
+ public static final String SQLWARNING = "SQLWARNING"; //$NON-NLS-1$
+ public static final String SQL_TSI_FRAC_SECOND = "SQL_TSI_FRAC_SECOND"; //$NON-NLS-1$
+ public static final String SQL_TSI_SECOND = "SQL_TSI_SECOND"; //$NON-NLS-1$
+ public static final String SQL_TSI_MINUTE = "SQL_TSI_MINUTE"; //$NON-NLS-1$
+ public static final String SQL_TSI_HOUR = "SQL_TSI_HOUR"; //$NON-NLS-1$
+ public static final String SQL_TSI_DAY = "SQL_TSI_DAY"; //$NON-NLS-1$
+ public static final String SQL_TSI_WEEK = "SQL_TSI_WEEK"; //$NON-NLS-1$
+ public static final String SQL_TSI_MONTH = "SQL_TSI_MONTH"; //$NON-NLS-1$
+ public static final String SQL_TSI_QUARTER = "SQL_TSI_QUARTER"; //$NON-NLS-1$
+ public static final String SQL_TSI_YEAR = "SQL_TSI_YEAR"; //$NON-NLS-1$
+ public static final String START = "START"; //$NON-NLS-1$
+ public static final String STATIC = "STATIC"; //$NON-NLS-1$
+ public static final String STRING = "STRING"; //$NON-NLS-1$
+ public static final String SYSTEM = "SYSTEM"; //$NON-NLS-1$
+ public static final String SYSTEM_USER = "SYSTEM_USER"; //$NON-NLS-1$
+ public static final String SUM = "SUM"; //$NON-NLS-1$
+ public static final String TABLE = "TABLE"; //$NON-NLS-1$
+ public static final String TEMPORARY = "TEMPORARY"; //$NON-NLS-1$
+ public static final String THEN = "THEN"; //$NON-NLS-1$
+ public static final String TIME = "TIME"; //$NON-NLS-1$
+ public static final String TIMESTAMP = "TIMESTAMP"; //$NON-NLS-1$
+ public static final String TIMESTAMPADD = "TIMESTAMPADD"; //$NON-NLS-1$
+ public static final String TIMESTAMPDIFF = "TIMESTAMPDIFF"; //$NON-NLS-1$
+ public static final String TIMEZONE_HOUR = "TIMEZONE_HOUR"; //$NON-NLS-1$
+ public static final String TIMEZONE_MINUTE = "TIMEZONE_MINUTE"; //$NON-NLS-1$
+ public static final String TO = "TO"; //$NON-NLS-1$
+ public static final String TRAILING = "TRAILING"; //$NON-NLS-1$
+ public static final String TRANSLATE = "TRANSLATE"; //$NON-NLS-1$
+ public static final String TRIGGER = "TRIGGER"; //$NON-NLS-1$
+ public static final String TRUE = "TRUE"; //$NON-NLS-1$
+ public static final String UNION = "UNION"; //$NON-NLS-1$
+ public static final String UNIQUE = "UNIQUE"; //$NON-NLS-1$
+ public static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
+ public static final String UPDATE = "UPDATE"; //$NON-NLS-1$
+ public static final String USER = "USER"; //$NON-NLS-1$
+ public static final String USING = "USING"; //$NON-NLS-1$
+ public static final String VALUE = "VALUE"; //$NON-NLS-1$
+ public static final String VALUES = "VALUES"; //$NON-NLS-1$
+ public static final String VARCHAR = "VARCHAR"; //$NON-NLS-1$
+ public static final String VIRTUAL = "VIRTUAL"; //$NON-NLS-1$
+ public static final String WHEN = "WHEN"; //$NON-NLS-1$
+ public static final String WHENEVER = "WHENEVER"; //$NON-NLS-1$
+ public static final String WHERE = "WHERE"; //$NON-NLS-1$
+ public static final String WHILE = "WHILE"; //$NON-NLS-1$
+ public static final String WINDOW = "WINDOW"; //$NON-NLS-1$
+ public static final String WITH = "WITH"; //$NON-NLS-1$
+ public static final String WITHIN = "WITHIN"; //$NON-NLS-1$
+ public static final String WITHOUT = "WITHOUT"; //$NON-NLS-1$
+ public static final String YEAR = "YEAR"; //$NON-NLS-1$
+
+ //SQL/XML
+
+ public static final String XML = "XML"; //$NON-NLS-1$
+ public static final String XMLAGG = "XMLAGG"; //$NON-NLS-1$
+ public static final String XMLATTRIBUTES = "XMLATTRIBUTES"; //$NON-NLS-1$
+ public static final String XMLBINARY = "XMLBINARY"; //$NON-NLS-1$
+ public static final String XMLCONCAT = "XMLCONCAT"; //$NON-NLS-1$
+ public static final String XMLCOMMENT = "XMLCOMMENT"; //$NON-NLS-1$
+ public static final String XMLELEMENT = "XMLELEMENT"; //$NON-NLS-1$
+ public static final String XMLFOREST = "XMLFOREST"; //$NON-NLS-1$
+ public static final String XMLNAMESPACES = "XMLNAMESPACES"; //$NON-NLS-1$
+ public static final String XMLPARSE = "XMLPARSE"; //$NON-NLS-1$
+ public static final String XMLPI = "XMLPI"; //$NON-NLS-1$
+ public static final String XMLROOT = "XMLROOT"; //$NON-NLS-1$
+ public static final String XMLSERIALIZE = "XMLSERIALIZE"; //$NON-NLS-1$
+
+ //SQL/MED
+
+ public static final String DATALINK = "DATALINK"; //$NON-NLS-1$
+ public static final String DLNEWCOPY = "DLNEWCOPY"; //$NON-NLS-1$
+ public static final String DLPREVIOUSCOPY = "DLPREVIOUSCOPY"; //$NON-NLS-1$
+ public static final String DLURLCOMPLETE = "DLURLCOMPLETE"; //$NON-NLS-1$
+ public static final String DLURLCOMPLETEWRITE = "DLURELCOMPLETEWRITE"; //$NON-NLS-1$
+ public static final String DLURLCOMPLETEONLY = "DLURLCOMPLETEONLY"; //$NON-NLS-1$
+ public static final String DLURLPATH = "DLURLPATH"; //$NON-NLS-1$
+ public static final String DLURLPATHWRITE = "DLURLPATHWRITE"; //$NON-NLS-1$
+ public static final String DLURLPATHONLY = "DLURLPATHONLY"; //$NON-NLS-1$
+ public static final String DLURLSCHEME = "DLURLSCHEME"; //$NON-NLS-1$
+ public static final String DLURLSERVER = "DLURLSEVER"; //$NON-NLS-1$
+ public static final String DLVALUE = "DLVALUE"; //$NON-NLS-1$
+ public static final String IMPORT = "XMLPI"; //$NON-NLS-1$
+
+ /**
+ * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
+ */
+ private static final Set<String> RESERVED_WORDS = new HashSet<String>();
+
+ // Initialize RESERVED_WORDS set - This is a poor man's enum. To much legacy code expects the constants to be Strings.
+ static {
+ Field[] fields = SQLReservedWords.class.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getType() == String.class) {
+ try {
+ RESERVED_WORDS.add((String)field.get(null));
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ /** Can't construct */
+ private SQLReservedWords() {}
+
+ /**
+ * Check whether a string is a reserved word.
+ * @param str String to check
+ * @return True if reserved word, false if not or null
+ */
+ public static final boolean isReservedWord(String str) {
+ if(str == null) {
+ return false;
+ }
+ return RESERVED_WORDS.contains(str.toUpperCase());
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,60 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a scalar subquery. That is, a query that is evaluated as a scalar
+ * expression and returns a single value. The inner subquery must return exactly
+ * 1 column as well.
+ */
+public class ScalarSubquery extends BaseLanguageObject implements Expression, SubqueryContainer {
+
+ private QueryExpression query;
+
+ public ScalarSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+ @Override
+ public QueryExpression getSubquery() {
+ return this.query;
+ }
+
+ @Override
+ public void setSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ @Override
+ public Class<?> getType() {
+ return query.getProjectedQuery().getDerivedColumns().get(0).getExpression().getType();
+ }
+
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a searched CASE expression:
+ * <br/> CASE WHEN criteria THEN expression ... END
+ */
+public class SearchedCase extends BaseLanguageObject implements Expression {
+
+ private List<SearchedWhenClause> cases;
+ private Expression elseExpression;
+ private Class<?> type;
+
+ public SearchedCase(List<SearchedWhenClause> cases, Expression elseExpression, Class<?> type) {
+ this.cases = cases;
+ this.elseExpression = elseExpression;
+ this.type = type;
+ }
+
+ public Expression getElseExpression() {
+ return elseExpression;
+ }
+
+ public List<SearchedWhenClause> getCases() {
+ return cases;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setElseExpression(Expression expression) {
+ this.elseExpression = expression;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedWhenClause.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SearchedWhenClause.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedWhenClause.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedWhenClause.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,57 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class SearchedWhenClause extends BaseLanguageObject {
+
+ private Condition condition;
+ private Expression result;
+
+ public SearchedWhenClause(Condition condition, Expression result) {
+ this.condition = condition;
+ this.result = result;
+ }
+
+ public Condition getCondition() {
+ return condition;
+ }
+
+ public Expression getResult() {
+ return result;
+ }
+
+ public void setCondition(Condition symbol) {
+ this.condition = symbol;
+ }
+
+ public void setResult(Expression value) {
+ this.result = value;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Select.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Select.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Select.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,139 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a simple SELECT query.
+ */
+public class Select extends QueryExpression {
+
+ private List<DerivedColumn> derivedColumns;
+ private boolean isDistinct;
+ private List<TableReference> from;
+ private Condition where;
+ private GroupBy groupBy;
+ private Condition having;
+
+ public Select(List<DerivedColumn> derivedColumns, boolean distinct, List<TableReference> from, Condition where,
+ GroupBy groupBy, Condition having, OrderBy orderBy) {
+ this.derivedColumns = derivedColumns;
+ this.isDistinct = distinct;
+ this.from = from;
+ this.where = where;
+ this.groupBy = groupBy;
+ this.having = having;
+ this.setOrderBy(orderBy);
+ }
+
+ public List<DerivedColumn> getDerivedColumns() {
+ return derivedColumns;
+ }
+
+ public boolean isDistinct() {
+ return this.isDistinct;
+ }
+
+ public void setDerivedColumns(List<DerivedColumn> symbols) {
+ this.derivedColumns = symbols;
+ }
+
+ public void setDistinct(boolean distinct) {
+ this.isDistinct = distinct;
+ }
+
+ /**
+ * Get FROM clause, should never be null.
+ * @return From clause object
+ */
+ public List<TableReference> getFrom() {
+ return from;
+ }
+
+ /**
+ * Get WHERE clause, may be null.
+ * @return A criteria object
+ */
+ public Condition getWhere() {
+ return where;
+ }
+
+ /**
+ * Get GROUP BY clause, may be null.
+ * @return A group by object
+ */
+ public GroupBy getGroupBy() {
+ return groupBy;
+ }
+
+ /**
+ * Get HAVING clause, may be null.
+ * @return A criteria object
+ */
+ public Condition getHaving() {
+ return having;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set FROM clause, should never be null.
+ * @param from From clause object
+ */
+ public void setFrom(List<TableReference> from) {
+ this.from = from;
+ }
+
+ /**
+ * Set WHERE clause, may be null.
+ * @param criteria A criteria object
+ */
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+ /**
+ * Set GROUP BY clause, may be null.
+ * @param groupBy A group by object
+ */
+ public void setGroupBy(GroupBy groupBy) {
+ this.groupBy = groupBy;
+ }
+
+ /**
+ * Set HAVING clause, may be null.
+ * @param criteria A criteria object
+ */
+ public void setHaving(Condition criteria) {
+ this.having = criteria;
+ }
+
+ public Select getProjectedQuery() {
+ return this;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SetClause.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetClause.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SetClause.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SetClause.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,57 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class SetClause extends BaseLanguageObject {
+
+ private ColumnReference symbol;
+ private Expression value;
+
+ public SetClause(ColumnReference symbol, Expression value) {
+ this.symbol = symbol;
+ this.value = value;
+ }
+
+ public ColumnReference getSymbol() {
+ return symbol;
+ }
+
+ public Expression getValue() {
+ return value;
+ }
+
+ public void setSymbol(ColumnReference symbol) {
+ this.symbol = symbol;
+ }
+
+ public void setValue(Expression value) {
+ this.value = value;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,116 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class SetQuery extends QueryExpression {
+
+ public enum Operation {
+ /** Represents UNION of two queries */
+ UNION,
+ /** Represents intersection of two queries */
+ INTERSECT,
+ /** Represents set difference of two queries */
+ EXCEPT
+ }
+
+ private boolean all;
+ private QueryExpression leftQuery;
+ private QueryExpression rightQuery;
+ private Operation operation;
+
+ /**
+ * @see org.teiid.connector.language.QueryExpression#getProjectedQuery()
+ */
+ public Select getProjectedQuery() {
+ if (leftQuery instanceof Select) {
+ return (Select)leftQuery;
+ }
+ return leftQuery.getProjectedQuery();
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#getLeftQuery()
+ */
+ public QueryExpression getLeftQuery() {
+ return leftQuery;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#getOperation()
+ */
+ public Operation getOperation() {
+ return operation;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#getRightQuery()
+ */
+ public QueryExpression getRightQuery() {
+ return rightQuery;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#isAll()
+ */
+ public boolean isAll() {
+ return all;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#setAll(boolean)
+ */
+ public void setAll(boolean all) {
+ this.all = all;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#setLeftQuery(org.teiid.connector.language.QueryExpression)
+ */
+ public void setLeftQuery(QueryExpression leftQuery) {
+ this.leftQuery = leftQuery;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#setOperation(org.teiid.connector.language.SetQuery.Operation)
+ */
+ public void setOperation(Operation operation) {
+ this.operation = operation;
+ }
+
+ /**
+ * @see org.teiid.connector.language.SetQuery#setRightQuery(org.teiid.connector.language.QueryExpression)
+ */
+ public void setRightQuery(QueryExpression rightQuery) {
+ this.rightQuery = rightQuery;
+ }
+
+ /**
+ * @see org.teiid.connector.language.LanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
+ */
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SortSpecification.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SortSpecification.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SortSpecification.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SortSpecification.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+public class SortSpecification extends BaseLanguageObject {
+
+ public enum Ordering {
+ ASC,
+ DESC
+ }
+
+ private Ordering ordering;
+ private Expression expression;
+
+ public SortSpecification(Ordering direction, Expression expression) {
+ this.ordering = direction;
+ this.expression = expression;
+ }
+
+ public Ordering getOrdering() {
+ return ordering;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setOrdering(Ordering direction) {
+ this.ordering = direction;
+ }
+
+ public Expression getExpression() {
+ return this.expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryComparison.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SubqueryComparison.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryComparison.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryComparison.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.language;
+
+import org.teiid.connector.language.Comparison.Operator;
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a quantified comparison criteria. This criteria has an expression on the left,
+ * a comparison operator (such as =, <, etc), a quantification operator (ALL, ANY),
+ * and a subquery.
+ */
+public class SubqueryComparison extends Condition implements Predicate, SubqueryContainer {
+
+ public enum Quantifier {
+ SOME,
+ ALL
+ }
+
+ private Expression leftExpr;
+ private Operator operator;
+ private Quantifier quantifier;
+ private QueryExpression query;
+
+ /**
+ *
+ */
+ public SubqueryComparison(Expression leftExpr, Operator operator, Quantifier quantifier, QueryExpression query) {
+ this.leftExpr = leftExpr;
+ this.operator = operator;
+ this.quantifier = quantifier;
+ this.query = query;
+ }
+
+ public Expression getLeftExpression() {
+ return this.leftExpr;
+ }
+
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ public Quantifier getQuantifier() {
+ return this.quantifier;
+ }
+
+ public QueryExpression getSubquery() {
+ return this.query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setLeftExpression(Expression expression) {
+ this.leftExpr = expression;
+ }
+
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ public void setQuantifier(Quantifier quantifier) {
+ this.quantifier = quantifier;
+ }
+
+ public void setSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryContainer.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SubqueryContainer.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryContainer.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryContainer.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,42 @@
+/*
+ * 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.language;
+
+/**
+ * This is a marker interface for language interfaces that contain a subquery.
+ */
+public interface SubqueryContainer {
+
+ /**
+ * Get the inner subquery
+ * @return Subquery
+ */
+ QueryExpression getSubquery();
+
+ /**
+ * Set the inner subquery
+ * @param query Subquery
+ */
+ void setSubquery(QueryExpression query);
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryIn.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SubqueryIn.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryIn.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryIn.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,52 @@
+/*
+ * 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.language;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an IN criteria that uses a subquery on the right side rather than a
+ * list of values.
+ */
+public class SubqueryIn extends BaseInCondition implements SubqueryContainer {
+
+ private QueryExpression rightQuery;
+
+ public SubqueryIn(Expression leftExpr, boolean isNegated, QueryExpression rightQuery) {
+ super(leftExpr, isNegated);
+ this.rightQuery = rightQuery;
+ }
+
+ public QueryExpression getSubquery() {
+ return this.rightQuery;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setSubquery(QueryExpression query) {
+ this.rightQuery = query;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/TableReference.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/TableReference.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/TableReference.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/TableReference.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,30 @@
+/*
+ * 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.language;
+
+/**
+ * Represents an item in the FROM clause
+ */
+public interface TableReference extends LanguageObject {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/language/Update.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Update.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/language/Update.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/language/Update.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,72 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents an UPDATE command in the language objects.
+ */
+public class Update extends BaseLanguageObject implements Command {
+
+ private NamedTable table;
+ private List<SetClause> changes;
+ private Condition where;
+
+ public Update(NamedTable group, List<SetClause> changes, Condition criteria) {
+ this.table = group;
+ this.changes = changes;
+ this.where = criteria;
+ }
+
+ public NamedTable getTable() {
+ return table;
+ }
+
+ public List<SetClause> getChanges() {
+ return changes;
+ }
+
+ public Condition getWhere() {
+ return where;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ public void setChanges(List<SetClause> changes) {
+ this.changes = changes;
+ }
+
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
import com.metamatrix.core.util.EquivalenceUtil;
@@ -33,8 +34,10 @@
* AbstractMetadataRecord
*/
public abstract class AbstractMetadataRecord implements Serializable {
-
- public final static char NAME_DELIM_CHAR = '.';
+
+ public final static char NAME_DELIM_CHAR = '.';
+
+ private static AtomicLong UUID_SEQUENCE = new AtomicLong();
private String uuid; //globally unique id
private String name; //contextually unique name
@@ -45,6 +48,9 @@
private String annotation;
public String getUUID() {
+ if (uuid == null) {
+ uuid = String.valueOf(UUID_SEQUENCE.getAndIncrement());
+ }
return uuid;
}
@@ -97,9 +103,9 @@
}
/**
- * Return the extension properties for this record - may be null
+ * Return the extension properties for this record - may be unmodifiable
* if {@link #setProperties(LinkedHashMap)} or {@link #setProperty(String, String)}
- * has not been called
+ * has not been called.
* @return
*/
public Map<String, String> getProperties() {
@@ -109,6 +115,11 @@
return properties;
}
+ /**
+ * The preferred setter for extension properties.
+ * @param key
+ * @param value
+ */
public void setProperty(String key, String value) {
if (this.properties == null) {
this.properties = new LinkedHashMap<String, String>();
@@ -146,7 +157,7 @@
}
public int hashCode() {
- return this.uuid.hashCode();
+ return getUUID().hashCode();
}
}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,6 +22,8 @@
package org.teiid.connector.metadata.runtime;
+import org.teiid.connector.api.TypeFacility;
+
public abstract class BaseColumn extends AbstractMetadataRecord {
public enum NullType {
@@ -57,6 +59,10 @@
public String getRuntimeType() {
return runtimeType;
}
+
+ public Class<?> getJavaType() {
+ return TypeFacility.getDataTypeClass(runtimeType);
+ }
public int getLength() {
return length;
@@ -128,5 +134,25 @@
public void setDatatype(Datatype datatype) {
this.datatype = datatype;
}
+
+ public String getDatatypeID() {
+ if (this.datatype != null) {
+ return this.datatype.getDatatypeID();
+ }
+ return null;
+ }
+
+ public String getBaseTypeID() {
+ if (this.datatype != null) {
+ return this.datatype.getBasetypeID();
+ }
+ return null;
+ }
+ public String getPrimitiveTypeID() {
+ if (this.datatype != null) {
+ return this.datatype.getPrimitiveTypeID();
+ }
+ return null;
+ }
}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,250 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-/**
- * ColumnRecordImpl
- */
-public class Column extends BaseColumn implements Comparable<Column> {
-
- public enum SearchType {
- Unsearchable,
- Like_Only {
- @Override
- public String toString() {
- return "Like Only"; //$NON-NLS-1$
- }
- },
- All_Except_Like {
- @Override
- public String toString() {
- return "All Except Like"; //$NON-NLS-1$
- }
- },
- Searchable
- }
-
- private boolean selectable = true;
- private boolean updatable;
- private boolean autoIncrementable;
- private boolean caseSensitive;
- private boolean signed;
- private boolean currency;
- private boolean fixedLength;
- private SearchType searchType;
- private String minValue;
- private String maxValue;
- private String nativeType;
- private String format;
- private int charOctetLength;
- private int distinctValues = -1;
- private int nullValues = -1;
- private ColumnSet parent;
-
- public void setParent(ColumnSet parent) {
- this.parent = parent;
- }
-
- @Override
- public AbstractMetadataRecord getParent() {
- return parent;
- }
-
- @Override
- public int compareTo(Column record) {
- return this.getPosition() - record.getPosition();
- }
-
- public int getCharOctetLength() {
- return charOctetLength;
- }
-
- public String getMaxValue() {
- return maxValue;
- }
-
- public String getMinValue() {
- return minValue;
- }
-
- public SearchType getSearchType() {
- if (searchType == null) {
- return this.getDatatype().getSearchType();
- }
- return searchType;
- }
-
- public String getFormat() {
- return format;
- }
-
- public boolean isAutoIncrementable() {
- return autoIncrementable;
- }
-
- public boolean isCaseSensitive() {
- return caseSensitive;
- }
-
- public boolean isCurrency() {
- return currency;
- }
-
- public boolean isFixedLength() {
- return fixedLength;
- }
-
- public boolean isSelectable() {
- return selectable;
- }
-
- public boolean isSigned() {
- return signed;
- }
-
- public boolean isUpdatable() {
- return updatable;
- }
-
- public String getNativeType() {
- return nativeType;
- }
-
- public int getDistinctValues() {
- return this.distinctValues;
- }
-
- public int getNullValues() {
- return this.nullValues;
- }
-
- /**
- * @param b
- */
- public void setAutoIncrementable(boolean b) {
- autoIncrementable = b;
- }
-
- /**
- * @param b
- */
- public void setCaseSensitive(boolean b) {
- caseSensitive = b;
- }
-
- /**
- * @param i
- */
- public void setCharOctetLength(int i) {
- charOctetLength = i;
- }
-
- /**
- * @param b
- */
- public void setCurrency(boolean b) {
- currency = b;
- }
-
- /**
- * @param b
- */
- public void setFixedLength(boolean b) {
- fixedLength = b;
- }
-
- /**
- * @param object
- */
- public void setMaxValue(String object) {
- maxValue = object;
- }
-
- /**
- * @param object
- */
- public void setMinValue(String object) {
- minValue = object;
- }
-
- /**
- * @param s
- */
- public void setSearchType(SearchType s) {
- searchType = s;
- }
-
- /**
- * @param b
- */
- public void setSelectable(boolean b) {
- selectable = b;
- }
-
- /**
- * @param b
- */
- public void setSigned(boolean b) {
- signed = b;
- }
-
- /**
- * @param b
- */
- public void setUpdatable(boolean b) {
- updatable = b;
- }
-
- /**
- * @param string
- */
- public void setFormat(String string) {
- format = string;
- }
-
- /**
- * @param distinctValues The distinctValues to set.
- * @since 4.3
- */
- public void setDistinctValues(int distinctValues) {
- this.distinctValues = distinctValues;
- }
-
- /**
- * @param nullValues The nullValues to set.
- * @since 4.3
- */
- public void setNullValues(int nullValues) {
- this.nullValues = nullValues;
- }
-
- /**
- * @param nativeType The nativeType to set.
- * @since 4.2
- */
- public void setNativeType(String nativeType) {
- this.nativeType = nativeType;
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,250 @@
+/*
+ * 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.runtime;
+
+
+/**
+ * ColumnRecordImpl
+ */
+public class Column extends BaseColumn implements Comparable<Column> {
+
+ public enum SearchType {
+ Unsearchable,
+ Like_Only {
+ @Override
+ public String toString() {
+ return "Like Only"; //$NON-NLS-1$
+ }
+ },
+ All_Except_Like {
+ @Override
+ public String toString() {
+ return "All Except Like"; //$NON-NLS-1$
+ }
+ },
+ Searchable
+ }
+
+ private boolean selectable = true;
+ private boolean updatable;
+ private boolean autoIncremented;
+ private boolean caseSensitive;
+ private boolean signed;
+ private boolean currency;
+ private boolean fixedLength;
+ private SearchType searchType;
+ private String minimumValue;
+ private String maximumValue;
+ private String nativeType;
+ private String format;
+ private int charOctetLength;
+ private int distinctValues = -1;
+ private int nullValues = -1;
+ private ColumnSet<?> parent;
+
+ public void setParent(ColumnSet<?> parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public AbstractMetadataRecord getParent() {
+ return parent;
+ }
+
+ @Override
+ public int compareTo(Column record) {
+ return this.getPosition() - record.getPosition();
+ }
+
+ public int getCharOctetLength() {
+ return charOctetLength;
+ }
+
+ public String getMaximumValue() {
+ return maximumValue;
+ }
+
+ public String getMinimumValue() {
+ return minimumValue;
+ }
+
+ public SearchType getSearchType() {
+ if (searchType == null) {
+ return this.getDatatype().getSearchType();
+ }
+ return searchType;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public boolean isAutoIncremented() {
+ return autoIncremented;
+ }
+
+ public boolean isCaseSensitive() {
+ return caseSensitive;
+ }
+
+ public boolean isCurrency() {
+ return currency;
+ }
+
+ public boolean isFixedLength() {
+ return fixedLength;
+ }
+
+ public boolean isSelectable() {
+ return selectable;
+ }
+
+ public boolean isSigned() {
+ return signed;
+ }
+
+ public boolean isUpdatable() {
+ return updatable;
+ }
+
+ public String getNativeType() {
+ return nativeType;
+ }
+
+ public int getDistinctValues() {
+ return this.distinctValues;
+ }
+
+ public int getNullValues() {
+ return this.nullValues;
+ }
+
+ /**
+ * @param b
+ */
+ public void setAutoIncremented(boolean b) {
+ autoIncremented = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setCaseSensitive(boolean b) {
+ caseSensitive = b;
+ }
+
+ /**
+ * @param i
+ */
+ public void setCharOctetLength(int i) {
+ charOctetLength = i;
+ }
+
+ /**
+ * @param b
+ */
+ public void setCurrency(boolean b) {
+ currency = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setFixedLength(boolean b) {
+ fixedLength = b;
+ }
+
+ /**
+ * @param object
+ */
+ public void setMaximumValue(String object) {
+ maximumValue = object;
+ }
+
+ /**
+ * @param object
+ */
+ public void setMinimumValue(String object) {
+ minimumValue = object;
+ }
+
+ /**
+ * @param s
+ */
+ public void setSearchType(SearchType s) {
+ searchType = s;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSelectable(boolean b) {
+ selectable = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSigned(boolean b) {
+ signed = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setUpdatable(boolean b) {
+ updatable = b;
+ }
+
+ /**
+ * @param string
+ */
+ public void setFormat(String string) {
+ format = string;
+ }
+
+ /**
+ * @param distinctValues The distinctValues to set.
+ * @since 4.3
+ */
+ public void setDistinctValues(int distinctValues) {
+ this.distinctValues = distinctValues;
+ }
+
+ /**
+ * @param nullValues The nullValues to set.
+ * @since 4.3
+ */
+ public void setNullValues(int nullValues) {
+ this.nullValues = nullValues;
+ }
+
+ /**
+ * @param nativeType The nativeType to set.
+ * @since 4.2
+ */
+ public void setNativeType(String nativeType) {
+ this.nativeType = nativeType;
+ }
+
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -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 org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-public class ColumnSet<T extends AbstractMetadataRecord> extends AbstractMetadataRecord {
-
- private List<Column> columns;
- private T parent;
-
- public List<Column> getColumns() {
- return columns;
- }
-
- public void addColumn(Column column) {
- columns.add(column);
- }
-
- public void setColumns(List<Column> columns) {
- this.columns = columns;
- }
-
- @Override
- public T getParent() {
- return parent;
- }
-
- public void setParent(T parent) {
- this.parent = parent;
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,57 @@
+/*
+ * 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.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ColumnSet<T extends AbstractMetadataRecord> extends AbstractMetadataRecord {
+
+ private List<Column> columns;
+ private T parent;
+
+ public List<Column> getColumns() {
+ return columns;
+ }
+
+ public void addColumn(Column column) {
+ if (columns == null) {
+ columns = new ArrayList<Column>();
+ }
+ columns.add(column);
+ }
+
+ public void setColumns(List<Column> columns) {
+ this.columns = columns;
+ }
+
+ @Override
+ public T getParent() {
+ return parent;
+ }
+
+ public void setParent(T parent) {
+ this.parent = parent;
+ }
+
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,282 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
-
-
-
-/**
- * ColumnRecordImpl
- */
-public class Datatype extends AbstractMetadataRecord {
-
- public enum Type {
- Basic,
- UserDefined,
- ResultSet
- }
-
- public enum Variety {
- Atomic,
- List,
- Union,
- Complex
- }
-
- /** Delimiter used to separate the URI string from the URI fragment */
- public static final String URI_REFERENCE_DELIMITER = "#"; //$NON-NLS-1$
-
- private static final String DEFAULT_JAVA_CLASS_NAME = "java.lang.Object"; //$NON-NLS-1$
-
- private int length;
- private int precisionLength;
- private int scale;
- private int radix;
- private boolean isSigned;
- private boolean isAutoIncrement;
- private boolean isCaseSensitive;
- private Type type;
- private SearchType searchType;
- private NullType nullType;
- private String javaClassName = DEFAULT_JAVA_CLASS_NAME;
- private String runtimeTypeName;
- private String datatypeID;
- private String basetypeID;
- private String primitiveTypeID;
- private Variety varietyType;
-
- public int getLength() {
- return this.length;
- }
-
- public int getPrecisionLength() {
- return this.precisionLength;
- }
-
- public int getScale() {
- return this.scale;
- }
-
- public int getRadix() {
- return this.radix;
- }
-
- public boolean isSigned() {
- return this.isSigned;
- }
-
- public boolean isAutoIncrement() {
- return this.isAutoIncrement;
- }
-
- public boolean isCaseSensitive() {
- return this.isCaseSensitive;
- }
-
- public Type getType() {
- return this.type;
- }
-
- public boolean isBuiltin() {
- return getType() == Type.Basic;
- }
-
-
- public SearchType getSearchType() {
- return this.searchType;
- }
-
- public NullType getNullType() {
- if (this.nullType == null) {
- return NullType.Unknown;
- }
- return this.nullType;
- }
-
- public String getJavaClassName() {
- return this.javaClassName;
- }
-
- public String getRuntimeTypeName() {
- return this.runtimeTypeName;
- }
-
- public String getDatatypeID() {
- return this.datatypeID;
- }
-
- public String getBasetypeID() {
- return this.basetypeID;
- }
-
- public String getBasetypeName() {
- if ( this.basetypeID != null ) {
- final int i = getBasetypeID().lastIndexOf(URI_REFERENCE_DELIMITER);
- if ( i != -1 && getBasetypeID().length() > (i+1)) {
- return getBasetypeID().substring(i+1);
- }
- }
- return null;
- }
-
- public String getPrimitiveTypeID() {
- return this.primitiveTypeID;
- }
-
- public Variety getVarietyType() {
- return this.varietyType;
- }
-
- /**
- * @param string
- */
- public void setBasetypeID(String string) {
- basetypeID = string;
- }
-
- /**
- * @param string
- */
- public void setPrimitiveTypeID(String string) {
- primitiveTypeID = string;
- }
-
- /**
- * @param b
- */
- public void setAutoIncrement(boolean b) {
- isAutoIncrement = b;
- }
-
- /**
- * @param b
- */
- public void setCaseSensitive(boolean b) {
- isCaseSensitive = b;
- }
-
- /**
- * @param b
- */
- public void setSigned(boolean b) {
- isSigned = b;
- }
-
- /**
- * @param string
- */
- public void setJavaClassName(String string) {
- javaClassName = string;
- }
-
- /**
- * @param i
- */
- public void setLength(int i) {
- length = i;
- }
-
- /**
- * @param s
- */
- public void setNullType(NullType s) {
- nullType = s;
- }
-
- /**
- * @param i
- */
- public void setPrecisionLength(int i) {
- precisionLength = i;
- }
-
- /**
- * @param i
- */
- public void setRadix(int i) {
- radix = i;
- }
-
- /**
- * @param string
- */
- public void setRuntimeTypeName(String string) {
- runtimeTypeName = string;
- }
-
- /**
- * @param i
- */
- public void setScale(int i) {
- scale = i;
- }
-
- /**
- * @param s
- */
- public void setSearchType(SearchType s) {
- searchType = s;
- }
-
- /**
- * @param s
- */
- public void setType(Type s) {
- type = s;
- }
-
- /**
- * @param string
- */
- public void setDatatypeID(String string) {
- datatypeID = string;
- }
-
- /**
- * @param s
- */
- public void setVarietyType(Variety s) {
- varietyType = s;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", basetype name="); //$NON-NLS-1$
- sb.append(getBasetypeName());
- sb.append(", runtimeType="); //$NON-NLS-1$
- sb.append(getRuntimeTypeName());
- sb.append(", javaClassName="); //$NON-NLS-1$
- sb.append(getJavaClassName());
- sb.append(", ObjectID="); //$NON-NLS-1$
- sb.append(getUUID());
- sb.append(", datatypeID="); //$NON-NLS-1$
- sb.append(getDatatypeID());
- return sb.toString();
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,282 @@
+/*
+ * 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.runtime;
+
+import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+
+
+
+/**
+ * ColumnRecordImpl
+ */
+public class Datatype extends AbstractMetadataRecord {
+
+ public enum Type {
+ Basic,
+ UserDefined,
+ ResultSet
+ }
+
+ public enum Variety {
+ Atomic,
+ List,
+ Union,
+ Complex
+ }
+
+ /** Delimiter used to separate the URI string from the URI fragment */
+ public static final String URI_REFERENCE_DELIMITER = "#"; //$NON-NLS-1$
+
+ private static final String DEFAULT_JAVA_CLASS_NAME = "java.lang.Object"; //$NON-NLS-1$
+
+ private int length;
+ private int precisionLength;
+ private int scale;
+ private int radix;
+ private boolean isSigned;
+ private boolean isAutoIncrement;
+ private boolean isCaseSensitive;
+ private Type type;
+ private SearchType searchType;
+ private NullType nullType;
+ private String javaClassName = DEFAULT_JAVA_CLASS_NAME;
+ private String runtimeTypeName;
+ private String datatypeID;
+ private String basetypeID;
+ private String primitiveTypeID;
+ private Variety varietyType;
+
+ public int getLength() {
+ return this.length;
+ }
+
+ public int getPrecisionLength() {
+ return this.precisionLength;
+ }
+
+ public int getScale() {
+ return this.scale;
+ }
+
+ public int getRadix() {
+ return this.radix;
+ }
+
+ public boolean isSigned() {
+ return this.isSigned;
+ }
+
+ public boolean isAutoIncrement() {
+ return this.isAutoIncrement;
+ }
+
+ public boolean isCaseSensitive() {
+ return this.isCaseSensitive;
+ }
+
+ public Type getType() {
+ return this.type;
+ }
+
+ public boolean isBuiltin() {
+ return getType() == Type.Basic;
+ }
+
+
+ public SearchType getSearchType() {
+ return this.searchType;
+ }
+
+ public NullType getNullType() {
+ if (this.nullType == null) {
+ return NullType.Unknown;
+ }
+ return this.nullType;
+ }
+
+ public String getJavaClassName() {
+ return this.javaClassName;
+ }
+
+ public String getRuntimeTypeName() {
+ return this.runtimeTypeName;
+ }
+
+ public String getDatatypeID() {
+ return this.datatypeID;
+ }
+
+ public String getBasetypeID() {
+ return this.basetypeID;
+ }
+
+ public String getBasetypeName() {
+ if ( this.basetypeID != null ) {
+ final int i = getBasetypeID().lastIndexOf(URI_REFERENCE_DELIMITER);
+ if ( i != -1 && getBasetypeID().length() > (i+1)) {
+ return getBasetypeID().substring(i+1);
+ }
+ }
+ return null;
+ }
+
+ public String getPrimitiveTypeID() {
+ return this.primitiveTypeID;
+ }
+
+ public Variety getVarietyType() {
+ return this.varietyType;
+ }
+
+ /**
+ * @param string
+ */
+ public void setBasetypeID(String string) {
+ basetypeID = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setPrimitiveTypeID(String string) {
+ primitiveTypeID = string;
+ }
+
+ /**
+ * @param b
+ */
+ public void setAutoIncrement(boolean b) {
+ isAutoIncrement = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setCaseSensitive(boolean b) {
+ isCaseSensitive = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSigned(boolean b) {
+ isSigned = b;
+ }
+
+ /**
+ * @param string
+ */
+ public void setJavaClassName(String string) {
+ javaClassName = string;
+ }
+
+ /**
+ * @param i
+ */
+ public void setLength(int i) {
+ length = i;
+ }
+
+ /**
+ * @param s
+ */
+ public void setNullType(NullType s) {
+ nullType = s;
+ }
+
+ /**
+ * @param i
+ */
+ public void setPrecisionLength(int i) {
+ precisionLength = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setRadix(int i) {
+ radix = i;
+ }
+
+ /**
+ * @param string
+ */
+ public void setRuntimeTypeName(String string) {
+ runtimeTypeName = string;
+ }
+
+ /**
+ * @param i
+ */
+ public void setScale(int i) {
+ scale = i;
+ }
+
+ /**
+ * @param s
+ */
+ public void setSearchType(SearchType s) {
+ searchType = s;
+ }
+
+ /**
+ * @param s
+ */
+ public void setType(Type s) {
+ type = s;
+ }
+
+ /**
+ * @param string
+ */
+ public void setDatatypeID(String string) {
+ datatypeID = string;
+ }
+
+ /**
+ * @param s
+ */
+ public void setVarietyType(Variety s) {
+ varietyType = s;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append(getClass().getSimpleName());
+ sb.append(" name="); //$NON-NLS-1$
+ sb.append(getName());
+ sb.append(", basetype name="); //$NON-NLS-1$
+ sb.append(getBasetypeName());
+ sb.append(", runtimeType="); //$NON-NLS-1$
+ sb.append(getRuntimeTypeName());
+ sb.append(", javaClassName="); //$NON-NLS-1$
+ sb.append(getJavaClassName());
+ sb.append(", ObjectID="); //$NON-NLS-1$
+ sb.append(getUUID());
+ sb.append(", datatypeID="); //$NON-NLS-1$
+ sb.append(getDatatypeID());
+ return sb.toString();
+ }
+
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Element.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Element.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Element.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,109 +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.
- */
-
-/*
- * Date: Aug 18, 2003
- * Time: 11:58:05 AM
- */
-package org.teiid.connector.metadata.runtime;
-
-import org.teiid.connector.api.ConnectorException;
-
-/**
- * Represents an element, such as a column, in runtime metadata.
- */
-public interface Element extends MetadataObject, TypeModel {
-
- /**
- * Get position of this element in it's group.
- * @return Position, 0-based
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- int getPosition() throws ConnectorException;
-
- /**
- * Get minimum value
- * @return Minimum value, may be null
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- Object getMinimumValue() throws ConnectorException;
-
- /**
- * Get maximum value
- * @return Maximum value, may be null
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- Object getMaximumValue() throws ConnectorException;
-
- /**
- * Is auto-incremented?
- * @return True if auto-incremented, false otherwise
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- boolean isAutoIncremented() throws ConnectorException;
-
- /**
- * Get searchability of this column.
- * @return Code indicating searchability
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @see #NOT_SEARCHABLE
- * @see #SEARCHABLE
- * @see #SEARCHABLE_COMPARE
- * @see #SEARCHABLE_LIKE
- */
- int getSearchability() throws ConnectorException;
-
- /**
- * Is case sensitive?
- * @return True if case sensitive, false otherwise
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- boolean isCaseSensitive() throws ConnectorException;
-
- /**
- * Get the native type imported for this column.
- * @return The native type, may be null
- * @throws ConnectorException If an error occurs retrieving the data
- * @since 4.2
- */
- String getNativeType() throws ConnectorException;
-
- /**
- * Get the Format property
- * @return
- * @throws ConnectorException
- */
- String getFormat() throws ConnectorException;
-
- /**
- * Get the parent
- * @return Parent
- */
- Group getParent() throws ConnectorException;
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-/**
- * ForeignKeyRecordImpl
- */
-public class ForeignKey extends KeyRecord {
-
- private String uniqueKeyID;
- private KeyRecord primaryKey;
-
- public ForeignKey() {
- super(Type.Foreign);
- }
-
- public String getUniqueKeyID() {
- return uniqueKeyID;
- }
-
- /**
- * @param object
- */
- public void setUniqueKeyID(String keyID) {
- uniqueKeyID = keyID;
- }
-
- public KeyRecord getPrimaryKey() {
- return this.primaryKey;
- }
-
- public void setPrimaryKey(KeyRecord primaryKey) {
- this.primaryKey = primaryKey;
- }
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,55 @@
+/*
+ * 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.runtime;
+
+/**
+ * ForeignKeyRecordImpl
+ */
+public class ForeignKey extends KeyRecord {
+
+ private String uniqueKeyID;
+ private KeyRecord primaryKey;
+
+ public ForeignKey() {
+ super(Type.Foreign);
+ }
+
+ public String getUniqueKeyID() {
+ return uniqueKeyID;
+ }
+
+ /**
+ * @param object
+ */
+ public void setUniqueKeyID(String keyID) {
+ uniqueKeyID = keyID;
+ }
+
+ public KeyRecord getPrimaryKey() {
+ return this.primaryKey;
+ }
+
+ public void setPrimaryKey(KeyRecord primaryKey) {
+ this.primaryKey = primaryKey;
+ }
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Group.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Group.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Group.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-
-
-/**
- * Represents a group, such as a table, in the runtime metadata.
- */
-public interface Group extends MetadataObject {
-
- List<Element> getChildren() throws ConnectorException;
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-public class KeyRecord extends ColumnSet<Table> {
-
- public enum Type {
- Primary,
- Foreign,
- Unique, //constraint
- NonUnique,
- AccessPattern,
- Index,
- }
-
- private Type type;
-
- public KeyRecord(Type type) {
- this.type = type;
- }
-
- public Type getType() {
- return type;
- }
-
- public Table getTable() {
- return super.getParent();
- }
-
-}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,46 @@
+/*
+ * 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.runtime;
+
+public class KeyRecord extends ColumnSet<Table> {
+
+ public enum Type {
+ Primary,
+ Foreign,
+ Unique, //constraint
+ NonUnique,
+ AccessPattern,
+ Index,
+ }
+
+ private Type type;
+
+ public KeyRecord(Type type) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -50,11 +50,11 @@
public MetadataFactory(String modelName, Map<String, Datatype> dataTypes, Properties importProperties) {
this.dataTypes = dataTypes;
- this.importProperties = importProperties;
schema = new Schema();
schema.setName(modelName);
setUUID(schema);
store.addSchema(schema);
+ this.importProperties = importProperties;
}
public MetadataStore getMetadataStore() {
@@ -79,11 +79,6 @@
Table table = new Table();
table.setTableType(Table.Type.Table);
table.setName(name);
- table.setColumns(new LinkedList<Column>());
- table.setAccessPatterns(new LinkedList<KeyRecord>());
- table.setIndexes(new LinkedList<KeyRecord>());
- table.setForiegnKeys(new LinkedList<ForeignKey>());
- table.setUniqueKeys(new LinkedList<KeyRecord>());
setUUID(table);
this.schema.addTable(table);
return table;
@@ -103,14 +98,13 @@
}
Column column = new Column();
column.setName(name);
- table.getColumns().add(column);
+ table.addColumn(column);
column.setPosition(table.getColumns().size()); //1 based indexing
Datatype datatype = setColumnType(type, column);
column.setCaseSensitive(datatype.isCaseSensitive());
- column.setAutoIncrementable(datatype.isAutoIncrement());
+ column.setAutoIncremented(datatype.isAutoIncrement());
column.setSigned(datatype.isSigned());
setUUID(column);
- column.setParent(table);
return column;
}
@@ -218,8 +212,8 @@
* @return
* @throws ConnectorException
*/
- public ProcedureRecordImpl addProcedure(String name) throws ConnectorException {
- ProcedureRecordImpl procedure = new ProcedureRecordImpl();
+ public Procedure addProcedure(String name) throws ConnectorException {
+ Procedure procedure = new Procedure();
procedure.setName(name);
setUUID(procedure);
procedure.setParameters(new LinkedList<ProcedureParameter>());
@@ -236,7 +230,7 @@
* @return
* @throws ConnectorException
*/
- public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, ProcedureRecordImpl procedure) throws ConnectorException {
+ public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure) throws ConnectorException {
ProcedureParameter param = new ProcedureParameter();
param.setName(name);
setUUID(param);
@@ -256,9 +250,9 @@
* @return
* @throws ConnectorException
*/
- public Column addProcedureResultSetColumn(String name, String type, ProcedureRecordImpl procedure) throws ConnectorException {
+ public Column addProcedureResultSetColumn(String name, String type, Procedure procedure) throws ConnectorException {
if (procedure.getResultSet() == null) {
- ColumnSet<ProcedureRecordImpl> resultSet = new ColumnSet<ProcedureRecordImpl>();
+ ColumnSet<Procedure> resultSet = new ColumnSet<Procedure>();
resultSet.setParent(procedure);
resultSet.setName("RSParam"); //$NON-NLS-1$
setUUID(resultSet);
@@ -283,5 +277,4 @@
}
}
}
-
}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataObject.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataObject.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataObject.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorException;
-
-
-/**
- * Represents a runtime metadata object.
- */
-public interface MetadataObject {
-
- /**
- * Get name in source for this object, as provided in the model
- * @return Name in source
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- String getNameInSource() throws ConnectorException;
-
- /**
- * Get any arbitrary properties that are provided on this object.
- * Typically these properties are provided via metamodel extensions.
- * @return Properties
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- Properties getProperties() throws ConnectorException;
-
- /**
- * Get the short name from the metadataID
- * @return String shortName
- */
- String getName();
-
- /**
- * Get the full name from the metadataID
- * @return String fullName
- */
- String getFullName();
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Simple holder for metadata.
- */
-public class MetadataStore implements Serializable {
-
- private static final long serialVersionUID = -3130247626435324312L;
- protected Map<String, Schema> schemas = new LinkedHashMap<String, Schema>();
- protected Collection<Datatype> datatypes = new ArrayList<Datatype>();
-
- public Map<String, Schema> getSchemas() {
- return schemas;
- }
-
- public void addSchema(Schema schema) {
- this.schemas.put(schema.getName().toLowerCase(), schema);
- }
-
- public void addDatatype(Datatype datatype) {
- this.datatypes.add(datatype);
- }
-
- /**
- * Get the datatypes defined in this store
- * @return
- */
- public Collection<Datatype> getDatatypes() {
- return datatypes;
- }
-
-}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,60 @@
+/*
+ * 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.runtime;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Simple holder for metadata.
+ */
+public class MetadataStore implements Serializable {
+
+ private static final long serialVersionUID = -3130247626435324312L;
+ protected Map<String, Schema> schemas = new LinkedHashMap<String, Schema>();
+ protected Collection<Datatype> datatypes = new ArrayList<Datatype>();
+
+ public Map<String, Schema> getSchemas() {
+ return schemas;
+ }
+
+ public void addSchema(Schema schema) {
+ this.schemas.put(schema.getName().toLowerCase(), schema);
+ }
+
+ public void addDatatype(Datatype datatype) {
+ this.datatypes.add(datatype);
+ }
+
+ /**
+ * Get the datatypes defined in this store
+ * @return
+ */
+ public Collection<Datatype> getDatatypes() {
+ return datatypes;
+ }
+
+}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Parameter.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Parameter.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Parameter.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-
-
-/**
- * Represents a procedure parameter in the runtime metadata.
- */
-public interface Parameter extends MetadataObject, TypeModel {
-
- public static final int IN = 0;
- public static final int OUT = 1;
- public static final int INOUT = 2;
- public static final int RETURN = 3;
- public static final int RESULT_SET = 4;
-
- /**
- * Index of the parameter in the procedure. If the parameter has
- * no index, then the index will be returned as -1.
- * @return Index of the parameter
- */
- int getIndex() throws ConnectorException;
-
- /**
- * Get direction of the parameter, as specified by direction constants.
- * @return Direction constant
- * @see #IN
- * @see #OUT
- * @see #INOUT
- * @see #RETURN
- * @see #RESULT_SET
- */
- int getDirection() throws ConnectorException;
-
- /**
- * Get the parent
- * @return Parent
- */
- Procedure getParent() throws ConnectorException;
-
- List<Element> getChildren() throws ConnectorException;
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-/**
- * Represents a procedure construct (such as a Stored Procedure).
- */
-public interface Procedure extends MetadataObject{
-
- List<Parameter> getChildren();
-}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,129 @@
+/*
+ * 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.runtime;
+
+import java.util.LinkedList;
+import java.util.List;
+
+
+/**
+ * ProcedureRecordImpl
+ */
+public class Procedure extends AbstractMetadataRecord {
+
+ public enum Type {
+ Function,
+ UDF,
+ StoredProc,
+ StoredQuery
+ }
+
+ private boolean isFunction;
+ private boolean isVirtual;
+ private int updateCount = 1;
+ private List<ProcedureParameter> parameters = new LinkedList<ProcedureParameter>();
+ private ColumnSet<Procedure> resultSet;
+ private String queryPlan;
+
+ private Schema parent;
+
+ public void setParent(Schema parent) {
+ this.parent = parent;
+ }
+
+ public boolean isFunction() {
+ return isFunction;
+ }
+
+ public boolean isVirtual() {
+ return this.isVirtual;
+ }
+
+ public Type getType() {
+ if (isFunction()) {
+ if (isVirtual()) {
+ return Type.UDF;
+ }
+ return Type.Function;
+ }
+ if (isVirtual()) {
+ return Type.StoredQuery;
+ }
+ return Type.StoredProc;
+ }
+
+ public int getUpdateCount() {
+ return this.updateCount;
+ }
+
+ public List<ProcedureParameter> getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(List<ProcedureParameter> parameters) {
+ this.parameters = parameters;
+ }
+
+ public String getQueryPlan() {
+ return queryPlan;
+ }
+
+ public void setQueryPlan(String queryPlan) {
+ this.queryPlan = queryPlan;
+ }
+
+ /**
+ * @param b
+ */
+ public void setFunction(boolean b) {
+ isFunction = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setVirtual(boolean b) {
+ isVirtual = b;
+ }
+
+ public void setUpdateCount(int count) {
+ this.updateCount = count;
+ }
+
+ public void setResultSet(ColumnSet<Procedure> resultSet) {
+ this.resultSet = resultSet;
+ if (resultSet != null) {
+ resultSet.setParent(this);
+ }
+ }
+
+ public ColumnSet<Procedure> getResultSet() {
+ return resultSet;
+ }
+
+ @Override
+ public Schema getParent() {
+ return parent;
+ }
+
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-/**
- * ProcedureParameterRecordImpl
- */
-public class ProcedureParameter extends BaseColumn {
-
- public enum Type {
- Unknown,
- In,
- InOut,
- ResultSet,
- Out,
- ReturnValue
- }
-
- private Type type;
- private boolean optional;
- private ProcedureRecordImpl procedure;
-
- public void setType(Type type) {
- this.type = type;
- }
-
- public Type getType() {
- return type;
- }
-
- public void setOptional(boolean optional) {
- this.optional = optional;
- }
-
- public boolean isOptional() {
- return optional;
- }
-
- public ProcedureRecordImpl getProcedure() {
- return procedure;
- }
-
- public void setProcedure(ProcedureRecordImpl procedure) {
- this.procedure = procedure;
- }
-
- @Override
- public AbstractMetadataRecord getParent() {
- return this.procedure;
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,83 @@
+/*
+ * 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.runtime;
+
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * ProcedureParameterRecordImpl
+ */
+public class ProcedureParameter extends BaseColumn {
+
+ public enum Type {
+ Unknown,
+ In,
+ InOut,
+ ResultSet,
+ Out,
+ ReturnValue
+ }
+
+ private Type type;
+ private boolean optional;
+ private Procedure procedure;
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+
+ public boolean isOptional() {
+ return optional;
+ }
+
+ public void setProcedure(Procedure procedure) {
+ this.procedure = procedure;
+ }
+
+ @Override
+ public Procedure getParent() {
+ return this.procedure;
+ }
+
+ /**
+ * Get the result set columns only if this parameter represents a result set.
+ * @return
+ */
+ public List<Column> getResultSetColumns() {
+ if (this.type == Type.ResultSet) {
+ return this.procedure.getResultSet().getColumns();
+ }
+ return Collections.emptyList();
+ }
+
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-
-/**
- * ProcedureRecordImpl
- */
-public class ProcedureRecordImpl extends AbstractMetadataRecord {
-
- public enum Type {
- Function,
- UDF,
- StoredProc,
- StoredQuery
- }
-
- private boolean isFunction;
- private boolean isVirtual;
- private int updateCount = 1;
- private List<ProcedureParameter> parameters;
- private ColumnSet<ProcedureRecordImpl> resultSet;
- private String queryPlan;
-
- private Schema schema;
-
- public Schema getSchema() {
- return schema;
- }
-
- public void setSchema(Schema schema) {
- this.schema = schema;
- }
-
- public boolean isFunction() {
- return isFunction;
- }
-
- public boolean isVirtual() {
- return this.isVirtual;
- }
-
- public Type getType() {
- if (isFunction()) {
- if (isVirtual()) {
- return Type.UDF;
- }
- return Type.Function;
- }
- if (isVirtual()) {
- return Type.StoredQuery;
- }
- return Type.StoredProc;
- }
-
- public int getUpdateCount() {
- return this.updateCount;
- }
-
- public List<ProcedureParameter> getParameters() {
- return parameters;
- }
-
- public void setParameters(List<ProcedureParameter> parameters) {
- this.parameters = parameters;
- }
-
- public String getQueryPlan() {
- return queryPlan;
- }
-
- public void setQueryPlan(String queryPlan) {
- this.queryPlan = queryPlan;
- }
-
- /**
- * @param b
- */
- public void setFunction(boolean b) {
- isFunction = b;
- }
-
- /**
- * @param b
- */
- public void setVirtual(boolean b) {
- isVirtual = b;
- }
-
- public void setUpdateCount(int count) {
- this.updateCount = count;
- }
-
- public void setResultSet(ColumnSet<ProcedureRecordImpl> resultSet) {
- this.resultSet = resultSet;
- }
-
- public ColumnSet<ProcedureRecordImpl> getResultSet() {
- return resultSet;
- }
-
- @Override
- public AbstractMetadataRecord getParent() {
- return schema;
- }
-
-}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -34,14 +34,14 @@
* @param fullName
* @return The object
*/
- Group getGroup(String fullName) throws ConnectorException;
+ Table getGroup(String fullName) throws ConnectorException;
/**
* Look up an object by identifier
* @param fullName
* @return The object
*/
- Element getElement(String fullName) throws ConnectorException;
+ Column getElement(String fullName) throws ConnectorException;
/**
* Look up an object by identifier
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class Schema extends AbstractMetadataRecord {
-
- private boolean physical = true;
- private boolean isVisible = true;
- private String primaryMetamodelUri = "http://www.metamatrix.com/metamodels/Relational"; //$NON-NLS-1$
-
- private Map<String, Table> tables = new LinkedHashMap<String, Table>();
- private Map<String, ProcedureRecordImpl> procedures = new LinkedHashMap<String, ProcedureRecordImpl>();
-
- public void addTable(Table table) {
- table.setParent(this);
- this.tables.put(table.getName().toLowerCase(), table);
- }
-
- public void addProcedure(ProcedureRecordImpl procedure) {
- procedure.setSchema(this);
- this.procedures.put(procedure.getName().toLowerCase(), procedure);
- }
-
- /**
- * Get the tables defined in this schema
- * @return
- */
- public Map<String, Table> getTables() {
- return tables;
- }
-
- /**
- * Get the procedures defined in this schema
- * @return
- */
- public Map<String, ProcedureRecordImpl> getProcedures() {
- return procedures;
- }
-
- public String getPrimaryMetamodelUri() {
- return primaryMetamodelUri;
- }
-
- public boolean isVisible() {
- return isVisible;
- }
-
- public boolean isPhysical() {
- return physical;
- }
-
- /**
- * @param string
- */
- public void setPrimaryMetamodelUri(String string) {
- primaryMetamodelUri = string;
- }
-
- /**
- * @param b
- */
- public void setVisible(boolean b) {
- isVisible = b;
- }
-
- public void setPhysical(boolean physical) {
- this.physical = physical;
- }
-
-}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,93 @@
+/*
+ * 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.runtime;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class Schema extends AbstractMetadataRecord {
+
+ private boolean physical = true;
+ private boolean isVisible = true;
+ private String primaryMetamodelUri = "http://www.metamatrix.com/metamodels/Relational"; //$NON-NLS-1$
+
+ private Map<String, Table> tables = new LinkedHashMap<String, Table>();
+ private Map<String, Procedure> procedures = new LinkedHashMap<String, Procedure>();
+
+ public void addTable(Table table) {
+ table.setParent(this);
+ this.tables.put(table.getName().toLowerCase(), table);
+ }
+
+ public void addProcedure(Procedure procedure) {
+ procedure.setParent(this);
+ this.procedures.put(procedure.getName().toLowerCase(), procedure);
+ }
+
+ /**
+ * Get the tables defined in this schema
+ * @return
+ */
+ public Map<String, Table> getTables() {
+ return tables;
+ }
+
+ /**
+ * Get the procedures defined in this schema
+ * @return
+ */
+ public Map<String, Procedure> getProcedures() {
+ return procedures;
+ }
+
+ public String getPrimaryMetamodelUri() {
+ return primaryMetamodelUri;
+ }
+
+ public boolean isVisible() {
+ return isVisible;
+ }
+
+ public boolean isPhysical() {
+ return physical;
+ }
+
+ /**
+ * @param string
+ */
+ public void setPrimaryMetamodelUri(String string) {
+ primaryMetamodelUri = string;
+ }
+
+ /**
+ * @param b
+ */
+ public void setVisible(boolean b) {
+ isVisible = b;
+ }
+
+ public void setPhysical(boolean physical) {
+ this.physical = physical;
+ }
+
+}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,270 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * TableRecordImpl
- */
-public class Table extends ColumnSet<Schema> {
-
- public enum Type {
- Table,
- View,
- Document,
- XmlMappingClass,
- XmlStagingTable,
- MaterializedTable
- }
-
- private int cardinality;
- private Type tableType;
- private boolean isVirtual;
- private boolean isSystem;
- private boolean isMaterialized;
- private boolean supportsUpdate;
- private List<ForeignKey> foriegnKeys;
- private List<KeyRecord> indexes;
- private List<KeyRecord> uniqueKeys;
- private List<KeyRecord> accessPatterns;
- private KeyRecord primaryKey;
-
- //view information
- private String selectTransformation;
- private String insertPlan;
- private String updatePlan;
- private String deletePlan;
- private Table materializedStageTable;
- private Table materializedTable;
-
- //XML specific
- private List<String> bindings;
- private List<String> schemaPaths;
- private String resourcePath;
-
- public Schema getSchema() {
- return super.getParent();
- }
-
- public List<String> getBindings() {
- return bindings;
- }
-
- public void setBindings(List<String> bindings) {
- this.bindings = bindings;
- }
-
- public List<String> getSchemaPaths() {
- return schemaPaths;
- }
-
- public void setSchemaPaths(List<String> schemaPaths) {
- this.schemaPaths = schemaPaths;
- }
-
- public int getCardinality() {
- return cardinality;
- }
-
- public boolean isVirtual() {
- return isVirtual;
- }
-
- public boolean isMaterialized() {
- return isMaterialized;
- }
-
- public boolean isPhysical() {
- return !isVirtual();
- }
-
- public boolean isSystem() {
- return isSystem;
- }
-
- public Type getTableType() {
- if (tableType == null) {
- return Type.Table;
- }
- return tableType;
- }
-
- public boolean supportsUpdate() {
- return supportsUpdate;
- }
-
- /**
- * @param i
- */
- public void setCardinality(int i) {
- cardinality = i;
- }
-
- /**
- * @param i
- */
- public void setTableType(Type i) {
- tableType = i;
- }
-
- /**
- * @param b
- */
- public void setSupportsUpdate(boolean b) {
- supportsUpdate = b;
- }
-
- /**
- * @param b
- */
- public void setVirtual(boolean b) {
- isVirtual = b;
- }
-
- /**
- * @param isMaterialized The isMaterialized to set.
- * @since 4.2
- */
- public void setMaterialized(boolean isMaterialized) {
- this.isMaterialized = isMaterialized;
- }
-
- /**
- * @param b
- */
- public void setSystem(boolean b) {
- isSystem = b;
- }
-
- public String getInsertPlan() {
- return insertPlan;
- }
-
- public String getUpdatePlan() {
- return updatePlan;
- }
-
- public String getDeletePlan() {
- return deletePlan;
- }
-
- public void setInsertPlan(String insertPlan) {
- this.insertPlan = insertPlan;
- }
-
- public void setUpdatePlan(String updatePlan) {
- this.updatePlan = updatePlan;
- }
-
- public void setDeletePlan(String deletePlan) {
- this.deletePlan = deletePlan;
- }
-
- public List<ForeignKey> getForeignKeys() {
- return this.foriegnKeys;
- }
-
- public void setForiegnKeys(List<ForeignKey> foriegnKeys) {
- this.foriegnKeys = foriegnKeys;
- }
-
- public List<KeyRecord> getIndexes() {
- return this.indexes;
- }
-
- public void setIndexes(List<KeyRecord> indexes) {
- this.indexes = indexes;
- }
-
- public List<KeyRecord> getUniqueKeys() {
- return this.uniqueKeys;
- }
-
- public void setUniqueKeys(List<KeyRecord> uniqueKeys) {
- this.uniqueKeys = uniqueKeys;
- }
-
- public List<KeyRecord> getAccessPatterns() {
- return this.accessPatterns;
- }
-
- public void setAccessPatterns(List<KeyRecord> accessPatterns) {
- this.accessPatterns = accessPatterns;
- }
-
- public KeyRecord getPrimaryKey() {
- return this.primaryKey;
- }
-
- public void setPrimaryKey(KeyRecord primaryKey) {
- this.primaryKey = primaryKey;
- }
-
- public String getSelectTransformation() {
- return selectTransformation;
- }
-
- public void setSelectTransformation(String selectTransformation) {
- this.selectTransformation = selectTransformation;
- }
-
- public Table getMaterializedStageTable() {
- return materializedStageTable;
- }
-
- public Table getMaterializedTable() {
- return materializedTable;
- }
-
- public void setMaterializedStageTable(Table materializedStageTable) {
- this.materializedStageTable = materializedStageTable;
- }
-
- public void setMaterializedTable(Table materializedTable) {
- this.materializedTable = materializedTable;
- }
-
- public void setResourcePath(String resourcePath) {
- this.resourcePath = resourcePath;
- }
-
- public String getResourcePath() {
- return resourcePath;
- }
-
- public Collection<KeyRecord> getAllKeys() {
- Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
- if (getPrimaryKey() != null) {
- keys.add(getPrimaryKey());
- }
- keys.addAll(getForeignKeys());
- keys.addAll(getAccessPatterns());
- keys.addAll(getIndexes());
- keys.addAll(getUniqueKeys());
- return keys;
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java (from rev 1899, branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,272 @@
+/*
+ * 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.runtime;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * TableRecordImpl
+ */
+public class Table extends ColumnSet<Schema> {
+
+ public enum Type {
+ Table,
+ View,
+ Document,
+ XmlMappingClass,
+ XmlStagingTable,
+ MaterializedTable
+ }
+
+ private int cardinality;
+ private Type tableType;
+ private boolean isVirtual;
+ private boolean isSystem;
+ private boolean isMaterialized;
+ private boolean supportsUpdate;
+ private List<ForeignKey> foriegnKeys = new LinkedList<ForeignKey>();
+ private List<KeyRecord> indexes = new LinkedList<KeyRecord>();
+ private List<KeyRecord> uniqueKeys = new LinkedList<KeyRecord>();
+ private List<KeyRecord> accessPatterns = new LinkedList<KeyRecord>();
+ private KeyRecord primaryKey;
+
+ //view information
+ private String selectTransformation;
+ private String insertPlan;
+ private String updatePlan;
+ private String deletePlan;
+ private Table materializedStageTable;
+ private Table materializedTable;
+
+ //XML specific
+ private List<String> bindings;
+ private List<String> schemaPaths;
+ private String resourcePath;
+
+ public List<String> getBindings() {
+ return bindings;
+ }
+
+ public void setBindings(List<String> bindings) {
+ this.bindings = bindings;
+ }
+
+ public List<String> getSchemaPaths() {
+ return schemaPaths;
+ }
+
+ public void setSchemaPaths(List<String> schemaPaths) {
+ this.schemaPaths = schemaPaths;
+ }
+
+ public int getCardinality() {
+ return cardinality;
+ }
+
+ public boolean isVirtual() {
+ return isVirtual;
+ }
+
+ public boolean isMaterialized() {
+ return isMaterialized;
+ }
+
+ public boolean isPhysical() {
+ return !isVirtual();
+ }
+
+ public boolean isSystem() {
+ return isSystem;
+ }
+
+ public Type getTableType() {
+ if (tableType == null) {
+ return Type.Table;
+ }
+ return tableType;
+ }
+
+ public boolean supportsUpdate() {
+ return supportsUpdate;
+ }
+
+ /**
+ * @param i
+ */
+ public void setCardinality(int i) {
+ cardinality = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setTableType(Type i) {
+ tableType = i;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSupportsUpdate(boolean b) {
+ supportsUpdate = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setVirtual(boolean b) {
+ isVirtual = b;
+ }
+
+ /**
+ * @param isMaterialized The isMaterialized to set.
+ * @since 4.2
+ */
+ public void setMaterialized(boolean isMaterialized) {
+ this.isMaterialized = isMaterialized;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSystem(boolean b) {
+ isSystem = b;
+ }
+
+ public String getInsertPlan() {
+ return insertPlan;
+ }
+
+ public String getUpdatePlan() {
+ return updatePlan;
+ }
+
+ public String getDeletePlan() {
+ return deletePlan;
+ }
+
+ public void setInsertPlan(String insertPlan) {
+ this.insertPlan = insertPlan;
+ }
+
+ public void setUpdatePlan(String updatePlan) {
+ this.updatePlan = updatePlan;
+ }
+
+ public void setDeletePlan(String deletePlan) {
+ this.deletePlan = deletePlan;
+ }
+
+ public List<ForeignKey> getForeignKeys() {
+ return this.foriegnKeys;
+ }
+
+ public void setForiegnKeys(List<ForeignKey> foriegnKeys) {
+ this.foriegnKeys = foriegnKeys;
+ }
+
+ public List<KeyRecord> getIndexes() {
+ return this.indexes;
+ }
+
+ public void setIndexes(List<KeyRecord> indexes) {
+ this.indexes = indexes;
+ }
+
+ public List<KeyRecord> getUniqueKeys() {
+ return this.uniqueKeys;
+ }
+
+ public void setUniqueKeys(List<KeyRecord> uniqueKeys) {
+ this.uniqueKeys = uniqueKeys;
+ }
+
+ public List<KeyRecord> getAccessPatterns() {
+ return this.accessPatterns;
+ }
+
+ public void setAccessPatterns(List<KeyRecord> accessPatterns) {
+ this.accessPatterns = accessPatterns;
+ }
+
+ public KeyRecord getPrimaryKey() {
+ return this.primaryKey;
+ }
+
+ public void setPrimaryKey(KeyRecord primaryKey) {
+ this.primaryKey = primaryKey;
+ }
+
+ public String getSelectTransformation() {
+ return selectTransformation;
+ }
+
+ public void setSelectTransformation(String selectTransformation) {
+ this.selectTransformation = selectTransformation;
+ }
+
+ public Table getMaterializedStageTable() {
+ return materializedStageTable;
+ }
+
+ public Table getMaterializedTable() {
+ return materializedTable;
+ }
+
+ public void setMaterializedStageTable(Table materializedStageTable) {
+ this.materializedStageTable = materializedStageTable;
+ }
+
+ public void setMaterializedTable(Table materializedTable) {
+ this.materializedTable = materializedTable;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public Collection<KeyRecord> getAllKeys() {
+ Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
+ if (getPrimaryKey() != null) {
+ keys.add(getPrimaryKey());
+ }
+ keys.addAll(getForeignKeys());
+ keys.addAll(getAccessPatterns());
+ keys.addAll(getIndexes());
+ keys.addAll(getUniqueKeys());
+ return keys;
+ }
+
+ @Override
+ public void addColumn(Column column) {
+ super.addColumn(column);
+ column.setParent(this);
+ }
+
+}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TypeModel.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TypeModel.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TypeModel.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import org.teiid.connector.api.ConnectorException;
-
-
-/**
- * @since 4.3
- */
-public interface TypeModel {
-
- /**
- * Nullability constant - indicates column does not allow nulls
- */
- public static final int NOT_NULLABLE = 0;
- /**
- * Searchability constant - indicates column is not searchable (cannot be evaluated in a comparison).
- */
- public static final int NOT_SEARCHABLE = 0;
- /**
- * Nullability constant - indicates column does allow nulls
- */
- public static final int NULLABLE = 1;
- /**
- * Nullability constant - indicates column may or may not allow nulls
- */
- public static final int NULLABLE_UNKNOWN = 2;
- /**
- * Searchability constant - indicates column can be searched by either a comparison or a LIKE.
- */
- public static final int SEARCHABLE = 3;
- /**
- * Searchability constant - indicates column can be searched with a comparison but not with a LIKE
- */
- public static final int SEARCHABLE_COMPARE = 1;
- /**
- * Searchability constant - indicates column can be searched with a LIKE but not with a comparison
- */
- public static final int SEARCHABLE_LIKE = 2;
- /**
- * Get the expected Java class that should be returned for this element.
- * @return Data type as Java class
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- Class<?> getJavaType() throws ConnectorException;
-
- /**
- * Get nullability of this column.
- * @return Code indicating nullability
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @see #NOT_NULLABLE
- * @see #NULLABLE
- * @see #NULLABLE_UNKNOWN
- */
- int getNullability() throws ConnectorException;
-
- /**
- * Get default value of this element.
- * @return Default value, may be null
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- Object getDefaultValue() throws ConnectorException;
-
- /**
- * Get length of this element or 0 if no length is available.
- * @return Length of this element
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- */
- int getLength() throws ConnectorException;
-
- /**
- * Get precision of this column.
- * @return Precision
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @since 4.2
- */
- int getPrecision() throws ConnectorException;
-
- /**
- * Get scale of this column.
- * @return Scale
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @since 4.3.2
- */
- int getScale() throws ConnectorException;
-
- /**
- * Get the design-time model type name.
- * @return Model type name
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @since 5.0
- */
- String getModeledType() throws ConnectorException;
-
- /**
- * Get the base type of the design-time model type name.
- * @return Model base type name
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @since 5.0
- */
- String getModeledBaseType() throws ConnectorException;
-
- /**
- * Get the primitive type of the design-time model type name.
- * @return Model primitive type name
- * @throws ConnectorException If an error occurs retrieving the data
- * from runtime metadata
- * @since 5.0
- */
- String getModeledPrimitiveType() throws ConnectorException;
-
-}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,43 +24,41 @@
import java.util.Collection;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.Function;
+import org.teiid.connector.language.GroupBy;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.LanguageObject;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Limit;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetClause;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.Update;
/**
@@ -82,7 +80,7 @@
* @see HierarchyVisitor
* @param obj an ILanguageObject instance
*/
- public void visitNode(ILanguageObject obj) {
+ public void visitNode(LanguageObject obj) {
if (obj != null) {
obj.acceptVisitor(this);
}
@@ -93,9 +91,9 @@
* can be used by subclasses to visit each ILanguageObject in the Collection
* @param nodes a Collection of ILanguageObjects
*/
- public void visitNodes(Collection<? extends ILanguageObject> nodes) {
+ public void visitNodes(Collection<? extends LanguageObject> nodes) {
if (nodes != null && nodes.size() > 0) {
- for (ILanguageObject node : nodes) {
+ for (LanguageObject node : nodes) {
visitNode(node);
}
}
@@ -106,7 +104,7 @@
* subclasses to visit each ILanguageObject in the array.
* @param nodes an ILanguageObject[]
*/
- public void visitNodes(ILanguageObject[] nodes) {
+ public void visitNodes(LanguageObject[] nodes) {
if (nodes != null && nodes.length > 0) {
for (int i = 0; i < nodes.length; i++) {
visitNode(nodes[i]);
@@ -114,40 +112,38 @@
}
}
- public void visit(IAggregate obj) {}
- public void visit(IBatchedUpdates obj) {}
- public void visit(ICompareCriteria obj) {}
- public void visit(ICompoundCriteria obj) {}
- public void visit(IDelete obj) {}
- public void visit(IElement obj) {}
- public void visit(IProcedure obj) {}
- public void visit(IExistsCriteria obj) {}
- public void visit(IFrom obj) {}
- public void visit(IFunction obj) {}
- public void visit(IGroup obj) {}
- public void visit(IGroupBy obj) {}
- public void visit(IInCriteria obj) {}
- public void visit(IInlineView obj) {}
- public void visit(IInsert obj) {}
- public void visit(IInsertExpressionValueSource obj) {}
- public void visit(IIsNullCriteria obj) {}
- public void visit(IJoin obj) {}
- public void visit(ILikeCriteria obj) {}
- public void visit(ILimit obj) {}
- public void visit(ILiteral obj) {}
- public void visit(INotCriteria obj) {}
- public void visit(IOrderBy obj) {}
- public void visit(IOrderByItem obj) {}
- public void visit(IParameter obj) {}
- public void visit(IQuery obj) {}
- public void visit(IScalarSubquery obj) {}
- public void visit(ISearchedCaseExpression obj) {}
- public void visit(ISelect obj) {}
- public void visit(ISelectSymbol obj) {}
- public void visit(ISubqueryCompareCriteria obj) {}
- public void visit(ISubqueryInCriteria obj) {}
- public void visit(IUpdate obj) {}
- public void visit(ISetQuery obj) {}
- public void visit(ISetClauseList obj) {}
- public void visit(ISetClause obj) {}
+ public void visit(AggregateFunction obj) {}
+ public void visit(BatchedUpdates obj) {}
+ public void visit(Comparison obj) {}
+ public void visit(AndOr obj) {}
+ public void visit(Delete obj) {}
+ public void visit(ColumnReference obj) {}
+ public void visit(Call obj) {}
+ public void visit(Exists obj) {}
+ public void visit(Function obj) {}
+ public void visit(NamedTable obj) {}
+ public void visit(GroupBy obj) {}
+ public void visit(In obj) {}
+ public void visit(DerivedTable obj) {}
+ public void visit(Insert obj) {}
+ public void visit(ExpressionValueSource obj) {}
+ public void visit(IsNull obj) {}
+ public void visit(Join obj) {}
+ public void visit(Like obj) {}
+ public void visit(Limit obj) {}
+ public void visit(Literal obj) {}
+ public void visit(Not obj) {}
+ public void visit(OrderBy obj) {}
+ public void visit(SortSpecification obj) {}
+ public void visit(Argument obj) {}
+ public void visit(Select obj) {}
+ public void visit(ScalarSubquery obj) {}
+ public void visit(SearchedCase obj) {}
+ public void visit(DerivedColumn obj) {}
+ public void visit(SubqueryComparison obj) {}
+ public void visit(SubqueryIn obj) {}
+ public void visit(Update obj) {}
+ public void visit(SetQuery obj) {}
+ public void visit(SetClause obj) {}
+ public void visit(SearchedWhenClause obj) {}
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -23,42 +23,40 @@
package org.teiid.connector.visitor.framework;
import org.teiid.connector.DataPlugin;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.Function;
+import org.teiid.connector.language.GroupBy;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.LanguageObject;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Limit;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetClause;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.Update;
/**
* Delegates pre- and post-processing for each node in the hierarchy to
@@ -86,7 +84,7 @@
return preVisitor;
}
- public void visit(IAggregate obj) {
+ public void visit(AggregateFunction obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -96,7 +94,7 @@
}
}
- public void visit(IBatchedUpdates obj) {
+ public void visit(BatchedUpdates obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -106,7 +104,7 @@
}
}
- public void visit(ICompareCriteria obj) {
+ public void visit(Comparison obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -115,7 +113,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ICompoundCriteria obj) {
+ public void visit(AndOr obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -124,7 +122,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IDelete obj) {
+ public void visit(Delete obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -133,7 +131,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IElement obj) {
+ public void visit(ColumnReference obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -142,7 +140,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IProcedure obj) {
+ public void visit(Call obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -154,7 +152,7 @@
/*
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExistsCriteria)
*/
- public void visit(IExistsCriteria obj) {
+ public void visit(Exists obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -163,25 +161,16 @@
postVisitor.visit(obj);
}
}
- public void visit(IFrom obj) {
+ public void visit(Function obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
super.visit(obj);
if (postVisitor != null) {
postVisitor.visit(obj);
- }
- }
- public void visit(IFunction obj) {
- if (preVisitor != null) {
- preVisitor.visit(obj);
}
- super.visit(obj);
- if (postVisitor != null) {
- postVisitor.visit(obj);
- }
}
- public void visit(IGroup obj) {
+ public void visit(NamedTable obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -190,7 +179,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IGroupBy obj) {
+ public void visit(GroupBy obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -199,7 +188,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IInCriteria obj) {
+ public void visit(In obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -209,7 +198,7 @@
}
}
- public void visit(IInlineView obj) {
+ public void visit(DerivedTable obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -219,7 +208,7 @@
}
}
- public void visit(IInsert obj) {
+ public void visit(Insert obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -228,7 +217,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IIsNullCriteria obj) {
+ public void visit(IsNull obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -237,7 +226,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IJoin obj) {
+ public void visit(Join obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -246,7 +235,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ILikeCriteria obj) {
+ public void visit(Like obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -255,7 +244,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ILimit obj) {
+ public void visit(Limit obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -264,7 +253,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ILiteral obj) {
+ public void visit(Literal obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -273,7 +262,7 @@
postVisitor.visit(obj);
}
}
- public void visit(INotCriteria obj) {
+ public void visit(Not obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -282,7 +271,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IOrderBy obj) {
+ public void visit(OrderBy obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -291,7 +280,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IOrderByItem obj) {
+ public void visit(SortSpecification obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -300,7 +289,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IParameter obj) {
+ public void visit(Argument obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -309,7 +298,7 @@
postVisitor.visit(obj);
}
}
- public void visit(IQuery obj) {
+ public void visit(Select obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -319,10 +308,7 @@
}
}
- /*
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IScalarSubquery)
- */
- public void visit(IScalarSubquery obj) {
+ public void visit(ScalarSubquery obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -331,7 +317,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ISearchedCaseExpression obj) {
+ public void visit(SearchedCase obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -340,7 +326,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ISelect obj) {
+ public void visit(DerivedColumn obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -349,7 +335,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ISelectSymbol obj) {
+ public void visit(SubqueryComparison obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -358,7 +344,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ISubqueryCompareCriteria obj) {
+ public void visit(SubqueryIn obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -367,18 +353,8 @@
postVisitor.visit(obj);
}
}
- public void visit(ISubqueryInCriteria obj) {
- if (preVisitor != null) {
- preVisitor.visit(obj);
- }
- super.visit(obj);
- if (postVisitor != null) {
- postVisitor.visit(obj);
- }
- }
-
- public void visit(ISetQuery obj) {
+ public void visit(SetQuery obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -388,7 +364,7 @@
}
}
- public void visit(IUpdate obj) {
+ public void visit(Update obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -399,7 +375,7 @@
}
@Override
- public void visit(ISetClauseList obj) {
+ public void visit(SetClause obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -407,12 +383,11 @@
if (postVisitor != null) {
postVisitor.visit(obj);
}
-
}
@Override
- public void visit(ISetClause obj) {
- if (preVisitor != null) {
+ public void visit(SearchedWhenClause obj) {
+ if (preVisitor != null) {
preVisitor.visit(obj);
}
super.visit(obj);
@@ -430,7 +405,7 @@
* @param behaviorVisitor The visitor specifying what behavior is performed at each node type
* @param object The root of the object tree to perform visitation on
*/
- public static void preOrderVisit(LanguageObjectVisitor behaviorVisitor, ILanguageObject object) {
+ public static void preOrderVisit(LanguageObjectVisitor behaviorVisitor, LanguageObject object) {
DelegatingHierarchyVisitor hierarchyVisitor = new DelegatingHierarchyVisitor(behaviorVisitor, null);
object.acceptVisitor(hierarchyVisitor);
}
@@ -444,7 +419,7 @@
* @param behaviorVisitor The visitor specifying what behavior is performed at each node type
* @param object The root of the object tree to perform visitation on
*/
- public static void postOrderVisit(LanguageObjectVisitor behaviorVisitor, ILanguageObject object) {
+ public static void postOrderVisit(LanguageObjectVisitor behaviorVisitor, LanguageObject object) {
DelegatingHierarchyVisitor hierarchyVisitor = new DelegatingHierarchyVisitor(null, behaviorVisitor);
object.acceptVisitor(hierarchyVisitor);
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -22,37 +22,35 @@
package org.teiid.connector.visitor.framework;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.Function;
+import org.teiid.connector.language.GroupBy;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.QueryExpression;
+import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetClause;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.Update;
/**
* Visits each node in a hierarchy of ILanguageObjects. The default
@@ -77,96 +75,91 @@
this.visitSubcommands = visitSubcommands;
}
- public void visit(IAggregate obj) {
+ public void visit(AggregateFunction obj) {
visitNode(obj.getExpression());
}
- public void visit(IBatchedUpdates obj) {
+ public void visit(BatchedUpdates obj) {
visitNodes(obj.getUpdateCommands());
}
- public void visit(ICompareCriteria obj) {
+ public void visit(Comparison obj) {
visitNode(obj.getLeftExpression());
visitNode(obj.getRightExpression());
}
- public void visit(ICompoundCriteria obj) {
- visitNodes(obj.getCriteria());
+ public void visit(AndOr obj) {
+ visitNode(obj.getLeftCondition());
+ visitNode(obj.getRightCondition());
}
- public void visit(IDelete obj) {
- visitNode(obj.getGroup());
- visitNode(obj.getCriteria());
+ public void visit(Delete obj) {
+ visitNode(obj.getTable());
+ visitNode(obj.getWhere());
}
- public void visit(IProcedure obj) {
- visitNodes(obj.getParameters());
+ public void visit(Call obj) {
+ visitNodes(obj.getArguments());
}
- public void visit(IExistsCriteria obj) {
+ public void visit(Exists obj) {
if (visitSubcommands) {
- visitNode(obj.getQuery());
+ visitNode(obj.getSubquery());
}
}
- public void visit(IFrom obj) {
- visitNodes(obj.getItems());
- }
-
- public void visit(IFunction obj) {
+ public void visit(Function obj) {
visitNodes(obj.getParameters());
}
- public void visit(IGroupBy obj) {
+ public void visit(GroupBy obj) {
visitNodes(obj.getElements());
}
- public void visit(IInCriteria obj) {
+ public void visit(In obj) {
visitNode(obj.getLeftExpression());
visitNodes(obj.getRightExpressions());
}
- public void visit(IInsert obj) {
- visitNode(obj.getGroup());
- visitNodes(obj.getElements());
- if (!(obj.getValueSource() instanceof IQueryCommand) || visitSubcommands) {
+ public void visit(Insert obj) {
+ visitNode(obj.getTable());
+ visitNodes(obj.getColumns());
+ if (!(obj.getValueSource() instanceof QueryExpression) || visitSubcommands) {
visitNode(obj.getValueSource());
}
}
@Override
- public void visit(IInsertExpressionValueSource obj) {
+ public void visit(ExpressionValueSource obj) {
visitNodes(obj.getValues());
}
- public void visit(IIsNullCriteria obj) {
+ public void visit(IsNull obj) {
visitNode(obj.getExpression());
}
- public void visit(IJoin obj) {
+ public void visit(Join obj) {
visitNode(obj.getLeftItem());
visitNode(obj.getRightItem());
- if(obj.getCriteria() != null) {
- visitNodes(obj.getCriteria());
- }
+ visitNode(obj.getCondition());
}
- public void visit(ILikeCriteria obj) {
+ public void visit(Like obj) {
visitNode(obj.getLeftExpression());
visitNode(obj.getRightExpression());
}
- public void visit(INotCriteria obj) {
+ public void visit(Not obj) {
visitNode(obj.getCriteria());
}
- public void visit(IOrderBy obj) {
- visitNodes(obj.getItems());
+ public void visit(OrderBy obj) {
+ visitNodes(obj.getSortSpecifications());
}
- public void visit(IQuery obj) {
- visitNode(obj.getSelect());
- visitNode(obj.getFrom());
+ public void visit(Select obj) {
+ visitNodes(obj.getDerivedColumns());
+ visitNodes(obj.getFrom());
visitNode(obj.getWhere());
visitNode(obj.getGroupBy());
visitNode(obj.getHaving());
@@ -174,44 +167,42 @@
visitNode(obj.getLimit());
}
- public void visit(IScalarSubquery obj) {
+ public void visit(ScalarSubquery obj) {
if (visitSubcommands) {
- visitNode(obj.getQuery());
+ visitNode(obj.getSubquery());
}
}
- public void visit(ISearchedCaseExpression obj) {
- int whenCount = obj.getWhenCount();
- for (int i = 0; i < whenCount; i++) {
- visitNode(obj.getWhenCriteria(i));
- visitNode(obj.getThenExpression(i));
- }
+ public void visit(SearchedCase obj) {
+ visitNodes(obj.getCases());
visitNode(obj.getElseExpression());
}
- public void visit(ISelect obj) {
- visitNodes(obj.getSelectSymbols());
+ @Override
+ public void visit(SearchedWhenClause obj) {
+ visitNode(obj.getCondition());
+ visitNode(obj.getResult());
}
- public void visit(ISelectSymbol obj) {
+ public void visit(DerivedColumn obj) {
visitNode(obj.getExpression());
}
- public void visit(ISubqueryCompareCriteria obj) {
+ public void visit(SubqueryComparison obj) {
visitNode(obj.getLeftExpression());
if (visitSubcommands) {
- visitNode(obj.getQuery());
+ visitNode(obj.getSubquery());
}
}
- public void visit(ISubqueryInCriteria obj) {
+ public void visit(SubqueryIn obj) {
visitNode(obj.getLeftExpression());
if (visitSubcommands) {
- visitNode(obj.getQuery());
+ visitNode(obj.getSubquery());
}
}
- public void visit(ISetQuery obj) {
+ public void visit(SetQuery obj) {
if (visitSubcommands) {
visitNode(obj.getLeftQuery());
visitNode(obj.getRightQuery());
@@ -220,26 +211,21 @@
visitNode(obj.getLimit());
}
- public void visit(IUpdate obj) {
- visitNode(obj.getGroup());
- visitNode(obj.getChanges());
- visitNode(obj.getCriteria());
+ public void visit(Update obj) {
+ visitNode(obj.getTable());
+ visitNodes(obj.getChanges());
+ visitNode(obj.getWhere());
}
@Override
- public void visit(IInlineView obj) {
+ public void visit(DerivedTable obj) {
if (visitSubcommands) {
visitNode(obj.getQuery());
}
}
@Override
- public void visit(ISetClauseList obj) {
- visitNodes(obj.getClauses());
- }
-
- @Override
- public void visit(ISetClause obj) {
+ public void visit(SetClause obj) {
visitNode(obj.getSymbol());
visitNode(obj.getValue());
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -27,40 +27,38 @@
/**
*/
public interface LanguageObjectVisitor {
- public void visit(IAggregate obj);
- public void visit(IBatchedUpdates obj);
- public void visit(IInsertExpressionValueSource obj);
- public void visit(ICompareCriteria obj);
- public void visit(ICompoundCriteria obj);
- public void visit(IDelete obj);
- public void visit(IElement obj);
- public void visit(IProcedure obj);
- public void visit(IExistsCriteria obj);
- public void visit(IFrom obj);
- public void visit(IFunction obj);
- public void visit(IGroup obj);
- public void visit(IGroupBy obj);
- public void visit(IInCriteria obj);
- public void visit(IInlineView obj);
- public void visit(IInsert obj);
- public void visit(IIsNullCriteria obj);
- public void visit(IJoin obj);
- public void visit(ILikeCriteria obj);
- public void visit(ILimit obj);
- public void visit(ILiteral obj);
- public void visit(INotCriteria obj);
- public void visit(IOrderBy obj);
- public void visit(IOrderByItem obj);
- public void visit(IParameter obj);
- public void visit(IQuery obj);
- public void visit(IScalarSubquery obj);
- public void visit(ISearchedCaseExpression obj);
- public void visit(ISelect obj);
- public void visit(ISelectSymbol obj);
- public void visit(ISubqueryCompareCriteria obj);
- public void visit(ISubqueryInCriteria obj);
- public void visit(IUpdate obj);
- public void visit(ISetQuery obj);
- public void visit(ISetClauseList obj);
- public void visit(ISetClause obj);
+ public void visit(AggregateFunction obj);
+ public void visit(BatchedUpdates obj);
+ public void visit(ExpressionValueSource obj);
+ public void visit(Comparison obj);
+ public void visit(AndOr obj);
+ public void visit(Delete obj);
+ public void visit(ColumnReference obj);
+ public void visit(Call obj);
+ public void visit(Exists obj);
+ public void visit(Function obj);
+ public void visit(NamedTable obj);
+ public void visit(GroupBy obj);
+ public void visit(In obj);
+ public void visit(DerivedTable obj);
+ public void visit(Insert obj);
+ public void visit(IsNull obj);
+ public void visit(Join obj);
+ public void visit(Like obj);
+ public void visit(Limit obj);
+ public void visit(Literal obj);
+ public void visit(Not obj);
+ public void visit(OrderBy obj);
+ public void visit(SortSpecification obj);
+ public void visit(Argument obj);
+ public void visit(Select obj);
+ public void visit(ScalarSubquery obj);
+ public void visit(SearchedCase obj);
+ public void visit(DerivedColumn obj);
+ public void visit(SubqueryComparison obj);
+ public void visit(SubqueryIn obj);
+ public void visit(Update obj);
+ public void visit(SetQuery obj);
+ public void visit(SetClause obj);
+ public void visit(SearchedWhenClause obj);
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -27,43 +27,41 @@
import java.util.HashSet;
import java.util.Set;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.Function;
+import org.teiid.connector.language.GroupBy;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.LanguageObject;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Limit;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetClause;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.Update;
import org.teiid.connector.visitor.framework.DelegatingHierarchyVisitor;
import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
@@ -83,7 +81,7 @@
}
@SuppressWarnings("unchecked")
- private void checkInstance(ILanguageObject obj) {
+ private void checkInstance(LanguageObject obj) {
if(type.isInstance(obj)) {
this.objects.add((T)obj);
}
@@ -93,246 +91,142 @@
return this.objects;
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IAggregate)
- */
- public void visit(IAggregate obj) {
+ public void visit(AggregateFunction obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IBatchedUpdates)
- * @since 4.2
- */
- public void visit(IBatchedUpdates obj) {
+ public void visit(BatchedUpdates obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICompareCriteria)
- */
- public void visit(ICompareCriteria obj) {
+ public void visit(Comparison obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICompoundCriteria)
- */
- public void visit(ICompoundCriteria obj) {
+ public void visit(AndOr obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IDelete)
- */
- public void visit(IDelete obj) {
+ public void visit(Delete obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IElement)
- */
- public void visit(IElement obj) {
+ public void visit(ColumnReference obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExistsCriteria)
- */
- public void visit(IExistsCriteria obj) {
+ public void visit(Exists obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IFrom)
- */
- public void visit(IFrom obj) {
+ public void visit(Function obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IFunction)
- */
- public void visit(IFunction obj) {
+ public void visit(NamedTable obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IGroup)
- */
- public void visit(IGroup obj) {
+ public void visit(GroupBy obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IGroupBy)
- */
- public void visit(IGroupBy obj) {
+ public void visit(In obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IInCriteria)
- */
- public void visit(IInCriteria obj) {
+ public void visit(DerivedTable obj) {
checkInstance(obj);
}
- public void visit(IInlineView obj) {
+ public void visit(Insert obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IInsert)
- */
- public void visit(IInsert obj) {
+ public void visit(ExpressionValueSource obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IBulkInsert)
- */
- public void visit(IInsertExpressionValueSource obj) {
+ public void visit(IsNull obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IIsNullCriteria)
- */
- public void visit(IIsNullCriteria obj) {
- checkInstance(obj);
- }
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IJoin)
- */
- public void visit(IJoin obj) {
+ public void visit(Join obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ILikeCriteria)
- */
- public void visit(ILikeCriteria obj) {
+ public void visit(Like obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ILimit)
- */
- public void visit(ILimit obj) {
+ public void visit(Limit obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ILiteral)
- */
- public void visit(ILiteral obj) {
+ public void visit(Literal obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.INotCriteria)
- */
- public void visit(INotCriteria obj) {
+ public void visit(Not obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IOrderBy)
- */
- public void visit(IOrderBy obj) {
+ public void visit(OrderBy obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IOrderByItem)
- */
- public void visit(IOrderByItem obj) {
+ public void visit(SortSpecification obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IParameter)
- */
- public void visit(IParameter obj) {
+ public void visit(Argument obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IProcedure)
- */
- public void visit(IProcedure obj) {
+ public void visit(Call obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IQuery)
- */
- public void visit(IQuery obj) {
+ public void visit(Select obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IScalarSubquery)
- */
- public void visit(IScalarSubquery obj) {
+ public void visit(ScalarSubquery obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISearchedCaseExpression)
- */
- public void visit(ISearchedCaseExpression obj) {
+ public void visit(SearchedCase obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISelect)
- */
- public void visit(ISelect obj) {
+ public void visit(DerivedColumn obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISelectSymbol)
- */
- public void visit(ISelectSymbol obj) {
+ public void visit(SubqueryComparison obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISubqueryCompareCriteria)
- */
- public void visit(ISubqueryCompareCriteria obj) {
+ public void visit(SubqueryIn obj) {
checkInstance(obj);
}
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISubqueryInCriteria)
- */
- public void visit(ISubqueryInCriteria obj) {
+ public void visit(Update obj) {
checkInstance(obj);
}
-
- /*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.IUpdate)
- */
- public void visit(IUpdate obj) {
- checkInstance(obj);
- }
- public void visit(ISetQuery obj) {
+ public void visit(SetQuery obj) {
checkInstance(obj);
}
@Override
- public void visit(ISetClauseList obj) {
+ public void visit(SetClause obj) {
checkInstance(obj);
}
@Override
- public void visit(ISetClause obj) {
- checkInstance(obj);
+ public void visit(SearchedWhenClause obj) {
+ checkInstance(obj);
}
/**
@@ -343,7 +237,7 @@
* @param object Root of the language object tree
* @return Collection of ILanguageObject of the specified type
*/
- public static <T> Collection<T> collectObjects(Class<T> type, ILanguageObject object) {
+ public static <T> Collection<T> collectObjects(Class<T> type, LanguageObject object) {
CollectorVisitor<T> visitor = new CollectorVisitor<T>(type);
DelegatingHierarchyVisitor hierarchyVisitor = new DelegatingHierarchyVisitor(visitor, null);
object.acceptVisitor(hierarchyVisitor);
@@ -357,8 +251,8 @@
* @param object Root of the language object tree
* @return Collection of IElement of the specified type
*/
- public static Collection<IElement> collectElements(ILanguageObject object) {
- return CollectorVisitor.collectObjects(IElement.class, object);
+ public static Collection<ColumnReference> collectElements(LanguageObject object) {
+ return CollectorVisitor.collectObjects(ColumnReference.class, object);
}
/**
@@ -368,8 +262,8 @@
* @param object Root of the language object tree
* @return Collection of IGroup of the specified type
*/
- public static Collection<IGroup> collectGroups(ILanguageObject object) {
- return CollectorVisitor.collectObjects(IGroup.class, object);
+ public static Collection<NamedTable> collectGroups(LanguageObject object) {
+ return CollectorVisitor.collectObjects(NamedTable.class, object);
}
/**
@@ -379,11 +273,11 @@
* @param object Root of the language object tree
* @return Set of IGroup
*/
- public static Set<IGroup> collectGroupsUsedByElements(ILanguageObject object) {
- Set<IGroup> groups = new HashSet<IGroup>();
- for (IElement element : CollectorVisitor.collectElements(object)) {
- if(element.getGroup() != null) {
- groups.add(element.getGroup());
+ public static Set<NamedTable> collectGroupsUsedByElements(LanguageObject object) {
+ Set<NamedTable> groups = new HashSet<NamedTable>();
+ for (ColumnReference element : CollectorVisitor.collectElements(object)) {
+ if(element.getTable() != null) {
+ groups.add(element.getTable());
}
}
return groups;
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,191 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.visitor.util;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class SQLReservedWords {
-
- public static final String ANY = "ANY"; //$NON-NLS-1$
- public static final String ALL = "ALL"; //$NON-NLS-1$
- public static final String ALL_COLS = "*"; //$NON-NLS-1$
- public static final String AND = "AND"; //$NON-NLS-1$
- public static final String AS = "AS"; //$NON-NLS-1$
- public static final String ASC = "ASC"; //$NON-NLS-1$
- public static final String AVG = "AVG"; //$NON-NLS-1$
- public static final String BEGIN = "BEGIN"; //$NON-NLS-1$
- public static final String BETWEEN = "BETWEEN"; //$NON-NLS-1$
- public static final String BIGDECIMAL = "BIGDECIMAL"; //$NON-NLS-1$
- public static final String BIGINTEGER = "BIGINTEGER"; //$NON-NLS-1$
- public static final String BREAK = "BREAK"; //$NON-NLS-1$
- public static final String BY = "BY"; //$NON-NLS-1$
- public static final String BYTE = "BYTE"; //$NON-NLS-1$
- public static final String CASE = "CASE"; //$NON-NLS-1$
- public static final String CAST = "CAST"; //$NON-NLS-1$
- public static final String CHAR = "CHAR"; //$NON-NLS-1$
- public static final String CONVERT = "CONVERT"; //$NON-NLS-1$
- public static final String CONTINUE = "CONTINUE"; //$NON-NLS-1$
- public static final String COUNT = "COUNT"; //$NON-NLS-1$
- public static final String CRITERIA = "CRITERIA"; //$NON-NLS-1$
- public static final String CREATE = "CREATE"; //$NON-NLS-1$
- public static final String CROSS = "CROSS"; //$NON-NLS-1$
- public static final String DATE = "DATE"; //$NON-NLS-1$
- public static final String DEBUG = "DEBUG"; //$NON-NLS-1$
- public static final String DECLARE = "DECLARE"; //$NON-NLS-1$
- public static final String DELETE = "DELETE"; //$NON-NLS-1$
- public static final String DESC = "DESC"; //$NON-NLS-1$
- public static final String DISTINCT = "DISTINCT"; //$NON-NLS-1$
- public static final String DOUBLE = "DOUBLE"; //$NON-NLS-1$
- public static final String ELSE = "ELSE"; //$NON-NLS-1$
- public static final String END = "END"; //$NON-NLS-1$
- public static final String ERROR = "ERROR"; //$NON-NLS-1$
- public static final String ESCAPE = "ESCAPE"; //$NON-NLS-1$
- public static final String EXCEPT = "EXCEPT"; //$NON-NLS-1$
- public static final String EXEC = "EXEC"; //$NON-NLS-1$
- public static final String EXECUTE = "EXECUTE"; //$NON-NLS-1$
- public static final String EXISTS = "EXISTS"; //$NON-NLS-1$
- public static final String FALSE = "FALSE"; //$NON-NLS-1$
- public static final String FLOAT = "FLOAT"; //$NON-NLS-1$
- public static final String FOR = "FOR"; //$NON-NLS-1$
- public static final String FROM = "FROM"; //$NON-NLS-1$
- public static final String FULL = "FULL"; //$NON-NLS-1$
- public static final String GROUP = "GROUP"; //$NON-NLS-1$
- public static final String HAS = "HAS"; //$NON-NLS-1$
- public static final String HAVING = "HAVING"; //$NON-NLS-1$
- public static final String IF = "IF"; //$NON-NLS-1$
- public static final String IN = "IN"; //$NON-NLS-1$
- public static final String INNER = "INNER"; //$NON-NLS-1$
- public static final String INSERT = "INSERT"; //$NON-NLS-1$
- public static final String INTEGER = "INTEGER"; //$NON-NLS-1$
- public static final String INTERSECT = "INTERSECT"; //$NON-NLS-1$
- public static final String INTO = "INTO"; //$NON-NLS-1$
- public static final String IS = "IS"; //$NON-NLS-1$
- public static final String JOIN = "JOIN"; //$NON-NLS-1$
- public static final String LEFT = "LEFT"; //$NON-NLS-1$
- public static final String LIKE = "LIKE"; //$NON-NLS-1$
- public static final String LIMIT = "LIMIT"; //$NON-NLS-1$
- public static final String LONG = "LONG"; //$NON-NLS-1$
- public static final String LOOP = "LOOP"; //$NON-NLS-1$
- public static final String MAKEDEP = "MAKEDEP"; //$NON-NLS-1$
- public static final String MIN = "MIN"; //$NON-NLS-1$
- public static final String MAX = "MAX"; //$NON-NLS-1$
- public static final String NOT = "NOT"; //$NON-NLS-1$
- public static final String NULL = "NULL"; //$NON-NLS-1$
- public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
- public static final String ON = "ON"; //$NON-NLS-1$
- public static final String OR = "OR"; //$NON-NLS-1$
- public static final String ORDER = "ORDER"; //$NON-NLS-1$
- public static final String OPTION = "OPTION"; //$NON-NLS-1$
- public static final String OUTER = "OUTER"; //$NON-NLS-1$
- public static final String PROCEDURE = "PROCEDURE"; //$NON-NLS-1$
- public static final String RIGHT = "RIGHT"; //$NON-NLS-1$
- public static final String SELECT = "SELECT"; //$NON-NLS-1$
- public static final String SET = "SET"; //$NON-NLS-1$
- public static final String SHORT = "SHORT"; //$NON-NLS-1$
- public static final String SHOWPLAN = "SHOWPLAN"; //$NON-NLS-1$
- public static final String SOME = "SOME"; //$NON-NLS-1$
- public static final String SQL_TSI_FRAC_SECOND = "SQL_TSI_FRAC_SECOND"; //$NON-NLS-1$
- public static final String SQL_TSI_SECOND = "SQL_TSI_SECOND"; //$NON-NLS-1$
- public static final String SQL_TSI_MINUTE = "SQL_TSI_MINUTE"; //$NON-NLS-1$
- public static final String SQL_TSI_HOUR = "SQL_TSI_HOUR"; //$NON-NLS-1$
- public static final String SQL_TSI_DAY = "SQL_TSI_DAY"; //$NON-NLS-1$
- public static final String SQL_TSI_WEEK = "SQL_TSI_WEEK"; //$NON-NLS-1$
- public static final String SQL_TSI_MONTH = "SQL_TSI_MONTH"; //$NON-NLS-1$
- public static final String SQL_TSI_QUARTER = "SQL_TSI_QUARTER"; //$NON-NLS-1$
- public static final String SQL_TSI_YEAR = "SQL_TSI_YEAR"; //$NON-NLS-1$
- public static final String STRING = "STRING"; //$NON-NLS-1$
- public static final String SUM = "SUM"; //$NON-NLS-1$
- public static final String THEN = "THEN"; //$NON-NLS-1$
- public static final String TIME = "TIME"; //$NON-NLS-1$
- public static final String TIMESTAMP = "TIMESTAMP"; //$NON-NLS-1$
- public static final String TIMESTAMPADD = "TIMESTAMPADD"; //$NON-NLS-1$
- public static final String TIMESTAMPDIFF = "TIMESTAMPDIFF"; //$NON-NLS-1$
- public static final String TRANSLATE = "TRANSLATE"; //$NON-NLS-1$
- public static final String TRUE = "TRUE"; //$NON-NLS-1$
- public static final String UNION = "UNION"; //$NON-NLS-1$
- public static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
- public static final String UPDATE = "UPDATE"; //$NON-NLS-1$
- public static final String USING = "USING"; //$NON-NLS-1$
- public static final String VALUES = "VALUES"; //$NON-NLS-1$
- public static final String VIRTUAL = "VIRTUAL"; //$NON-NLS-1$
- public static final String WHEN = "WHEN"; //$NON-NLS-1$
- public static final String WITH = "WITH"; //$NON-NLS-1$
- public static final String WHERE = "WHERE"; //$NON-NLS-1$
- public static final String WHILE = "WHILE"; //$NON-NLS-1$
-
- public static final String SPACE = " "; //$NON-NLS-1$
- public static final String COMMA = ","; //$NON-NLS-1$
- public static final String DOT = "."; //$NON-NLS-1$
- public static final String QUOTE = "'"; //$NON-NLS-1$
-
- public static final String EQ = "="; //$NON-NLS-1$
- public static final String NE = "<>"; //$NON-NLS-1$
- public static final String LT = "<"; //$NON-NLS-1$
- public static final String GT = ">"; //$NON-NLS-1$
- public static final String LE = "<="; //$NON-NLS-1$
- public static final String GE = ">="; //$NON-NLS-1$
-
- public static final String LPAREN = "("; //$NON-NLS-1$
- public static final String RPAREN = ")"; //$NON-NLS-1$
-
- public static final String[] ALL_WORDS = new String[] {ALL, ALL_COLS, AND, ANY, AS, ASC, AVG, BEGIN, BETWEEN, BIGINTEGER,
- BIGDECIMAL, BREAK, BY, BYTE, CASE, CAST, CHAR, CONVERT, CONTINUE, COUNT, CREATE, CRITERIA, CROSS, DATE, DEBUG, DECLARE,
- DELETE, DESC, DISTINCT, DOUBLE, ELSE, END, ERROR, ESCAPE, EXCEPT, EXEC, EXECUTE, EXISTS, FALSE, FLOAT, FOR, FROM, FULL,
- GROUP, HAS, HAVING, IF, IN, INNER, INSERT, INTEGER, INTERSECT, INTO, IS, JOIN, LEFT, LIKE, LONG, LOOP, MAKEDEP, MIN, MAX,
- NOT, NULL, OBJECT, ON, OR, ORDER, OPTION, OUTER, PROCEDURE, RIGHT, SELECT, SET, SHORT, SHOWPLAN, SOME,
- SQL_TSI_FRAC_SECOND, SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH,
- SQL_TSI_QUARTER, SQL_TSI_YEAR, STRING, SUM, THEN, TIME, TIMESTAMP, TIMESTAMPADD, TIMESTAMPDIFF, TRANSLATE, TRUE, UNION,
- UNKNOWN, UPDATE, USING, VALUES, VIRTUAL, WHEN, WITH, WHERE, WHILE,};
-
- /**
- * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
- */
- private static final Set RESERVED_WORDS = new HashSet();
-
- // Initialize RESERVED_WORDS set
- static {
- // Iterate through the reserved words and capitalize all of them
- for (int i = 0; i != SQLReservedWords.ALL_WORDS.length; ++i) {
- String reservedWord = SQLReservedWords.ALL_WORDS[i];
- SQLReservedWords.RESERVED_WORDS.add(reservedWord.toUpperCase());
- }
- }
-
- /** Can't construct */
- private SQLReservedWords() {
- }
-
- /**
- * Check whether a string is a reserved word.
- *
- * @param str String to check
- * @return True if reserved word, false if not or null
- */
- public static final boolean isReservedWord( String str ) {
- if (str == null) {
- return false;
- }
- return RESERVED_WORDS.contains(str.toUpperCase());
- }
-}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -24,55 +24,53 @@
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IPredicateCriteria;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.connector.metadata.runtime.MetadataObject;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Command;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Condition;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.Function;
+import org.teiid.connector.language.GroupBy;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.LanguageObject;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Limit;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.QueryExpression;
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetClause;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.TableReference;
+import org.teiid.connector.language.Update;
+import org.teiid.connector.language.Argument.Direction;
+import org.teiid.connector.language.SQLReservedWords.Tokens;
+import org.teiid.connector.language.SortSpecification.Ordering;
+import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.visitor.framework.AbstractLanguageVisitor;
import com.metamatrix.common.types.DataTypeManager;
@@ -97,23 +95,19 @@
* @param id the id of the group or element
* @return the name of that element or group as defined in the source
*/
- protected String getName(MetadataObject object) {
- try {
- String nameInSource = object.getNameInSource();
- if(nameInSource != null && nameInSource.length() > 0) {
- return nameInSource;
- }
- return object.getName();
- } catch(ConnectorException e) {
- return object.getName();
+ protected String getName(AbstractMetadataRecord object) {
+ String nameInSource = object.getNameInSource();
+ if(nameInSource != null && nameInSource.length() > 0) {
+ return nameInSource;
}
+ return object.getName();
}
/**
* Appends the string form of the ILanguageObject to the current buffer.
* @param obj the language object instance
*/
- public void append(ILanguageObject obj) {
+ public void append(LanguageObject obj) {
if (obj == null) {
buffer.append(UNDEFINED);
} else {
@@ -126,12 +120,12 @@
* by creating a comma-separated list.
* @param items a list of ILanguageObjects
*/
- protected void append(List<? extends ILanguageObject> items) {
+ protected void append(List<? extends LanguageObject> items) {
if (items != null && items.size() != 0) {
append(items.get(0));
for (int i = 1; i < items.size(); i++) {
- buffer.append(SQLReservedWords.COMMA)
- .append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.COMMA)
+ .append(Tokens.SPACE);
append(items.get(i));
}
}
@@ -142,12 +136,12 @@
* by creating a comma-separated list.
* @param items an array of ILanguageObjects
*/
- protected void append(ILanguageObject[] items) {
+ protected void append(LanguageObject[] items) {
if (items != null && items.length != 0) {
append(items[0]);
for (int i = 1; i < items.length; i++) {
- buffer.append(SQLReservedWords.COMMA)
- .append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.COMMA)
+ .append(Tokens.SPACE);
append(items[i]);
}
}
@@ -166,94 +160,69 @@
return buffer.toString();
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IAggregate)
- */
- public void visit(IAggregate obj) {
+ public void visit(AggregateFunction obj) {
buffer.append(obj.getName())
- .append(SQLReservedWords.LPAREN);
+ .append(Tokens.LPAREN);
if ( obj.isDistinct()) {
buffer.append(SQLReservedWords.DISTINCT)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
}
if (obj.getExpression() == null) {
- buffer.append(SQLReservedWords.ALL_COLS);
+ buffer.append(Tokens.ALL_COLS);
} else {
append(obj.getExpression());
}
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ICompareCriteria)
- */
- public void visit(ICompareCriteria obj) {
+ public void visit(Comparison obj) {
append(obj.getLeftExpression());
- buffer.append(SQLReservedWords.SPACE);
-
- switch(obj.getOperator()) {
- case EQ: buffer.append(SQLReservedWords.EQ); break;
- case GE: buffer.append(SQLReservedWords.GE); break;
- case GT: buffer.append(SQLReservedWords.GT); break;
- case LE: buffer.append(SQLReservedWords.LE); break;
- case LT: buffer.append(SQLReservedWords.LT); break;
- case NE: buffer.append(SQLReservedWords.NE); break;
- default: buffer.append(UNDEFINED);
- }
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
+ buffer.append(obj.getOperator());
+ buffer.append(Tokens.SPACE);
append(obj.getRightExpression());
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ICompoundCriteria)
- */
- public void visit(ICompoundCriteria obj) {
- String opString = null;
- switch(obj.getOperator()) {
- case AND: opString = SQLReservedWords.AND; break;
- case OR: opString = SQLReservedWords.OR; break;
- default: opString = UNDEFINED;
- }
-
- List criteria = obj.getCriteria();
- if (criteria == null || criteria.size() == 0) {
- buffer.append(UNDEFINED);
- } else if(criteria.size() == 1) {
- // Special case - should really never happen, but we are tolerant
- append((ILanguageObject)criteria.get(0));
- } else {
- buffer.append(SQLReservedWords.LPAREN);
- append((ILanguageObject)criteria.get(0));
- buffer.append(SQLReservedWords.RPAREN);
- for (int i = 1; i < criteria.size(); i++) {
- buffer.append(SQLReservedWords.SPACE)
- .append(opString)
- .append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.LPAREN);
- append((ILanguageObject)criteria.get(i));
- buffer.append(SQLReservedWords.RPAREN);
- }
-
- }
+ public void visit(AndOr obj) {
+ String opString = obj.getOperator().toString();
+
+ appendNestedCondition(obj, obj.getLeftCondition());
+ buffer.append(Tokens.SPACE)
+ .append(opString)
+ .append(Tokens.SPACE);
+ appendNestedCondition(obj, obj.getRightCondition());
}
+
+ protected void appendNestedCondition(AndOr parent, Condition condition) {
+ if (condition instanceof AndOr) {
+ AndOr nested = (AndOr)condition;
+ if (nested.getOperator() != parent.getOperator()) {
+ buffer.append(Tokens.LPAREN);
+ append(condition);
+ buffer.append(Tokens.RPAREN);
+ return;
+ }
+ }
+ append(condition);
+ }
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IDelete)
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.Delete)
*/
- public void visit(IDelete obj) {
+ public void visit(Delete obj) {
buffer.append(SQLReservedWords.DELETE)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
buffer.append(getSourceComment(obj));
buffer.append(SQLReservedWords.FROM)
- .append(SQLReservedWords.SPACE);
- append(obj.getGroup());
- if (obj.getCriteria() != null) {
- buffer.append(SQLReservedWords.SPACE)
+ .append(Tokens.SPACE);
+ append(obj.getTable());
+ if (obj.getWhere() != null) {
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.WHERE)
- .append(SQLReservedWords.SPACE);
- append(obj.getCriteria());
+ .append(Tokens.SPACE);
+ append(obj.getWhere());
}
}
@@ -278,30 +247,30 @@
}
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IElement)
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ColumnReference)
*/
- public void visit(IElement obj) {
+ public void visit(ColumnReference obj) {
buffer.append(getElementName(obj, true));
}
- private String getElementName(IElement obj, boolean qualify) {
+ private String getElementName(ColumnReference obj, boolean qualify) {
String groupName = null;
- IGroup group = obj.getGroup();
+ NamedTable group = obj.getTable();
if (group != null && qualify) {
- if(group.getDefinition() != null) {
- groupName = group.getContext();
+ if(group.getCorrelationName() != null) {
+ groupName = group.getCorrelationName();
} else {
- MetadataObject groupID = group.getMetadataObject();
+ AbstractMetadataRecord groupID = group.getMetadataObject();
if(groupID != null) {
groupName = getName(groupID);
} else {
- groupName = group.getContext();
+ groupName = group.getName();
}
}
}
String elemShortName = null;
- MetadataObject elementID = obj.getMetadataObject();
+ AbstractMetadataRecord elementID = obj.getMetadataObject();
if(elementID != null) {
elemShortName = getName(elementID);
} else {
@@ -319,7 +288,7 @@
// If not, do normal logic: [group + "."] + element
if(groupName != null) {
elementName.append(groupName);
- elementName.append(SQLReservedWords.DOT);
+ elementName.append(Tokens.DOT);
}
elementName.append(elemShortName);
return elementName.toString();
@@ -341,9 +310,9 @@
/**
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExecute)
*/
- public void visit(IProcedure obj) {
+ public void visit(Call obj) {
buffer.append(SQLReservedWords.EXEC)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
if(obj.getMetadataObject() != null) {
buffer.append(getName(obj.getMetadataObject()));
@@ -351,139 +320,119 @@
buffer.append(obj.getProcedureName());
}
- buffer.append(SQLReservedWords.LPAREN);
- final List params = obj.getParameters();
+ buffer.append(Tokens.LPAREN);
+ final List<Argument> params = obj.getArguments();
if (params != null && params.size() != 0) {
- IParameter param = null;
+ Argument param = null;
for (int i = 0; i < params.size(); i++) {
- param = (IParameter)params.get(i);
+ param = params.get(i);
if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) {
if (i != 0) {
- buffer.append(SQLReservedWords.COMMA)
- .append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.COMMA)
+ .append(Tokens.SPACE);
}
- if (param.getValue() != null) {
- buffer.append(param.getValue().toString());
- } else {
- buffer.append(UNDEFINED_PARAM);
- }
+ append(param);
}
}
}
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
}
/*
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExistsCriteria)
*/
- public void visit(IExistsCriteria obj) {
+ public void visit(Exists obj) {
buffer.append(SQLReservedWords.EXISTS)
- .append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.LPAREN);
- append(obj.getQuery());
- buffer.append(SQLReservedWords.RPAREN);
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IFrom)
- */
- public void visit(IFrom obj) {
- buffer.append(SQLReservedWords.FROM)
- .append(SQLReservedWords.SPACE);
- append(obj.getItems());
- }
-
protected boolean isInfixFunction(String function) {
return infixFunctions.contains(function);
}
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IFunction)
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.Function)
*/
- public void visit(IFunction obj) {
+ public void visit(Function obj) {
String name = obj.getName();
- List<IExpression> args = obj.getParameters();
+ List<Expression> args = obj.getParameters();
if(name.equalsIgnoreCase(SQLReservedWords.CONVERT) || name.equalsIgnoreCase(SQLReservedWords.CAST)) {
- Object typeValue = ((ILiteral)args.get(1)).getValue();
+ Object typeValue = ((Literal)args.get(1)).getValue();
buffer.append(name);
- buffer.append(SQLReservedWords.LPAREN);
+ buffer.append(Tokens.LPAREN);
append(args.get(0));
if(name.equalsIgnoreCase(SQLReservedWords.CONVERT)) {
- buffer.append(SQLReservedWords.COMMA);
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.COMMA);
+ buffer.append(Tokens.SPACE);
} else {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
buffer.append(SQLReservedWords.AS);
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
}
buffer.append(typeValue);
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
} else if(isInfixFunction(name)) {
- buffer.append(SQLReservedWords.LPAREN);
+ buffer.append(Tokens.LPAREN);
if(args != null) {
for(int i=0; i<args.size(); i++) {
append(args.get(i));
if(i < (args.size()-1)) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
buffer.append(name);
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
}
}
}
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
} else if(name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPDIFF)) {
buffer.append(name);
- buffer.append(SQLReservedWords.LPAREN);
+ buffer.append(Tokens.LPAREN);
if(args != null && args.size() > 0) {
- buffer.append(((ILiteral)args.get(0)).getValue());
+ buffer.append(((Literal)args.get(0)).getValue());
for(int i=1; i<args.size(); i++) {
- buffer.append(SQLReservedWords.COMMA);
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.COMMA);
+ buffer.append(Tokens.SPACE);
append(args.get(i));
}
}
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
} else {
buffer.append(obj.getName())
- .append(SQLReservedWords.LPAREN);
+ .append(Tokens.LPAREN);
append(obj.getParameters());
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
}
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IGroup)
- */
- public void visit(IGroup obj) {
- MetadataObject groupID = obj.getMetadataObject();
+ public void visit(NamedTable obj) {
+ AbstractMetadataRecord groupID = obj.getMetadataObject();
if(groupID != null) {
buffer.append(getName(groupID));
} else {
- if(obj.getDefinition() == null) {
- buffer.append(obj.getContext());
- } else {
- buffer.append(obj.getDefinition());
- }
+ buffer.append(obj.getName());
}
- if (obj.getDefinition() != null) {
- buffer.append(SQLReservedWords.SPACE);
+ if (obj.getCorrelationName() != null) {
+ buffer.append(Tokens.SPACE);
if (useAsInGroupAlias()){
buffer.append(SQLReservedWords.AS)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
}
- buffer.append(obj.getContext());
+ buffer.append(obj.getCorrelationName());
}
}
@@ -499,110 +448,98 @@
}
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IGroupBy)
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.GroupBy)
*/
- public void visit(IGroupBy obj) {
+ public void visit(GroupBy obj) {
buffer.append(SQLReservedWords.GROUP)
- .append(SQLReservedWords.SPACE)
+ .append(Tokens.SPACE)
.append(SQLReservedWords.BY)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
append(obj.getElements());
}
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IInCriteria)
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.In)
*/
- public void visit(IInCriteria obj) {
+ public void visit(In obj) {
append(obj.getLeftExpression());
if (obj.isNegated()) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.NOT);
}
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.IN)
- .append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.LPAREN);
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
append(obj.getRightExpressions());
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
}
- public void visit(IInlineView obj) {
- buffer.append(SQLReservedWords.LPAREN);
- if (obj.getOutput() != null) {
- buffer.append(obj.getOutput());
- } else {
- append(obj.getQuery());
- }
- buffer.append(SQLReservedWords.RPAREN);
- buffer.append(SQLReservedWords.SPACE);
+ public void visit(DerivedTable obj) {
+ buffer.append(Tokens.LPAREN);
+ append(obj.getQuery());
+ buffer.append(Tokens.RPAREN);
+ buffer.append(Tokens.SPACE);
if(useAsInGroupAlias()) {
buffer.append(SQLReservedWords.AS);
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
}
- buffer.append(obj.getContext());
+ buffer.append(obj.getCorrelationName());
}
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IInsert)
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.Insert)
*/
- public void visit(IInsert obj) {
- buffer.append(SQLReservedWords.INSERT).append(SQLReservedWords.SPACE);
+ public void visit(Insert obj) {
+ buffer.append(SQLReservedWords.INSERT).append(Tokens.SPACE);
buffer.append(getSourceComment(obj));
- buffer.append(SQLReservedWords.INTO).append(SQLReservedWords.SPACE);
- append(obj.getGroup());
- if (obj.getElements() != null && obj.getElements().size() != 0) {
- buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.LPAREN);
+ buffer.append(SQLReservedWords.INTO).append(Tokens.SPACE);
+ append(obj.getTable());
+ buffer.append(Tokens.SPACE).append(Tokens.LPAREN);
- int elementCount = obj.getElements().size();
- for (int i = 0; i < elementCount; i++) {
- buffer.append(getElementName(obj.getElements().get(i), false));
- if (i < elementCount - 1) {
- buffer.append(SQLReservedWords.COMMA);
- buffer.append(SQLReservedWords.SPACE);
- }
+ int elementCount = obj.getColumns().size();
+ for (int i = 0; i < elementCount; i++) {
+ buffer.append(getElementName(obj.getColumns().get(i), false));
+ if (i < elementCount - 1) {
+ buffer.append(Tokens.COMMA);
+ buffer.append(Tokens.SPACE);
}
-
- buffer.append(SQLReservedWords.RPAREN);
}
- buffer.append(SQLReservedWords.SPACE);
+
+ buffer.append(Tokens.RPAREN);
+ buffer.append(Tokens.SPACE);
append(obj.getValueSource());
}
@Override
- public void visit(IInsertExpressionValueSource obj) {
- buffer.append(SQLReservedWords.VALUES).append(SQLReservedWords.SPACE).append(SQLReservedWords.LPAREN);
+ public void visit(ExpressionValueSource obj) {
+ buffer.append(SQLReservedWords.VALUES).append(Tokens.SPACE).append(Tokens.LPAREN);
append(obj.getValues());
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IIsNullCriteria)
- */
- public void visit(IIsNullCriteria obj) {
+ public void visit(IsNull obj) {
append(obj.getExpression());
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.IS)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
if (obj.isNegated()) {
buffer.append(SQLReservedWords.NOT)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
}
buffer.append(SQLReservedWords.NULL);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IJoin)
- */
- public void visit(IJoin obj) {
- IFromItem leftItem = obj.getLeftItem();
- if(useParensForJoins() && leftItem instanceof IJoin) {
- buffer.append(SQLReservedWords.LPAREN);
+ public void visit(Join obj) {
+ TableReference leftItem = obj.getLeftItem();
+ if(useParensForJoins() && leftItem instanceof Join) {
+ buffer.append(Tokens.LPAREN);
append(leftItem);
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
} else {
append(leftItem);
}
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
switch(obj.getJoinType()) {
case CROSS_JOIN:
@@ -610,7 +547,7 @@
break;
case FULL_OUTER_JOIN:
buffer.append(SQLReservedWords.FULL)
- .append(SQLReservedWords.SPACE)
+ .append(Tokens.SPACE)
.append(SQLReservedWords.OUTER);
break;
case INNER_JOIN:
@@ -618,100 +555,77 @@
break;
case LEFT_OUTER_JOIN:
buffer.append(SQLReservedWords.LEFT)
- .append(SQLReservedWords.SPACE)
+ .append(Tokens.SPACE)
.append(SQLReservedWords.OUTER);
break;
case RIGHT_OUTER_JOIN:
buffer.append(SQLReservedWords.RIGHT)
- .append(SQLReservedWords.SPACE)
+ .append(Tokens.SPACE)
.append(SQLReservedWords.OUTER);
break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.JOIN)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
- IFromItem rightItem = obj.getRightItem();
- if(rightItem instanceof IJoin && (useParensForJoins() || obj.getJoinType() == IJoin.JoinType.CROSS_JOIN)) {
- buffer.append(SQLReservedWords.LPAREN);
+ TableReference rightItem = obj.getRightItem();
+ if(rightItem instanceof Join && (useParensForJoins() || obj.getJoinType() == Join.JoinType.CROSS_JOIN)) {
+ buffer.append(Tokens.LPAREN);
append(rightItem);
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
} else {
append(rightItem);
}
- final List criteria = obj.getCriteria();
- if (criteria != null && criteria.size() != 0) {
- buffer.append(SQLReservedWords.SPACE)
+ final Condition condition = obj.getCondition();
+ if (condition != null) {
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.ON)
- .append(SQLReservedWords.SPACE);
-
- Iterator critIter = criteria.iterator();
- while(critIter.hasNext()) {
- ICriteria crit = (ICriteria) critIter.next();
- if(crit instanceof IPredicateCriteria) {
- append(crit);
- } else {
- buffer.append(SQLReservedWords.LPAREN);
- append(crit);
- buffer.append(SQLReservedWords.RPAREN);
- }
-
- if(critIter.hasNext()) {
- buffer.append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.AND)
- .append(SQLReservedWords.SPACE);
- }
- }
+ .append(Tokens.SPACE);
+ append(condition);
}
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ILikeCriteria)
- */
- public void visit(ILikeCriteria obj) {
+ public void visit(Like obj) {
append(obj.getLeftExpression());
if (obj.isNegated()) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.NOT);
}
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.LIKE)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
append(obj.getRightExpression());
if (obj.getEscapeCharacter() != null) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.ESCAPE)
- .append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.QUOTE)
+ .append(Tokens.SPACE)
+ .append(Tokens.QUOTE)
.append(obj.getEscapeCharacter().toString())
- .append(SQLReservedWords.QUOTE);
+ .append(Tokens.QUOTE);
}
}
- public void visit(ILimit obj) {
+ public void visit(Limit obj) {
buffer.append(SQLReservedWords.LIMIT)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
if (obj.getRowOffset() > 0) {
buffer.append(obj.getRowOffset())
- .append(SQLReservedWords.COMMA)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.COMMA)
+ .append(Tokens.SPACE);
}
buffer.append(obj.getRowLimit());
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ILiteral)
- */
- public void visit(ILiteral obj) {
+ public void visit(Literal obj) {
if (obj.isBindValue()) {
buffer.append("?"); //$NON-NLS-1$
} else if (obj.getValue() == null) {
buffer.append(SQLReservedWords.NULL);
} else {
- Class type = obj.getType();
+ Class<?> type = obj.getType();
String val = obj.getValue().toString();
if(Number.class.isAssignableFrom(type)) {
buffer.append(val);
@@ -732,277 +646,218 @@
.append(val)
.append("'}"); //$NON-NLS-1$
} else {
- buffer.append(SQLReservedWords.QUOTE)
- .append(escapeString(val, SQLReservedWords.QUOTE))
- .append(SQLReservedWords.QUOTE);
+ buffer.append(Tokens.QUOTE)
+ .append(escapeString(val, Tokens.QUOTE))
+ .append(Tokens.QUOTE);
}
}
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.INotCriteria)
- */
- public void visit(INotCriteria obj) {
+ public void visit(Not obj) {
buffer.append(SQLReservedWords.NOT)
- .append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.LPAREN);
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
append(obj.getCriteria());
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IOrderBy)
- */
- public void visit(IOrderBy obj) {
+ public void visit(OrderBy obj) {
buffer.append(SQLReservedWords.ORDER)
- .append(SQLReservedWords.SPACE)
+ .append(Tokens.SPACE)
.append(SQLReservedWords.BY)
- .append(SQLReservedWords.SPACE);
- append(obj.getItems());
+ .append(Tokens.SPACE);
+ append(obj.getSortSpecifications());
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IOrderByItem)
- */
- public void visit(IOrderByItem obj) {
- if(obj.getName() != null) {
- String name = getShortName(obj.getName());
- buffer.append(name);
- } else if (obj.getElement() != null) {
- append(obj.getElement());
- } else {
- buffer.append(UNDEFINED);
- }
- if (obj.getDirection() == IOrderByItem.DESC) {
- buffer.append(SQLReservedWords.SPACE)
+ public void visit(SortSpecification obj) {
+ append(obj.getExpression());
+ if (obj.getOrdering() == Ordering.DESC) {
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.DESC);
} // Don't print default "ASC"
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IParameter)
- */
- public void visit(IParameter obj) {
- if (obj.getValue() == null) {
- buffer.append(UNDEFINED_PARAM);
- } else if (obj.getValue() == null) {
- buffer.append(SQLReservedWords.NULL);
- } else {
- buffer.append(obj.getValue().toString());
- }
+ public void visit(Argument obj) {
+ buffer.append(obj.getArgumentValue());
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IQuery)
- */
- public void visit(IQuery obj) {
- visitSelect(obj.getSelect(), obj);
+ public void visit(Select obj) {
+ buffer.append(SQLReservedWords.SELECT).append(Tokens.SPACE);
+ buffer.append(getSourceComment(obj));
+ if (obj.isDistinct()) {
+ buffer.append(SQLReservedWords.DISTINCT).append(Tokens.SPACE);
+ }
+ if (useSelectLimit() && obj.getLimit() != null) {
+ append(obj.getLimit());
+ buffer.append(Tokens.SPACE);
+ }
+ append(obj.getDerivedColumns());
if (obj.getFrom() != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE).append(SQLReservedWords.FROM).append(Tokens.SPACE);
append(obj.getFrom());
}
if (obj.getWhere() != null) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.WHERE)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
append(obj.getWhere());
}
if (obj.getGroupBy() != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
append(obj.getGroupBy());
}
if (obj.getHaving() != null) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.HAVING)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
append(obj.getHaving());
}
if (obj.getOrderBy() != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
append(obj.getOrderBy());
}
if (!useSelectLimit() && obj.getLimit() != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
append(obj.getLimit());
}
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ISearchedCaseExpression)
- */
- public void visit(ISearchedCaseExpression obj) {
+ public void visit(SearchedCase obj) {
buffer.append(SQLReservedWords.CASE);
- final int whenCount = obj.getWhenCount();
- for (int i = 0; i < whenCount; i++) {
- buffer.append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.WHEN)
- .append(SQLReservedWords.SPACE);
- append(obj.getWhenCriteria(i));
- buffer.append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.THEN)
- .append(SQLReservedWords.SPACE);
- append(obj.getThenExpression(i));
- }
+ for (SearchedWhenClause swc : obj.getCases()) {
+ append(swc);
+ }
if (obj.getElseExpression() != null) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.ELSE)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
append(obj.getElseExpression());
}
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.END);
}
-
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ISelect)
- */
- public void visit(ISelect obj) {
- visitSelect(obj, null);
+
+ @Override
+ public void visit(SearchedWhenClause obj) {
+ buffer.append(Tokens.SPACE).append(SQLReservedWords.WHEN)
+ .append(Tokens.SPACE);
+ append(obj.getCondition());
+ buffer.append(Tokens.SPACE).append(SQLReservedWords.THEN)
+ .append(Tokens.SPACE);
+ append(obj.getResult());
}
- private void visitSelect(ISelect obj, IQuery command) {
- buffer.append(SQLReservedWords.SELECT).append(SQLReservedWords.SPACE);
- buffer.append(getSourceComment(command));
- if (obj.isDistinct()) {
- buffer.append(SQLReservedWords.DISTINCT).append(SQLReservedWords.SPACE);
- }
- if (useSelectLimit() && command.getLimit() != null) {
- append(command.getLimit());
- buffer.append(SQLReservedWords.SPACE);
- }
- append(obj.getSelectSymbols());
- }
-
- protected String getSourceComment(ICommand command) {
+ protected String getSourceComment(Command command) {
return ""; //$NON-NLS-1$
}
- /*
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IScalarSubquery)
- */
- public void visit(IScalarSubquery obj) {
- buffer.append(SQLReservedWords.LPAREN);
- append(obj.getQuery());
- buffer.append(SQLReservedWords.RPAREN);
+ public void visit(ScalarSubquery obj) {
+ buffer.append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ISelectSymbol)
- */
- public void visit(ISelectSymbol obj) {
+ public void visit(DerivedColumn obj) {
append(obj.getExpression());
- if (obj.hasAlias()) {
- buffer.append(SQLReservedWords.SPACE)
+ if (obj.getAlias() != null) {
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.AS)
- .append(SQLReservedWords.SPACE)
- .append(obj.getOutputName());
+ .append(Tokens.SPACE)
+ .append(obj.getAlias());
}
}
- /*
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISubqueryCompareCriteria)
- */
- public void visit(ISubqueryCompareCriteria obj) {
+ public void visit(SubqueryComparison obj) {
append(obj.getLeftExpression());
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
switch(obj.getOperator()) {
- case EQ: buffer.append(SQLReservedWords.EQ); break;
- case GE: buffer.append(SQLReservedWords.GE); break;
- case GT: buffer.append(SQLReservedWords.GT); break;
- case LE: buffer.append(SQLReservedWords.LE); break;
- case LT: buffer.append(SQLReservedWords.LT); break;
- case NE: buffer.append(SQLReservedWords.NE); break;
+ case EQ: buffer.append(Tokens.EQ); break;
+ case GE: buffer.append(Tokens.GE); break;
+ case GT: buffer.append(Tokens.GT); break;
+ case LE: buffer.append(Tokens.LE); break;
+ case LT: buffer.append(Tokens.LT); break;
+ case NE: buffer.append(Tokens.NE); break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
switch(obj.getQuantifier()) {
case ALL: buffer.append(SQLReservedWords.ALL); break;
case SOME: buffer.append(SQLReservedWords.SOME); break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SQLReservedWords.SPACE);
- buffer.append(SQLReservedWords.LPAREN);
- append(obj.getQuery());
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.SPACE);
+ buffer.append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
}
- /*
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISubqueryInCriteria)
- */
- public void visit(ISubqueryInCriteria obj) {
+ public void visit(SubqueryIn obj) {
append(obj.getLeftExpression());
if (obj.isNegated()) {
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.NOT);
}
- buffer.append(SQLReservedWords.SPACE)
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.IN)
- .append(SQLReservedWords.SPACE)
- .append(SQLReservedWords.LPAREN);
- append(obj.getQuery());
- buffer.append(SQLReservedWords.RPAREN);
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IUpdate)
- */
- public void visit(IUpdate obj) {
+ public void visit(Update obj) {
buffer.append(SQLReservedWords.UPDATE)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
buffer.append(getSourceComment(obj));
- append(obj.getGroup());
- buffer.append(SQLReservedWords.SPACE)
+ append(obj.getTable());
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.SET)
- .append(SQLReservedWords.SPACE);
+ .append(Tokens.SPACE);
append(obj.getChanges());
- if (obj.getCriteria() != null) {
- buffer.append(SQLReservedWords.SPACE)
+ if (obj.getWhere() != null) {
+ buffer.append(Tokens.SPACE)
.append(SQLReservedWords.WHERE)
- .append(SQLReservedWords.SPACE);
- append(obj.getCriteria());
+ .append(Tokens.SPACE);
+ append(obj.getWhere());
}
}
- public void visit(ISetClauseList obj) {
- append(obj.getClauses());
- }
-
- public void visit(ISetClause clause) {
+ public void visit(SetClause clause) {
buffer.append(getElementName(clause.getSymbol(), false));
- buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.EQ).append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE).append(Tokens.EQ).append(Tokens.SPACE);
append(clause.getValue());
}
- public void visit(ISetQuery obj) {
+ public void visit(SetQuery obj) {
appendSetQuery(obj, obj.getLeftQuery(), false);
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
appendSetOperation(obj.getOperation());
if(obj.isAll()) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
buffer.append(SQLReservedWords.ALL);
}
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
appendSetQuery(obj, obj.getRightQuery(), true);
- IOrderBy orderBy = obj.getOrderBy();
+ OrderBy orderBy = obj.getOrderBy();
if(orderBy != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
append(orderBy);
}
- ILimit limit = obj.getLimit();
+ Limit limit = obj.getLimit();
if(limit != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(Tokens.SPACE);
append(limit);
}
}
- protected void appendSetOperation(ISetQuery.Operation operation) {
+ protected void appendSetOperation(SetQuery.Operation operation) {
buffer.append(operation);
}
@@ -1010,17 +865,17 @@
return false;
}
- protected void appendSetQuery(ISetQuery parent, IQueryCommand obj, boolean right) {
- if((!(obj instanceof ISetQuery) && useParensForSetQueries())
- || (right && obj instanceof ISetQuery
- && ((parent.isAll() && !((ISetQuery)obj).isAll())
- || parent.getOperation() != ((ISetQuery)obj).getOperation()))) {
- buffer.append(SQLReservedWords.LPAREN);
+ protected void appendSetQuery(SetQuery parent, QueryExpression obj, boolean right) {
+ if((!(obj instanceof SetQuery) && useParensForSetQueries())
+ || (right && obj instanceof SetQuery
+ && ((parent.isAll() && !((SetQuery)obj).isAll())
+ || parent.getOperation() != ((SetQuery)obj).getOperation()))) {
+ buffer.append(Tokens.LPAREN);
append(obj);
- buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(Tokens.RPAREN);
} else {
- if (!parent.isAll() && obj instanceof ISetQuery) {
- ((ISetQuery)obj).setAll(false);
+ if (!parent.isAll() && obj instanceof SetQuery) {
+ ((SetQuery)obj).setAll(false);
}
append(obj);
}
@@ -1033,7 +888,7 @@
* command
* @return the SQL representation of that ILanguageObject hierarchy
*/
- public static String getSQLString(ILanguageObject obj) {
+ public static String getSQLString(LanguageObject obj) {
SQLStringVisitor visitor = new SQLStringVisitor();
visitor.append(obj);
return visitor.toString();
Deleted: trunk/connector-api/src/test/java/org/teiid/connector/TestCredentialMap.java
===================================================================
--- trunk/connector-api/src/test/java/org/teiid/connector/TestCredentialMap.java 2010-03-04 20:22:20 UTC (rev 1912)
+++ trunk/connector-api/src/test/java/org/teiid/connector/TestCredentialMap.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -1,350 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.teiid.connector.api.CredentialMap;
-
-
-import junit.framework.TestCase;
-
-/**
- * Note-- due to time constraints, tests make hard-coded assumptions that
- * keywords for system, user name, and password, are "system",
- * "user", and "password". The actual keywords are found in
- * com.metamatrix.platform.security.CredentialsMap: SYSTEM_KEYWORD,
- * USER_KEYWORD, and PASSWORD_KEYWORD.
- */
-public class TestCredentialMap extends TestCase {
-
- /**
- * Constructor for TestCredentialMap.
- * @param arg0
- */
- public TestCredentialMap(String arg0) {
- super(arg0);
- }
-
- public void testParseNullCredentialString() {
- String command = null;
- try {
- CredentialMap.parseCredentials(command);
- fail("Did not throw exception on null credential string"); //$NON-NLS-1$
- } catch (Exception ex) {
- }
- }
-
- public void testParseEmptyCredentialString() {
- String command = ""; //$NON-NLS-1$
- try {
- CredentialMap.parseCredentials(command);
- fail("Did not throw exception on empyt credential string"); //$NON-NLS-1$
- } catch (Exception ex) {
- }
- }
-
-
- public void testParseMissingSystem() {
- String command = "(user=myusername)"; //$NON-NLS-1$
- try {
- CredentialMap.parseCredentials(command);
- fail("Did not throw exception on missing system keyword"); //$NON-NLS-1$
- } catch (Exception ex) {
- }
- }
-
-
- public void testParseNoOpeningParen() {
- String command = "system=mysystem,username=me,mypassword=you)"; //$NON-NLS-1$
- try {
- CredentialMap.parseCredentials(command);
- fail("Did not throw exception on missing open paren"); //$NON-NLS-1$
- } catch (Exception ex) {
- }
- }
-
- public void testParseNoClosingParen() {
- String command = "(system=mysystem,username=me,mypassword=you"; //$NON-NLS-1$
- try {
- CredentialMap.parseCredentials(command);
- fail("Did not throw exception on missing closing paren"); //$NON-NLS-1$
- } catch (Exception ex) {
- }
- }
-
- public void testCaseSensitivity() throws Exception {
- String command = "(system=mysystem,username=me,mypassword=you)"; //$NON-NLS-1$
- CredentialMap cm = CredentialMap.parseCredentials(command);
- Map map = cm.getSystemCredentials("MySystem"); //$NON-NLS-1$
- if (map == null) {
- fail("Error looking up MySystem credentials using different cases."); //$NON-NLS-1$
- }
- }
-
- public void testCorrectMixedEntries() throws Exception {
- String command = "(system=system1,user=username1, password=password1 / " + //$NON-NLS-1$
- " system=system2,user=username2, password=password2 / " + //$NON-NLS-1$
- " system=system3,user=username3, password=password3 / " + //$NON-NLS-1$
- " system=system4,user=username4, password=password4)"; //$NON-NLS-1$
-
- CredentialMap cm = CredentialMap.parseCredentials(command);
- assertNotNull("Null CredentialsMap returned on correct entry", cm); //$NON-NLS-1$
-
- int mapSize = cm.getSystems().length;
- assertEquals("Incorrect number of entries in credential map", 4, //$NON-NLS-1$
- mapSize);
-
- // test 1st set of credentials
- String system = "system1"; //$NON-NLS-1$
- String userVal = "username1"; //$NON-NLS-1$
- String passwordVal = "password1"; //$NON-NLS-1$
-
- Map map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: system1", map); //$NON-NLS-1$
-
- String user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
-
- String password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
-
- // test 2nd set of credentials
- system = "system2"; //$NON-NLS-1$
- userVal = "username2"; //$NON-NLS-1$
- passwordVal = "password2"; //$NON-NLS-1$
-
- map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: " + system, map); //$NON-NLS-1$
-
- user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
-
- password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
-
- // test 3rd set of credentials
- system = "system3"; //$NON-NLS-1$
- userVal = "username3"; //$NON-NLS-1$
- passwordVal = "password3"; //$NON-NLS-1$
-
- map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: " + system, map); //$NON-NLS-1$
-
- user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
-
- password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
-
- // test 4th set of credentials
- system = "system4"; //$NON-NLS-1$
- userVal = "username4"; //$NON-NLS-1$
- passwordVal = "password4"; //$NON-NLS-1$
-
- map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: " + system, map); //$NON-NLS-1$
-
- user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
-
- password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
-
- }
-
- public void testEscapeCharacters() throws Exception {
- String command = "(system=test\\/system1,user=username1, password=\\=password1 / " + //$NON-NLS-1$
- " system=system2,user=username2, password=\\=\\,)\\/;password2 / " + //$NON-NLS-1$
- " system=system3,user=username3, password=\"\'\\password3 / " + //$NON-NLS-1$
- " system=system4,user=username4, password=\\password4)"; //$NON-NLS-1$
-
- CredentialMap cm = CredentialMap.parseCredentials(command);
- assertNotNull("Null CredentialsMap returned on correct entry", cm); //$NON-NLS-1$
-
- int mapSize = cm.getSystems().length;
- assertEquals("Incorrect number of entries in credential map", 4, //$NON-NLS-1$
- mapSize);
-
- // test 1st set of credentials
- String system = "test/system1"; //$NON-NLS-1$
- String userVal = "username1"; //$NON-NLS-1$
- String passwordVal = "=password1"; //$NON-NLS-1$
-
- Map map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: system1", map); //$NON-NLS-1$
-
- String user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(cm.getUser(system))); //$NON-NLS-1$
-
-
- String password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(cm.getPassword(system))); //$NON-NLS-1$
-
- // test 2nd set of credentials
- system = "system2"; //$NON-NLS-1$
- userVal = "username2"; //$NON-NLS-1$
- passwordVal = "=,)/;password2"; //$NON-NLS-1$
-
- map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: " + system, map); //$NON-NLS-1$
-
- user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(cm.getUser(system))); //$NON-NLS-1$
-
- password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(cm.getPassword(system))); //$NON-NLS-1$
-
- // test 3rd set of credentials
- system = "system3"; //$NON-NLS-1$
- userVal = "username3"; //$NON-NLS-1$
- passwordVal = "\"\'\\password3"; //$NON-NLS-1$
-
- map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: " + system, map); //$NON-NLS-1$
-
- user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(cm.getUser(system))); //$NON-NLS-1$
-
- password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(cm.getPassword(system))); //$NON-NLS-1$
-
- // test 4th set of credentials
- system = "system4"; //$NON-NLS-1$
- userVal = "username4"; //$NON-NLS-1$
- passwordVal = "\\password4"; //$NON-NLS-1$
-
- map = cm.getSystemCredentials(system);
- assertNotNull("Null Map returned on correct entry: " + system, map); //$NON-NLS-1$
-
- user = (String) map.get("user"); //$NON-NLS-1$
- assertTrue("Incorrect username returned for " + system, userVal.equals(user)); //$NON-NLS-1$
-
- password = (String) map.get("password"); //$NON-NLS-1$
- assertTrue("Incorrect password returned for " + system, passwordVal.equals(password)); //$NON-NLS-1$
-
- }
-
- private Map getDefaultCredentials() {
- Map defaults = new HashMap();
- defaults.put("user", "defaultUser"); //$NON-NLS-1$ //$NON-NLS-2$
- defaults.put("password", "defaultPassword"); //$NON-NLS-1$ //$NON-NLS-2$
- return defaults;
- }
-
- private Map getSystemCredentials() {
- Map map = new HashMap();
- map.put("user", "user1"); //$NON-NLS-1$ //$NON-NLS-2$
- map.put("password", "password1"); //$NON-NLS-1$ //$NON-NLS-2$
- map.put("bonus1", "ziggy"); //$NON-NLS-1$ //$NON-NLS-2$
- return map;
- }
-
- private Map getPartialSystemCredentials() {
- Map map = new HashMap();
- map.put("bonus2", "ziggy"); //$NON-NLS-1$ //$NON-NLS-2$
- return map;
- }
-
- public CredentialMap setupDefaultsTest(short mode, boolean setDefaults) {
- CredentialMap cm = new CredentialMap();
- if(setDefaults) {
- cm.setDefaultCredentials(getDefaultCredentials());
- }
- cm.addSystemCredentials("sys1", getSystemCredentials()); //$NON-NLS-1$
- cm.addSystemCredentials("sys2", getPartialSystemCredentials()); //$NON-NLS-1$
- cm.setDefaultCredentialMode(mode);
- return cm;
- }
-
- public void assertCredentialsMatch(Map expected, CredentialMap creds, String system) {
- Map sysCreds = creds.getSystemCredentials(system);
- assertEquals(expected, sysCreds);
- }
-
- public void testIgnoreDefaults() {
- CredentialMap cm = setupDefaultsTest(CredentialMap.MODE_IGNORE_DEFAULTS, true);
-
- assertCredentialsMatch(null, cm, "x"); //$NON-NLS-1$
- assertCredentialsMatch(getSystemCredentials(), cm, "sys1"); //$NON-NLS-1$
- assertCredentialsMatch(getPartialSystemCredentials(), cm, "sys2"); //$NON-NLS-1$
- }
-
- public void testGlobalDefaultsUnknownSystem() {
- CredentialMap cm = setupDefaultsTest(CredentialMap.MODE_USE_DEFAULTS_GLOBALLY, true);
-
- assertCredentialsMatch(getDefaultCredentials(), cm, "x"); //$NON-NLS-1$
- assertCredentialsMatch(getSystemCredentials(), cm, "sys1"); //$NON-NLS-1$
-
- // Get mixture of system and defaults
- Map mixed = new HashMap();
- mixed.putAll(getDefaultCredentials());
- mixed.putAll(getPartialSystemCredentials());
- assertCredentialsMatch(mixed, cm, "sys2"); //$NON-NLS-1$
- }
-
- public void testExistingDefaultsUnknownSystem() {
- CredentialMap cm = setupDefaultsTest(CredentialMap.MODE_USE_DEFAULTS_ON_EXISTING, true);
-
- assertCredentialsMatch(null, cm, "x"); //$NON-NLS-1$
- assertCredentialsMatch(getSystemCredentials(), cm, "sys1"); //$NON-NLS-1$
-
- // Get mixture of system and defaults
- Map mixed = new HashMap();
- mixed.putAll(getDefaultCredentials());
- mixed.putAll(getPartialSystemCredentials());
- assertCredentialsMatch(mixed, cm, "sys2"); //$NON-NLS-1$
- }
-
- public void testIgnoreWithNoDefaults() {
- CredentialMap cm = setupDefaultsTest(CredentialMap.MODE_IGNORE_DEFAULTS, false);
-
- assertCredentialsMatch(null, cm, "x"); //$NON-NLS-1$
- assertCredentialsMatch(getSystemCredentials(), cm, "sys1"); //$NON-NLS-1$
- assertCredentialsMatch(getPartialSystemCredentials(), cm, "sys2"); //$NON-NLS-1$
- }
-
- public void testGlobalDefaultsUnknownSystemNoDefaults() {
- CredentialMap cm = setupDefaultsTest(CredentialMap.MODE_USE_DEFAULTS_GLOBALLY, false);
-
- assertCredentialsMatch(null, cm, "x"); //$NON-NLS-1$
- assertCredentialsMatch(getSystemCredentials(), cm, "sys1"); //$NON-NLS-1$
- assertCredentialsMatch(getPartialSystemCredentials(), cm, "sys2"); //$NON-NLS-1$
- }
-
- public void testExistingDefaultsUnknownSystemNoDefaults() {
- CredentialMap cm = setupDefaultsTest(CredentialMap.MODE_USE_DEFAULTS_ON_EXISTING, false);
-
- assertCredentialsMatch(null, cm, "x"); //$NON-NLS-1$
- assertCredentialsMatch(getSystemCredentials(), cm, "sys1"); //$NON-NLS-1$
- assertCredentialsMatch(getPartialSystemCredentials(), cm, "sys2"); //$NON-NLS-1$
- }
-
-}
Copied: trunk/connector-api/src/test/java/org/teiid/connector/TestWrappedConnector.java (from rev 1900, branches/JCA/connector-api/src/test/java/org/teiid/connector/TestWrappedConnector.java)
===================================================================
--- trunk/connector-api/src/test/java/org/teiid/connector/TestWrappedConnector.java (rev 0)
+++ trunk/connector-api/src/test/java/org/teiid/connector/TestWrappedConnector.java 2010-03-04 20:47:34 UTC (rev 1913)
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.basic.BasicConnectorCapabilities;
+import org.teiid.connector.basic.WrappedConnector;
+
+
+public class TestWrappedConnector {
+
+ @Test public void testConnectorCapabilitiesOverride() throws Exception {
+
+ Connector c = Mockito.mock(Connector.class);
+ Mockito.stub(c.getCapabilities()).toReturn(new BasicConnectorCapabilities());
+ ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+ Mockito.stub(c.getConnectorEnvironment()).toReturn(env);
+
+ WrappedConnector connector = new WrappedConnector(c, null, null);
+
+ ConnectorCapabilities caps = connector.getCapabilities();
+ assertFalse(caps.supportsExistsCriteria());
+ assertFalse(caps.supportsExcept());
+
+
+ c = Mockito.mock(Connector.class);
+ Mockito.stub(c.getCapabilities()).toReturn(new BasicConnectorCapabilities());
+
+ connector = new WrappedConnector(c, null, null);
+
+ Properties props = new Properties();
+ props.setProperty("supportsExistsCriteria", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("supportsExcept", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ env = Mockito.mock(ConnectorEnvironment.class);
+ Mockito.stub(env.getOverrideCapabilities()).toReturn(props);
+ Mockito.stub(c.getConnectorEnvironment()).toReturn(env);
+
+ caps = connector.getCapabilities();
+ assertTrue(caps.supportsExistsCriteria());
+ assertTrue(caps.supportsExcept());
+ }
+}
14 years, 2 months
teiid SVN: r1912 - trunk.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-04 15:22:20 -0500 (Thu, 04 Mar 2010)
New Revision: 1912
Removed:
trunk/txn-jbossts/
Log:
TEIID-833 committing JCA merge
14 years, 2 months
teiid SVN: r1911 - in trunk/common-internal: src/main/java and 27 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-04 15:00:27 -0500 (Thu, 04 Mar 2010)
New Revision: 1911
Added:
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
trunk/common-internal/src/main/java/org/
trunk/common-internal/src/main/java/org/teiid/
trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java
Removed:
trunk/common-internal/src/main/java/com/metamatrix/admin/
trunk/common-internal/src/main/java/com/metamatrix/api/exception/
trunk/common-internal/src/main/java/com/metamatrix/common/actions/
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/
trunk/common-internal/src/main/java/com/metamatrix/common/config/util/
trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/
trunk/common-internal/src/main/java/com/metamatrix/common/extensionmodule/
trunk/common-internal/src/main/java/com/metamatrix/common/namedobject/
trunk/common-internal/src/main/java/com/metamatrix/common/object/
trunk/common-internal/src/main/java/com/metamatrix/common/queue/
trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java
trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java
trunk/common-internal/src/main/java/com/metamatrix/common/util/crypto/
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/
trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java
trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java
trunk/common-internal/src/main/java/com/metamatrix/core/util/
trunk/common-internal/src/main/java/com/metamatrix/core/xml/
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/vdb/
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/xmi/
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/xsd/
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/apiimpl/
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/
trunk/common-internal/src/main/java/com/metamatrix/server/admin/apiimpl/
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/template/
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java
trunk/common-internal/src/main/java/org/teiid/
trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java
trunk/common-internal/src/main/resources/com/metamatrix/vdb/materialization/
trunk/common-internal/src/test/java/com/metamatrix/common/config/connector/
trunk/common-internal/src/test/java/com/metamatrix/common/config/xml/
trunk/common-internal/src/test/java/com/metamatrix/common/queue/
trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java
trunk/common-internal/src/test/java/com/metamatrix/common/util/crypto/keymanage/
trunk/common-internal/src/test/java/com/metamatrix/common/vdb/api/
trunk/common-internal/src/test/java/com/metamatrix/core/util/
trunk/common-internal/src/test/java/com/metamatrix/internal/core/xml/vdb/
trunk/common-internal/src/test/java/com/metamatrix/internal/core/xml/xmi/
trunk/common-internal/src/test/java/com/metamatrix/internal/core/xml/xsd/
trunk/common-internal/src/test/java/com/metamatrix/vdb/edit/materialization/
Modified:
trunk/common-internal/
trunk/common-internal/pom.xml
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java
trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd
Log:
TEIID-833 committing JCA merge
Property changes on: trunk/common-internal
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: trunk/common-internal/pom.xml
===================================================================
--- trunk/common-internal/pom.xml 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/pom.xml 2010-03-04 20:00:27 UTC (rev 1911)
@@ -16,6 +16,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -27,6 +28,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -44,16 +46,11 @@
<artifactId>saxon-dom</artifactId>
</dependency>
- <dependency>
- <groupId>antlr</groupId>
- <artifactId>stringtemplate</artifactId>
- </dependency>
-
<dependency>
- <groupId>com.google.code.guice</groupId>
- <artifactId>guice</artifactId>
- </dependency>
-
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -27,7 +27,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import com.google.inject.Inject;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.JavaLogWriter;
@@ -87,10 +86,8 @@
*/
public final class LogManager {
- @Inject
static LogConfiguration configuration = new LogConfigurationImpl(MessageLevel.DETAIL); // either injected or manually set using the set methods
- @Inject
static LogListener logListener = new JavaLogWriter(); // either injected or manually set using the set methods
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,175 +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.common.util;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.util.Properties;
-
-import com.metamatrix.core.util.Assertion;
-
-/**
- * PlatformAwareFileSystemView
- */
-public class OSPlatformUtil {
- public static String OS_PROPERTY_NAME = "os.name"; //$NON-NLS-1$
-
- /** Operating system is Windows NT. */
- public static final int OS_WINNT = 1;
- /** Operating system is Windows 95. */
- public static final int OS_WIN95 = 2;
- /** Operating system is Windows 98. */
- public static final int OS_WIN98 = 4;
- /** Operating system is Solaris. */
- public static final int OS_SOLARIS = 8;
- /** Operating system is Linux. */
- public static final int OS_LINUX = 16;
- /** Operating system is HP-UX. */
- public static final int OS_HP = 32;
- /** Operating system is IBM AIX. */
- public static final int OS_AIX = 64;
- /** Operating system is SGI IRIX. */
- public static final int OS_IRIX = 128;
- /** Operating system is Sun OS. */
- public static final int OS_SUNOS = 256;
- /** Operating system is Compaq TRU64 Unix */
- public static final int OS_TRU64 = 512;
- /** @deprecated please use OS_TRU64 instead */
- public static final int OS_DEC = OS_TRU64;
- /** Operating system is OS/2. */
- public static final int OS_OS2 = 1024;
- /** Operating system is Mac. */
- public static final int OS_MAC = 2048;
- /** Operating system is Windows 2000. */
- public static final int OS_WIN2000 = 4096;
- /** Operating system is Compaq OpenVMS */
- public static final int OS_VMS = 8192;
- /** Operating system is Compaq OpenVMS */
- public static final int OS_WINXP = 16384;
- /**
- *Operating system is one of the Windows variants but we don't know which
- *one it is
- */
- public static final int OS_WIN_OTHER = 16384;
-
- /** Operating system is unknown. */
- public static final int OS_OTHER = 65536;
-
- /** A mask for Windows platforms. */
- public static final int OS_WINDOWS_MASK = OS_WINNT | OS_WIN95 | OS_WIN98 | OS_WIN2000 | OS_WINXP | OS_WIN_OTHER;
- /** A mask for Unix platforms. */
- public static final int OS_UNIX_MASK = OS_SOLARIS | OS_LINUX | OS_HP | OS_AIX | OS_IRIX | OS_SUNOS | OS_TRU64 | OS_MAC;
- /** A mask for Linux platform **/
- public static final int OS_LINUX_MASK = OS_LINUX;
-
- /** The operating system on which MetaMatrix runs*/
- private static int operatingSystem = -1;
-
- /** Get the operating system on which the IDE is running.
- * @return one of the <code>OS_*</code> constants (such as {@link #OS_WINNT})
- */
- public static final int getOperatingSystem () {
- if (operatingSystem == -1) {
- String osName = System.getProperty(OS_PROPERTY_NAME);
- if ("Windows NT".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WINNT;
- else if ("Windows 95".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WIN95;
- else if ("Windows 98".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WIN98;
- else if ("Windows 2000".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WIN2000;
- else if ("Windows XP".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WINXP;
- else if (osName.startsWith("Windows ")) //$NON-NLS-1$
- operatingSystem = OS_WIN_OTHER;
- else if ("Solaris".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_SOLARIS;
- else if (osName.startsWith ("SunOS")) //$NON-NLS-1$
- operatingSystem = OS_SOLARIS;
- // JDK 1.4 b2 defines os.name for me as "Redhat Linux" -jglick
- else if (osName.endsWith ("Linux")) //$NON-NLS-1$
- operatingSystem = OS_LINUX;
- else if ("HP-UX".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_HP;
- else if ("AIX".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_AIX;
- else if ("Irix".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_IRIX;
- else if ("SunOS".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_SUNOS;
- else if ("Digital UNIX".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_TRU64;
- else if ("OS/2".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_OS2;
- else if ("OpenVMS".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_VMS;
- else if (osName.equals ("Mac OS X")) //$NON-NLS-1$
- operatingSystem = OS_MAC;
- else if (osName.startsWith ("Darwin")) //$NON-NLS-1$
- operatingSystem = OS_MAC;
- else
- operatingSystem = OS_OTHER;
- }
- return operatingSystem;
- }
-
- /** Test whether the IDE is running on some variant of Windows.
- * @return <code>true</code> if Windows, <code>false</code> if some other manner of operating system
- */
- public static final boolean isWindows () {
- return (getOperatingSystem () & OS_WINDOWS_MASK) != 0;
- }
-
- /** Test whether the IDE is running on some variant of Unix.
- * Linux is included as well as the commercial vendors.
- * @return <code>true</code> some sort of Unix, <code>false</code> if some other manner of operating system
- */
- public static final boolean isUnix () {
- return (getOperatingSystem () & OS_UNIX_MASK) != 0;
- }
-
- /** Test whether the IDE is running on some variant of Unix.
- * Linux is included as well as the commercial vendors.
- * @return <code>true</code> some sort of Unix, <code>false</code> if some other manner of operating system
- */
- public static final boolean isLinux () {
- return (getOperatingSystem () & OS_LINUX_MASK) != 0;
- }
-
- static void printSystemProperties( PrintStream stream ) {
- Assertion.isNotNull(stream,"The PrintStream reference may not be null"); //$NON-NLS-1$
- Properties p = System.getProperties();
- p.list(stream);
- }
- static void printPermissions(File f, String action) {
- System.out.println("\nFile \"" + f + "\" action = " + action); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("exists = "+f.exists()+" canRead = "+f.canRead()+" canWrite = "+f.canWrite()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- static void printRuntimeCmd(String methodName, String cmd) {
- System.out.println("\n[" + methodName + "] Runtime.exec( " + cmd + " )"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,121 +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.common.util;
-
-import java.text.StringCharacterIterator;
-
-
-/**
- * @since 5.0
- * This class contains static methods used to validate VDB and Source names. It is not intented to be a fancy string
- * parser/checker, it is only intented for VDB name validation with the following rules.
- *
- * Rules:
- * Names must contain only alphanumeric characters and _ (underscores)
- * Names must begin with a alpha character
- *
- * Along with the above rules there are reserved words that cannot be used for VDB names:
- *
- * System
- * Admin
- * Help
- *
- * Along with the above rules there are reserved words that cannot be used for Source names:
- *
- * System
- *
- *
- */
-public class VDBNameValidator {
-
- static String reservedVDBNames[] = {"System", "Admin", "Help"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- static String reservedSourceNames[] = {"System"}; //$NON-NLS-1$
-
-
- static public boolean isValid (String vdbName) {
-
- if (vdbName == null || vdbName.length() == 0) {
- return false;
- }
-
- if (containsInvalidChars(vdbName)) {
- return false;
- }
-
- // Check for Reserved words
- for (int i=0; i < reservedVDBNames.length; i++) {
- if (vdbName.equalsIgnoreCase(reservedVDBNames[i])) {
- return false;
- }
- }
- return true;
- }
-
- static public boolean isSourceValid (String sourceName) {
-
- if (sourceName == null || sourceName.length() == 0) {
- return false;
- }
-
- if (containsInvalidChars(sourceName)) {
- return false;
- }
- return !isSourceNameReserved(sourceName);
- }
-
- public static boolean isSourceNameReserved(String sourceName) {
- // Check for Reserved words
- for (int i=0; i < reservedSourceNames.length; i++) {
- if (sourceName.equalsIgnoreCase(reservedVDBNames[i])) {
- return true;
- }
- }
- return false;
- }
-
-
- private static boolean containsInvalidChars(String vdbName) {
-
- StringCharacterIterator charIterator = new StringCharacterIterator(vdbName);
-
- // Check to insure 1st character is a letter
- char c = charIterator.first();
- if (c != StringCharacterIterator.DONE) {
- if (!Character.isLetter(c)) {
- return true; // first character must be a letter
- }
- } else {
- return true; // empty string is invalid, should never happen
- }
-
- while (true) {
- c = charIterator.next();
- if (c == StringCharacterIterator.DONE) {
- return false;
- }
- if (!Character.isLetterOrDigit(c) & (c != '_')) {
- return true;
- }
- }
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,60 +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.common.xml;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.jdom.Document;
-import org.jdom.JDOMException;
-
-
-/**
-* This interface is used to read and write JDOM compliant XML files.
-*/
-public interface XMLReaderWriter {
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param doc the JDOM document to be written to the OutputStream
- * @param stream the output stream to be written to.
- * @throws IOException if there is a problem writing to the OutputStream
- */
- public void writeDocument(Document doc, OutputStream stream) throws IOException;
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param stream the input stream to read the XML document from.
- * @return the JDOM document reference that represents the XML text in the
- * InputStream.
- * @throws IOException if there is a problem reading from the InputStream
- * @throws JDOMException if the InputStream does not represent a JDOM
- * compliant XML document.
- */
- public Document readDocument(InputStream stream) throws JDOMException, IOException;
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,104 +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.common.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.jdom.Document;
-import org.jdom.output.XMLOutputter;
-import org.jdom.JDOMException;
-
-import com.metamatrix.internal.core.xml.JdomHelper;
-
-
-/**
-* This implementation will use the JDOMhelper to read in XML files and will
-* use the JDOM utility to write out JDOM XML files.
-*/
-public class XMLReaderWriterImpl implements XMLReaderWriter{
-
- public static final int DEFAULT_INDENT_SIZE = 4;
- public static final boolean DEFAULT_USE_NEW_LINES = true;
-
- private int indent = DEFAULT_INDENT_SIZE;
- private boolean newLines = DEFAULT_USE_NEW_LINES;
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param doc the JDOM document to be written to the OutputStream
- * @param stream the output stream to be written to.
- * @throws IOException if there is a problem writing to the OutputStream
- */
- public void writeDocument(Document doc, OutputStream stream) throws IOException{
- StringBuffer indentBuffer = new StringBuffer();
- for (int i = 0; i < indent; i++) {
- indentBuffer.append(" "); //$NON-NLS-1$
- }
- XMLOutputter outputter = new XMLOutputter(JdomHelper.getFormat(indentBuffer.toString(), newLines));
-
- outputter.output(doc, stream);
- stream.flush();
- stream.close();
-
- }
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param stream the input stream to read the XML document from.
- * @return the JDOM document reference that represents the XML text in the
- * InputStream.
- * @throws IOException if there is a problem reading from the InputStream
- * @throws JDOMException if the InputStream does not represent a JDOM
- * compliant XML document.
- */
- public Document readDocument(InputStream stream) throws JDOMException, IOException{
- return JdomHelper.buildDocument(stream);
- }
-
- /**
- * This method will set the indent size of all JDOM Documents that are
- * written using this object.
- *
- * @param indent the number of spaces to indent the XML heirarchy in the
- * output files.
- */
- public void setIndentSize(int indent) {
- this.indent = indent;
- }
-
- /**
- * This method will set whether or not new Lines are used to mimic the
- * hierarchal structure of all JDOM Documents that are
- * written using this object.
- *
- * @param newLines whether or not to include new line chars in output files.
- */
- public void setUseNewLines(boolean newLines) {
- this.newLines = newLines;
- }
-
-}
Modified: trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -738,22 +738,20 @@
* @throws IOException if there are problems writing to the file.
*/
public static void write( Document doc , String filename, String indent, boolean newlines ) throws IOException {
- if(doc == null){
- ArgCheck.isNotNull(doc,CorePlugin.Util.getString("JdomHelper.The_Document_reference_may_not_be_null_42")); //$NON-NLS-1$
- }
+ ArgCheck.isNotNull(doc,CorePlugin.Util.getString("JdomHelper.The_Document_reference_may_not_be_null_42")); //$NON-NLS-1$
+ ArgCheck.isNotNull(filename,CorePlugin.Util.getString("JdomHelper.The_filename_may_not_be_null_43")); //$NON-NLS-1$
- if(filename == null){
- ArgCheck.isNotNull(filename,CorePlugin.Util.getString("JdomHelper.The_filename_may_not_be_null_43")); //$NON-NLS-1$
- }
-
if(filename.length() == 0){
ArgCheck.isNotZeroLength(filename,CorePlugin.Util.getString("JdomHelper.The_filename_may_not_be_zero-length_44")); //$NON-NLS-1$
}
FileOutputStream out = new FileOutputStream( filename );
- write(doc,out,indent,newlines);
- out.flush();
- out.close();
+ try {
+ write(doc,out,indent,newlines);
+ out.flush();
+ } finally {
+ out.close();
+ }
}
/**
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,170 +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.api;
-
-import java.io.Serializable;
-import java.util.List;
-
-
-/**
- * The MetadataID class serves as the interface class for identifiers
- * of objects. This class provides the method signatures
- * common to all ID classes as well as the majority of the implementation, and
- * defines an identification name as a list of one or more non-zero length atomic name components
- * delimeted by a '.' (similar to JNDI names).
- * <p>
- * These classes are shipped between the client and RuntimeMetadata, so
- * the MetadataID class is serializable. To speed serialization and decrease
- * the overhead of shipping MetadataID across the network using RMI, several
- * instance variables that may not be required by all users are made transient
- * and recomputed as needed.
- * <p>
- * Additionally, because IDs are designed
- * to be used as primary keys, the <code>hashCode</code>, <code>equals</code>
- * and <code>compareTo</code> methods are all consistent and optimized for
- * fast performance. This is in part accomplished by caching the hash code value,
- * which is tolerable since all MetadataID subclasses are <i>immutable</i>: they
- * cannot be modified after they have been created.
- * <p>
- * Finally, several key methods that are very commonly used and that will not be
- * overridden in subclasses are marked as <code>final</code> as an inlining hint to the
- * compiler.
- */
-public interface MetadataID extends Cloneable, Comparable, Serializable {
-
- /**
- * Obtain the full name for the object that this identifier represents.
- * @return the full name for this identifier.
- */
- public String getFullName() ;
- /**
- * Obtain the last name component this identifier. This last name component
- * is the logical name for the object that this identifier represents.
- * @return the name for this identifier.
- */
- public String getName();
-
- /**
- * Obtain the path for this component.
- * @return the path
- */
- public String getPath();
-
- /**
- * Obtain the specified component of the name.
- * @param the index of the atomic name component to return; must be less than
- * the result of the method <code>size</code> in order to be valid.
- * @return the full name for this identifier.
- * @throws IndexOutOfBoundsException if the index is not valid and is out of the bounds of this name.
- */
- public String getNameComponent( int index ) ;
- /**
- * Obtain the list of atomic name components for this ID.
- * @return the unmodifiable list of String objects.
- * @throws IndexOutOfBoundsException if the index is not valid and is out of the bounds of this name.
- */
- public List getNameComponents();
- /**
- * Return the number of atomic name components in this identifier.
- * @return the size of this identifier.
- */
- public int size();
- /**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- public boolean equals(Object obj);
-
- /**
- * Compares this object to another. If the specified object is an instance of
- * the MetadataID class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class).
- * Note: this method <i>is</i> consistent with <code>equals()</code>, meaning
- * that <code>(compare(x, y)==0) == (x.equals(y))</code>.
- * <p>
- * The algorithm that this method follows is based primarily upon the
- * hash code. When two instances of MetadataID, objects A and B, are being compared,
- * this method first compares the (cached) hash code of the two objects. If the
- * two hash codes are not equal, the method returns the difference in the hash
- * codes (namely <code>A.hashCode() - B.hashCode()</code>).
- * If, however, the two hash code values are equivalent, then the
- * two MetadataID instances are <i>potentially</i> equivalent, and the
- * full names of the BaseIDs are compared (ignoring case) to determine <i>actual</i> result.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws IllegalArgumentException if the specified object reference is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- public int compareTo(Object obj);
-
- /**
- * Compares this object to another lexicographically. If the specified object is an instance of
- * the same class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class). Note: this method is consistent with <code>equals()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws IllegalArgumentException if the specified object reference is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- public int compareToByName(Object obj);
-
- /**
- * Returns the hash code value for this object.
- * @return a hash code value for this object.
- */
- public int hashCode();
-
- /**
- * Returns a string representing the current state of the object.
- * @return the string representation of this instance.
- */
- public String toString();
- /**
- * Return a deep cloned instance of this object. Subclasses must override
- * this method.
- * @return the object that is the clone of this instance.
- * @throws CloneNotSupportedException if this object cannot be cloned (i.e., only objects in
- * {@link com.metamatrix.metadata.api.Defaults Defaults} cannot be cloned).
- */
- public Object clone() throws CloneNotSupportedException;
- /**
- * Return the full name of the parent. This is a convenience method to return
- * the list of atomic name components that excludes this ID's last atomic name component.
- * @return the full name of the parent, or null if this ID has no parent.
- */
- public String getParentFullName() ;
-
-}
-
-
Deleted: 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 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,105 +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.api;
-
-import java.util.Properties;
-
-
-public interface MetadataObject extends java.io.Serializable{
-
- /**
- * Return the identifier for this object. The returned type will be an instance of the BaseID subclass
- * which corresponds to the class of this node.
- * @return the specialized BaseID instance for this node.
- */
- MetadataID getID();
-
-
- /**
- * Returns the name for this instance of the object. If you are using
- * the dot notation for a naming conventions, this will return the last
- * node in name.
- * @return the name
- *
- * @see getFullName
- */
- String getName();
-
- /**
- * Returns the full name for this instance of the object.
- * @return the name
- */
- String getFullName();
-
- /**
- * Compares this object to another. If the specified object is an instance of
- * the same class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class). Note: this method is consistent with <code>equals()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- int compareTo(Object obj);
-
- /**
- * Returns a string representing the current state of the object.
- * @return the string representation of this instance.
- */
- String toString();
-
- /**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- boolean equals(Object obj);
-
- /**
- * Return a deep cloned instance of this object. Subclasses must override
- * this method.
- * @return the object that is the clone of this instance.
- * @throws CloneNotSupportedException if this object cannot be cloned (i.e., only objects in
- * {@link com.metamatrix.metadata.api.Defaults Defaults} cannot be cloned).
- */
- public Object clone() throws CloneNotSupportedException;
-
- /**
- * returns the VirtualDatabaseID that identifies the VirtualDatabase this metadata object resides.
- * @return VirtualDatabaseID
- */
- VirtualDatabaseID getVirtualDatabaseID();
-
-
- /**
- * returns the user defined properties for this metadata object.
- * @return Properties
- */
- Properties getProperties() throws VirtualDatabaseException;
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,52 +0,0 @@
-package com.metamatrix.metadata.runtime.api;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import com.metamatrix.common.vdb.api.ModelInfo;
-
-public interface MetadataSource {
-
- String getName();
-
- /**
- * Return all files known by this metadata source
- * @return
- */
- Set<String> getEntries();
-
- /**
- * Returns the file for the given path, which must exist in the entry set
- * @param path
- * @return
- */
- File getFile(String path);
-
- /**
- * Get the list of model names that will provide metadata
- * @return
- */
- Set<String> getConnectorMetadataModelNames();
-
- /**
- * Whether to cache connector metadata
- * @return
- */
- boolean cacheConnectorMetadata();
-
- /**
- * Save the stream to given path.
- * @param path
- */
- void saveFile(InputStream stream, String path) throws IOException;
-
- /**
- * Get the model with the given name.
- * @param name
- * @return
- */
- ModelInfo getModelInfo(String name);
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,50 +0,0 @@
-package com.metamatrix.metadata.runtime.api;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.StringUtil;
-
-public class MetadataSourceUtil {
-
- public static String getFileContentAsString(String path, MetadataSource iss) {
- File f = iss.getFile(path);
- if (f == null) {
- return null;
- }
- try {
- return ObjectConverterUtil.convertFileToString(f);
- } catch (IOException e) {
- LogManager.logError(LogConstants.CTX_CONFIG, e, e.getMessage());
- }
- return null;
- }
-
- /**
- * @see com.metamatrix.modeler.core.index.IndexSelector#getFileContent(java.lang.String, java.lang.String[], java.lang.String[])
- * @since 4.2
- */
- public static InputStream getFileContent(final String path, MetadataSource iss, final String[] tokens, final String[] tokenReplacements) {
- ArgCheck.isNotNull(tokens);
- ArgCheck.isNotNull(tokenReplacements);
- Assertion.isEqual(tokens.length, tokenReplacements.length);
- String fileContents = getFileContentAsString(path, iss);
- if(fileContents != null) {
- for(int i=0; i < tokens.length; i++) {
- final String token = tokens[i];
- final String tokenReplacement = tokenReplacements[i];
- fileContents = StringUtil.replaceAll(fileContents, token, tokenReplacement);
- }
- return new ByteArrayInputStream(fileContents.getBytes());
- }
- return null;
- }
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,116 +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.api;
-
-import java.util.Collection;
-import java.util.Date;
-
-/**
- * <p>The VirtualDatabase identifies a collection of DataSources and Virtual DataSources that a client can connect to and interrogate its metadata.</p>
- */
-public interface VirtualDatabase extends MetadataObject {
-/**
- * Return the description.
- * @return String
- */
- String getDescription();
-/**
- * Returns the ModelID's that exist in this virtual database.
- * @return Collection of the ModelID's contained in this VirtualDatabase
- */
- Collection getModelIDs();
-/**
- * Returns a short indicating if the status of the VirtualDatabase. There are four
- * status of the VirtualDatabase: "Incomplete", "Inactive", "Active", and "Deleted".
- * @return boolean true indicates marked for deletion
- */
- short getStatus();
-/**
- * Return the global unique identifier for this Virtual Databse. This is the ProjectGUID
- * that identifies the Design Time Configuration that created this VDB.
- * @return String
- */
- String getGUID();
-/**
- * Return the date the Virtual Database was created.
- * @return Date
- */
- Date getVersionDate();
-/**
- * Return the user name who create this version of the Virtual Database.
- * @return String
- */
- String getVersionBy();
-/**
- * Return the date the Virtual Database was created.
- * @return Date
- */
- Date getCreationDate();
-/**
- * Return the user name who create this Virtual Database.
- * @return String
- */
- String getCreatedBy();
-/**
- * Return the date the Virtual Database was updated.
- * @return Date
- */
- Date getUpdateDate();
-/**
- * Return the user name who update this version of the Virtual Database.
- * @return String
- */
- String getUpdatedBy();
-/**
- * Returns the DataTypeID's that exist in this virtual database.
- * @return Collection of the DataTypeID's contained in this VirtualDatabase
- */
- Collection getDataTypeIDs();
-/**
- * Update a VDB attribute. Only the attributes defined in <code>VirtualDatabase.ModifiableAttributes</code>
- * can be modefied.
- * @param attribute attribute to be updated.
- * @param value new value.
- */
- void update(String attribute, Object value);
-
- /**
- * Get this name of the VDB jar file.
- * @return the VDB's name; never null or zero-length
- */
- String getFileName();
-
- /**
- * Returns true if a WSDL is defined for this VDB
- * @return true if a WSDL is defined for this VDB
- */
- boolean hasWSDLDefined();
-
-/**
- * Defines the VDB attributes that can be modified.
- */
- public interface ModifiableAttributes{
- String DESCRIPTION = "description";
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -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.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 );
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,38 +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.api;
-
-
-/**
- * <p>The VirtualDatabaseID should uniquely identify a VirutalDatabase. This is accomplished when instantiating the class by passing the full name of the VirtualDatabase and the version. These 2 arguments uniquely identify a Virtual Database.</p>
- */
-public interface VirtualDatabaseID extends MetadataID {
-
-/**
- * Returns the version.
- * @return String
- */
- public String getVersion();
-
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,691 +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.platform.security.api;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import com.metamatrix.common.actions.AbstractObjectEditor;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
-import com.metamatrix.platform.admin.api.PermissionTreeView;
-import com.metamatrix.platform.security.util.RolePermissionFactory;
-
-public abstract class AbstractAuthorizationObjectEditor extends AbstractObjectEditor {
- public final static long serialVersionUID = -3690038844414207808L;
-
-
- /**
- * Create an instance of this editor, and specify whether actions are to be created
- * during modifications. If actions are created, then each action is sent directly
- * to the destination at the time the action is created.
- * @param createActions flag specifying whether modification actions should be created
- * for each invocation to <code>modifyObject</code>
- */
- public AbstractAuthorizationObjectEditor( boolean createActions ) {
- super(createActions);
-
- if ( doCreateActions() ) {
- this.setDestination(new com.metamatrix.common.actions.BasicModificationActionQueue());
- }
- }
-
- /**
- * Default ctor creates actions.
- */
- public AbstractAuthorizationObjectEditor() {
- this(true);
- }
-
- // ----------------------------------------------------------------------------------
- // C R E A T E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Create a new AuthorizationPolicy.
- * @param policyID the new policyID from which to create the policy (may not be null).
- * @return The newly created policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicyID</code> is null.
- */
- public AuthorizationPolicy createAuthorizationPolicy(AuthorizationPolicyID policyID) {
- if ( policyID == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
- }
- AuthorizationPolicyID targetID = (AuthorizationPolicyID) verifyTargetClass(policyID, AuthorizationPolicyID.class);
- AuthorizationPolicy policy = new AuthorizationPolicy(targetID);
-
- createCreationAction(targetID, policy);
-
- return policy;
- }
-
- // ----------------------------------------------------------------------------------
- // D E L E T E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Remove an <code>AuthorizationPolicy</code>.
- * @param policyID The target policy ID (may not be null).
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicyIC</code> is null.
- */
- public void remove( AuthorizationPolicyID policyID ) {
- if ( policyID == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
- }
- AuthorizationPolicyID targetID = (AuthorizationPolicyID) verifyTargetClass(policyID, AuthorizationPolicyID.class);
-
- createDestroyAction(targetID, targetID);
-
- }
-
- // ----------------------------------------------------------------------------------
- // C L O N E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Copy the <code>AuthorizationPermission</code>s from a source <code>AuthorizationPolicy</code>
- * to a target <code>AuthorizationPolicy</code> given an <code>AuthorizationRealm</code>.
- * @param targetPolicy The source policy for cloning.
- * @param sourcePerm The source permisison for cloning.
- * @param targetRealm The destination realm in which to place the permissions (may not be null).
- * @return The cloned policy.
- * @throws IllegalArgumentException if either the target <code>AuthorizationPolicy</code>
- * the source <code>AuthorizationPolicy</code> or the <code>AuthorizationRealm</code> is null.
- */
- public AuthorizationPolicy clonePermission(AuthorizationPolicy targetPolicy,
- AuthorizationPermission sourcePerm,
- AuthorizationRealm targetRealm) {
- if ( targetPolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( sourcePerm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0003));
- }
- if ( targetRealm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0004));
- }
-
- AuthorizationPolicy theTargetPolicy = (AuthorizationPolicy) verifyTargetClass(targetPolicy, AuthorizationPolicy.class);
- AuthorizationRealm newRealm = (AuthorizationRealm) verifyTargetClass(targetRealm, AuthorizationRealm.class);
-
- // Clone the permission
- AuthorizationPermission newPerm = null;
-
- try {
- newPerm = (AuthorizationPermission) sourcePerm.clone();
- } catch(CloneNotSupportedException e) {
- // They're all clonable but log anyway
- final Object[] params = { sourcePerm };
- final String msg = SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0005,params);
- LogManager.logError(LogConstants.CTX_AUTHORIZATION, e, msg );
- }
- newPerm.setRealm(newRealm);
-
- theTargetPolicy = this.addPermission(theTargetPolicy, newPerm);
-
- return theTargetPolicy;
- }
-
-
- /**
- * Copy the <code>Principals</code>s from a source <code>AuthorizationPolicy</code>
- * to a target <code>AuthorizationPolicy</code>.
- * @param sourcePolicy The source policy for cloning.
- * @param targetPolicy The source policy for cloning.
- * @return The cloned policy.
- * @throws IllegalArgumentException if either the target <code>AuthorizationPolicy</code>
- * the source <code>AuthorizationPolicy</code> or the <code>AuthorizationRealm</code> is null.
- */
- public AuthorizationPolicy clonePolicyPrincipals(AuthorizationPolicy sourcePolicy,
- AuthorizationPolicy targetPolicy) {
- return this.clonePolicyPrincipals(sourcePolicy, targetPolicy, null, null);
- }
-
- public AuthorizationPolicy clonePolicyPrincipals(AuthorizationPolicy sourcePolicy,
- AuthorizationPolicy targetPolicy, Set allPrincipals, EntitlementMigrationReport rpt) {
- if ( targetPolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( sourcePolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0006));
- }
-
- AuthorizationPolicy theSourcePolicy = (AuthorizationPolicy) verifyTargetClass(sourcePolicy, AuthorizationPolicy.class);
- AuthorizationPolicy theTargetPolicy = (AuthorizationPolicy) verifyTargetClass(targetPolicy, AuthorizationPolicy.class);
-
- Set oldPrincipals = theTargetPolicy.getPrincipals();
- if ( oldPrincipals.size() > 0 ) {
- theTargetPolicy = removeAllPrincipals(theTargetPolicy);
- }
-
- // Clone the Principals
- Set principals = new HashSet(theSourcePolicy.getPrincipals());
-
- //filter principals
- //TODO: add reporting for principals
- if (allPrincipals != null) {
- for (Iterator i = principals.iterator(); i.hasNext();) {
- MetaMatrixPrincipalName principal = (MetaMatrixPrincipalName)i.next();
- if (!allPrincipals.contains(principal.getName())) {
- i.remove();
- LogManager.logWarning(LogConstants.CTX_AUTHORIZATION, SecurityPlugin.Util.getString("AbstractAuthorizationObjectEditor.missing_principal", new Object[] {sourcePolicy.getAuthorizationPolicyID().getDisplayName(), principal.getName()})); //$NON-NLS-1$
- }
- }
- }
-
- theTargetPolicy = this.addAllPrincipals(theTargetPolicy, principals);
-
- return theTargetPolicy;
- }
-
- /**
- * Set the description on the policy.
- * @param policy The target policy (may not be null).
- * @param description The new policy description may be null or empty.
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy setDescription( AuthorizationPolicy policy, String description ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- AuthorizationPolicyID policyID = thePolicy.getAuthorizationPolicyID();
- // Keep old value for undo
- String oldDescription = policyID.getDescription();
-
- createExchangeAction(policyID,
- AuthorizationModel.Attribute.DESCRIPTION,
- oldDescription,
- description );
- policyID.setDescription(description);
-
- return thePolicy;
- }
-
- /**
- * Set the description on the policy.
- * @param policyID The target policy (may not be null).
- * @param description The new policy description may be null or empty.
- * @return The modified policyID.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicyID setDescription( AuthorizationPolicyID policyID, String description ) {
- if ( policyID == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
- }
-
- AuthorizationPolicyID thePolicyID = (AuthorizationPolicyID) verifyTargetClass(policyID, AuthorizationPolicyID.class);
- // Keep old value for undo
- String oldDescription = thePolicyID.getDescription();
-
- createExchangeAction(thePolicyID,
- AuthorizationModel.Attribute.DESCRIPTION,
- oldDescription,
- description );
- thePolicyID.setDescription(description);
-
- return thePolicyID;
- }
-
- /**
- * Add a principal to the policy.
- * @param policy The target policy (may not be null).
- * @param principal The principal to add to the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy addPrincipal( AuthorizationPolicy policy, MetaMatrixPrincipalName principal ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principal == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- createAddAction(thePolicy.getAuthorizationPolicyID(), AuthorizationModel.Attribute.PRINCIPAL_NAME, principal );
-
- thePolicy.addPrincipal(principal);
-
- return thePolicy;
- }
-
- /**
- * Add a set of principals to the policy.
- * @param policy The target policy (may not be null).
- * @param principals The set of principals to add to the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy addAllPrincipals( AuthorizationPolicy policy, Set principals ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principals == null || principals.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- createAddAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_SET,
- principals);
-
- thePolicy.addAllPrincipals(principals);
-
- return thePolicy;
- }
-
- /**
- * Remove a principal from the policy.
- * @param policy The target policy (may not be null).
- * @param principal The principal to remove from the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePrincipal( AuthorizationPolicy policy, MetaMatrixPrincipalName principal ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principal == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- Set principals = thePolicy.getPrincipals();
- if ( ! principals.contains(principal) ) {
- return policy;
- }
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_NAME,
- principal );
-
- thePolicy.removePrincipal(principal);
-
- return thePolicy;
- }
-
- /**
- * Remove a set of principals from the policy.
- * @param policy The target policy (may not be null).
- * @param principals The set of principals to remove from the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePrincipals( AuthorizationPolicy policy, Set principals ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principals == null || principals.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- Set oldPrincipals = thePolicy.getPrincipals();
- oldPrincipals.removeAll(principals);
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_SET,
- principals);
-
- // Set the policy's prinicpals to new ref.
- thePolicy.setPrincipals(oldPrincipals);
-
- return thePolicy;
- }
-
- /**
- * Remove all of the principals from the policy.
- * @param policy The target policy (may not be null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removeAllPrincipals( AuthorizationPolicy policy ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Keep old value for undo
- Set oldPrincipals = thePolicy.getPrincipals();
-
- if ( oldPrincipals.size() == 0 ) {
- return policy;
- }
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_SET,
- oldPrincipals);
-
- // Set the policy's prinicpals to empty set.
- thePolicy.setPrincipals(Collections.EMPTY_SET);
-
- return thePolicy;
- }
-
- /**
- * Modifies permissions belonging to the given <code>AuthorizationPolicy</code>. All are found in
- * the given tree view of <code>PermissionDataNode</code>s.<br></br>
- * <strong>Note that if <code>showHidden</code> is set to <code>false</code> in <code>treeView</code>,
- * permissions WILL NOT be modified in those descendants.</strong>
- * @param treeView The permission tree view containg the modified nodes.
- * @param policy The <code>AuthorizationPolicy</code>, possibly new, on which to apply the new permissions.
- * @return The set of <code>PermissionDataNode</code>s that were modified.
- */
- public abstract Collection modifyPermissions(PermissionTreeView treeView, AuthorizationPolicy policy);
-
- /**
- * Add an <code>AuthorizationPermission</code> to the policy.
- * @param policy The target policy (may not be null).
- * @param permission The permission to add to the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy addPermission( AuthorizationPolicy policy, AuthorizationPermission permission ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permission == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- // Don't allow creation of roles
- AuthorizationRealm realm = permission.getRealm();
- if ( realm.getRealmName().equals(RolePermissionFactory.getRealmName()) ) {
- return thePolicy;
- }
-
- // If AuthorizationActions == NONE, just remove existing perm on this resource
- String resourceToRemove = null;
- if ( permission.getActions().equals(StandardAuthorizationActions.NONE) ) {
- resourceToRemove = permission.getResourceName();
- }
-
- Iterator itr = thePolicy.iterator();
- while ( itr.hasNext() ) {
- AuthorizationPermission tmpPerm = (AuthorizationPermission) itr.next();
-
- // See if there's a perm to remove...
- if ( resourceToRemove != null && tmpPerm.getResourceName().equals(resourceToRemove) ) {
- thePolicy = removePermission(thePolicy, tmpPerm);
- break;
- }
-
- // Don't do anything if permission is already present.
- if ( permission.equals(tmpPerm) ) {
- return thePolicy;
- }
- }
-
- createAddAction(thePolicy.getAuthorizationPolicyID(), AuthorizationModel.Attribute.PERMISSION, permission );
-
- thePolicy.addPermission(permission);
-
- return thePolicy;
- }
-
- /**
- * Add a set of <code>AuthorizationPermission</code>s to the policy.
- * @param policy The target policy (may not be null).
- * @param permissions The set of permissions to add to the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- protected AuthorizationPolicy addAllPermissions( AuthorizationPolicy policy, Set permissions ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permissions == null || permissions.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- Set permsToRemove = new HashSet();
-
- Iterator permItr = permissions.iterator();
- while ( permItr.hasNext() ) {
- AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
- // If any new perm has AuthorizationActions == NONE, just remove existing perm from policy
- if ( perm.getActions().equals(StandardAuthorizationActions.NONE) ) {
- permsToRemove.add(perm);
- }
-
- // Don't allow creation of roles
- AuthorizationRealm realm = perm.getRealm();
- if ( realm.getRealmName().equals(RolePermissionFactory.getRealmName()) ) {
- return thePolicy;
- }
- }
-
- // Remove permissions whose Actions are being set to NONE
- if ( permsToRemove.size() > 0 ) {
- thePolicy = removePermissions(thePolicy, permsToRemove);
- }
-
- // Keep old value for undo
- AuthorizationPermissions oldPermissions = thePolicy.getAuthorizationPermissions();
- AuthorizationPermissions newPermissions = new AuthorizationPermissionsImpl();
- newPermissions.add(permissions);
- if ( oldPermissions != null && oldPermissions.size() > 0 ) {
- // Don't add any that are already in there
- newPermissions.removeAll(oldPermissions);
- }
-// DEBUG:
-/*if ( newPermissions.size() > 0 ) {
- System.out.println(" *** addAllPermissions: adding " + newPermissions.size() + " permissions" );
- Iterator itr = newPermissions.iterator();
- while ( itr.hasNext() ) {
- System.out.println(" " + itr.next());
- }
-} else {
- System.out.println(" *** addAllPermissions: adding NO permissions");
-}*/
-
- // NOTE: The Set of permissions has been converted to an AuthorizationPermissionsImpl obj.
- // The arg[0] of the action must be cast to that type.
- createAddAction(thePolicy.getAuthorizationPolicyID(), AuthorizationModel.Attribute.PERMISSIONS, newPermissions );
-
- thePolicy.addAllPermissions(newPermissions);
-
- return thePolicy;
- }
-
- /**
- * Remove an <code>AuthorizationPermission</code> from the policy.
- * @param policy The target policy (may not be null).
- * @param permission The permission to remove from the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePermission( AuthorizationPolicy policy, AuthorizationPermission permission ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permission == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Keep old value for undo
- AuthorizationPermission oldPermission = null;
- AuthorizationPermissions oldPermissions = thePolicy.getAuthorizationPermissions();
- Iterator permissionItr = oldPermissions.iterator();
- while ( permissionItr.hasNext() ) {
- AuthorizationPermission tmpPermission = (AuthorizationPermission) permissionItr.next();
- if ( permission.equals( tmpPermission ) ) {
- oldPermission = tmpPermission;
- break;
- }
- }
-
- // If permission was not present, do nothing.
- if ( oldPermission == null ) {
- return policy;
- }
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PERMISSION,
- oldPermission);
-
- thePolicy.removePermission(permission);
-
- return thePolicy;
- }
-
- /**
- * Remove a <code>Set</code> of <code>AuthorizationPermission</code>s from the policy.
- * @param policy The target policy (may not be null).
- * @param permissions The set of permissions to remove from the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePermissions( AuthorizationPolicy policy, Set permissions ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permissions == null || permissions.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Some/All of these will be removed
- AuthorizationPermissions oldPermissions = thePolicy.getAuthorizationPermissions();
-
-// DEBUG:
-/*System.out.println(" *** removePermissions: Old perms " + oldPermissions.size());
-Iterator itr = oldPermissions.iterator();
-while ( itr.hasNext() ) {
- System.out.println(" Old perm: " + itr.next());
-}*/
-// DEBUG:
-/*System.out.println(" *** removePermissions: Perms to remove");
-itr = permissions.iterator();
-while ( itr.hasNext() ) {
- System.out.println(" Removing perm: " + itr.next());
-}*/
- oldPermissions.removeAll(permissions);
- // Now left with subset of old permissions
-// DEBUG:
-/*System.out.println(" *** removePermissions: Perms left:");
-itr = oldPermissions.iterator();
-while ( itr.hasNext() ) {
- System.out.println(" Leaving perm: " + itr.next());
-}*/
-
-// DEBUG:
-//System.out.println(" *** removePermissions: New size: " + oldPermissions.size() + "\n");
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PERMISSION_SET,
- permissions );
-
- thePolicy.setPermissions(oldPermissions);
-
- return thePolicy;
- }
-
- /**
- * Remove <emph>ALL</emph> <code>AuthorizationPermission</code>s from the
- * given <code>AuthorizationPolicy</code> that have the given resource and are
- * in the given <code>AuthorizationRealm</code>.
- * @param policy The target policy (may not be null).
- * @param resource The resource for which permissions will be removed.
- * @param realm The realm that permissions with given resource must belong to
- * to be removed.
- * @return The modified policy with permissions removed.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> or
- * <code>AuthorizationRealm</code> is null or if the resource is null or empty.
- */
- public AuthorizationPolicy removePermissions( AuthorizationPolicy policy, String resource, AuthorizationRealm realm ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( resource == null || resource.trim().length() == 0 ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0007));
- }
- if ( realm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0008));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- AuthorizationRealm theRealm = (AuthorizationRealm) verifyTargetClass(realm, AuthorizationRealm.class);
-
- // Find candidate permissions for removal
- Set removePerms = new HashSet();
- Iterator permItr = thePolicy.iterator();
- while ( permItr.hasNext() ) {
- AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
-
- if ( perm.getResourceName().equals(resource) && perm.getRealm().equals(theRealm) ) {
- removePerms.add(perm);
- }
- }
-
- // Remove the permissions
- if ( removePerms.size() > 0 ) {
- thePolicy = this.removePermissions(thePolicy, removePerms);
- }
-
- return thePolicy;
- }
-
- /**
- * Remove all of the permissions from the policy.
- * @param policy The target policy (may not be null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removeAllPermissions( AuthorizationPolicy policy ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Keep old value for undo
- AuthorizationPermissions oldPermissions = new AuthorizationPermissionsImpl(thePolicy.getAuthorizationPermissions());
- if ( oldPermissions.size() == 0 ) {
- return thePolicy;
- }
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PERMISSIONS,
- oldPermissions);
-
- // Sets the policy's permissions to new empty ref.
- thePolicy.removePermissions();
-
- return thePolicy;
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,88 +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.platform.security.api;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.common.actions.AttributeDefinition;
-import com.metamatrix.common.actions.ClassDefinition;
-
-public class AuthorizationModel {
-
- public static class Class {
- public static final ClassDefinition POLICY = new ClassDefinition( AuthorizationPolicy.class );
- public static final ClassDefinition POLICYID = new ClassDefinition( AuthorizationPolicyID.class );
- }
-
- public static class Attribute {
- // AuthorizationPolicy
- public static final AttributeDefinition DESCRIPTION = new AttributeDefinition(0,"DESCRIPTION"); //$NON-NLS-1$
- public static final AttributeDefinition PRINCIPAL_NAME = new AttributeDefinition(1,"PRINCIPAL_NAME"); //$NON-NLS-1$
- public static final AttributeDefinition PRINCIPAL_SET = new AttributeDefinition(2,"PRINCIPAL_SET"); //$NON-NLS-1$
- public static final AttributeDefinition PERMISSION = new AttributeDefinition(3,"PERMISSION"); //$NON-NLS-1$
- public static final AttributeDefinition PERMISSIONS = new AttributeDefinition(4,"PERMISSIONS"); //$NON-NLS-1$
- public static final AttributeDefinition PERMISSION_SET = new AttributeDefinition(5,"PERMISSION_SET"); //$NON-NLS-1$
- }
-
- private static int ATTRIBUTE_DEFINITION_COUNT = 6;
- private static Map classLookup = new HashMap(3);
- private static Map classLookupByIDClass = new HashMap();
- private static AttributeDefinition[] attributeDefinitions = new AttributeDefinition[ATTRIBUTE_DEFINITION_COUNT];
-
- static {
- // AuthorizationPolicy
- classLookup.put( Class.POLICY.getClassObject(), Class.POLICY );
-
- classLookupByIDClass.put( Class.POLICYID.getClassObject(), AuthorizationPolicyID.class );
-
- addAttributeToLookupMap( Attribute.DESCRIPTION );
- addAttributeToLookupMap( Attribute.PRINCIPAL_NAME );
- addAttributeToLookupMap( Attribute.PRINCIPAL_SET );
- addAttributeToLookupMap( Attribute.PERMISSION );
- addAttributeToLookupMap( Attribute.PERMISSIONS );
- addAttributeToLookupMap( Attribute.PERMISSION_SET );
-
- }
-
- public static ClassDefinition getClassDefinition( Class c ) {
- return (ClassDefinition) classLookup.get(c);
- }
- public static ClassDefinition getClassDefinition( Object obj ) {
- return (ClassDefinition) classLookup.get(obj.getClass());
- }
- public static ClassDefinition getClassDefinition( AuthorizationPolicyID policyID ) {
- return (ClassDefinition) classLookupByIDClass.get(policyID.getClass());
- }
- public static AttributeDefinition getAttributeDefinition( int code ) {
- if ( code < 0 || code >= ATTRIBUTE_DEFINITION_COUNT ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0009, code));
- }
- return attributeDefinitions[ code ];
- }
-
- private static void addAttributeToLookupMap( AttributeDefinition attribute ) {
- attributeDefinitions[ attribute.getCode() ] = attribute;
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,255 +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.platform.security.api;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.platform.admin.api.AuthorizationEditor;
-import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
-import com.metamatrix.platform.admin.api.PermissionDataNode;
-import com.metamatrix.platform.admin.api.PermissionTreeView;
-import com.metamatrix.platform.admin.apiimpl.PermissionDataNodeImpl;
-
-/**
- * Editor allows automatic creation of individual {@link com.metamatrix.common.actions.Actions}
- * in an enforcable way when making modifications to Authorizations.<br></br>
- * The actions can be submited to the Authorization Service to execute them in a transaction.
- */
-public class AuthorizationObjectEditor extends AbstractAuthorizationObjectEditor implements AuthorizationEditor {
-
- public final static long serialVersionUID = 5799168432068176908L;
-
- /**
- * Create an instance of this editor, and specify whether actions are to be created
- * during modifications. If actions are created, then each action is sent directly
- * to the destination at the time the action is created.
- * @param createActions flag specifying whether modification actions should be created
- * for each invocation to <code>modifyObject</code>
- */
- public AuthorizationObjectEditor( boolean createActions ) {
- super(createActions);
- }
-
- /**
- * Default ctor creates actions.
- */
- public AuthorizationObjectEditor() {
- super(true);
- }
-
- // ----------------------------------------------------------------------------------
- // C L O N E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Copy the <code>AuthorizationPermission</code>s from a source <code>AuthorizationPolicy</code>
- * to a target <code>AuthorizationPolicy</code> given an <code>AuthorizationRealm</code>.
- * @param sourcePolicy The source policy for cloning.
- * @param targetPolicy The source policy for cloning.
- * @param targetRealm The destination realm in which to place the permissions (may not be null).
- * @param allPaths Skip clone of any permission whose resource is not in this set. This set is
- * comprised of all allowable resources in the target realm.
- * @return The cloned policy.
- * @throws IllegalArgumentException if either the target <code>AuthorizationPolicy</code>
- * the source <code>AuthorizationPolicy</code> or the <code>AuthorizationRealm</code> is null.
- */
- public AuthorizationPolicy clonePolicyPermissions(AuthorizationPolicy sourcePolicy,
- AuthorizationPolicy targetPolicy,
- AuthorizationRealm targetRealm,
- Set allPaths, EntitlementMigrationReport rpt) {
- if ( targetPolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( sourcePolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0006));
- }
- if ( targetRealm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0004));
- }
-
- // Clone the permissions
- Set permissions = new HashSet();
- Iterator permItr = sourcePolicy.iterator();
- while ( permItr.hasNext() ) {
- AuthorizationPermission originalPerm = (AuthorizationPermission) permItr.next();
- String resourcePath = originalPerm.getResourceName();
-
- if ( BasicAuthorizationPermission.isRecursiveResource(resourcePath) ) {
- resourcePath = BasicAuthorizationPermission.removeRecursion(resourcePath);
- }
-
- if ( allPaths.contains(resourcePath) ) {
- // Fill in entry values
- if (rpt != null) {
- rpt.addResourceEntry(SecurityPlugin.Util.getString("AuthorizationServiceImpl.Succeeded_migration"), //$NON-NLS-1$
- resourcePath,
- sourcePolicy.getAuthorizationPolicyID().getDisplayName(),
- targetPolicy.getAuthorizationPolicyID().getDisplayName(),
- StandardAuthorizationActions.getActionsString(originalPerm.getActions().getValue()),
- SecurityPlugin.Util.getString("AuthorizationServiceImpl.Migrated")); //$NON-NLS-1$
- }
-
- try {
- // Clone for saftey
- AuthorizationPermission newPerm = (AuthorizationPermission) originalPerm.clone();
- newPerm.setRealm(targetRealm);
- permissions.add(newPerm);
- } catch(CloneNotSupportedException e) {
- // They're all clonable but log anyway
- final Object[] params = { originalPerm };
- final String msg = SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0005, params);
- LogManager.logError(LogConstants.CTX_AUTHORIZATION, e, msg);
- }
- } else {
- if (rpt != null) {
- rpt.addResourceEntry(SecurityPlugin.Util.getString("AuthorizationServiceImpl.Failed_migration"), //$NON-NLS-1$
- resourcePath,
- sourcePolicy.getAuthorizationPolicyID().getDisplayName(),
- "", //$NON-NLS-1$
- StandardAuthorizationActions.getActionsString(originalPerm.getActions().getValue()),
- SecurityPlugin.Util.getString("AuthorizationServiceImpl.The_resource_for_this_permission_does_not_exist_in_the_target_VDB.")); //$NON-NLS-1$
- }
-
- final Object[] params = { originalPerm };
- final String msg = SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0011, params);
- LogManager.logWarning(LogConstants.CTX_AUTHORIZATION, msg);
- }
-
- }
- return this.addAllPermissions(targetPolicy, permissions);
- }
-
- // ----------------------------------------------------------------------------------
- // M O D I F I C A T I O N M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Modifies permissions belonging to the given <code>AuthorizationPolicy</code>. All are found in
- * the given tree view of <code>PermissionDataNode</code>s.<br></br>
- * <strong>Note that if <code>showHidden</code> is set to <code>false</code> in <code>treeView</code>,
- * permissions WILL NOT be modified in those descendants.</strong>
- * @param treeView The permission tree view containg the modified nodes.
- * @param policy The <code>AuthorizationPolicy</code>, possibly new, on which to apply the new permissions.
- * @return The set of <code>PermissionDataNode</code>s that were modified.
- */
- public Collection modifyPermissions(PermissionTreeView treeView, AuthorizationPolicy policy) {
- // Make sure it's a valid policy
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0012));
- }
- AuthorizationPolicyID thePolicyID = policy.getAuthorizationPolicyID();
- AuthorizationRealm realm = new AuthorizationRealm(thePolicyID.getVDBName(), thePolicyID.getVDBVersionString());
-
- Set permissionsToAdd = new HashSet();
- Set permissionsToRemove = new HashSet();
- List modifiedNodes = treeView.getModified();
- Set effectedNodes = new HashSet();
- AuthorizationPermissions currentPerms = policy.getAuthorizationPermissions();
-
- // Create permissions for all modified nodes in tree
- BasicAuthorizationPermissionFactory permFactory = new BasicAuthorizationPermissionFactory();
-
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Starting..."); //$NON-NLS-1$
- Iterator nodeItr = modifiedNodes.iterator();
- while ( nodeItr.hasNext() ) {
- PermissionDataNodeImpl aNode = (PermissionDataNodeImpl) nodeItr.next();
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Effected node: " + aNode); //$NON-NLS-1$
- AuthorizationActions theActions = aNode.getActions();
- String resourceName = aNode.getResourceName();
- AuthorizationPermission newPerm = null;
- AuthorizationPermission oldPerm = null;
-
- boolean isGroupNode = aNode.isGroupNode();
-
- if ( aNode.isLeafNode() || isGroupNode ) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: LEAF or GROUP - actions <" + theActions + ">"); //$NON-NLS-1$ //$NON-NLS-2$
- // Remove old permission on this node, if it exists
- oldPerm = getExistingPermission(aNode, policy);
- if ( oldPerm != null ) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,
- "modifyPermissions: Removing permission: " + oldPerm); //$NON-NLS-1$
- currentPerms.remove(oldPerm);
- permissionsToRemove.add(oldPerm);
- effectedNodes.add(oldPerm);
- }
- if ( ! theActions.equals(StandardAuthorizationActions.NONE) ) {
-
- if ( aNode.isLeafNode() ) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Creating LEAF permission."); //$NON-NLS-1$
-
- // Create leaf permission
- newPerm = permFactory.create(resourceName, realm, theActions);
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Adding new ELEMENT perm: <" + newPerm.getResourceName() + " - " + newPerm.getActions() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- permissionsToAdd.add(newPerm);
-
- } else if (isGroupNode) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Creating GROUP " + theActions + " permission."); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Create new permissions
- newPerm = permFactory.create(resourceName, realm, theActions);
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Adding new GROUP perm: <" + newPerm.getResourceName() + " - " + newPerm.getActions() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- permissionsToAdd.add(newPerm);
- }
- }
-
- // Add this node as effected
-// effectedNodes.add(aNode);
- }
-
- // Unmodify this node
- aNode.setModified(false, false);
- } // end modified nodes itr
-
- // Remove all old modified permissions
- this.removePermissions(policy, permissionsToRemove);
-
- // Add new/modified permissions
- this.addAllPermissions(policy, permissionsToAdd);
-
- return effectedNodes;
- }
-
- // ----------------------------------------------------------------------------------
- // H E L P E R M E T H O D S
- // ----------------------------------------------------------------------------------
-
- private AuthorizationPermission getExistingPermission(PermissionDataNode aNode, AuthorizationPolicy policy) {
- AuthorizationPermission permToRemove = null;
- String resourceName = aNode.getResourceName();
- AuthorizationResource resource = new DataAccessResource(resourceName);
- permToRemove = policy.findPermissionWithResource(resource);
- return permToRemove;
- }
-
-}
-
-
-
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.concurrent.locks.ReentrantLock;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
@@ -47,34 +48,32 @@
*/
public final class AuthorizationPermissionsImpl implements AuthorizationPermissions {
- private Set thePermissions;
+ private static final long serialVersionUID = -5223347499647193459L;
+
+ private Set<AuthorizationPermission> thePermissions = new HashSet<AuthorizationPermission>();
// Used to provide permissions collection synchronization
- private Object lockObj = new Object();
+ private ReentrantLock lockObj = new ReentrantLock();
- private boolean readOnly;
+ private boolean readOnly = false;
- /**
- * Creates a new AuthorizationPermissionsImpl object containing no AuthorizationPermission objects.
- */
public AuthorizationPermissionsImpl() {
- this.readOnly = false;
- this.thePermissions = new HashSet();
+
}
-
/**
* Create a new AuthorizationPermissionsImpl object that is a copy of the original.
* Make a deep copy of the orig.
* @param orig The original to be copied.
*/
public AuthorizationPermissionsImpl( AuthorizationPermissions orig ) {
- this();
- synchronized (this.lockObj) {
+
+ lockObj.lock();
+ try {
Iterator permItr = orig.iterator();
while ( permItr.hasNext() ) {
AuthorizationPermission aPerm = (AuthorizationPermission) permItr.next();
if ( aPerm != null ) {
try {
- this.thePermissions.add(aPerm.clone());
+ this.thePermissions.add((AuthorizationPermission)aPerm.clone());
} catch ( CloneNotSupportedException e ) {
// They're all clonable but log anyway
final Object[] params = { aPerm };
@@ -84,6 +83,8 @@
}
}
}
+ } finally {
+ lockObj.unlock();
}
}
@@ -121,8 +122,11 @@
}
boolean result = false;
if ( permission != null ) {
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
result = this.thePermissions.add(permission);
+ } finally {
+ lockObj.unlock();
}
}
return result;
@@ -177,8 +181,11 @@
*/
public boolean remove(AuthorizationPermission permission) {
boolean result = false;
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
result = this.thePermissions.remove(permission);
+ } finally {
+ lockObj.unlock();
}
return result;
}
@@ -225,8 +232,11 @@
*/
public Iterator iterator() {
Iterator permItr = Collections.EMPTY_SET.iterator();
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
permItr = this.thePermissions.iterator();
+ } finally {
+ lockObj.unlock();
}
return permItr;
}
@@ -296,13 +306,16 @@
*/
private boolean addPermissions(Iterator permIter) {
boolean result = false;
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
while ( permIter.hasNext() ) {
AuthorizationPermission aPerm = (AuthorizationPermission) permIter.next();
if ( aPerm != null && this.thePermissions.add(aPerm) && !result ) {
result = true;
}
}
+ } finally {
+ lockObj.unlock();
}
return result;
}
@@ -316,13 +329,16 @@
*/
private boolean removePermissions(Iterator permIter) {
boolean result = false;
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
while ( permIter.hasNext() ) {
AuthorizationPermission aPerm = (AuthorizationPermission) permIter.next();
if ( aPerm != null && this.thePermissions.remove(aPerm) && !result ) {
result = true;
}
}
+ } finally {
+ lockObj.unlock();
}
return result;
}
Copied: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java (from rev 1899, branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java)
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java (rev 0)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -0,0 +1,36 @@
+/*
+ * 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.platform.security.api;
+
+import java.util.Collection;
+
+public class AuthorizationPoliciesHolder {
+ private Collection<AuthorizationPolicy> policies;
+
+ public void setAuthorizationPolicies(Collection<AuthorizationPolicy> policies) {
+ this.policies = policies;
+ }
+
+ public Collection<AuthorizationPolicy> getAuthorizationPolicies(){
+ return this.policies;
+ }
+}
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -38,10 +38,12 @@
*/
public class AuthorizationPolicy implements Comparable, Serializable {
- /**
+ private static final long serialVersionUID = -4542635173812413914L;
+
+ /**
* Contains principal name
*/
- private Set principals;
+ private Set<MetaMatrixPrincipalName> principals;
private AuthorizationPermissions permissions;
@@ -56,7 +58,7 @@
throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
}
this.authorizationPolicyID = id;
- this.principals = new LinkedHashSet();
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>();
this.permissions = new AuthorizationPermissionsImpl();
}
@@ -67,12 +69,12 @@
* @param principals the set of <code>MetaMatrixPrincipalName</code>s to which this policy applies.
* @param permissions the permissions that define the resource access for this policy.
*/
- public AuthorizationPolicy( AuthorizationPolicyID id, Set principals, Set permissions ) {
+ public AuthorizationPolicy( AuthorizationPolicyID id, Set<MetaMatrixPrincipalName> principals, Set permissions ) {
this.authorizationPolicyID = id;
if ( principals != null ) {
- this.principals = new LinkedHashSet(principals);
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>(principals);
} else {
- this.principals = new LinkedHashSet();
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>();
}
this.permissions = new AuthorizationPermissionsImpl();
this.permissions.add(permissions);
@@ -84,7 +86,7 @@
*/
public AuthorizationPolicy( AuthorizationPolicy orig ) {
this.authorizationPolicyID = orig.authorizationPolicyID;
- this.principals = new LinkedHashSet( orig.principals );
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>( orig.principals );
this.permissions = new AuthorizationPermissionsImpl();
Iterator iter = orig.iterator();
while ( iter.hasNext() ) {
@@ -172,7 +174,7 @@
* @return the set of <code>MetaMatrixPrincipalName</code>s to which this
* policy applies; never null but possibly empty
*/
- public Set getPrincipals() {
+ public Set<MetaMatrixPrincipalName> getPrincipals() {
return principals;
}
@@ -387,38 +389,6 @@
// Compare policy IDs
return (obj1.hashCode() == obj2.hashCode()) ? 0 :
obj1.authorizationPolicyID.compareTo(obj2.authorizationPolicyID);
-
-// JPC 04/25/03 - PolicyIDs are unique so doesn't seem like we need to compare all the rest of this stuff...
-// // Compare policy IDs
-// int compVal = AuthorizationPolicyID.compare(obj1.authorizationPolicyID, obj2.authorizationPolicyID);
-//
-// // Compare principals
-// if ( compVal == 0 ) {
-// compVal += obj1.principals.equals(obj2.principals) ? 0 : -1;
-// }
-//
-// // Compare permissions -
-// // One must imply all of the other AND other must imply all of the one
-// Iterator permItr = obj2.permissions.iterator();
-// while ( permItr.hasNext() && compVal == 0 ) {
-// AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
-// try {
-// compVal += obj1.permissions.implies(perm) ? 0 : -1;
-// } catch ( MetaBaseResourceNotResolvedException e ) {
-// // Do nothing
-// }
-// }
-// permItr = obj1.permissions.iterator();
-// while ( permItr.hasNext() && compVal == 0 ) {
-// AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
-// try {
-// compVal += obj2.permissions.implies(perm) ? 0 : -1;
-// } catch ( MetaBaseResourceNotResolvedException e ) {
-// // Do nothing
-// }
-// }
-//
-// return compVal;
}
// =========================================================================
@@ -453,9 +423,9 @@
* this policy will apply to no principals.
* @param principals the new set of <code>MetaMatrixPrincipalName</code>s to which this policy applies.
*/
- public void setPrincipals(Set principals) {
+ public void setPrincipals(Set<MetaMatrixPrincipalName> principals) {
if ( principals != null ) {
- this.principals = new LinkedHashSet(principals);
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>(principals);
} else {
this.principals.clear();
}
@@ -542,7 +512,7 @@
* @return true if this policy changed as a result of the additions.
* @throws IllegalArgumentException if the specified set of principals is null or if the set contains a null value.
*/
- public boolean addAllPrincipals(Set newPrincipals) {
+ public boolean addAllPrincipals(Set<MetaMatrixPrincipalName> newPrincipals) {
if ( newPrincipals == null ) {
throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0022));
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -42,6 +42,7 @@
import org.jdom.input.DOMBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
+import org.teiid.adminapi.AdminRoles;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -57,7 +58,7 @@
*/
public class AuthorizationPolicyFactory {
- private static final String GROUP = "group"; //$NON-NLS-1$
+ private static final String ROLE = "role"; //$NON-NLS-1$
private static final String PRINCIPALS = "principals"; //$NON-NLS-1$
private static final String ALLOW = "allow-"; //$NON-NLS-1$
private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
@@ -163,7 +164,7 @@
if (principalsElem != null) {
- List groups = principalsElem.getChildren(GROUP);
+ List groups = principalsElem.getChildren(ROLE);
for (final Iterator groupsIter = groups.iterator(); groupsIter.hasNext();) {
final Element group = (Element)groupsIter.next();
@@ -226,7 +227,7 @@
for (final Iterator principalsIter = principals.iterator(); principalsIter.hasNext();) {
MetaMatrixPrincipalName principal = (MetaMatrixPrincipalName)principalsIter.next();
- principalsElement.addContent(new Element(GROUP).setText(principal.getName()));
+ principalsElement.addContent(new Element(ROLE).setText(principal.getName()));
}
}
} // for
@@ -268,4 +269,14 @@
}
return result;
}
+
+ public static Collection<AuthorizationPolicy> buildDefaultAdminPolicies() {
+ Properties p = new Properties();
+ for (String role:AdminRoles.getAllRoleNames()) {
+ p.setProperty(role, role);
+ }
+ return buildAdminPolicies(p);
+
+ }
+
}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,208 +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.vdb.materialization;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.metamatrix.core.util.StringUtil;
-
-/**
- * Enumeration representing a type of database.
- * @since 4.2
- */
-public final class DatabaseDialect implements Serializable {
-
- private static final int NUMBER_OF_TYPES = 6;
- private static final Map DATABASE_DIALECT_MAP = new HashMap(NUMBER_OF_TYPES);
- private static final List DATABASE_DIALECTS = new ArrayList(NUMBER_OF_TYPES);
-
- private static final String ORACLE_TYPE = "Oracle"; //$NON-NLS-1$
- private static final String DB2_TYPE = "DB2"; //$NON-NLS-1$
- private static final String SQL_SERVER_TYPE = "SqlServer"; //$NON-NLS-1$
- private static final String SQL_SERVER_TYPE2 = "sql_server"; //$NON-NLS-1$
- private static final String SYBASE_TYPE = "Sybase"; //$NON-NLS-1$
- private static final String MYSQL_TYPE = "MySQL"; //$NON-NLS-1$
-
-
- private static final String METAMATRIX_TYPE = "MetaMatrix"; //$NON-NLS-1$
- private static final String CONNECTION_PROPS_TYPE = "ConnectionProps"; //$NON-NLS-1$
-
- private static final String ORACLE_DRIVER = "com.metamatrix.jdbc.oracle.OracleDriver"; //$NON-NLS-1$
- private static final String DB2_DRIVER = "com.metamatrix.jdbc.db2.DB2Driver"; //$NON-NLS-1$
- private static final String SQLSERVER_DRIVER = "com.metamatrix.jdbc.sqlserver.SQLServerDriver"; //$NON-NLS-1$
- private static final String SYBASE_DRIVER = "com.metamatrix.jdbc.sybase.SybaseDriver"; //$NON-NLS-1$
- private static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver"; //$NON-NLS-1$
- private static final String METAMATRIX_DRIVER = "com.metamatrix.jdbc.MMDriver"; //$NON-NLS-1$
-
- // Represents supported RDBMS types
- public static final DatabaseDialect ORACLE = newDatabaseDialect(ORACLE_TYPE, ORACLE_DRIVER);
- public static final DatabaseDialect DB2 = newDatabaseDialect(DB2_TYPE, DB2_DRIVER);
- public static final DatabaseDialect SQL_SERVER = newDatabaseDialect(SQL_SERVER_TYPE, SQLSERVER_DRIVER);
- public static final DatabaseDialect SYBASE = newDatabaseDialect(SYBASE_TYPE, SYBASE_DRIVER);
- public static final DatabaseDialect MYSQL = newDatabaseDialect(MYSQL_TYPE, MYSQL_DRIVER);
-
- // Used only internally for generating internal script types
- public static final DatabaseDialect METAMATRIX = new DatabaseDialect(METAMATRIX_TYPE, METAMATRIX_DRIVER);
- public static final DatabaseDialect CONNECTION_PROPS = new DatabaseDialect(CONNECTION_PROPS_TYPE);
-
- private String type;
- private String driverClassname;
-
- /**
- * Get the named type of this <code>DatabaseDialect</code>.
- * @return The named type.
- */
- public String getType() {
- return this.type;
- }
-
- /**
- * @return Returns the driverClassname.
- */
- public String getDriverClassname() {
- return driverClassname;
- }
-
- /**
- * Get a collection of all known DatabaseDialects that may be iterated over, etc.
- * @return All known DatabaseDialect instances.
- * @since 4.2
- */
- public static Collection getAllDialects() {
- return DATABASE_DIALECTS;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- * @since 4.2
- */
- public boolean equals(Object obj) {
- if ( ! (obj instanceof DatabaseDialect) ) {
- return false;
- }
- return ((DatabaseDialect)obj).type == type;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- * @since 4.2
- */
- public int hashCode() {
- return type.hashCode();
- }
-
- /**
- * @see java.lang.Object#toString()
- * @since 4.2
- */
- public String toString() {
- return type;
- }
-
- /**
- * Don't allow outside instantiation.
- * @param type
- * @since 4.2
- */
- private DatabaseDialect(String type) {
- this(type, null);
- }
- private DatabaseDialect(String type, String driver) {
- this.type = type;
- this.driverClassname = driver;
- }
-
- /**
- * @param type
- * @return
- * @since 4.2
- */
- private static DatabaseDialect newDatabaseDialect(final String type, final String driver) {
- final DatabaseDialect result = new DatabaseDialect(type, driver);
- DATABASE_DIALECT_MAP.put(type.toLowerCase(), result);
- DATABASE_DIALECTS.add(result);
- return result;
- }
-
- /**
- * Implemented so that deserialization of this object
- * produces the same value as the serialized.
- * @return A new instance of the equivalent serialized object.
- * @throws java.io.ObjectStreamException
- */
- private Object readResolve () throws java.io.ObjectStreamException {
- DatabaseDialect aType = (DatabaseDialect)DATABASE_DIALECT_MAP.get(this.type.toLowerCase());
- if ( aType != null ) {
- return aType;
- }
- return newDatabaseDialect(this.type, this.driverClassname);
- }
-
- /**
- * Based on the Database type supplied get the dialect supported. If the
- * type supplied not a registered dialect a null returned
- * @param type - type of database like oracle, sqlserver, db2 mmx etc.
- * @return dialect if match found; null otherwise.
- */
- public static DatabaseDialect getDatabaseDialect(String type) {
- if (type.equalsIgnoreCase("mmx")) { //$NON-NLS-1$
- type = METAMATRIX_TYPE;
- }
- return (DatabaseDialect)DATABASE_DIALECT_MAP.get(type.toLowerCase());
- }
-
-
- /**
- * Based on the Database type supplied get the dialect supported. If the
- * type supplied not a registered dialect a null returned
- * @param type - type of database like oracle, sqlserver, db2 mmx etc.
- * @return dialect if match found; null otherwise.
- */
- public static DatabaseDialect getDatabaseDialectByDDLName(String ddlName) {
-
- if (StringUtil.indexOfIgnoreCase(ddlName, ORACLE_TYPE) != -1) {
- return ORACLE;
- }
- else if (StringUtil.indexOfIgnoreCase(ddlName, DB2_TYPE) != -1) {
- return DB2;
- }
- else if ((StringUtil.indexOfIgnoreCase(ddlName, SQL_SERVER_TYPE) != -1) ||
- (StringUtil.indexOfIgnoreCase(ddlName, SQL_SERVER_TYPE2) != -1)) {
- return SQL_SERVER;
- }
- else if (StringUtil.indexOfIgnoreCase(ddlName, SYBASE_TYPE) != -1) {
- return SYBASE;
- }
- else if (StringUtil.indexOfIgnoreCase(ddlName, MYSQL_TYPE) != -1) {
- return MYSQL;
- }
- else {
- return METAMATRIX;
- }
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,80 +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.vdb.materialization;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-
-
-
-/**
- * This generator creates the load and refresh scripts necessary to facilitate all
- * Materialized Views in a VDB.
- *
- * @since 4.2
- */
-public interface MaterializedViewScriptGenerator {
-
- /**
- * Generate the materialization truncate scripts for all materialized views in a VDB
- * for all supported RDBMS platforms and write them to the given stream.
- * @param stream The stream that will contain all truncate scripts.
- * @param dialect The type of RDBMS for which to generated the script.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with scipt generation.
- * @since 4.2
- */
- void generateMaterializationTruncateScript(final OutputStream stream, DatabaseDialect dialect) throws IOException;
-
- /**
- * Generate the materialization load scripts for all materialized views in a VDB
- * for the MetaMatrix platform and write them to the given stream.
- * @param stream The stream that will contain all load scripts.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with scipt generation.
- * @since 4.2
- */
- void generateMaterializationLoadScript(final OutputStream stream) throws IOException;
-
- /**
- * Generate the materialization rename scripts for all materialized views in a VDB
- * for all supported RDBMS platforms and write them to the given stream.
- * @param stream The stream that will contain all rename scripts.
- * @param dialect The type of RDBMS for which to generated the script.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with scipt generation.
- * @since 4.2
- */
- void generateMaterializationSwapScript(final OutputStream stream, DatabaseDialect dialect) throws IOException;
-
- /**
- * Generate the connection properties file for all materialized views in a VDB and
- * write it to the given stream.
- * @param stream The stream that will contain the connection property file.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with file generation.
- * @since 4.2
- */
- void generateMaterializationConnectionPropFile(final OutputStream stream) throws IOException;
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,159 +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.vdb.materialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.vdb.materialization.template.ExpandedTemplate;
-import com.metamatrix.vdb.materialization.template.Template;
-import com.metamatrix.vdb.materialization.template.TemplateData;
-import com.metamatrix.vdb.materialization.template.TemplateExpander;
-
-
-/**
- * @since 4.2
- */
-public class MaterializedViewScriptGeneratorImpl implements MaterializedViewScriptGenerator {
-
- private static final String TEMPLATE_PATH = "com/metamatrix/vdb/materialization/template/"; //$NON-NLS-1$
- private static final String PARENT_TEMPLATE = "scriptMaterializedView"; //$NON-NLS-1$
- private static final String PLATFORM_SPECIALIZED_TEMPLATE = "loadMaterializedView_"; //$NON-NLS-1$
- private static final String TEMPLATE_EXT = ".stg"; //$NON-NLS-1$
-
- private TemplateData templateData;
-
- /**
- * Default ctor.
- * @param materializedViewTemplateData The template data for a materialization.
- *
- * @since 4.2
- */
- public MaterializedViewScriptGeneratorImpl(TemplateData materializedViewTemplateData) {
- this.templateData = materializedViewTemplateData;
- }
-
- /**
- * @throws IOException
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationTruncateScript(OutputStream, DatabaseDialect)
- * @since 4.2
- */
- public void generateMaterializationTruncateScript(OutputStream stream, DatabaseDialect dialect) throws IOException {
- generateTemplate(Template.TRUNCATE, this.templateData, dialect, stream);
- }
-
- /**
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationLoadScript(OutputStream)
- * @since 4.2
- */
- public void generateMaterializationLoadScript(OutputStream stream) throws IOException {
- generateTemplate(Template.LOAD, this.templateData, DatabaseDialect.METAMATRIX, stream);
- }
-
- /**
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationSwapScript(OutputStream, DatabaseDialect)
- * @since 4.2
- */
- public void generateMaterializationSwapScript(OutputStream stream, DatabaseDialect dialect) throws IOException {
- generateTemplate(Template.SWAP, this.templateData, dialect, stream);
- }
-
- /**
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationConnectionPropFile(java.io.OutputStream)
- * @since 4.2
- */
- public void generateMaterializationConnectionPropFile(OutputStream stream) throws IOException {
- generateTemplate(Template.CONN_PROPS, this.templateData, DatabaseDialect.CONNECTION_PROPS, stream);
- }
-
- /**
- *
- * @param command
- * @param data
- * @param database
- * @param stream
- * @throws IOException
- * @since 4.2
- */
- private void generateTemplate(String command, TemplateData data, DatabaseDialect database, OutputStream stream) throws IOException {
- String name = database.getType() + "_" + command; //$NON-NLS-1$
- TemplateExpander expander = new TemplateExpander(data, database);
- Reader[] templateReaders = getTemplateReaders(command, database);
- ExpandedTemplate template = expander.expand(name, templateReaders, command);
- closeReaders(templateReaders);
- toStream(template, stream);
- }
-
- /**
- * Get the heirarchy of template readers for the given database platform.
- * <p><b>Close readers when done!!!</b></p>
- * @param command
- * @param database
- * @return
- * @since 4.2
- */
- private Reader[] getTemplateReaders(String command, DatabaseDialect database) throws IOException {
- InputStreamReader parent = getReader(PARENT_TEMPLATE);
- InputStreamReader child = getReader(PLATFORM_SPECIALIZED_TEMPLATE + database);
- return new Reader[] {parent, child};
- }
-
- private void closeReaders(Reader[] readers) throws IOException {
- for ( int i=0; i<readers.length; ++i ) {
- readers[i].close();
- }
- }
-
- /**
- * Get an InputStreamReader for the given filename.
- * @param fileName the file for which to get the InputStreamReader.
- * @return InputStreamReader for the file.
- * @since 4.2
- */
- private InputStreamReader getReader(String fileName) throws IOException {
- String templateName = TEMPLATE_PATH + fileName + TEMPLATE_EXT;
- InputStream inputStream = MaterializedViewScriptGeneratorImpl.class.getClassLoader().getResourceAsStream(templateName);
- if ( inputStream == null ) {
- throw new MetaMatrixRuntimeException("Unable to find resource: " + templateName); //$NON-NLS-1$
- }
- return new InputStreamReader(inputStream);
- }
-
-
- /**
- * Stream the contents to an <code>OutputStream</code>.
- * @param contents the string to stream
- * @param stream the stream to write to
- * @throws IOException if the given OutputStream has problems
- */
- private void toStream(ExpandedTemplate template, OutputStream stream) throws IOException {
- OutputStreamWriter writer = new OutputStreamWriter(stream);
- writer.write(template.contents, 0, template.contents.length());
- writer.flush();
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,67 +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.vdb.materialization;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * This class modifies the DDL, which generated of the VDB. Sometimes like in the
- * Materialization Model, we need to add extra specific DDL statements into the
- * original DDL, which are not generated by default. This class used as
- * Intercepter after the generation, before saving, so that proper DDL can be
- * generated for any purpose.
- */
-public class ScriptDecorator {
-
- /**
- * Add the custom extensions or modify the original DDL script
- * into a customized format based on the database type supplied.
- *
- * @param dbType - Database Style
- * @param orignalContent - Byte stream of original DDL
- * @return modified DDL, if custom extnsion needed, otherwise
- * original byte stream returned
- */
- public byte[] modifyDDL(String name, byte[] orignalContent) {
- DatabaseDialect dbDialect = DatabaseDialect.getDatabaseDialectByDDLName(name);
-
- // For now just use simplified code to do the job fast, if we ever
- // need we can subclass and go more fancy.
- if (dbDialect == DatabaseDialect.DB2) {
- String orginalDDL = new String(orignalContent);
- try {
- Pattern pattern = Pattern.compile("\\)%"); //$NON-NLS-1$
- Matcher matcher = pattern.matcher(orginalDDL);
- String modifiedDDL = matcher.replaceAll(") NOT LOGGED INITIALLY%"); //$NON-NLS-1$
- return modifiedDDL.getBytes();
- } catch (PatternSyntaxException e) {
- // Ignore as this only happends on bad expression
- }
- }
- return orignalContent;
- }
-
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,129 +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.vdb.materialization;
-
-import com.metamatrix.core.util.StringUtil;
-
-
-/**
- * @since 4.2
- */
-public class ScriptType {
- public static final String MATERIALIZATION_SCRIPT_NAME_SEPARATOR = "_"; //$NON-NLS-1$
-
- public static final String MATERIALIZATION_MODEL_FILE_PREFIX = "MaterializationModel"; //$NON-NLS-1$
- public static final String MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX = "Create"; //$NON-NLS-1$
- public static final String MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX = "Load"; //$NON-NLS-1$
- public static final String MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX = "Truncate"; //$NON-NLS-1$
- public static final String MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX = "Swap"; //$NON-NLS-1$
- public static final String MATERIALIZATION_SCRIPT_FILE_SUFFIX = ".ddl"; //$NON-NLS-1$
-
- public static final String MATERIALIZATION_CONNECTION_PROP_FILE_PREFIX = "Connection"; //$NON-NLS-1$
- public static final String MATERIALIZATION_CONNECTION_PROP_FILE_SUFFIX = ".properties"; //$NON-NLS-1$
- public static final String MATERIALIZATION_SCRIPTS_LOG_FILE_SUFFIX = ".log"; //$NON-NLS-1$
-
- /**
- * Utility functions to create the needed file name patterns
- */
- public static String createScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String createScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String loadScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String loadScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String swapScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String swapScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String truncateScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String truncateScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String connectionPropertyFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion, MATERIALIZATION_CONNECTION_PROP_FILE_PREFIX, MATERIALIZATION_CONNECTION_PROP_FILE_SUFFIX);
- }
- public static String logFileName(String vdbName, String vdbVersion) {
- StringBuffer sb = new StringBuffer();
- sb.append(vdbName)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(vdbVersion)
- .append(MATERIALIZATION_SCRIPTS_LOG_FILE_SUFFIX);
- return sb.toString();
- }
-
- public static boolean isDDLScript(String name) {
- return StringUtil.endsWithIgnoreCase(name, ScriptType.MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static boolean isMaterializationScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_MODEL_FILE_PREFIX) >= 0;
- }
- public static boolean isCreateScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX) >= 0;
- }
-
- public static boolean isLoadScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX) >= 0;
- }
- public static boolean isSwapScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX) >= 0;
- }
- public static boolean isTruncateScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX) >= 0;
- }
-
- private static String buildRuntimeScriptName(String vdbName, String version, String type, String suffix) {
- StringBuffer sb = new StringBuffer();
- sb.append(vdbName)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(version)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(type)
- .append(suffix);
- return sb.toString();
- }
-
- private static String buildVDBScriptName(String dbType, String vdbName, String type, String suffix) {
- StringBuffer sb = new StringBuffer();
- sb.append(dbType).append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(vdbName)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(type)
- .append(suffix);
- return sb.toString();
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,454 +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.vdb.runtime;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import com.metamatrix.common.util.ByteArrayHelper;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.core.vdb.ModelType;
-
-/**
- */
-public class BasicModelInfo implements ModelInfo, Serializable {
-
-
- private static final URIResource uriresource = new URIResource();
-
- private String name;
- private String uuid;
- private String version;
- private Date versionDate;
- private String versionedBy;
- private String description;
- private boolean isPhysical;
- private boolean requireConnBinding;
- private String pathInVdb;
-
- // contains the binding name
- private Set bindingNames = Collections.synchronizedSet(new HashSet());
- private boolean multiSourceBindingEnabled;
-
-
- private int modelType = ModelType.UNKNOWN;
- private String uri=null;
-
- private boolean isVisible;
-
- private Map ddlFileNamesToFiles = Collections.EMPTY_MAP;
-
- private Properties properties;
-
- protected BasicModelInfo() {
-
- }
-
- /**
- * CTOR used when the vdb is being sent to the
- * runtime for creation.
- * @param model
- */
- public BasicModelInfo(ModelInfo model) {
- this(model.getName());
- this.setModelType(model.getModelType());
- this.setModelURI(model.getModelURI());
- this.setVersion(model.getVersion());
- this.setUuid(model.getUUID());
- this.setConnectorBindingNames(model.getConnectorBindingNames());
- this.setIsVisible(model.isVisible());
- this.enableMutliSourceBindings(model.isMultiSourceBindingEnabled());
- this.setDescription(model.getDescription());
- this.setVersionDate(model.getDateVersioned());
- this.setVersionedBy(model.getVersionedBy());
- this.setPath(model.getPath());
- }
-
-
-
- public BasicModelInfo(String modelName){
- this.name = modelName;
- }
-
- public String getUUID() {
- return uuid!=null?uuid:"NoUUID";//$NON-NLS-1$
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getVersion() {
- return version!=null?version:"0"; //$NON-NLS-1$
- }
-
- public int getModelType() {
- return this.modelType;
- }
-
- public String getModelTypeName() {
- return ModelType.MODEL_NAMES[this.modelType];
- }
-
- public String getModelURI() {
- return this.uri;
- }
-
-
- public Date getDateVersioned() {
- return versionDate;
- }
-
-
- public String getVersionedBy() {
- return versionedBy;
- }
-
-
- public boolean isPhysical() {
- return isPhysical;
- }
-
- public boolean requiresConnectorBinding() {
- return requireConnBinding;
- }
-
- public List getConnectorBindingNames() {
- if (bindingNames.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
-
- List bindings = new ArrayList(bindingNames.size());
- bindings.addAll(this.bindingNames);
- return bindings;
- }
-
-
- /**
- * Returns true if the model, based on its model type,
- * supports mutliple connector bindings.
- * If true, {@see #isMultiSourceBindingEnabled()} to determine
- * if the model has been flagged so that the user can
- * actually assign multi connector bindngs.
- *
- * @see org.teiid.adminapi.Model#supportsMultiSourceBindings()
- * @since 4.2
- */
- public boolean supportsMultiSourceBindings() {
- switch (modelType) {
- case ModelType.PHYSICAL: {
- return true;
- }
- default: {
- return false;
- }
- }
-
- }
-
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @param uuid
- */
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- /**
- * @param version
- */
- public void setVersion(String version) {
- this.version = version;
- }
-
- /**
- * @param date
- */
- public void setVersionDate(Date date) {
- versionDate = date;
- }
-
- /**
- * @param versionedBy
- */
- public void setVersionedBy(String versionedBy) {
- this.versionedBy = versionedBy;
- }
-
- public boolean isVisible() {
- if (this.uri == null) {
- return false;
- }
- return isVisible;
- }
-
- /**
- * Check whether this model is a materialization
- * of a virtual group.
- * @return Returns the isMaterialization.
- * @since 4.2
- */
- public boolean isMaterialization() {
- return (this.modelType == ModelType.MATERIALIZATION);
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#getDDLFileContentsGetBytes(java.lang.String)
- * @since 4.2
- */
- public byte[] getDDLFileContentsGetBytes(String ddlFileName) {
- byte[] ddlFile = null;
- if ( this.modelType == ModelType.MATERIALIZATION ) {
- ddlFile = (byte[]) this.ddlFileNamesToFiles.get(ddlFileName);
- }
- return ddlFile;
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#getDDLFileContentsAsStream(java.lang.String)
- * @since 4.2
- */
- public InputStream getDDLFileContentsAsStream(String ddlFileName) {
- if ( this.modelType == ModelType.MATERIALIZATION ) {
- byte[] ddlFile = (byte[]) this.ddlFileNamesToFiles.get(ddlFileName);
- if (ddlFile == null) {
- return null;
- }
- InputStream fileStream;
- try {
- fileStream = ByteArrayHelper.toInputStream(ddlFile);
- } catch (Exception err) {
- return null;
- }
- return fileStream;
- }
-
- return null;
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#getDDLFileNames()
- * @since 4.2
- */
- public String[] getDDLFileNames() {
- if ( this.modelType == ModelType.MATERIALIZATION ) {
- Set keys = this.ddlFileNamesToFiles.keySet();
- String[] ddlFileNames = new String[keys.size()];
- Iterator fileNameItr = keys.iterator();
- for ( int i=0; fileNameItr.hasNext(); i++ ) {
- String afileName = (String) fileNameItr.next();
- ddlFileNames[i] = afileName;
- }
- return ddlFileNames;
- }
- return new String[] {};
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#setDDLFiles(Map)
- * @param ddlFileNamesToFiles
- * @since 4.2
- */
- public void setDDLFiles(Map ddlFileNamesToFiles) {
- this.ddlFileNamesToFiles = ddlFileNamesToFiles;
- }
-
- public void setIsVisible(boolean visibility) {
- this.isVisible = visibility;
- }
-
- public void setVisibility(short visibility) {
- if (visibility == PUBLIC) {
- setIsVisible(true);
- } else {
- setIsVisible(false);
- }
- }
-
- public short getVisibility() {
- if (isVisible) {
- return PUBLIC;
- }
- return PRIVATE;
- }
-
- boolean isConnectorBindingUsed(String bindingName) {
- return this.bindingNames.contains(bindingName);
- }
-
- public void addConnectorBindingByName(String connectrBindingName) {
- if (this.bindingNames == null) {
- bindingNames = new HashSet();
- }
-
- bindingNames.add(connectrBindingName);
- }
-
-
- public void setConnectorBindingNames(List newbindingNames) {
- this.bindingNames.clear();
- this.bindingNames.addAll(newbindingNames);
- }
-
-
- public void removeConnectorBindingName(String bindingName) {
- this.bindingNames.remove(bindingName);
- }
-
-
- public void renameConnectorBinding(String exitingbindingName, String newbindingname) {
-
- boolean removed = this.bindingNames.remove(exitingbindingName);
- if (removed) {
- addConnectorBindingByName(newbindingname);
- }
- }
-
- public void setModelType(int type) {
- this.modelType = type;
-
- setTypeLogic();
- }
-
- public void setModelURI(String uri) {
- this.uri = uri;
- setTypeLogic();
- }
-
- public void setDescription(String desc) {
- this.description = desc;
- }
-
- private void setTypeLogic() {
- if (this.modelType == ModelType.PHYSICAL ||
- this.modelType == ModelType.MATERIALIZATION ) {
- setIsPhysical(true);
-
- if (this.uri != null && this.uri.trim().length() > 0) {
- if (uriresource.isPhysicalBindingAllowed(uri)) {
- setRequireConnectorBinding(true);
- } else {
- setRequireConnectorBinding(false);
- }
- } else {
- setRequireConnectorBinding(false);
-
- }
-
-
- } else {
-
- setIsPhysical(false);
- setRequireConnectorBinding(false);
-
- }
-
- }
-
-
- private void setRequireConnectorBinding(boolean requireConnBinding){
- this.requireConnBinding = requireConnBinding;
- }
-
-
- private void setIsPhysical(boolean isPhysical) {
- this.isPhysical = isPhysical;
- }
-
-
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#enableMutliSourceBindings(boolean)
- * @since 4.2
- */
- public void enableMutliSourceBindings(boolean isEnabled) {
- this.multiSourceBindingEnabled = isEnabled;
- }
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#isMultiSourceBindingEnabled()
- * @since 4.2
- */
-
-
- public boolean isMultiSourceBindingEnabled() {
- return this.multiSourceBindingEnabled;
- }
-
- public String getPath() {
- return this.pathInVdb!=null?pathInVdb:"NoPath";//$NON-NLS-1$
- }
-
- public void setPath(String path) {
- this.pathInVdb = path;
- }
-
- @Override
- public Properties getProperties() {
- return this.properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public String toString() {
- StringBuffer sw = new StringBuffer();
-
- sw.append("ModelInfo: " + this.getName());//$NON-NLS-1$
- sw.append("\n\tVersion: " + this.getVersion());//$NON-NLS-1$
- sw.append("\n\tTypeCode: " + this.getModelType());//$NON-NLS-1$
-
- sw.append("\n\tType: " + this.getModelTypeName());//$NON-NLS-1$
- sw.append("\n\thasBindings: " + (this.getConnectorBindingNames().size() > 0));//$NON-NLS-1$
-
- sw.append("\n\tIsVisible: " + this.isVisible());//$NON-NLS-1$
- sw.append("\n\tIsPhysical: " + this.isPhysical());//$NON-NLS-1$
- sw.append("\n\tIsMaterialization: " + this.isMaterialization());//$NON-NLS-1$
- sw.append("\n\tURI: " + this.getModelURI());//$NON-NLS-1$
- sw.append("\n\tRequiresBinding: " + this.requiresConnectorBinding());//$NON-NLS-1$
-
-
- return sw.toString();
-
- }
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,75 +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.vdb.runtime;
-
-
-/**
- */
-public class BasicURIModelResource implements URIModelResource {
-
-
-
- private String uri=null;
- private String authlevel;
- private boolean isXMLDocType = false;
- private boolean isPhysicalBindingAllowed = false;
-
-
- protected BasicURIModelResource(String uri) {
- this.uri = uri;
-
- }
-
- public String getURI() {
- return this.uri;
- }
-
- public String getAuthLevel() {
- return this.authlevel;
- }
-
- public boolean isXMLDocType() {
- return this.isXMLDocType;
- }
-
- public boolean isPhysicalBindingAllowed() {
- return this.isPhysicalBindingAllowed;
- }
-
- protected void setAuthLevel(String level) {
- this.authlevel = level;
- }
-
- protected void setIsXMLDocType(boolean isDocType) {
- this.isXMLDocType = isDocType;
- }
-
- protected void setIsPhysicalBindingAllowed(boolean allowsBinding) {
- this.isPhysicalBindingAllowed = allowsBinding;
- }
-
-
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,695 +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.vdb.runtime;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.model.BasicUtil;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.common.vdb.api.VDBStream;
-import com.metamatrix.core.vdb.VDBStatus;
-
-/**
- * Date Dec 3, 2002
- *
- * To import a VDB, the following information is required:
- * 1. VDB Jar {@link #setVDBJar(Object)}. This jar will provide
- * the model and their model info.
- * 2. Add a model to connector binding mapping {@link #addModelToConnectorMapping(String, String)}
- * that indicates which binding should be used for that model
- * 3. set VDB name (version will be assign at creation time)
- *
- * Optional information:
- * 1. Add a ConnectorBinding {@link #addConnectorBinding(ConnectorBinding)}. If this
- * already exist in the configration, it will not be loaded. The
- * model will reference the existing binding.
- * If not added, the connector binding mapping will indicate an
- * assumed already existing binding.
- * 2. Add a ConnectorType {@link #addConnectorType(ComponentType). If
- * already exist in the configration, it will not be loaded. The
- * binding will reference the existing type.
- */
-public class BasicVDBDefn extends BasicVDBInfo implements VDBDefn {
-
- /**
- * The connector types are optional, if
- * not specified on the import, then the
- * connector type(s) is assumed to already
- * exist in configuration
- * <key> connector type name <value> ComponentType {@see com.metamatrix.common.config.api.ComponentType }
- */
- private Map connectorTypes = null;
-
- /**
- * The connector bindings are optional, if
- * not specified on the import, then the
- * connector binding(s) is assumed to already
- * exist in configuration
- * <key> connector binding name <value> ConnectorBinding {@see com.metamatrix.common.config.api.ConnectorBinding }
- */
- private Map connectorBindings = null;
-
- /**
- * contains the VDB Jar.
- */
- private VDBStream vdbcontent = null;
-
- // list of validity errors.
- private ArrayList validityErrors = null;
-
-
- /**
- * Controls when the VDB is imported whether
- * its status will be set to active or not.
- */
- private short status = VDBStatus.INCOMPLETE;
-
- private boolean invalidVDBorModel = false;
-
- // Visibility information on the VDB resources.
- private Map visibilityMap = null;
-
- private char[] dataroles;
-
- private Properties headerProperties;
-
- private Properties infoProperties;
-
- public BasicVDBDefn(String name) {
- super(name);
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#getVDBStream()
- * @since 4.3
- */
- public VDBStream getVDBStream() {
- return vdbcontent;
- }
-
- public void setVDBStream(VDBStream stream) {
- this.vdbcontent = stream;
- }
-
- public boolean doesVDBHaveValidityError() {
- return this.invalidVDBorModel;
- }
-
- /**
- * Call to add the binding to the VDBDefn set of bindings and
- * add the binding to the model-to-binding mapping.
- * @param modelName
- * @param binding
- * @since 4.2
- */
- public void addConnectorBinding(String modelName, ConnectorBinding binding) {
- addConnectorBinding(binding);
- BasicModelInfo model = (BasicModelInfo) this.getModel(modelName);
- if (model != null) {
- model.addConnectorBindingByName(binding.getFullName());
- }
- }
-
- public void addConnectorBinding(ConnectorBinding binding) {
- if (connectorBindings == null) {
- connectorBindings = new HashMap();
- }
- connectorBindings.put(binding.getName(), binding);
-
- }
-
- public void renameConnectorBinding(String existingBindingName, String newBindingName) {
- ConnectorBinding cb = removeConnectorBindingFromMap(existingBindingName);
- if (cb != null) {
-
- // go thru each model and rename the binding where it is used
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(cb.getFullName())) {
- model.renameConnectorBinding(existingBindingName, newBindingName);
- }
- }
-
- // rename the binding and add it back
- ConnectorBinding newcb = BasicUtil.getEditor().createConnectorComponent(cb.getConfigurationID(), cb, newBindingName, cb.getRoutingUUID());
- addConnectorBinding(newcb);
-
- }
-
-
- }
-
- public void removeConnectorBinding(String bindingName) {
- if (connectorBindings != null) {
- ConnectorBinding cb = this.getConnectorBindingByName(bindingName);
- if (cb != null) {
- // remove the binding from any model that it is associated with
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(cb.getFullName())) {
- model.removeConnectorBindingName(cb.getFullName());
- }
- }
- removeFromAvailableConnectorBindings(bindingName);
-
- }
- }
- }
-
- public void removeConnectorBindingNameOnly(String bindingName) {
- if (connectorBindings != null) {
- ConnectorBinding cb = this.getConnectorBindingByName(bindingName);
- if (cb != null) {
- // remove the binding from any model that it is associated with
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(cb.getFullName())) {
- model.removeConnectorBindingName(cb.getFullName());
- }
- }
- removeConnectorBindingFromMap(bindingName);
- }
- }
- }
-
- private ConnectorBinding removeConnectorBindingFromMap(String bindingName) {
- ConnectorBinding cb = null;
- if (connectorBindings != null) {
- cb = (ConnectorBinding) connectorBindings.remove(bindingName);
- }
- return cb;
-
- }
-
- private void removeFromAvailableConnectorBindings(String bindingName) {
- ConnectorBinding cb = removeConnectorBindingFromMap(bindingName);
- if (cb != null) {
- if (!isConnectorTypeInUse(cb.getComponentTypeID().getFullName())) {
- removeConnectorType(cb.getComponentTypeID().getFullName());
- }
- }
-
- }
-
- public void removeConnectorBinding(String modelName, String bindingName) {
- if (connectorBindings != null) {
- ConnectorBinding cb = getConnectorBindingByName(bindingName);
- if (cb != null) {
- BasicModelInfo model = (BasicModelInfo) this.getModel(modelName);
- if (model != null) {
- model.removeConnectorBindingName(cb.getFullName());
- }
- // if the connector binding is no referenced by any model
- // then remove
- if (!isBindingInUse(cb)) {
- removeFromAvailableConnectorBindings(cb.getFullName());
- }
- }
- }
- }
-
- public boolean isBindingInUse(ConnectorBinding binding) {
-
-// if (binding.getRoutingUUID() == null) {
-// ArgCheck.isNotNull(binding.getRoutingUUID(), "ConnectorBinding routing UUID must not be null"); //$NON-NLS-1$
-// }
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(binding.getFullName())) {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean isBindingInUse(String bindingName) {
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(bindingName)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isConnectorTypeInUse(String typeName) {
- if (connectorTypes == null) {
- return true;
- }
-
- Iterator it = this.connectorBindings.values().iterator();
- while (it.hasNext()) {
- ConnectorBinding cb = (ConnectorBinding) it.next();
- if (cb.getComponentTypeID().getFullName().equalsIgnoreCase(typeName)) {
- return true;
- }
- }
- return false;
-
- }
-
- /**
- * Call to add the binding to the VDBDefn set of bindings and
- * initializes the set of model-to-binding mappings
- * with the binding.
- * @param modelName
- * @param binding
- * @since 4.2
- */
-
- public void setConnectorBinding(String modelName, ConnectorBinding binding) {
- addConnectorBinding(binding);
- BasicModelInfo model = (BasicModelInfo) this.getModel(modelName);
- if (model != null) {
- ArrayList names = new ArrayList(1);
- names.add(binding.getFullName());
- model.setConnectorBindingNames(names);
- }
- }
-
- protected void setConnectorBindings(Map bindings) {
- if (bindings != null) {
- if (connectorBindings == null) {
- connectorBindings = new HashMap(bindings.size());
- }
-
- connectorBindings.putAll(bindings);
- }
- }
-
-
- protected void setConnectorTypes(Map types) {
- if (types != null) {
- if (connectorTypes == null) {
- connectorTypes = new HashMap(types.size());
- }
- connectorTypes.putAll(types);
- }
- }
-
- public void removeConnectorType(String typeName) {
- if (connectorTypes != null) {
- connectorTypes.remove(typeName);
- }
- }
-
- public void addConnectorType(ComponentType type) {
- if (connectorTypes == null) {
- connectorTypes = new HashMap();
- }
- connectorTypes.put(type.getName(), type);
-
- }
-
- public Map getConnectorTypes() {
- Map m = new HashMap();
- if (this.connectorTypes != null) {
- m.putAll(this.connectorTypes);
- }
- return m;
-
- }
-
- public ComponentType getConnectorType(String componentTypeName) {
- if (this.connectorTypes == null) {
- return null;
- }
- if (this.connectorTypes.containsKey(componentTypeName)) {
- return (ComponentType) this.connectorTypes.get(componentTypeName);
- }
-
- return null;
- }
-
-
- public Map getConnectorBindings() {
- Map m = new HashMap();
- if (this.connectorBindings != null) {
- m.putAll(this.connectorBindings);
- }
- return m;
-
- }
-
- public ConnectorBinding getConnectorBindingByRouting(String routingUUID) {
- if (this.connectorBindings == null) {
- return null;
- }
- Iterator it = this.connectorBindings.values().iterator();
- while (it.hasNext()) {
- ConnectorBinding cb = (ConnectorBinding) it.next();
- if (cb.getRoutingUUID().equals(routingUUID)) {
- return cb;
- }
- }
-
- return null;
- }
-
- public ConnectorBinding getConnectorBindingByName(String bindingName) {
- if (this.connectorBindings == null) {
- return null;
- }
-
- ConnectorBinding cb = (ConnectorBinding) this.connectorBindings.get(bindingName);
- return cb;
-
- }
-
-
- public Map getModelToBindingMappings() {
- Map bm = new HashMap();
-
- Collection mdlsd = getModels();
- for (Iterator it=mdlsd.iterator(); it.hasNext(); ) {
- ModelInfo m = (ModelInfo) it.next();
-
-
- if(m.getConnectorBindingNames().size() > 0) {
- List uuids = new ArrayList();
- for (Iterator bits=m.getConnectorBindingNames().iterator(); bits.hasNext();) {
- String name = (String) bits.next();
- ConnectorBinding cb = (ConnectorBinding) this.connectorBindings.get(name);
- uuids.add(cb.getRoutingUUID());
- }
- bm.put(m.getName(), uuids);
-
- } else if(m.getConnectorBindingNames().size() > 0) {
- List uuids = new ArrayList();
- for (Iterator bits=m.getConnectorBindingNames().iterator(); bits.hasNext();) {
- String name = (String) bits.next();
- ConnectorBinding cb = (ConnectorBinding) this.connectorBindings.get(name);
- uuids.add(cb.getRoutingUUID());
- }
- bm.put(m.getName(), uuids);
-
- }
-
- }
-
- return bm;
-
- }
-
-
- /**
- * Returns the collection of all the model names contained
- * in the vdb archive.
- * @return Collection
- *
- */
- public Collection getModelNames() {
-
- Collection mdlsd = getModels();
- Collection mdls = new ArrayList(mdlsd.size());
- for (Iterator it=mdlsd.iterator(); it.hasNext(); ) {
- ModelInfo m = (ModelInfo) it.next();
- mdls.add(m.getName());
- }
-
- return mdls;
- }
-
- public ModelInfo removeModelInfo(String modelName, boolean removeBindings) {
-
- ModelInfo m = super.removeModelInfo(modelName);
- //this.getModel(modelName);
- if (m!= null && removeBindings) {
- Collection names = m.getConnectorBindingNames();
- for (Iterator it=names.iterator(); it.hasNext(); ) {
- final String cbName= (String) it.next();
- ConnectorBinding cb = getConnectorBindingByName(cbName);
- if (cb !=null) {
- if (!isBindingInUse(cb)) {
- removeConnectorBinding(cb.getFullName());
- }
-
- }
-
- }
-
- }
- return m;
- }
-
- public ModelInfo removeModelInfo(String modelName) {
- return removeModelInfo(modelName,true);
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#getMatertializationModel()
- * @since 4.2
- */
- public ModelInfo getMatertializationModel() {
- ModelInfo matModel = null;
- Iterator modelItr = getModels().iterator();
- while ( modelItr.hasNext() ) {
- ModelInfo aModel = (ModelInfo)modelItr.next();
- if ( aModel != null && aModel.isMaterialization() ) {
- matModel = aModel;
- break;
- }
- }
- return matModel;
- }
-
- public short getStatus() {
- if (invalidVDBorModel) {
- return VDBStatus.INCOMPLETE;
- }
-
- return this.status;
- }
-
- /**
- * Set the status of the VDB
- * see {@link MetadataConstants.VDB_STATUS}
- * @param status
- * @since 4.2
- */
- public void setStatus(short status) {
- this.status = status;
- }
-
- public boolean isActiveStatus() {
- // as long as it has a validity error, it cannot be active
- if (invalidVDBorModel) {
- return false;
- }
- if (this.status == VDBStatus.ACTIVE || this.status == VDBStatus.ACTIVE_DEFAULT) {
- return true;
- }
- return false;
- }
-
- public void setVDBValidityError(boolean hasError) {
- invalidVDBorModel = hasError;
- }
-
- public void setVDBValidityError(boolean hasError, String msg) {
- invalidVDBorModel = hasError;
- if (this.validityErrors == null) {
- this.validityErrors = new ArrayList();
- }
- if (msg != null) {
- this.validityErrors.add(msg);
- }
- }
-
- public String[] getVDBValidityErrors() {
- if (this.validityErrors != null) {
- return (String[])this.validityErrors.toArray(new String[this.validityErrors.size()]);
- }
- return new String[0];
- }
-
- public void determineVdbsStatus() {
- if (invalidVDBorModel) {
- setStatus( VDBStatus.INCOMPLETE);
- return;
- }
- Map mapConnBind = this.getModelToBindingMappings();
- // examine the map looking for any models that do
- // not have a connector binding specified.
- // if any missing, return:
- // MetadataConstants.VDB_STATUS.INCOMPLETE
- // if all are present, return
- // MetadataConstants.VDB_STATUS.INACTIVE
- // how about this... just look for values that are ""?
- short siStatus;
- boolean bHasMissingValues = false;
- boolean bHasNoBindings = false;
- boolean requiresBindings = false;
-
- // verify that at least one model requires a binding
- Iterator mit = getModels().iterator();
- while (mit.hasNext()) {
- ModelInfo mi = (ModelInfo)mit.next();
- if (mi.requiresConnectorBinding()) {
- requiresBindings = true;
- break;
- }
- }
-
- // if no binding is required, then the vdb can
- // be considered for active status
- if (!requiresBindings) {
- setStatus(VDBStatus.INACTIVE);
- return;
- }
-
- int connBind = 0;
- Iterator it = mapConnBind.values().iterator();
-
- // Count the number of bindings
- while (it.hasNext()) {
- List list = (List)it.next();
- if ((list == null) || (list.size() == 0)) {
- bHasMissingValues = true;
- } else {
- connBind += list.size();
- }
- }
-
- if (connBind == 0) {
- bHasNoBindings = true;
- }
-
- if (bHasNoBindings || bHasMissingValues) {
- siStatus = VDBStatus.INCOMPLETE;
- } else {
- siStatus = VDBStatus.ACTIVE;
- }
- setStatus(siStatus);
-
- }
-
-
- /**
- * Remove ConnectorBindings from this VDBDefn that are not referenced by any of the ModelInfos
- *
- * @since 4.3
- */
- public synchronized void removeUnmappedBindings() {
- //build up list of all binding names referred to by a model
- HashSet allBindingNames = new HashSet();
- for (Iterator iter = getModels().iterator(); iter.hasNext(); ) {
- ModelInfo model = (ModelInfo) iter.next();
- allBindingNames.addAll(model.getConnectorBindingNames());
- }
-
- //remove any connector binding that's not referred to
- for (Iterator iter = getConnectorBindings().values().iterator(); iter.hasNext(); ) {
- ConnectorBinding binding = (ConnectorBinding) iter.next();
- String bindingName = binding.getFullName();
-
- if (! allBindingNames.contains(bindingName)) {
- connectorBindings.remove(bindingName);
- }
- }
-
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#isVisible(java.lang.String)
- */
- public boolean isVisible(String resourcePath) {
- if (visibilityMap == null) {
- return false;
- }
-
- Boolean visibility = (Boolean)visibilityMap.get(resourcePath);
- if (visibility == null && resourcePath.startsWith("/")) { //$NON-NLS-1$
- visibility = (Boolean)visibilityMap.get(resourcePath.substring(1));
- }
-
- if (visibility == null || visibility.equals(Boolean.FALSE)) {
- return false;
- }
- return true;
- }
-
- public void setVisibility(String resoucePath, boolean visible) {
- if (visibilityMap == null) {
- visibilityMap = new HashMap();
- }
- visibilityMap.put(resoucePath, visible?Boolean.TRUE:Boolean.FALSE);
- }
-
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#getDataRoles()
- */
- public char[] getDataRoles() {
- return dataroles;
- }
-
- public void setDataRoles(char[] roles) {
- this.dataroles = roles;
- }
-
- public void renameModelInfo(String modelName, String newModelName) {
- if (modelName == null || modelName.length() == 0) {
- return;
- }
- if (this.modelInfos != null) {
- BasicModelInfo bmi = (BasicModelInfo) modelInfos.remove(modelName);
- if (bmi != null) {
- bmi.setName(newModelName);
- addModelInfo(bmi);
- }
- }
- }
-
- public Properties getHeaderProperties() {
- return headerProperties;
- }
-
- public void setHeaderProperties(Properties props) {
- this.headerProperties = props;
- }
-
- public Properties getInfoProperties() {
- return infoProperties;
- }
-
- public void setInfoProperties(Properties props) {
- this.infoProperties = props;
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,218 +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.vdb.runtime;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.VDBInfo;
-
-/**
- */
-public class BasicVDBInfo implements VDBInfo, Serializable {
- private String fileName;
- private String name;
- private String uuid;
- private String desc;
- private Date created;
- private String createdBy;
- protected Map modelInfos=Collections.synchronizedMap(new HashMap());
- private boolean WSDLDefined=false;
- private String version;
-
- public BasicVDBInfo(String vdbName){
- this.name = vdbName;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getName()
- */
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getUUID()
- */
- public String getUUID() {
- return uuid;
- }
-
- /**
- * Returns the vdbVersion.
- * @return String
- */
- public String getVersion() {
- return version;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getDescription()
- */
- public String getDescription() {
- return desc;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getDateCreated()
- */
- public Date getDateCreated() {
- return created;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getCreatedBy()
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getModels()
- */
- public Collection getModels() {
- if (modelInfos == null || modelInfos.size() == 0) {
- return Collections.EMPTY_LIST;
- }
-
- Collection models = new ArrayList(modelInfos.size());
- models.addAll(modelInfos.values());
- return models;
- }
-
- /**
- * Returns the {@link ModelInfo ModelInfo} for the name specified
- * @return ModelInfo
- *
- */
- public ModelInfo getModel(String name) {
- return (ModelInfo) modelInfos.get(name);
- }
-
- /**
- * Returns true if a WSDL is defined for this VDB
- * @return true if a WSDL is defined for this VDB
- */
- public boolean hasWSDLDefined() {
- return WSDLDefined;
- }
-
- /**
- * @param date
- */
- public void setDateCreated(Date date) {
- created = date;
- }
-
- /**
- * @param createdBy
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * @param description
- */
- public void setDescription(String description) {
- desc = description;
- }
-
- /**
- * @param modelInfos
- */
- public void setModelInfos(final Collection models) {
- modelInfos.clear();
- for (Iterator it=models.iterator(); it.hasNext();) {
- ModelInfo mi = (ModelInfo) it.next();
- modelInfos.put(mi.getName(), mi);
- }
- }
-
- public void addModelInfo(ModelInfo model) {
- if (model == null) {
- return;
- }
- // first remove an existing model,
- // model names are assumed unique
- removeModelInfo(model.getName());
- this.modelInfos.put(model.getName(), model);
- }
-
- public ModelInfo removeModelInfo(String modelName) {
- if (modelName == null || modelName.length() == 0) {
- return null;
- }
- if (this.modelInfos != null) {
- return (ModelInfo) modelInfos.remove(modelName);
- }
- return null;
- }
-
-
- /**
- * @param objectID
- */
- public void setUUID(String objectID) {
- uuid = objectID;
- }
-
- public void setHasWSDLDefined(boolean defined ) {
- WSDLDefined = defined;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getFileName()
- */
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-
- public String toString() {
- StringBuffer sb = new StringBuffer("\nDefn for VDB " + getName() + " and # models " + (modelInfos==null?0:modelInfos.size())); //$NON-NLS-1$ //$NON-NLS-2$
- return sb.toString();
-
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,50 +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.vdb.runtime;
-
-
-/**
- */
-public interface URIModelResource {
-
-
- String getURI();
-
- String getAuthLevel();
-
- boolean isXMLDocType();
-
- boolean isPhysicalBindingAllowed();
-
-
- public class AUTH_LEVEL {
- public static final String ALL = "all";//$NON-NLS-1$
- public static final String MODEL = "model";//$NON-NLS-1$
- public static final String GROUP = "group";//$NON-NLS-1$
-
-
- }
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -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.vdb.runtime;
-
-import java.util.Map;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-
-/**
- */
-public final class URIResource {
-
- private static Map resources = null;
-
-
- static {
- try {
- URIResourceReader reader = new URIResourceReader();
- resources = reader.getURIResources();
-
-
- } catch (Exception e) {
- String msg = CommonPlugin.Util.getString("URIResource.Resource_not_found", new Object[]{URIResourceReader.RESOURCE_NAME}); //$NON-NLS-1$
- throw new MetaMatrixRuntimeException(e, msg);
- }
- }
-
-
- public boolean isXMLDocument(String uri) {
- URIModelResource r = getURIModelResource(uri);
- if (r != null) {
- return r.isXMLDocType();
- }
- return false;
- }
-
- public String getAuthorizationLevel(String uri) {
- URIModelResource r = getURIModelResource(uri);
- if (r != null) {
- return r.getAuthLevel();
- }
- return URIModelResource.AUTH_LEVEL.ALL;
- }
-
- public boolean isPhysicalBindingAllowed(String uri) {
- URIModelResource r = getURIModelResource(uri);
- if (r != null) {
- return r.isPhysicalBindingAllowed();
- }
- return false;
- }
-
- private URIModelResource getURIModelResource(String uri) {
- if (resources.containsKey(uri)) {
- return (URIModelResource) resources.get(uri);
- }
- return null;
-
- }
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,170 +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.vdb.runtime;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.jdom.Attribute;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-
-import com.metamatrix.common.xml.XMLReaderWriter;
-import com.metamatrix.common.xml.XMLReaderWriterImpl;
-import com.metamatrix.core.util.ArgCheck;
-
-/**
- */
-public class URIResourceReader {
- private Map resources = new HashMap();
-
-// private static final String TRUE = Boolean.TRUE.toString();
- private static final String FALSE = Boolean.FALSE.toString();
-
- public static final String RESOURCE_NAME = "uriprimarymodeltypes.xml"; //$NON-NLS-1$
-
- public URIResourceReader () {
-
- }
-
-
- public Map getURIResources() throws Exception {
- InputStream in = loadAsResource(RESOURCE_NAME);
-
- ArgCheck.isNotNull(in);
- Document doc = null;
-
- try {
- doc = getXMLReaderWriter().readDocument(in);
- } catch (JDOMException e) {
- try {
- in.close();
- } catch (Exception ce) {
-
- }
- throw new Exception(e.getMessage());
- }
-
- Element root = doc.getRootElement();
-
- Collection uriElements = root.getChildren(Constants.URI.ELEMENT);
-
-
- Iterator iterator = uriElements.iterator();
- while (iterator.hasNext()) {
- Element uriElement = (Element)iterator.next();
- String name = null;
- String authlevel = URIModelResource.AUTH_LEVEL.ALL;
- String isxmldoctype = FALSE;
- String isphysicalbinding = FALSE;
- List attrs = uriElement.getAttributes();
- for (Iterator ait=attrs.iterator(); ait.hasNext();) {
- Attribute a = (Attribute) ait.next();
- String n = a.getName();
- if (n.equalsIgnoreCase(Constants.URI.Attribute.NAME)) {
- name = a.getValue();
- } else if (n.equalsIgnoreCase(Constants.URI.Attribute.AUTHLEVEL)) {
- authlevel = a.getValue();
- } else if (n.equalsIgnoreCase(Constants.URI.Attribute.ISXMLDOCTYPE)) {
- isxmldoctype = a.getValue();
- } else if (n.equalsIgnoreCase(Constants.URI.Attribute.PHYSICAL_BINDING)) {
- isphysicalbinding = a.getValue();
- }
-
-// System.out.println("Name: " + n + " value: " + a.getValue());
-
- }
- ArgCheck.isNotNull(name, "The attribute " + Constants.URI.Attribute.NAME + " was not defined"); //$NON-NLS-1$ //$NON-NLS-2$
- BasicURIModelResource resource = new BasicURIModelResource(name);
- resource.setAuthLevel(authlevel);
-
-// System.out.println("Name: " + name + " auth: " + authlevel + " doc: " + isxmldoctype);
- resource.setIsXMLDocType(new Boolean(isxmldoctype).booleanValue());
- resource.setIsPhysicalBindingAllowed(new Boolean(isphysicalbinding).booleanValue());
-
- resources.put(name, resource);
-
- }
-
- if (in != null) {
- try {
- in.close();
- } catch (Exception ce) {
-
- }
- }
-
- return resources;
-
- }
-
- private InputStream loadAsResource(String resourceName) throws Exception {
- InputStream is = null;
- try {
- is = URIResourceReader.class.getResourceAsStream(resourceName) ;
- // .getClassLoader().getResourceAsStream(resourceName);
- ArgCheck.isNotNull(is);
- } catch (Exception e) {
- throw e;
-
- }
- return is;
- }
-
- private XMLReaderWriter getXMLReaderWriter() {
- return new XMLReaderWriterImpl();
- }
-
-
- public static class Constants {
- public static final String URI_RESOURCES = "urimodeltypes";//$NON-NLS-1$
-
- public static class URI {
- public static final String ELEMENT = "uri"; //$NON-NLS-1$
- public static class Attribute {
- public static final String NAME = "name"; //$NON-NLS-1$
- // indicates to what level the authorization will be enabled
- public static final String AUTHLEVEL = "authlevel"; //$NON-NLS-1$
- // indicates if this is uri represents an xml document type
- public static final String ISXMLDOCTYPE = "xmldoctype"; //$NON-NLS-1$
- // indicates if this uri is associated with a physical model type, does it allow a binding
- public static final String PHYSICAL_BINDING = "physicalbindingallowed"; //$NON-NLS-1$
-
-
- }
- }
-
-
- }
-
-}
-
-
-
-
-
Modified: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -22,11 +22,14 @@
package com.metamatrix.vdb.runtime;
+import java.io.Serializable;
+
import com.metamatrix.core.util.HashCodeUtil;
-public class VDBKey {
-
- private String name;
+public class VDBKey implements Serializable{
+ private static final long serialVersionUID = -7249750823144856081L;
+
+ private String name;
private String version;
public VDBKey(String name, String version) {
@@ -36,6 +39,11 @@
}
}
+ public VDBKey(String name, int version) {
+ this.name = name.toUpperCase();
+ this.version = String.valueOf(version);
+ }
+
public String getName() {
return name;
}
Copied: trunk/common-internal/src/main/java/org (from rev 1899, branches/JCA/common-internal/src/main/java/org)
Copied: trunk/common-internal/src/main/java/org/teiid (from rev 1899, branches/JCA/common-internal/src/main/java/org/teiid)
Deleted: trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java
===================================================================
--- branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid;
-
-import java.security.Principal;
-
-import javax.security.auth.Subject;
-
-public interface SecurityHelper {
-
- boolean assosiateSecurityContext(String securityDomain, Object context);
-
- void clearSecurityContext(String securityDomain);
-
- Object getSecurityContext(String securityDomain);
-
- Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject);
-
-}
Copied: trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java (from rev 1899, branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java)
===================================================================
--- trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java (rev 0)
+++ trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+public interface SecurityHelper {
+
+ boolean assosiateSecurityContext(String securityDomain, Object context);
+
+ void clearSecurityContext(String securityDomain);
+
+ Object getSecurityContext(String securityDomain);
+
+ Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject);
+
+}
Modified: trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd
===================================================================
--- trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd 2010-03-04 20:00:27 UTC (rev 1911)
@@ -60,7 +60,7 @@
<xs:element minOccurs="0" name="principals">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" name="group" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" name="role" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Deleted: trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,102 +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.common.util;
-
-import junit.framework.TestCase;
-
-
-/**
- * @since 4.3
- */
-public class TestVDBNameValidator extends TestCase {
-
- public TestVDBNameValidator(String name) {
- super(name);
- }
-
- public final void testValidName1() {
- assertTrue(VDBNameValidator.isValid("ValidName")); //$NON-NLS-1$
- }
-
- public final void testValidName2() {
- assertTrue(VDBNameValidator.isValid("System_1")); //$NON-NLS-1$
- }
-
- public final void testValidName3() {
- assertTrue(VDBNameValidator.isValid("Admin__")); //$NON-NLS-1$
- }
-
- public final void testValidNameWithUnderscore() {
- assertTrue(VDBNameValidator.isValid("Valid_Name")); //$NON-NLS-1$
- }
-
- public final void testAllValidCharacters() {
- assertTrue(VDBNameValidator.isValid("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")); //$NON-NLS-1$
- }
-
- public final void testInvalidName1() {
- assertFalse(VDBNameValidator.isValid("InvalidName`")); //$NON-NLS-1$
- }
-
- public final void testInvalidName2() {
- assertFalse(VDBNameValidator.isValid("Inalid/Name")); //$NON-NLS-1$
- }
-
- public final void testInvalidName3() {
- assertFalse(VDBNameValidator.isValid("Invalid-Name")); //$NON-NLS-1$
- }
-
- public final void testInvalidName4() {
- assertFalse(VDBNameValidator.isValid("Invalid?Name")); //$NON-NLS-1$
- }
-
- public final void testNameThatStartWithDigit() {
- assertFalse(VDBNameValidator.isValid("1VDBName")); //$NON-NLS-1$
- }
-
- public final void testNameThatStartWithUnderscore() {
- assertFalse(VDBNameValidator.isValid("_VDBName")); //$NON-NLS-1$
- }
-
- public final void testEmptyVDBName() {
- assertFalse(VDBNameValidator.isValid("")); //$NON-NLS-1$
- }
-
- public final void testNullName() {
- assertFalse(VDBNameValidator.isValid(null));
- }
-
- public final void testReservedSystemName() {
- assertFalse(VDBNameValidator.isValid("System")); //$NON-NLS-1$
- }
-
- public final void testReservedHelpName() {
- assertFalse(VDBNameValidator.isValid("System")); //$NON-NLS-1$
- }
-
- public final void testReservedAdminName() {
- assertFalse(VDBNameValidator.isValid("System")); //$NON-NLS-1$
- }
-
-
-}
14 years, 2 months
teiid SVN: r1910 - in trunk: client/src/main/java/org/teiid/transport and 9 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-04 14:47:03 -0500 (Thu, 04 Mar 2010)
New Revision: 1910
Removed:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/
trunk/common-core/src/main/java/com/metamatrix/common/protocol/
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java
Log:
TEIID-833 committing JCA merge
Modified: trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -26,15 +26,12 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Properties;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.client.ExceptionUtil;
@@ -48,7 +45,7 @@
import com.metamatrix.platform.security.api.SessionToken;
public class LocalServerConnection implements ServerConnection {
- private static final String TEIID_RUNTIME = "teiid/engine-deployer";
+ private static final String TEIID_RUNTIME = "teiid/engine-deployer"; //$NON-NLS-1$
private final LogonResult result;
private boolean shutdown;
@@ -119,14 +116,8 @@
if (writeFuture != null) {
writeFuture.get(5000, TimeUnit.MILLISECONDS);
}
- } catch (InvalidSessionException e) {
+ } catch (Exception e) {
//ignore
- } catch (InterruptedException e) {
- //ignore
- } catch (ExecutionException e) {
- //ignore
- } catch (TimeoutException e) {
- //ignore
}
}
this.shutdown = true;
@@ -141,6 +132,7 @@
return (conn instanceof LocalServerConnection);
}
+ @SuppressWarnings("unchecked")
protected <T> T lookup(String jndiName) throws NamingException {
InitialContext ic = new InitialContext();
return (T)ic.lookup(jndiName);
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -23,7 +23,6 @@
package com.metamatrix.jdbc;
import java.io.PrintWriter;
-import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
@@ -141,18 +140,6 @@
*/
private String description;
- /**
- * The <code>Serializable</code> client token that will be passed directly
- * through to the connectors, which may use it and/or pass it down to their underlying data source.
- * This property is <i>optional</i>.
- * <p>
- * The form and type of the client token is up to the client but it <i>must</i> implement the
- * <code>Serializabe</code> interface. Teiid does nothing with this token except to make it
- * available for authentication/augmentation/replacement upon authentication to the system and to
- * connectors that may require it at the data source level.
- * </p>
- */
- private Serializable clientToken;
/**
* The user's name.
@@ -274,12 +261,6 @@
props.setProperty(BaseDataSource.APP_NAME,this.getApplicationName());
}
- Serializable token = this.getClientToken();
- if ( token != null ) {
- // Special case: token is a Serializable, not necessarily a String
- props.put(MMURL.CONNECTION.CLIENT_TOKEN_PROP, token);
- }
-
if (this.getPartialResultsMode() != null && this.getPartialResultsMode().trim().length() != 0) {
props.setProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, this.getPartialResultsMode());
}
@@ -317,11 +298,6 @@
throw new SQLException(reason);
}
- reason = reasonWhyInvalidClientToken(this.clientToken);
- if ( reason != null ) {
- throw new SQLException(reason);
- }
-
reason = reasonWhyInvalidDatabaseName(this.databaseName);
if ( reason != null ) {
throw new SQLException(reason);
@@ -553,23 +529,7 @@
}
/**
- * Get the <code>Serializable</code> client token that will be passed directly
- * through to the connectors, which may use it and/or pass it down to their underlying data source.
- * This property is <i>optional</i>.
- * <p>
- * The form and type of the client token is up to the client but it <i>must</i> implement the
- * <code>Serializabe</code> interface. Teiid does nothing with this token except to make it
- * available for authentication/augmentation/replacement upon authentication to the system and to
- * connectors that may require it at the data source level.
- * </p>
- * @return The client token that was supplied by the client at system connection time; may be <code>null</code>.
- */
- public Serializable getClientToken() {
- return clientToken;
- }
-
- /**
- * Sets the name of the application. Supplying this property may allow an administrator of a
+< * Sets the name of the application. Supplying this property may allow an administrator of a
* Teiid Server to better identify individual connections and usage patterns.
* This property is <i>optional</i>.
* @param applicationName The applicationName to set
@@ -621,22 +581,6 @@
}
/**
- * Set the <code>Serializable</code> client token that will be passed directly
- * through to the connectors, which may use it and/or pass it down to their underlying data source.
- * This property is <i>optional</i>.
- * <p>
- * The form and type of the client token is up to the client but it <i>must</i> implement the
- * <code>Serializabe</code> interface. Teiid does nothing with this token except to make it
- * available for authentication/augmentation/replacement upon authentication to the system and to
- * connectors that may require it at the data source level.
- * </p>
- * @param clientToken The client token that will be passed with this user's requests.
- */
- public void setClientToken(Serializable clientToken) {
- this.clientToken = clientToken;
- }
-
- /**
* Sets the description of this data source.
* @param description The description for this data source; may be null
*/
@@ -760,17 +704,8 @@
return null; // anything is valid
}
- /**
- * Return the reason why the supplied client token may be invalid, or null
- * if it is considered valid.
- * @param clientToken a possible value for the property
- * @return the reason why the property is invalid, or null if it is considered valid
- * @see #setClientToken(Serializable)
- */
- public static String reasonWhyInvalidClientToken(final Serializable clientToken) {
- return null; // it is optional
- }
+
/**
* Return the reason why the supplied virtual database name may be invalid, or null
* if it is considered valid.
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -33,23 +33,4 @@
}
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getBootstrapFile() {
- return getEmbeddedBootstrapFile();
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setBootstrapFile(final String configFile) {
- setEmbeddedBootstrapFile(configFile);
- }
-
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -51,6 +51,8 @@
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
/**
* <p> This class inherits Statement methods, which deal with SQL statements in
@@ -91,10 +93,9 @@
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
- RequestMessage message = super.createRequestMessage(commands, isBatchedCommand, requiresResultSet);
- message.setCallableStatement(true);
- message.setPreparedStatement(false);
+ boolean isBatchedCommand, ResultsMode resultsMode) {
+ RequestMessage message = super.createRequestMessage(commands, isBatchedCommand, resultsMode);
+ message.setStatementType(StatementType.CALLABLE);
return message;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -57,8 +57,6 @@
import javax.transaction.xa.Xid;
-import org.teiid.adminapi.Admin;
-
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.exception.CommunicationException;
@@ -67,6 +65,7 @@
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -215,7 +214,7 @@
String key = (String)enumeration.nextElement();
Object anObj = info.get(key);
// Log each property except for password and token.
- if (!MMURL.JDBC.CREDENTIALS.equalsIgnoreCase(key) && !MMURL.CONNECTION.PASSWORD.equalsIgnoreCase(key) && !MMURL.CONNECTION.CLIENT_TOKEN_PROP.equalsIgnoreCase(key)) {
+ if (!MMURL.CONNECTION.PASSWORD.equalsIgnoreCase(key)) {
logger.fine(key+"="+anObj); //$NON-NLS-1$
}
}
@@ -225,14 +224,6 @@
String getUrl() {
return this.url;
}
-
- /**
- * @see com.metamatrix.jdbc.api.Connection#getAdminAPI()
- * @since 4.3
- */
- public synchronized Admin getAdminAPI() throws SQLException {
- return this.serverConn.getService(Admin.class);
- }
/**
* Connection identifier of this connection
@@ -240,7 +231,7 @@
* @throws SQLException
*/
public String getConnectionId() {
- return this.serverConn.getLogonResult().getSessionID().toString();
+ return String.valueOf(this.serverConn.getLogonResult().getSessionID());
}
long currentRequestId() {
@@ -287,7 +278,7 @@
} catch (SQLException se) {
firstException = se;
} finally {
- this.serverConn.shutdown();
+ this.serverConn.close();
if ( firstException != null )
throw (SQLException)firstException;
}
@@ -357,8 +348,9 @@
private void directCommit() throws SQLException {
try {
- this.dqp.commit();
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.commit();
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
logger.fine(JDBCPlugin.Util.getString("MMConnection.Commit_success")); //$NON-NLS-1$
@@ -483,12 +475,12 @@
checkConnection();
//get the virtual database name to which we are connected.
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_NAME);
+ return this.serverConn.getLogonResult().getVdbName();
}
- public String getVDBVersion() throws SQLException {
+ public int getVDBVersion() throws SQLException {
checkConnection();
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_VERSION);
+ return this.serverConn.getLogonResult().getVdbVersion();
}
/**
@@ -726,8 +718,9 @@
if (!autoCommitFlag) {
try {
try {
- this.dqp.rollback();
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.rollback();
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
logger.fine(JDBCPlugin.Util.getString("MMConnection.Rollback_success")); //$NON-NLS-1$
@@ -812,8 +805,9 @@
transactionXid = null;
this.autoCommitFlag = true;
try {
- this.dqp.commit(arg0, arg1);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.commit(arg0, arg1);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -822,8 +816,9 @@
checkConnection();
this.autoCommitFlag = true;
try {
- this.dqp.end(arg0, arg1);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.end(arg0, arg1);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -831,8 +826,9 @@
protected void forgetTransaction(MMXid arg0) throws SQLException {
checkConnection();
try {
- this.dqp.forget(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.forget(arg0);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -841,8 +837,9 @@
checkConnection();
transactionXid = null;
try {
- return this.dqp.prepare(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<Integer> future = this.dqp.prepare(arg0);
+ return future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -850,8 +847,9 @@
protected Xid[] recoverTransaction(int arg0) throws SQLException {
checkConnection();
try {
- return this.dqp.recover(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<Xid[]> future = this.dqp.recover(arg0);
+ return future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -861,8 +859,9 @@
transactionXid = null;
this.autoCommitFlag = true;
try {
- this.dqp.rollback(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.rollback(arg0);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -870,8 +869,9 @@
protected void startTransaction(MMXid arg0, int arg1, int timeout) throws SQLException {
checkConnection();
try {
- this.dqp.start(arg0, arg1, timeout);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.start(arg0, arg1, timeout);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
transactionXid = arg0;
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -68,11 +68,6 @@
*/
private String serverName;
- /**
- * Specify a set of data source credentials to pass to the connectors as defined in
- * {@link MMURL.JDBC.CREDENTIALS}.
- */
- private String credentials;
/**
* Specify whether to make a secure (SSL, mms:) connection or a normal non-SSL mm: connection.
@@ -115,10 +110,6 @@
props.setProperty(MMURL.CONNECTION.AUTO_FAILOVER, this.getAutoFailover());
}
- if (this.getCredentials() != null) {
- props.setProperty(MMURL.JDBC.CREDENTIALS, this.getCredentials());
- }
-
if (this.getDiscoveryStrategy() != null) {
props.setProperty(MMURL.CONNECTION.DISCOVERY_STRATEGY, this.getDiscoveryStrategy());
}
@@ -248,14 +239,6 @@
}
/**
- * Returns the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public String getCredentials() {
- return credentials;
- }
-
- /**
* Returns a flag indicating whether to create a secure connection or not.
* @return True if using secure mms: protocol, false for normal mm: protocol.
* @since 5.0.2
@@ -297,14 +280,6 @@
}
/**
- * Sets the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public void setCredentials(final String credentials) {
- this.credentials = credentials;
- }
-
- /**
* Sets the secure flag to use mms: protocol instead of the default mm: protocol.
* @param secure True to use mms:
* @since 5.0.2
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -46,6 +46,7 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
import com.metamatrix.common.util.SqlUtil;
+import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
@@ -63,6 +64,8 @@
*/
public class MMDatabaseMetaData extends WrapperImpl implements com.metamatrix.jdbc.api.DatabaseMetaData {
+ private static final String DATA_TYPES = "DataTypes"; //$NON-NLS-1$
+
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
/** CONSTANTS */
@@ -122,7 +125,7 @@
private final static String LIKE_ESCAPE = " LIKE ? ESCAPE '" + ESCAPE_SEARCH_STRING + "' ";//$NON-NLS-1$//$NON-NLS-2$
final private static class RUNTIME_MODEL{
- public final static String VIRTUAL_MODEL_NAME = "System"; //$NON-NLS-1$
+ public final static String VIRTUAL_MODEL_NAME = CoreConstants.SYSTEM_MODEL;
}
private static final String TYPE_MAPPING;
@@ -1786,24 +1789,24 @@
Map[] metadataList = new Map[18];
- metadataList[0] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[1] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[2] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.PRECISION, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[3] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[4] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[5] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.CREATE_PARAMS, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[6] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.NULLABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[7] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE);//$NON-NLS-1$
- metadataList[8] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.SEARCHABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[9] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[10] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[11] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.AUTOINCREMENT, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE);//$NON-NLS-1$
- metadataList[12] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[13] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[14] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[15] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[16] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[17] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[0] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[1] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[2] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.PRECISION, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[3] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[4] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[5] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CREATE_PARAMS, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[6] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NULLABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[7] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE);//$NON-NLS-1$
+ metadataList[8] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SEARCHABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[9] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[10] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[11] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.AUTOINCREMENT, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE);//$NON-NLS-1$
+ metadataList[12] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[13] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[14] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[15] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[16] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[17] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
ResultSetMetaData rmetadata = ResultsMetadataWithProvider.newInstance(StaticMetadataProvider.createWithData(metadataList, 0));
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -43,7 +43,6 @@
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.jdbc.util.MMJDBCURL;
/**
@@ -140,7 +139,7 @@
MMConnection createMMConnection(String url, Properties info)
throws ConnectionException, CommunicationException {
- ServerConnection serverConn = SocketServerConnectionFactory.getInstance().createConnection(info);
+ ServerConnection serverConn = SocketServerConnectionFactory.getInstance().getConnection(info);
// construct a MMConnection object.
MMConnection connection = new MMConnection(serverConn, info, url);
@@ -238,7 +237,6 @@
dpis.add(dpi);
dpis.add(new DriverPropertyInfo(BaseDataSource.USER_NAME, info.getProperty(BaseDataSource.USER_NAME)));
dpis.add(new DriverPropertyInfo(BaseDataSource.PASSWORD, info.getProperty(BaseDataSource.PASSWORD)));
- dpis.add(new DriverPropertyInfo(ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD, info.getProperty(BaseDataSource.PASSWORD)));
return dpis;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -60,6 +60,8 @@
import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -186,7 +188,7 @@
@Override
//## JDBC4.0-end ##
public boolean execute() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, null);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER);
return hasResultSet();
}
@@ -196,7 +198,7 @@
return new int[0];
}
try{
- executeSql(new String[] {this.prepareSql}, true, false);
+ executeSql(new String[] {this.prepareSql}, true, ResultsMode.UPDATECOUNT);
}finally{
batchParameterList.clear();
}
@@ -207,7 +209,7 @@
@Override
//## JDBC4.0-end ##
public ResultSet executeQuery() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, true);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.RESULTSET);
return resultSet;
}
@@ -215,17 +217,17 @@
@Override
//## JDBC4.0-end ##
public int executeUpdate() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, false);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.UPDATECOUNT);
return this.updateCounts[0];
}
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
- RequestMessage message = super.createRequestMessage(commands, false, requiresResultSet);
- message.setPreparedStatement(true);
+ boolean isBatchedCommand, ResultsMode resultsMode) {
+ RequestMessage message = super.createRequestMessage(commands, false, resultsMode);
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(isBatchedCommand?getParameterValuesList(): getParameterValues());
- message.setPreparedBatchUpdate(isBatchedCommand);
+ message.setBatchedUpdate(isBatchedCommand);
return message;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -127,7 +127,7 @@
this.statement = statement;
this.parameters = parameters;
// server latency-related timestamp
- this.processingTimestamp = resultsMsg.getProcessingTimestamp();
+ this.processingTimestamp = statement.getProcessingTimestamp();
this.requestID = statement.getCurrentRequestID();
this.cursorType = statement.getResultSetType();
this.batchResults = new BatchResults(this, getCurrentBatch(resultsMsg), this.cursorType == ResultSet.TYPE_FORWARD_ONLY ? 1 : BatchResults.DEFAULT_SAVED_BATCHES);
@@ -1121,7 +1121,7 @@
}
protected void setResultsData(ResultsMessage resultsMsg) {
- this.completedTimestamp = resultsMsg.getCompletedTimestamp();
+ this.completedTimestamp = new java.util.Date();
this.statement.accumulateWarnings(resultsMsg.getWarnings());
}
@@ -1191,9 +1191,9 @@
}
/**
- * Gets the time command execution is compleated on the server.
+ * Gets the time command execution is completed on the server.
*
- * @return Date object representing time the commond finished execution.
+ * @return Date object representing time the command finished execution.
*/
public java.util.Date getCompletedTimestamp() throws SQLException {
checkClosed();
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -22,7 +22,6 @@
package com.metamatrix.jdbc;
-import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
@@ -33,6 +32,7 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -51,12 +51,13 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.util.SqlUtil;
+import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.jdbc.api.Annotation;
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.jdbc.api.PlanNode;
@@ -157,6 +158,8 @@
private Pattern setStatement = Pattern.compile("\\s*set\\s*(\\w+)\\s*=\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private Date processingTimestamp;
+
/**
* Factory Constructor
* @param driverConnection
@@ -318,7 +321,7 @@
@Override
//## JDBC4.0-end ##
public boolean execute(String sql) throws SQLException {
- executeSql(new String[] {sql}, false, null);
+ executeSql(new String[] {sql}, false, ResultsMode.EITHER);
return hasResultSet();
}
@@ -330,7 +333,7 @@
return new int[0];
}
String[] commands = (String[])batchedUpdates.toArray(new String[batchedUpdates.size()]);
- executeSql(commands, true, false);
+ executeSql(commands, true, ResultsMode.UPDATECOUNT);
return updateCounts;
}
@@ -338,7 +341,7 @@
@Override
//## JDBC4.0-end ##
public ResultSet executeQuery(String sql) throws SQLException {
- executeSql(new String[] {sql}, false, true);
+ executeSql(new String[] {sql}, false, ResultsMode.RESULTSET);
return resultSet;
}
@@ -347,7 +350,7 @@
//## JDBC4.0-end ##
public int executeUpdate(String sql) throws SQLException {
String[] commands = new String[] {sql};
- executeSql(commands, false, false);
+ executeSql(commands, false, ResultsMode.UPDATECOUNT);
return this.updateCounts[0];
}
@@ -402,13 +405,13 @@
resultSet.setMaxFieldSize(this.maxFieldSize);
}
- protected void executeSql(String[] commands, boolean isBatchedCommand, Boolean requiresResultSet)
+ protected void executeSql(String[] commands, boolean isBatchedCommand, ResultsMode resultsMode)
throws SQLException, MMSQLException {
checkStatement();
resetExecutionState();
//handle set statement
- if (commands.length == 1 && requiresResultSet != Boolean.TRUE) {
+ if (commands.length == 1 && resultsMode != ResultsMode.RESULTSET) {
Matcher match = setStatement.matcher(commands[0]);
if (match.matches()) {
String key = match.group(1);
@@ -419,7 +422,7 @@
}
}
- RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, requiresResultSet);
+ RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, resultsMode);
ResultsMessage resultsMsg = null;
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
@@ -449,6 +452,15 @@
for (int i = 0; i < results.length; i++) {
updateCounts[i] = (Integer)results[i].get(0);
}
+
+ // In update scenarios close the statement implicitly
+ try {
+ getDQP().closeRequest(getCurrentRequestID());
+ } catch (MetaMatrixProcessingException e) {
+ throw MMSQLException.create(e);
+ } catch (MetaMatrixComponentException e) {
+ throw MMSQLException.create(e);
+ }
} else {
createResultSet(resultsMsg);
}
@@ -457,11 +469,11 @@
}
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
+ boolean isBatchedCommand, ResultsMode resultsMode) {
RequestMessage reqMessage = new RequestMessage();
reqMessage.setCommands(commands);
reqMessage.setBatchedUpdate(isBatchedCommand);
- reqMessage.setRequireResultSet(requiresResultSet);
+ reqMessage.setResultsMode(resultsMode);
return reqMessage;
}
@@ -752,6 +764,15 @@
// Get result set cache mode
String rsCache = getExecutionProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
res.setUseResultSetCache(Boolean.valueOf(rsCache).booleanValue());
+
+ res.setAnsiQuotedIdentifiers(Boolean.valueOf(
+ getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS))
+ .booleanValue());
+ String sqlOptions = getExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS);
+ if (sqlOptions != null &&
+ sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
+ res.setShowPlan(true);
+ }
}
/**
@@ -812,34 +833,13 @@
/**
* Send out request message with necessary states.
- * @param transaction UsertTransaction
- * @param sql String of command or prepared string
- * @param listener Message Listener
- * @param timeout Maybe 0
- * @param isPreparedStatement flag indicating whether this statement is a PreparedStatement
- * @param isCallableStatement flag indicating whether this statement is a CallableStatement
- * @param params Parameters values of either PreparedStatement or CallableStatement
- * @param isBatchedCommand flag indicating whether the statements are being executed as a batch
- * @throws SQLException
- * @throws TimeoutException
- * @throws InterruptedException
- * @throws CommunicationException
*/
protected ResultsMessage sendRequestMessageAndWait(RequestMessage reqMsg)
throws SQLException, InterruptedException, TimeoutException {
-
+ this.processingTimestamp = new Date();
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
- reqMsg.markSubmissionStart();
reqMsg.setExecutionPayload(this.payload);
- reqMsg.setAnsiQuotedIdentifiers(Boolean.valueOf(
- getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS))
- .booleanValue());
- String sqlOptions = getExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS);
- if (sqlOptions != null &&
- sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
- reqMsg.setShowPlan(true);
- }
reqMsg.setCursorType(this.resultSetType);
reqMsg.setFetchSize(this.fetchSize);
reqMsg.setStyleSheet(this.styleSheet);
@@ -896,23 +896,7 @@
* @throws IOException if unable to read the style sheet from the Reader object.
*/
public void attachStylesheet(Reader reader) throws IOException {
- BufferedReader bufferedReader = null;
- StringBuffer buffer = new StringBuffer();
- try {
- bufferedReader = new BufferedReader(reader);
- while(true) {
- String line = bufferedReader.readLine();
- if(line == null) {
- break;
- }
- buffer.append( line );
- }
- } finally {
- if(bufferedReader != null) {
- bufferedReader.close();
- }
- }
- this.styleSheet = buffer.toString();
+ this.styleSheet = ObjectConverterUtil.convertToString(reader);
}
/**
@@ -972,6 +956,10 @@
public Collection getAnnotations() {
return this.annotations;
}
+
+ public Date getProcessingTimestamp() {
+ return processingTimestamp;
+ }
public void setPartialResults(boolean isPartialResults){
if(isPartialResults){
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -24,23 +24,13 @@
import java.sql.SQLException;
-import org.teiid.adminapi.Admin;
-
/**
- * MetaMatrix extensions to the standard JDBC Connection interface.
+ * Extensions to the standard JDBC Connection interface.
*/
public interface Connection extends java.sql.Connection {
- /**
- * Retrieve an administrative object used to control MM Query.
- * @return EmbeddedAdmin object to administer the MM Query component
- * corresponding to this connection.
- * @throws SQLException
- */
- Admin getAdminAPI() throws SQLException;
-
- String getVDBVersion() throws SQLException;
+ int getVDBVersion() throws SQLException;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -31,7 +31,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.jdbc.api.ExecutionProperties;
@@ -59,11 +58,8 @@
ExecutionProperties.PROP_XML_FORMAT,
ExecutionProperties.PROP_XML_VALIDATION,
ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
- ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD,
- ConnectionProperties.PROP_CREDENTIALS,
MMURL.CONNECTION.AUTO_FAILOVER,
- MMURL.CONNECTION.DISCOVERY_STRATEGY,
- MMURL.CONNECTION.SHUTDOWN
+ MMURL.CONNECTION.DISCOVERY_STRATEGY
};
private String vdbName;
@@ -77,8 +73,7 @@
}
public MMJDBCURL(String vdbName, String connectionURL, Properties props) {
- if (vdbName == null || vdbName.trim().length() == 0 ||
- connectionURL == null || connectionURL.trim().length() == 0) {
+ if (vdbName == null || vdbName.trim().length() == 0) {
throw new IllegalArgumentException();
}
this.vdbName = vdbName;
@@ -201,9 +196,10 @@
public String getJDBCURL() {
if (urlString == null) {
StringBuffer buf = new StringBuffer(JDBC_PROTOCOL)
- .append(vdbName)
- .append('@')
- .append(connectionURL);
+ .append(vdbName);
+ if (this.connectionURL != null) {
+ buf.append('@').append(connectionURL);
+ }
for (Iterator i = properties.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry)i.next();
if (entry.getValue() instanceof String) {
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -22,70 +22,41 @@
package org.teiid.jdbc;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Enumeration;
-import java.util.List;
import java.util.Properties;
import java.util.ResourceBundle;
-import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
+import org.teiid.transport.LocalServerConnection;
-import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.protocol.MMURLConnection;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMConnection;
-import com.metamatrix.jdbc.MMSQLException;
-import com.metamatrix.jdbc.api.SQLStates;
import com.metamatrix.jdbc.util.MMJDBCURL;
final class EmbeddedProfile {
- /**
+
+ private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
+
+ /**
* Match URL like
- * - jdbc:metamatrix:BQT@c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT@c:\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@/foo.properties;version=1..
- * - jdbc:metamatrix:BQT@../foo.properties;version=1..
- * - jdbc:metamatrix:BQT@./foo.properties;version=1..
- * - jdbc:metamatrix:BQT@file:///c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT
- * - jdbc:metamatrix:BQT;verson=1
+ * - jdbc:teiid:BQT
+ * - jdbc:teiid:BQT;verson=1
*/
- static final String URL_PATTERN = "jdbc:(teiid|metamatrix):(\\w+)@(([^;]*)[;]?)((.*)*)"; //$NON-NLS-1$
- static final String BASE_PATTERN = "jdbc:(teiid|metamatrix):((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
+ static final String BASE_PATTERN = "jdbc:teiid:((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
- private static EmbeddedTransport currentTransport = null;
- static Pattern urlPattern = Pattern.compile(URL_PATTERN);
static Pattern basePattern = Pattern.compile(BASE_PATTERN);
/**
@@ -106,79 +77,32 @@
// parse the URL to add it's properties to properties object
parseURL(url, info);
- MMConnection conn = createConnection(info);
- boolean shutdown = Boolean.parseBoolean(info.getProperty(MMURL.CONNECTION.SHUTDOWN, "false")); //$NON-NLS-1$
- if (shutdown) {
- Admin admin = conn.getAdminAPI();
- try {
- // this will make sure the user has permissions to do the shutdown.
- admin.shutdown(0);
- shutdown();
- throw new MMSQLException(getResourceMessage("EmbeddedDriver.shutdown_sucessful"), SQLStates.SUCESS); //$NON-NLS-1$
- } catch (AdminException e) {
- conn.close();
- throw new MMSQLException(e, getResourceMessage("EmbeddedDriver.shutdown_failure"), SQLStates.DEFAULT); //$NON-NLS-1$
- }
- }
-
- // logging
- String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
- logger.fine(logMsg);
-
+ MMConnection conn = createConnection(url, info);
+ logger.fine(JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess")); //$NON-NLS-1$
return conn;
-
}
- static MMConnection createConnection(Properties info) throws SQLException{
+ static MMConnection createConnection(String url, Properties info) throws SQLException{
// first validate the properties as this may called from the EmbeddedDataSource
// and make sure we have all the properties we need.
validateProperties(info);
-
- URL dqpURL;
- try {
- dqpURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE));
- } catch (MalformedURLException e) {
- throw MMSQLException.create(e);
+ try {
+ return new MMConnection(new LocalServerConnection(info), info, url);
+ } catch (MetaMatrixRuntimeException e) {
+ throw new SQLException(e);
+ } catch (ConnectionException e) {
+ throw new SQLException(e);
+ } catch (CommunicationException e) {
+ throw new SQLException(e);
}
-
- // now create the connection
- EmbeddedTransport transport = getDQPTransport(dqpURL);
-
- MMConnection conn = transport.createConnection(info);
-
- return conn;
}
/**
- * Get the DQP transport or build the transport if one not available from the
- * DQP URL supplied. DQP transport contains all the details about DQP.
- * @param dqpURL - URL to the DQP.properties file
- * @return EmbeddedTransport
- * @throws SQLException
- * @since 4.4
- */
- private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL) throws SQLException {
- EmbeddedTransport transport = currentTransport;
- if (transport == null || !transport.isAlive() || !currentTransport.getURL().equals(dqpURL)) {
- // shutdown any previous instance; we do encourage single instance in a given VM
- shutdown();
- try {
- transport = new EmbeddedTransport(dqpURL);
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
- throw e;
- }
- }
- currentTransport = transport;
- return transport;
- }
-
- /**
* This method parses the URL and adds properties to the the properties object. These include required and any optional
* properties specified in the URL.
* Expected URL format --
- * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;credentials=mycredentials;
+ * jdbc:teiid:VDB;[name=value]*;
*
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
@@ -195,16 +119,6 @@
// Set the VDB Name
info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
-
- // Need to resolve the URL fully, if we are using the default URL like
- // jdbc:metamatrix:<vdbName>.., where as this fully qualifies to
- // jdbc:metamatrix:<vdbName>@classpath:<vdbName>/mm.properties;...
- String connectionURL = jdbcURL.getConnectionURL();
- if (connectionURL == null) {
- connectionURL = getDefaultConnectionURL();
- info.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, jdbcURL.getVDBName()+".vdb"); //$NON-NLS-1$
- }
- info.setProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, connectionURL);
Properties optionalParams = jdbcURL.getProperties();
MMJDBCURL.normalizeProperties(info);
@@ -231,15 +145,6 @@
}
/**
- * Create the default connection URL, if one is not supplied
- * @param jdbcURL
- * @return default connection URL
- */
- static String getDefaultConnectionURL() {
- return "classpath:/deploy.properties"; //$NON-NLS-1$
- }
-
- /**
* validate some required properties
* @param info the connection properties to be validated
* @throws SQLException
@@ -257,226 +162,12 @@
}
public static boolean acceptsURL(String url) {
- Matcher m = urlPattern.matcher(url);
- boolean matched = m.matches();
- if (matched) {
- // make sure the group (2) which is the name of the file
- // does not start with mm:// or mms://
- String name = m.group(3).toLowerCase();
- return (!name.startsWith("mm://") && !name.startsWith("mms://") && (name.endsWith(".properties")||name.endsWith(".properties;"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
// Check if this can match our default one, then allow it.
- m = basePattern.matcher(url);
- matched = m.matches();
+ Matcher m = basePattern.matcher(url);
+ boolean matched = m.matches();
return matched;
}
-
-
- /**
- * Shutdown the DQP instance which has been started using the given URL
- * @param dqpURL
- */
- public static synchronized void shutdown() {
- if (currentTransport != null) {
- currentTransport.shutdown();
- currentTransport = null;
- }
- }
-
- /**
- * inner class to hold DQP tansportMap object
- * @since 4.3
- */
- static class EmbeddedTransport {
- private ServerConnectionFactory connectionFactory;
- private ClassLoader classLoader;
- private URL url;
-
- public EmbeddedTransport(URL dqpURL) throws SQLException {
- this.url = dqpURL;
-
- //Load the properties from dqp.properties file
- Properties props = loadDQPProperties(dqpURL);
-
- props = PropertiesUtils.resolveNestedProperties(props);
-
- // a non-delegating class loader will be created from where all third party dependent jars can be loaded
- ArrayList<URL> runtimeClasspathList = new ArrayList<URL>();
- String libLocation = props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
- if (!libLocation.endsWith("/")) { //$NON-NLS-1$
- libLocation = libLocation + "/"; //$NON-NLS-1$
- }
-
- // find jars in the "lib" directory; patches is reverse alpaha and not case sensitive so small letters then capitals
- if (!EmbeddedProfile.getDefaultConnectionURL().equals(dqpURL.toString())) {
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation+"patches/", MMURLConnection.REVERSEALPHA)); //$NON-NLS-1$
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation, MMURLConnection.DATE));
-
- try {
- String configLocation = props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "./deploy/"); //$NON-NLS-1$
- if (!configLocation.endsWith("/")) { //$NON-NLS-1$
- configLocation = configLocation + "/"; //$NON-NLS-1$
- }
- runtimeClasspathList.add(URLHelper.buildURL(dqpURL, configLocation));
- } catch(IOException e) {
- // ignore..
- }
- }
-
- URL[] dqpClassPath = runtimeClasspathList.toArray(new URL[runtimeClasspathList.size()]);
- this.classLoader = new PostDelegatingClassLoader(dqpClassPath, this.getClass().getClassLoader(), new MetaMatrixURLStreamHandlerFactory());
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
-
- props.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
- props.setProperty(DQPEmbeddedProperties.TEIID_HOME, getHomeDirectory(props));
- // Now using this class loader create the connection factory to the dqp.
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.classLoader);
- String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
- try {
- this.connectionFactory = (ServerConnectionFactory)ReflectionHelper.create(className, null, this.classLoader);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$
- }
- try {
- this.connectionFactory.initialize(props);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- URL getURL() {
- return this.url;
- }
-
- /**
- * Note that this only works when embedded loaded with "mmfile" protocol in the URL.
- * @param dqpURL
- * @return
- */
- private List<URL> libClassPath (URL dqpURL, String directory, String sortStyle) {
- ObjectInputStream in = null;
- ArrayList<URL> urlList = new ArrayList<URL>();
- try {
- urlList.add(URLHelper.buildURL(dqpURL, directory));
- dqpURL = URLHelper.buildURL(dqpURL, directory+"?action=list&filter=.jar&sort="+sortStyle); //$NON-NLS-1$
- in = new ObjectInputStream(dqpURL.openStream());
- String[] urls = (String[])in.readObject();
- for (int i = 0; i < urls.length; i++) {
- urlList.add(URLHelper.buildURL(urls[i]));
- }
- } catch(IOException e) {
- //ignore, treat as if lib does not exist
- } catch(ClassNotFoundException e) {
- //ignore, treat as if lib does not exist
- } finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- return urlList;
- }
-
- /**
- * Load DQP Properties from the URL supplied.
- * @param dqpURL - URL to the "dqp.properties" object
- * @return Properties loaded
- * @throws SQLException
- */
- Properties loadDQPProperties(URL dqpURL) throws SQLException {
- InputStream in = null;
- try{
- in = dqpURL.openStream();
- Properties props = new Properties(System.getProperties());
- props.load(in);
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_properties"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + props);
- return props;
- }catch(IOException e) {
- String logMsg = getResourceMessage("EmbeddedTransport.invalid_dqpproperties_path", new Object[] {dqpURL}); //$NON-NLS-1$
- throw MMSQLException.create(e, logMsg);
- }finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- }
-
- /**
- * Shutdown the current transport
- */
- void shutdown() {
- this.connectionFactory.shutdown(false);
- }
-
- boolean isAlive() {
- return this.connectionFactory.isAlive();
- }
-
- /**
- * Create a connection to the DQP defined by this transport object based on
- * properties supplied
- * @param info
- * @return Connection
- */
- MMConnection createConnection(Properties info) throws SQLException {
- ClassLoader current = null;
- try {
- current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
- try {
- ServerConnection conn = connectionFactory.createConnection(info);
- return new MMConnection(conn, info, url.toExternalForm());
- } catch (CommunicationException e) {
- throw MMSQLException.create(e);
- } catch (ConnectionException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- String getHomeDirectory(Properties props) throws SQLException {
- try {
- String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
-
- if (teiidHome == null) {
- if (EmbeddedProfile.getDefaultConnectionURL().equals(url.toString())) {
- teiidHome = System.getProperty("user.dir")+"/teiid"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- URL installDirectory = URLHelper.buildURL(url, "."); //$NON-NLS-1$
- teiidHome = installDirectory.getPath();
- }
- }
- File f = new File(teiidHome);
- return f.getCanonicalPath();
- } catch(IOException e) {
- throw MMSQLException.create(e);
- }
- }
-
- }
- private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
-
-
- static String getResourceMessage(String key, Object[] args) {
- ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
- String messageTemplate = messages.getString(key);
- return MessageFormat.format(messageTemplate, args);
- }
-
-
static String getResourceMessage(String key) {
ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
String messageTemplate = messages.getString(key);
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -105,7 +105,7 @@
static MMConnection createConnection(String url, Properties info)
throws ConnectionException, CommunicationException {
- ServerConnection serverConn = SocketServerConnectionFactory.getInstance().createConnection(info);
+ ServerConnection serverConn = SocketServerConnectionFactory.getInstance().getConnection(info);
// construct a MMConnection object.
MMConnection connection = new MMConnection(serverConn, info, url);
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -22,21 +22,17 @@
package org.teiid.jdbc;
-import java.net.URL;
import java.sql.Connection;
-import java.sql.SQLException;
import java.util.Properties;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMSQLException;
import com.metamatrix.jdbc.util.MMJDBCURL;
/**
- * The MetaMatrix JDBC DataSource implementation class of {@link javax.sql.DataSource} and
+ * The Teiid JDBC DataSource implementation class of {@link javax.sql.DataSource} and
* {@link javax.sql.XADataSource}.
* <p>
* The {@link javax.sql.DataSource} interface follows the JavaBean design pattern,
@@ -52,10 +48,11 @@
* The following are the properties for this DataSource:
* <table cellspacing="0" cellpadding="0" border="1" width="100%">
* <tr><td><b>Property Name</b></td><td><b>Type</b></td><td><b>Description</b></td></tr>
- * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a MetaMatrix Server is listening
+ * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a Teiid Server is listening
* for requests.</td></tr>
- * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the MetaMatrix Server.</td></tr>
- * <table>
+ * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the Teiid Server.</td></tr>
+ * <table>
+ * If "serverName" property is not set then data source will try to create a embedded connection to the Teiid server.
* </p>
*/
public class TeiidDataSource extends BaseDataSource {
@@ -75,12 +72,6 @@
private String serverName;
/**
- * Specify a set of data source credentials to pass to the connectors as defined in
- * {@link MMURL.JDBC.CREDENTIALS}.
- */
- private String credentials;
-
- /**
* Specify whether to make a secure (SSL, mms:) connection or a normal non-SSL mm: connection.
* the default is to use a non-secure connection.
* @since 5.0.2
@@ -102,8 +93,6 @@
private String discoveryStrategy;
- private String bootstrapFile;
-
/**
* Constructor for MMDataSource.
*/
@@ -121,10 +110,6 @@
props.setProperty(MMURL.CONNECTION.AUTO_FAILOVER, this.getAutoFailover());
}
- if (this.getCredentials() != null) {
- props.setProperty(MMURL.JDBC.CREDENTIALS, this.getCredentials());
- }
-
if (this.getDiscoveryStrategy() != null) {
props.setProperty(MMURL.CONNECTION.DISCOVERY_STRATEGY, this.getDiscoveryStrategy());
}
@@ -227,10 +212,9 @@
final TeiidDriver driver = new TeiidDriver();
// check if this is embedded connection
- if (getEmbeddedBootstrapFile() != null) {
- validateEmbeddedProperties(userName,password);
+ if (getServerName() == null) {
final Properties props = buildEmbeddedProperties(userName, password);
- String url = new MMJDBCURL(getDatabaseName(), getEmbeddedBootstrapFile(), props).getJDBCURL();
+ String url = new MMJDBCURL(getDatabaseName(), null, props).getJDBCURL();
return driver.connect(url, props);
}
@@ -243,20 +227,7 @@
private Properties buildEmbeddedProperties(final String userName, final String password) {
Properties props = buildProperties(userName, password);
-
- if (this.getEmbeddedBootstrapFile().equals(EmbeddedProfile.getDefaultConnectionURL())) {
- props.put(DQPEmbeddedProperties.VDB_DEFINITION, getDatabaseName() + ".vdb"); //$NON-NLS-1$
- }
- props.put(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, this.bootstrapFile);
return props;
- }
-
- private void validateEmbeddedProperties(final String userName, final String password) throws java.sql.SQLException {
- super.validateProperties(userName, password);
- String reason = reasonWhyInvalidConfigFile(this.bootstrapFile);
- if (reason != null) {
- throw new SQLException(reason);
- }
}
/**
@@ -287,14 +258,6 @@
}
/**
- * Returns the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public String getCredentials() {
- return credentials;
- }
-
- /**
* Returns a flag indicating whether to create a secure connection or not.
* @return True if using secure mms: protocol, false for normal mm: protocol.
* @since 5.0.2
@@ -336,14 +299,6 @@
}
/**
- * Sets the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public void setCredentials(final String credentials) {
- this.credentials = credentials;
- }
-
- /**
* Sets the secure flag to use mms: protocol instead of the default mm: protocol.
* @param secure True to use mms:
* @since 5.0.2
@@ -521,46 +476,5 @@
public void setDiscoveryStrategy(String discoveryStrategy) {
this.discoveryStrategy = discoveryStrategy;
}
-
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getEmbeddedBootstrapFile() {
- return bootstrapFile;
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setEmbeddedBootstrapFile(final String configFile) {
- this.bootstrapFile = configFile;
- }
-
- /**
- * Return the reason why the supplied config file may be invalid, or null if it is considered valid.
- *
- * @param configFile
- * a possible value for the property
- * @return the reason why the property is invalid, or null if it is considered valid
- * @see #setEmbeddedBootstrapFile(String)
- */
- public static String reasonWhyInvalidConfigFile(final String configFile) {
- if(configFile == null) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_property_is_null"); //$NON-NLS-1$
- }
-
- try {
- URL url = URLHelper.buildURL(configFile);
- url.openStream();
- } catch (Exception e) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read"); //$NON-NLS-1$
- }
- return null;
- }
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
@@ -675,35 +674,6 @@
rs.close();
}
-
- /**
- * Case 4293 - timestamps for begin and end processing should both be set
- * server-side (from the same system clock)
- */
- @Test public void testProcessingTime() throws Exception {
- RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(12345678L));
- ResultsMessage resultsMsg = new ResultsMessage(request);
-
- // these two lines not important to the test
- resultsMsg.setColumnNames(new String[] { "IntNum" }); //$NON-NLS-1$
- resultsMsg.setDataTypes(new String[] { MMJDBCSQLTypeInfo.INTEGER });
-
- // expected results
- long expectedProcessingTime = resultsMsg.getCompletedTimestamp()
- .getTime()
- - resultsMsg.getProcessingTimestamp().getTime();
-
- // sleep for a couple milliseconds
- Thread.sleep(200);
-
- MMResultSet rs = new MMResultSet(resultsMsg, statement);
-
- long actualProcessingTime = rs.getProcessingTime();
-
- assertEquals(expectedProcessingTime, actualProcessingTime);
-
- }
/**
* 3 batches
@@ -850,7 +820,6 @@
private static ResultsMessage exampleResultsMsg4(int begin, int length, int fetchSize, boolean lastBatch) {
RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
List[] results = exampleResults1(length, begin);
@@ -879,7 +848,6 @@
@Test public void testDateType() throws SQLException {
RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
resultsMsg.setResults(new List[] {Arrays.asList(new Timestamp(0))});
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -29,17 +29,22 @@
import junit.framework.TestCase;
-import com.metamatrix.common.api.MMURL;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestMMConnection extends TestCase {
protected static final String STD_DATABASE_NAME = "QT_Ora9DS"; //$NON-NLS-1$
- protected static final String STD_DATABASE_VERSION = "1"; //$NON-NLS-1$
+ protected static final int STD_DATABASE_VERSION = 1;
static String serverUrl = "jdbc:metamatrix:QT_Ora9DS@mm://localhost:7001;version=1;user=metamatrixadmin;password=mm"; //$NON-NLS-1$
@@ -49,15 +54,35 @@
public static MMConnection getMMConnection() {
ServerConnection mock = mock(ServerConnection.class);
- stub(mock.getService(ClientSideDQP.class)).toReturn(mock(ClientSideDQP.class));
+ ClientSideDQP dqp = mock(ClientSideDQP.class);
+ try {
+ stub(dqp.start((MMXid)Mockito.anyObject(), Mockito.anyInt(), Mockito.anyInt())).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ stub(dqp.rollback((MMXid)Mockito.anyObject())).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ stub(dqp.rollback()).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ } catch (XATransactionException e) {
+ throw new RuntimeException(e);
+ }
+ stub(mock.getService(ClientSideDQP.class)).toReturn(dqp);
Properties props = new Properties();
props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
- props.setProperty(BaseDataSource.VDB_VERSION, STD_DATABASE_VERSION);
+ props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
- Properties productInfo = new Properties();
- productInfo.setProperty(MMURL.JDBC.VDB_NAME, STD_DATABASE_NAME);
- productInfo.setProperty(MMURL.JDBC.VDB_VERSION, STD_DATABASE_VERSION);
- stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(new MetaMatrixSessionID(1), "metamatrixadmin"), productInfo, "fake")); //$NON-NLS-1$
+ stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
return new MMConnection(mock, props, serverUrl);
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -128,7 +128,7 @@
public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:metamatrix:vdb@mm://localhost:12345", null); //$NON-NLS-1$
- assertEquals(6, info.length);
+ assertEquals(5, info.length);
assertEquals(true, info[0].required);
assertEquals("VirtualDatabaseName", info[0].name); //$NON-NLS-1$
assertEquals("vdb", info[0].value); //$NON-NLS-1$
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -41,6 +41,7 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.platform.security.api.LogonResult;
/**
@@ -113,8 +114,7 @@
// Now verify the statement's RequestMessage is what we expect
assertEquals("Command does not match", sqlCommand, statement.requestMessage.getCommandString()); //$NON-NLS-1$
assertEquals("Parameter values do not match", expectedParameterValues, statement.requestMessage.getParameterValues()); //$NON-NLS-1$
- assertTrue("RequestMessage.isPreparedBatchUpdate should be true", statement.requestMessage.isPreparedBatchUpdate()); //$NON-NLS-1$
- assertFalse("RequestMessage.isBatchedUpdate should be false", statement.requestMessage.isBatchedUpdate()); //$NON-NLS-1$
+ assertTrue("RequestMessage.isBatchedUpdate should be true", statement.requestMessage.isBatchedUpdate()); //$NON-NLS-1$
assertFalse("RequestMessage.isCallableStatement should be false", statement.requestMessage.isCallableStatement()); //$NON-NLS-1$
assertTrue("RequestMessage.isPreparedStatement should be true", statement.requestMessage.isPreparedStatement()); //$NON-NLS-1$
}
@@ -323,9 +323,9 @@
public RequestMessage requestMessage;
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
+ boolean isBatchedCommand, ResultsMode resultsMode) {
this.requestMessage = super
- .createRequestMessage(commands, isBatchedCommand, requiresResultSet);
+ .createRequestMessage(commands, isBatchedCommand, resultsMode);
return this.requestMessage;
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -673,7 +673,7 @@
/** test getProcessingTime() -- include test for getProcessingTimestamp() and getCompletedTimestamp() */
@Test public void testGetProcessingTime() throws SQLException {
MMResultSet cs = helpExecuteQuery();
- assertTrue(cs.getProcessingTime() == cs.getCompletedTimestamp().getTime() - 1);
+ assertNotNull(cs.getCompletedTimestamp());
cs.close();
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -88,10 +88,10 @@
protected void checkResult(String testName, ResultSet actualResults, String testsuite) throws Exception {
ResultSetMetaData resultMetadata = actualResults.getMetaData();
- String metafilename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".metadata.txt"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String metafilename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".metadata.txt"; //$NON-NLS-1$ //$NON-NLS-2$
assertResultsSetMetadataEquals(resultMetadata, new File(metafilename));
- String filename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".txt"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String filename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".txt"; //$NON-NLS-1$ //$NON-NLS-2$
assertResultsSetEquals(actualResults, new File(filename));
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -41,7 +41,6 @@
import java.sql.Statement;
import org.junit.After;
-import org.teiid.adminapi.Admin;
import com.metamatrix.script.io.MetadataReader;
import com.metamatrix.script.io.ResultSetReader;
@@ -80,17 +79,7 @@
@After public void tearDown() throws Exception {
closeConnection();
}
-
- public Admin getAdmin() {
- try {
- assertNotNull(this.internalConnection);
- com.metamatrix.jdbc.api.Connection conn = (com.metamatrix.jdbc.api.Connection) this.internalConnection;
- return conn.getAdminAPI();
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
+
public void setConnection(Connection c) {
this.internalConnection = c;
}
@@ -251,7 +240,6 @@
}
}
-
private void writeResultSet(File expected, BufferedReader resultReader)
throws IOException {
if (WRITE_ACTUAL) {
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -29,7 +29,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.jdbc.api.ExecutionProperties;
@@ -243,15 +242,10 @@
} catch (Exception e) {
}
+
try {
- new MMJDBCURL("myVDB", null, null); //$NON-NLS-1$
- fail("Should have failed."); //$NON-NLS-1$
- } catch (Exception e) {
-
- }
- try {
+ // in embedded situation there is no connection url
new MMJDBCURL("myVDB", " ", null); //$NON-NLS-1$ //$NON-NLS-2$
- fail("Should have failed."); //$NON-NLS-1$
} catch (Exception e) {
}
@@ -265,7 +259,6 @@
MMJDBCURL.normalizeProperties(props);
assertEquals("myuser", props.getProperty(BaseDataSource.USER_NAME)); //$NON-NLS-1$
assertEquals("mypassword", props.getProperty(BaseDataSource.PASSWORD)); //$NON-NLS-1$
- assertEquals(new Integer(1), props.get(ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD));
}
public final void testEncodedPropertyProperties() throws Exception {
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -45,112 +45,81 @@
* // (\\w:[\\\\,\\/]|file:\\/\\/|\\/|\\\\|(\\.){1,2}){1}
*/
@Test public void testAcceptsURL() {
-// // Windows Path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
- // Alternative windows path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // Abosolute path (Unix or windows)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // relative path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // File URL should be supported (not sure)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
-
// ClassPath based URL
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT@classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
// These are specific to the MMorg.teiid.jdbc.EmbeddedProfile and should not be suported
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@mm://host:7001;version=1")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@mms://host:7001;version=1")); //$NON-NLS-1$
- //assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@http://host:7001;version=1"));
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT@mm://host:7001;version=1")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT@mms://host:7001;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT!/path/foo.properties")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
}
@Test public void testParseURL() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("c:\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
- assertEquals(3, p.size());
+ assertEquals(2, p.size());
}
@Test public void testParseURL2() throws SQLException {
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;version=3", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
- assertEquals(5, p.size());
+ assertEquals(4, p.size());
}
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
- assertEquals(7, p.size());
+ assertEquals(6, p.size());
}
@Test public void testParseURL4() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("testdata/dqp/dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
- assertEquals(4, p.size());
+ assertEquals(3, p.size());
}
@Test public void testParseURL5() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL55() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL6() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1")); //$NON-NLS-1$
- assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(7, p.size());
+ assertEquals(5, p.size());
}
@Test public void test() throws Exception {
try {
Class.forName("org.teiid.jdbc.TeiidDriver"); //$NON-NLS-1$
- DriverManager.getConnection("jdbc:metamatrix:Parts@invalidConfig.properties;version=1"); //$NON-NLS-1$
+ DriverManager.getConnection("jdbc:teiid:Parts@invalidConfig.properties;version=1"); //$NON-NLS-1$
fail();
} catch (SQLException e) {
}
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import java.sql.DriverPropertyInfo;
@@ -35,19 +36,19 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345", null); //$NON-NLS-1$
- assertEquals(20, info.length);
+ assertEquals(17, info.length);
}
@Test public void testAccepts() throws Exception {
assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:12345")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
}
14 years, 2 months