teiid SVN: r4523 - in branches/7.7.x: engine/src/main/java/org/teiid/query/optimizer and 5 other directories.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2012-10-31 14:45:08 -0400 (Wed, 31 Oct 2012)
New Revision: 4523
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
branches/7.7.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
Log:
TEIID-2245: Limit pushdown of nulls first/last
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -93,7 +93,7 @@
public QueryMetadataInterface getDesignTimeMetadata() {
if (isSession()) {
- return this.actualMetadata.getDesignTimeMetadata();
+ return new TempMetadataAdapter(this.actualMetadata.getDesignTimeMetadata(), new TempMetadataStore());
}
return new TempMetadataAdapter(this.actualMetadata.getDesignTimeMetadata(), tempStore, materializationTables, queryNodes);
}
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -92,9 +92,14 @@
boolean debug = analysisRecord.recordDebug();
- Map tempMetadata = command.getTemporaryMetadata();
- metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(tempMetadata));
+ if (!(metadata instanceof TempMetadataAdapter)) {
+ metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
+ }
+ if (context.getMetadata() == null) {
+ context.setMetadata(metadata);
+ }
+
// Create an ID generator that can be used for all plans to generate unique data node IDs
if(idGenerator == null) {
idGenerator = new IDGenerator();
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -461,6 +461,7 @@
} else {
JoinNode joinAsSet = new JoinNode(getID());
joinAsSet.setJoinStrategy(new MergeJoinStrategy(SortOption.SORT_DISTINCT, SortOption.SORT_DISTINCT, true));
+ //If we push these sorts, we will have to enforce null order, since nulls are equal here
List leftExpressions = (List) node.getFirstChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
List rightExpressions = (List) node.getLastChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
joinAsSet.setJoinType(setOp == Operation.EXCEPT ? JoinType.JOIN_ANTI_SEMI : JoinType.JOIN_SEMI);
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -470,28 +470,16 @@
throws QueryMetadataException, TeiidComponentException {
boolean supportsNullOrdering = CapabilitiesUtil.supports(Capability.QUERY_ORDERBY_NULL_ORDERING, modelID, metadata, capFinder);
NullOrder defaultNullOrder = CapabilitiesUtil.getDefaultNullOrder(modelID, metadata, capFinder);
- if (symbol.getNullOrdering() != null) {
- if (!supportsNullOrdering) {
- if (symbol.getNullOrdering() == NullOrdering.FIRST) {
- if (defaultNullOrder != NullOrder.FIRST && !(symbol.isAscending() && defaultNullOrder == NullOrder.LOW)
- && !(!symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)) {
- return false;
- }
- } else if (defaultNullOrder != NullOrder.LAST && !(symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)
- && !(!symbol.isAscending() && defaultNullOrder == NullOrder.LOW)) {
- return false;
- }
- symbol.setNullOrdering(null);
+ if (symbol.getNullOrdering() != null && !supportsNullOrdering) {
+ if (symbol.getNullOrdering() == NullOrdering.FIRST) {
+ if (defaultNullOrder != NullOrder.FIRST && !(symbol.isAscending() && defaultNullOrder == NullOrder.LOW)
+ && !(!symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)) {
+ return false;
+ }
+ } else if (defaultNullOrder != NullOrder.LAST && !(symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)
+ && !(!symbol.isAscending() && defaultNullOrder == NullOrder.LOW)) {
+ return false;
}
- } else if (supportsNullOrdering && defaultNullOrder != NullOrder.LOW) {
- //try to match the expected default of low
- if (symbol.isAscending()) {
- if (defaultNullOrder != NullOrder.FIRST) {
- symbol.setNullOrdering(NullOrdering.FIRST);
- }
- } else if (defaultNullOrder != NullOrder.LAST) {
- symbol.setNullOrdering(NullOrdering.LAST);
- }
}
return true;
}
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -38,6 +38,7 @@
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.SupportConstants;
@@ -71,8 +72,8 @@
import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import org.teiid.query.util.CommandContext;
+import org.teiid.translator.ExecutionFactory.NullOrder;
-
public final class RuleCollapseSource implements OptimizerRule {
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
@@ -96,7 +97,7 @@
commandRoot = NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.SOURCE).getFirstChild();
}
plan = removeUnnecessaryInlineView(plan, commandRoot);
- QueryCommand queryCommand = createQuery(metadata, capFinder, accessNode, commandRoot);
+ QueryCommand queryCommand = createQuery(context, capFinder, accessNode, commandRoot);
addDistinct(metadata, capFinder, accessNode, queryCommand);
command = queryCommand;
if (intoGroup != null) {
@@ -193,8 +194,10 @@
return root;
}
- private QueryCommand createQuery(QueryMetadataInterface metadata, CapabilitiesFinder capFinder, PlanNode accessRoot, PlanNode node) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
+ private QueryCommand createQuery(CommandContext context, CapabilitiesFinder capFinder, PlanNode accessRoot, PlanNode node) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
+ QueryMetadataInterface metadata = context.getMetadata();
PlanNode setOpNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
+ Object modelID = RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata);
if (setOpNode != null) {
Operation setOp = (Operation)setOpNode.getProperty(NodeConstants.Info.SET_OPERATION);
SetQuery unionCommand = new SetQuery(setOp);
@@ -202,7 +205,7 @@
unionCommand.setAll(unionAll);
PlanNode sort = NodeEditor.findNodePreOrder(node, NodeConstants.Types.SORT, NodeConstants.Types.SET_OP);
if (sort != null) {
- processOrderBy(sort, unionCommand);
+ processOrderBy(sort, unionCommand, modelID, context, capFinder);
}
PlanNode limit = NodeEditor.findNodePreOrder(node, NodeConstants.Types.TUPLE_LIMIT, NodeConstants.Types.SET_OP);
if (limit != null) {
@@ -210,7 +213,7 @@
}
int count = 0;
for (PlanNode child : setOpNode.getChildren()) {
- QueryCommand command = createQuery(metadata, capFinder, accessRoot, child);
+ QueryCommand command = createQuery(context, capFinder, accessRoot, child);
if (count == 0) {
unionCommand.setLeftQuery(command);
} else if (count == 1) {
@@ -229,11 +232,10 @@
select.addSymbols(columns);
query.setSelect(select);
query.setFrom(new From());
- buildQuery(accessRoot, node, query, metadata, capFinder);
+ buildQuery(accessRoot, node, query, context, capFinder);
if (query.getCriteria() instanceof CompoundCriteria) {
query.setCriteria(QueryRewriter.optimizeCriteria((CompoundCriteria)query.getCriteria(), metadata));
}
- Object modelID = RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata);
if (!CapabilitiesUtil.useAnsiJoin(modelID, metadata, capFinder)) {
simplifyFromClause(query);
}
@@ -297,8 +299,8 @@
return null;
}
- void buildQuery(PlanNode accessRoot, PlanNode node, Query query, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
-
+ void buildQuery(PlanNode accessRoot, PlanNode node, Query query, CommandContext context, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
+ QueryMetadataInterface metadata = context.getMetadata();
//visit source and join nodes as they appear
switch(node.getType()) {
case NodeConstants.Types.JOIN:
@@ -324,12 +326,12 @@
* if the join is a left outer join, criteria from the right side will be added to the on clause
*/
Criteria savedCriteria = null;
- buildQuery(accessRoot, left, query, metadata, capFinder);
+ buildQuery(accessRoot, left, query, context, capFinder);
if (joinType == JoinType.JOIN_LEFT_OUTER) {
savedCriteria = query.getCriteria();
query.setCriteria(null);
}
- buildQuery(accessRoot, right, query, metadata, capFinder);
+ buildQuery(accessRoot, right, query, context, capFinder);
if (joinType == JoinType.JOIN_LEFT_OUTER) {
moveWhereClauseIntoOnClause(query, crits);
query.setCriteria(savedCriteria);
@@ -360,7 +362,7 @@
{
if (Boolean.TRUE.equals(node.getProperty(NodeConstants.Info.INLINE_VIEW))) {
PlanNode child = node.getFirstChild();
- QueryCommand newQuery = createQuery(metadata, capFinder, accessRoot, child);
+ QueryCommand newQuery = createQuery(context, capFinder, accessRoot, child);
//ensure that the group is consistent
GroupSymbol symbol = node.getGroups().iterator().next();
@@ -374,7 +376,7 @@
}
for (PlanNode childNode : node.getChildren()) {
- buildQuery(accessRoot, childNode, query, metadata, capFinder);
+ buildQuery(accessRoot, childNode, query, context, capFinder);
}
switch(node.getType()) {
@@ -391,7 +393,7 @@
}
case NodeConstants.Types.SORT:
{
- processOrderBy(node, query);
+ processOrderBy(node, query, RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), context, capFinder);
break;
}
case NodeConstants.Types.DUP_REMOVE:
@@ -486,8 +488,9 @@
query.setCriteria(null);
}
- private void processOrderBy(PlanNode node, QueryCommand query) {
- OrderBy orderBy = (OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER);
+ private void processOrderBy(PlanNode node, QueryCommand query, Object modelID, CommandContext context, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
+ boolean userOrdering = NodeEditor.findParent(node, NodeConstants.Types.JOIN|NodeConstants.Types.SOURCE) == null;
+ OrderBy orderBy = (OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER);
query.setOrderBy(orderBy);
if (query instanceof Query) {
List<SingleElementSymbol> cols = query.getProjectedSymbols();
@@ -496,6 +499,25 @@
}
QueryRewriter.rewriteOrderBy(query, orderBy, query.getProjectedSymbols(), new LinkedList<OrderByItem>());
}
+ boolean supportsNullOrdering = CapabilitiesUtil.supports(Capability.QUERY_ORDERBY_NULL_ORDERING, modelID, context.getMetadata(), capFinder);
+ NullOrder defaultNullOrder = CapabilitiesUtil.getDefaultNullOrder(modelID, context.getMetadata(), capFinder);
+ for (OrderByItem item : orderBy.getOrderByItems()) {
+ if (item.getNullOrdering() != null) {
+ if (!supportsNullOrdering) {
+ item.setNullOrdering(null);
+ }
+ // assuming true for backport, context.getOptions().isPushdownDefaultNullOrder()
+ } else if (userOrdering && supportsNullOrdering && defaultNullOrder != NullOrder.LOW && true) {
+ //try to match the expected default of low
+ if (item.isAscending()) {
+ if (defaultNullOrder != NullOrder.FIRST) {
+ item.setNullOrdering(NullOrdering.FIRST);
+ }
+ } else if (defaultNullOrder != NullOrder.LAST) {
+ item.setNullOrdering(NullOrdering.LAST);
+ }
+ }
+ }
}
/**
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -34,9 +34,11 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.optimizer.relational.OptimizerRule;
import org.teiid.query.optimizer.relational.RuleStack;
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
@@ -48,9 +50,12 @@
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
@@ -58,6 +63,7 @@
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
import org.teiid.query.util.CommandContext;
+import org.teiid.translator.ExecutionFactory.NullOrder;
/**
@@ -249,14 +255,14 @@
if (distinct || NewCalculateCostUtil.usesKey(sourceNode, expressions, metadata)) {
joinNode.setProperty(joinNode.getFirstChild() == childNode ? NodeConstants.Info.IS_LEFT_DISTINCT : NodeConstants.Info.IS_RIGHT_DISTINCT, true);
}
- if (attemptPush && RuleRaiseAccess.canRaiseOverSort(sourceNode, metadata, capFinder, sortNode, null, false)) {
- sourceNode.getFirstChild().addAsParent(sortNode);
-
- if (needsCorrection) {
- correctOutputElements(joinNode, outputSymbols, sortNode);
- }
- return true;
- }
+ if (attemptPush && RuleRaiseAccess.canRaiseOverSort(sourceNode, metadata, capFinder, sortNode, null, false)) {
+ sourceNode.getFirstChild().addAsParent(sortNode);
+
+ if (needsCorrection) {
+ correctOutputElements(joinNode, outputSymbols, sortNode);
+ }
+ return true;
+ }
} else if (sourceNode.getType() == NodeConstants.Types.GROUP) {
sourceNode.addAsParent(sortNode);
sort = false; // the grouping columns must contain all of the ordering columns
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -52,6 +52,7 @@
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.ExecutionFactory.NullOrder;
@SuppressWarnings("nls")
public class TestJoinOptimization {
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -34,6 +34,7 @@
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.query.util.CommandContext;
import org.teiid.translator.ExecutionFactory.NullOrder;
@SuppressWarnings({"nls", "unchecked"})
@@ -141,62 +142,68 @@
@Test public void testNullOrdering() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
+ //caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from pm1.g1 order by e1 desc, e2 asc", //$NON-NLS-1$
RealMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC NULLS LAST, g_0.e2 NULLS FIRST"}, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC, g_0.e2"}, //$NON-NLS-1$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- @Test public void testNullOrdering1() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
- caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.LAST);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from pm1.g1 order by e1 desc, e2 asc", //$NON-NLS-1$
- RealMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC, g_0.e2 NULLS FIRST"}, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
+
@Test public void testNullOrdering2() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from pm1.g1 order by e1 desc NULLS FIRST, e2 asc NULLS LAST", //$NON-NLS-1$
- RealMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC NULLS FIRST, g_0.e2 NULLS LAST"}, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
+ caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.FIRST);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+ CommandContext cc = new CommandContext();
+ //cc.setOptions(new Options().pushdownDefaultNullOrder(true));
+ ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", metadata, null), metadata, capFinder, null, true, cc);
+ TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC NULLS LAST, g_0.e2 NULLS LAST"}, plan); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
/**
* The engine will remove the null ordering if it's not needed
* @throws Exception
*/
@Test public void testNullOrdering3() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.HIGH);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.HIGH);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+ CommandContext cc = new CommandContext();
+ //cc.setOptions(new Options().pushdownDefaultNullOrder(true));
+ ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", metadata, null), metadata, capFinder, null, true, cc);
+ TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC, g_0.e2"}, plan); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * turns on virtualization
+ * @throws Exception
+ */
+ @Test public void testNullOrdering4() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
+ caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.UNKNOWN);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+ CommandContext cc = new CommandContext();
+ //cc.setOptions(new Options().pushdownDefaultNullOrder(true));
+ ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc", metadata, null), metadata, capFinder, null, true, cc);
+ TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC NULLS LAST, g_0.e2 NULLS FIRST"}, plan); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
- ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", //$NON-NLS-1$
- RealMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC, g_0.e2"}, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -38,6 +38,7 @@
import org.teiid.query.processor.relational.ProjectNode;
import org.teiid.query.processor.relational.WindowFunctionProjectNode;
import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.translator.ExecutionFactory.NullOrder;
@SuppressWarnings({"nls", "unchecked"})
public class TestWindowFunctions {
@@ -99,6 +100,7 @@
caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.UNKNOWN);
ProcessorPlan plan = TestOptimizer.helpPlan("select max(e1) over (order by e1 nulls first) as y from pm1.g1", //$NON-NLS-1$
RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
new String[] {
Modified: branches/7.7.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
===================================================================
--- branches/7.7.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2012-10-30 21:51:45 UTC (rev 4522)
+++ branches/7.7.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2012-10-31 18:45:08 UTC (rev 4523)
@@ -121,7 +121,7 @@
new List[] { Arrays.asList(new Object[] { new Long(5), "Bill", "101 Fake St.", "392839283", "21.12" } ), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Arrays.asList(new Object[] { new Long(6), "Stu", "102 Fake St.", "385729385", "51.50" } )}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- dataMgr.addData("SELECT g_0.C_CUSTKEY AS c_0, g_0.C_NAME AS c_1, g_0.C_ADDRESS AS c_2, g_0.C_PHONE AS c_3, g_0.C_ACCTBAL AS c_4 FROM TPCR_Ora.CUSTOMER AS g_0 WHERE g_0.C_ACCTBAL > 50 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+ dataMgr.addData("SELECT g_0.C_CUSTKEY AS c_0, g_0.C_NAME AS c_1, g_0.C_ADDRESS AS c_2, g_0.C_PHONE AS c_3, g_0.C_ACCTBAL AS c_4 FROM TPCR_Ora.CUSTOMER AS g_0 WHERE g_0.C_ACCTBAL > 50 ORDER BY c_0", //$NON-NLS-1$
oracleExpected);
List[] sqlServerExpected =
@@ -161,7 +161,7 @@
new List[] { Arrays.asList(new Object[] { new Long(5), "Bill", "101 Fake St.", "392839283", "51.12" } ), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Arrays.asList(new Object[] { new Long(6), "Stu", "102 Fake St.", "385729385", "51.50" } )}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- dataMgr.addData("SELECT g_0.C_CUSTKEY AS c_0, g_0.C_NAME AS c_1, g_0.C_ADDRESS AS c_2, g_0.C_PHONE AS c_3, g_0.C_ACCTBAL AS c_4 FROM TPCR_Ora.CUSTOMER AS g_0 WHERE g_0.C_ACCTBAL > 50 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+ dataMgr.addData("SELECT g_0.C_CUSTKEY AS c_0, g_0.C_NAME AS c_1, g_0.C_ADDRESS AS c_2, g_0.C_PHONE AS c_3, g_0.C_ACCTBAL AS c_4 FROM TPCR_Ora.CUSTOMER AS g_0 WHERE g_0.C_ACCTBAL > 50 ORDER BY c_0", //$NON-NLS-1$
oracleExpected);
List[] sqlServerExpected =
12 years, 1 month
[teiid/teiid] f343d0: teiid-669: fixing bug in native query, where it wa...
by Ramesh Reddy
Branch: refs/heads/master
Home: https://github.com/teiid/teiid
Commit: f343d056701313bb30cb28445bec9e293bac1523
https://github.com/teiid/teiid/commit/f343d056701313bb30cb28445bec9e293ba...
Author: rareddy <rareddy(a)jboss.org>
Date: 2012-10-31 (Wed, 31 Oct 2012)
Changed paths:
M connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java
M connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java
M connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
M connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
Log Message:
-----------
teiid-669: fixing bug in native query, where it was accidentlly adding orginal table name as alias for in-line view
Commit: 5b6d5ea1deac66f8c4ed06b8d4573bf16aee3411
https://github.com/teiid/teiid/commit/5b6d5ea1deac66f8c4ed06b8d4573bf16ae...
Author: Ramesh Reddy <rareddy(a)jboss.org>
Date: 2012-10-31 (Wed, 31 Oct 2012)
Changed paths:
M connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java
M connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java
M connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
M connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
Log Message:
-----------
Merge pull request #17 from rareddy/teiid-669
teiid-669: fixing bug in native query, where it was accidentlly adding o...
Compare: https://github.com/teiid/teiid/compare/cf91f6c83783...5b6d5ea1deac
12 years, 1 month
[teiid/teiid] f97111: Spreadsheet translator
by shawkins
Branch: refs/heads/master
Home: https://github.com/teiid/teiid
Commit: f971117e19e93116bded41f4e73f6bc1f9152a74
https://github.com/teiid/teiid/commit/f971117e19e93116bded41f4e73f6bc1f91...
Author: Filip Nguyen <nguyen.filip(a)gmail.com>
Date: 2012-10-29 (Mon, 29 Oct 2012)
Changed paths:
M build/assembly/embedded-dist.xml
M build/assembly/jboss-as7/dist.xml
A build/kits/jboss-as7/docs/teiid/datasources/google/google.xml
A build/kits/jboss-as7/docs/teiid/datasources/google/modules/com/google/gdata/main/module.xml
A build/kits/jboss-as7/docs/teiid/datasources/google/modules/net/sf/opencsv/main/module.xml
A build/kits/jboss-as7/docs/teiid/datasources/google/readme.txt
A build/kits/jboss-as7/modules/org/jboss/teiid/translator/google/api/main/module.xml
A build/kits/jboss-as7/modules/org/jboss/teiid/translator/google/main/module.xml
M build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
A connectors/connector-google/.gitignore
A connectors/connector-google/pom.xml
A connectors/connector-google/src/main/java/org/teiid/resource/adapter/google/SpreadsheetConnectionImpl.java
A connectors/connector-google/src/main/java/org/teiid/resource/adapter/google/SpreadsheetManagedConnectionFactory.java
A connectors/connector-google/src/main/java/org/teiid/resource/adapter/google/SpreadsheetResourceAdapter.java
A connectors/connector-google/src/main/rar/META-INF/MANIFEST.MF
A connectors/connector-google/src/main/rar/META-INF/ra.xml
A connectors/connector-google/src/main/resources/org/teiid/resource/adapter/google/i18n.properties
A connectors/google-api/.gitignore
A connectors/google-api/pom.xml
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/GoogleSpreadsheetConnection.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/AuthHeaderFactory.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/AuthUrlResponse.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/ClientLoginHeaderFactory.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2Authenticator.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2AuthenticatorGoogle.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2HeaderFactory.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2Tokens.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/GDataAPI.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/GDataAPI.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/RectangleIdentifier.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SheetRow.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SheetRow.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SpreadsheetAuthException.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SpreadsheetAuthException.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SpreadsheetOperationException.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SpreadsheetOperationException.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/Util.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/dataprotocol/GoogleDataProtocolAPI.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/gdata/GDataClientLoginAPI.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/gdata/SpreadsheetMetadataExtractor.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/Column.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/SpreadsheetColumnType.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/SpreadsheetInfo.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/Worksheet.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/WorksheetsElement.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/PartialResultExecutor.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/PartialResultExecutor.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/RowsResult$BatchingRowIterator.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/RowsResult.class
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/RowsResult.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/AuthenticationTest.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/IntegrationTest.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/MetadataLoadingTest.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/SpreadsheetDataRetrievalTest.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/unit/MetadataOverridesTest.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/unit/RowsResultTest.java
A connectors/google-api/src/test/resources/empty.xml
A connectors/google-api/src/test/resources/overrides.xml
A connectors/google-api/src/test/resources/simpleOverride.xml
A connectors/google-api/src/test/resources/test.xml
M connectors/pom.xml
A connectors/translator-google/.gitignore
A connectors/translator-google/pom.xml
A connectors/translator-google/src/main/java/org/teiid/translator/google/Constants.java
A connectors/translator-google/src/main/java/org/teiid/translator/google/SpreadsheetExecutionFactory.java
A connectors/translator-google/src/main/java/org/teiid/translator/google/execution/SpreadsheetProcedureExecution.java
A connectors/translator-google/src/main/java/org/teiid/translator/google/execution/SpreadsheetQueryExecution.java
A connectors/translator-google/src/main/java/org/teiid/translator/google/execution/SpreadsheetSQLVisitor.java
A connectors/translator-google/src/main/java/org/teiid/translator/google/metadata/MetadataProcessor.java
A connectors/translator-google/src/main/resources/META-INF/services/org.teiid.translator.ExecutionFactory
A connectors/translator-google/src/main/resources/org/teiid/translator/google/i18n.properties
A connectors/translator-google/src/test/java/org/teiid/translator/google/TestProcedureGetNext.java
A connectors/translator-google/src/test/java/org/teiid/translator/google/TestSQLtoSpreadsheetQuery.java
Log Message:
-----------
Spreadsheet translator
Commit: e52c8a36ca1dec023598a292994945091ed1402f
https://github.com/teiid/teiid/commit/e52c8a36ca1dec023598a292994945091ed...
Author: Filip Nguyen <nguyen.filip(a)gmail.com>
Date: 2012-10-29 (Mon, 29 Oct 2012)
Changed paths:
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/AuthenticationTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/IntegrationTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/MetadataLoadingTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/SpreadsheetDataRetrievalTest.java
Log Message:
-----------
Disabling integration tests in Google Spreadsheet Translator
Commit: bb49203d96fb29808ca92a5fc025ccf128bef58f
https://github.com/teiid/teiid/commit/bb49203d96fb29808ca92a5fc025ccf128b...
Author: Filip Nguyen <nguyen.filip(a)gmail.com>
Date: 2012-10-29 (Mon, 29 Oct 2012)
Changed paths:
M connectors/translator-google/src/main/java/org/teiid/translator/google/SpreadsheetExecutionFactory.java
Log Message:
-----------
disabling capability of OrderBy on Spreadsheet Connector
Commit: 4eacf26deff1e30d4c40432b68bf1873e9d9df29
https://github.com/teiid/teiid/commit/4eacf26deff1e30d4c40432b68bf1873e9d...
Author: shawkins <shawkins(a)redhat.com>
Date: 2012-10-31 (Wed, 31 Oct 2012)
Changed paths:
M build/kits/jboss-as7/docs/teiid/datasources/odbc/odbc-ds.xml
M build/kits/jboss-as7/docs/teiid/datasources/odbc/readme.txt
M connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPManagedConnectionFactory.java
M connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF
Log Message:
-----------
Merge branch 'master' of https://github.com/teiid/teiid
Commit: 60e49119264d735fa0a36ec06bf35f11c56dcf86
https://github.com/teiid/teiid/commit/60e49119264d735fa0a36ec06bf35f11c56...
Author: shawkins <shawkins(a)redhat.com>
Date: 2012-10-31 (Wed, 31 Oct 2012)
Changed paths:
M build/assembly/embedded-dist.xml
M build/kits/jboss-as7/docs/teiid/datasources/google/google.xml
R build/kits/jboss-as7/docs/teiid/datasources/google/modules/net/sf/opencsv/main/module.xml
M build/kits/jboss-as7/docs/teiid/datasources/google/readme.txt
M build/kits/jboss-as7/modules/org/jboss/teiid/translator/google/api/main/module.xml
M build/kits/jboss-as7/modules/org/jboss/teiid/translator/google/main/module.xml
M common-core/src/main/java/org/teiid/core/util/StringUtil.java
M common-core/src/test/java/org/teiid/query/unittest/TimestampUtil.java
M connectors/connector-google/src/main/java/org/teiid/resource/adapter/google/SpreadsheetConnectionImpl.java
M connectors/connector-google/src/main/java/org/teiid/resource/adapter/google/SpreadsheetManagedConnectionFactory.java
M connectors/connector-google/src/main/rar/META-INF/ra.xml
M connectors/google-api/pom.xml
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/GoogleSpreadsheetConnection.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/AuthHeaderFactory.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/AuthUrlResponse.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/ClientLoginHeaderFactory.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2Authenticator.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2HeaderFactory.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/auth/OAuth2Tokens.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/GDataAPI.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SheetRow.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SpreadsheetAuthException.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/SpreadsheetOperationException.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/common/Util.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/dataprotocol/GoogleDataProtocolAPI.java
A connectors/google-api/src/main/java/org/teiid/resource/adapter/google/dataprotocol/GoogleJSONParser.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/gdata/GDataClientLoginAPI.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/gdata/SpreadsheetMetadataExtractor.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/Column.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/SpreadsheetColumnType.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/SpreadsheetInfo.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/metadata/Worksheet.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/PartialResultExecutor.java
M connectors/google-api/src/main/java/org/teiid/resource/adapter/google/result/RowsResult.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/AuthenticationTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/IntegrationTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/MetadataLoadingTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/integration/SpreadsheetDataRetrievalTest.java
A connectors/google-api/src/test/java/org/teiid/resource/adapter/google/unit/GoogleJSONParserTest.java
M connectors/google-api/src/test/java/org/teiid/resource/adapter/google/unit/RowsResultTest.java
M connectors/translator-google/pom.xml
M connectors/translator-google/src/main/java/org/teiid/translator/google/Constants.java
M connectors/translator-google/src/main/java/org/teiid/translator/google/SpreadsheetExecutionFactory.java
R connectors/translator-google/src/main/java/org/teiid/translator/google/execution/SpreadsheetProcedureExecution.java
M connectors/translator-google/src/main/java/org/teiid/translator/google/execution/SpreadsheetSQLVisitor.java
M connectors/translator-google/src/main/java/org/teiid/translator/google/metadata/MetadataProcessor.java
R connectors/translator-google/src/test/java/org/teiid/translator/google/TestProcedureGetNext.java
M connectors/translator-google/src/test/java/org/teiid/translator/google/TestSQLtoSpreadsheetQuery.java
M engine/src/main/java/org/teiid/query/function/FunctionMethods.java
Log Message:
-----------
TEIID-1064 merging and refining the google spreadsheet connectivity
Compare: https://github.com/teiid/teiid/compare/ba48aaf2513d...60e49119264d
12 years, 1 month
teiid SVN: r4522 - in branches/7.7.x: console/src/main/java/org/teiid/rhq/plugin and 4 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2012-10-30 17:51:45 -0400 (Tue, 30 Oct 2012)
New Revision: 4522
Modified:
branches/7.7.x/console/pom.xml
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
branches/7.7.x/documentation/javadocs/pom.xml
Log:
TEIID-2240: Upgraded RHQ plugin code to support RHQ 4.2 (JON 3.0) and RHQ 4.4 (JON 3.1). Used reflection to account for different return types/missing methods between versions.
Modified: branches/7.7.x/console/pom.xml
===================================================================
--- branches/7.7.x/console/pom.xml 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/pom.xml 2012-10-30 21:51:45 UTC (rev 4522)
@@ -15,14 +15,15 @@
<!--
<org.jboss.jopr.as4.version>1.2.0.GA</org.jboss.jopr.as4.version>
-->
- <org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
- <jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
- <org.rhq.version>1.3.0.GA</org.rhq.version>
+ <jopr.jboss.as5.plugin.version>4.4.0</jopr.jboss.as5.plugin.version>
+ <org.rhq.version>4.4.0</org.rhq.version>
<apache.ant.version>1.7.0</apache.ant.version>
<teiid.version>${project.version}</teiid.version>
</properties>
+
+
<dependencies>
<!--
@@ -128,17 +129,11 @@
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
</dependency>
- <dependency>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas5</artifactId>
- <type>war</type>
- <version>${org.jboss.jopr.as5.version}</version>
- </dependency>
-
- <dependency>
+
+ <dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
- <version>5.1.0.CR2</version>
+ <version>5.1.0.SP1</version>
</dependency>
<dependency>
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -59,6 +59,8 @@
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
@@ -80,7 +82,6 @@
* @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
* ResourceContext)
*/
- @Override
public void start(ResourceContext context) {
this.resourceConfiguration = context.getPluginConfiguration();
this.componentType = PluginConstants.ComponentType.DATA_ROLE.NAME;
@@ -307,4 +308,11 @@
return null;
}
+ @Override
+ public ResourceContext getResourceContext() {
+ // TODO Auto-generated method stub
+ return this.getResourceContext();
+ }
+
+
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -95,7 +95,7 @@
* by all MetaMatrix components.
*/
public abstract class Facet implements
- ProfileServiceComponent<ResourceComponent>, MeasurementFacet,
+ ProfileServiceComponent, MeasurementFacet,
OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
CreateChildResourceFacet {
@@ -112,7 +112,7 @@
* All AMPS plugins are stateful - this context contains information that
* your resource component can use when performing its processing.
*/
- protected ResourceContext<?> resourceContext;
+ protected ResourceContext resourceContext;
protected String name;
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -48,9 +48,9 @@
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
+import org.teiid.rhq.plugin.util.PluginConstants.Operation;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.Operation;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
/**
*
@@ -58,7 +58,6 @@
public class PlatformComponent extends Facet {
private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- @Override
public void start(ResourceContext context) {
this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name", null)); //$NON-NLS-1$
this.resourceConfiguration = context.getPluginConfiguration();
@@ -267,4 +266,10 @@
return null;
}
+ @Override
+ public ResourceContext getResourceContext() {
+ return this.getResourceContext();
+ }
+
+
}
\ No newline at end of file
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -63,7 +63,6 @@
String RESOURCE_NAME = "resourceName";
}
- @Override
public void start(ResourceContext context) {
this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name", null));
this.resourceConfiguration=context.getPluginConfiguration();
@@ -185,5 +184,11 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public ResourceContext getResourceContext() {
+ // TODO Auto-generated method stub
+ return this.getResourceContext();
+ }
}
\ No newline at end of file
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -68,10 +68,10 @@
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
-import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.Operation;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.VDB;
+import org.teiid.rhq.plugin.util.PluginConstants.Operation;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
* Component class for a Teiid VDB
@@ -87,7 +87,6 @@
* @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
* ResourceContext)
*/
- @Override
public void start(ResourceContext context) {
this.setComponentName(context.getPluginConfiguration().getSimpleValue(
"fullName", null));
@@ -693,8 +692,12 @@
@Override
public EmsConnection getEmsConnection() {
- // TODO Auto-generated method stub
return null;
}
+ @Override
+ public ResourceContext getResourceContext() {
+ return this.getResourceContext();
+ }
+
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -21,6 +21,8 @@
*/
package org.teiid.rhq.plugin.adapter.impl;
+import java.util.List;
+
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
@@ -47,7 +49,7 @@
compositeValueSupport.set(key, value);
}
- protected CompositeValue createCompositeValue(PropertyDefinitionMap propDefMap, MetaType metaType)
+ protected CompositeValue createCompositeValue(PropertyDefinitionMap propertyDefinitionMap, MetaType metaType)
{
MutableCompositeMetaType compositeMetaType;
if (metaType != null)
@@ -55,16 +57,20 @@
else
{
// TODO: See if this else block is actually necessary (I think it is needed for creates).
- String name = (propDefMap != null) ?
- propDefMap.getName() : "CompositeMetaType";
- String desc = (propDefMap != null && propDefMap.getDescription() != null) ?
- propDefMap.getDescription() : "none";
+ String name = (propertyDefinitionMap != null) ?
+ propertyDefinitionMap.getName() : "CompositeMetaType";
+ String desc = (propertyDefinitionMap != null && propertyDefinitionMap.getDescription() != null) ?
+ propertyDefinitionMap.getDescription() : "none";
compositeMetaType = new MutableCompositeMetaType(name, desc);
- if (propDefMap != null)
+
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList =ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ if (propertyDefinitionMap != null)
{
- for (PropertyDefinition mapMemberPropDef : propDefMap.getPropertyDefinitions().values())
+ for (PropertyDefinition mapMemberPropDef : propDefList)
{
- String mapMemberDesc = (propDefMap.getDescription() != null) ? propDefMap.getDescription() : "none";
+ String mapMemberDesc = (propertyDefinitionMap.getDescription() != null) ? propertyDefinitionMap.getDescription() : "none";
MetaType mapMemberMetaType = ProfileServiceUtil.convertPropertyDefinitionToMetaType(mapMemberPropDef);
compositeMetaType.addItem(mapMemberPropDef.getName(), mapMemberDesc, mapMemberMetaType);
}
@@ -72,4 +78,6 @@
}
return new CompositeValueSupport(compositeMetaType);
}
-}
\ No newline at end of file
+
+}
+
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -21,6 +21,9 @@
*/
package org.teiid.rhq.plugin.adapter.impl;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.managed.api.ManagedObject;
@@ -84,31 +87,49 @@
}
}
- public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propDefMap, MetaType metaType)
+ public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propertyDefinitionMap, MetaType metaType)
{
//GenericMetaType genericMetaType = (GenericMetaType)metaType;
- ManagedObjectImpl managedObject = new ManagedObjectImpl(propDefMap.getName());
- for (PropertyDefinition mapMemberPropDef : propDefMap.getPropertyDefinitions().values())
- {
- ManagedPropertyImpl managedProp = new ManagedPropertyImpl(mapMemberPropDef.getName());
- MetaType managedPropMetaType = ProfileServiceUtil.convertPropertyDefinitionToMetaType(mapMemberPropDef);
+ ManagedObjectImpl managedObject = new ManagedObjectImpl(propertyDefinitionMap.getName());
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check types.
+ Object object = ((PropertyDefinitionMap) propertyDefinitionMap).getPropertyDefinitions();
+ Iterable<PropertyDefinition> propDefIter = null;
+ List<PropertyDefinition> propDefList = null;
+
+ if (object instanceof Map){
+ propDefIter = (Iterable<PropertyDefinition>) ((Map)object).values().iterator();
+ }else{
+ propDefList = (List<PropertyDefinition>)object;
+ }
+
+ for (PropertyDefinition definition : propDefIter != null?propDefIter:propDefList) {
+ ManagedPropertyImpl managedProp = new ManagedPropertyImpl(definition.getName());
+ MetaType managedPropMetaType = ProfileServiceUtil.convertPropertyDefinitionToMetaType(definition);
managedProp.setMetaType(managedPropMetaType);
managedProp.setManagedObject(managedObject);
managedObject.getProperties().put(managedProp.getName(), managedProp);
}
- GenericValue genericValue = new GenericValueSupport(new GenericMetaType(propDefMap.getName(),
- propDefMap.getDescription()), managedObject);
- populateMetaValueFromProperty(propMap, genericValue, propDefMap);
+ GenericValue genericValue = new GenericValueSupport(new GenericMetaType(propertyDefinitionMap.getName(),
+ propertyDefinitionMap.getDescription()), managedObject);
+ populateMetaValueFromProperty(propMap, genericValue, propertyDefinitionMap);
return genericValue;
}
- public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propertyDefinitionMap)
{
GenericValue genericValue = (GenericValue)metaValue;
ManagedObject managedObject = (ManagedObject)genericValue.getValue();
- for (String propName : propDefMap.getPropertyDefinitions().keySet())
- {
- ManagedProperty managedProp = managedObject.getProperty(propName);
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check types.
+ Object object = ((PropertyDefinitionMap) propertyDefinitionMap).getPropertyDefinitions();
+ Iterable<PropertyDefinition> propDefIter = null;
+
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList =ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ ManagedProperty managedProp = managedObject.getProperty(definition.getName());
if (managedProp != null)
{
MetaType metaType = managedProp.getMetaType();
@@ -129,7 +150,7 @@
+ "] is not a SimpleValue or EnumValue - unsupported!");
continue;
}
- propMap.put(new PropertySimple(propName, value));
+ propMap.put(new PropertySimple(definition.getName(), value));
}
}
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -22,6 +22,7 @@
package org.teiid.rhq.plugin.adapter.impl;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.jboss.metatype.api.types.MetaType;
@@ -37,6 +38,7 @@
import org.teiid.rhq.plugin.adapter.api.AbstractPropertyMapAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
*
@@ -51,19 +53,19 @@
}
//@todo need to implement this like the other Map to Composite, but not until there is an actual property that needs this
- public void populateMetaValueFromProperty(PropertyMap property, MetaValue metaValue, PropertyDefinitionMap propertyDefinition)
+ public void populateMetaValueFromProperty(PropertyMap property, MetaValue metaValue, PropertyDefinitionMap propertyDefinitionMap)
{
if (metaValue != null)
{
TableValueSupport tableValueSupport = (TableValueSupport)metaValue;
- Map<String, PropertyDefinition> map = propertyDefinition.getPropertyDefinitions();
- Map<String, Property> properties = property.getMap();
- for (String key : map.keySet())
- {
- PropertyDefinition definition = map.get(key);
- MetaValue[] getKey = new MetaValue[]{SimpleValueSupport.wrap(key)};
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList =ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ Map<String, Property> properties = property.getMap();
+ for (PropertyDefinition definition : propDefList) {
+ MetaValue[] getKey = new MetaValue[]{SimpleValueSupport.wrap(definition.getName())};
MetaValue value = tableValueSupport.get(getKey);
- Property innerProperty = properties.get(key);
+ Property innerProperty = properties.get(definition.getName());
PropertyAdapter adapter = PropertyAdapterFactory.getPropertyAdapter(value);
adapter.populateMetaValueFromProperty(innerProperty, value, definition);
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -32,9 +33,9 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
public class ConfigurationResultImpl {
@@ -60,20 +61,16 @@
properties.add(new PropertySimple(key, values.get(fieldName)));
}
} else if (pdef instanceof PropertyDefinitionList) {
+
PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) pdef)
.getMemberDefinition();
- Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
- .getPropertyDefinitions();
- Iterator simplePropertiesIter = simpleProperties.values()
- .iterator();
-
- while (simplePropertiesIter.hasNext()) {
- PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
- .next();
- String fieldName = ((PropertyDefinitionSimple) simpleProp)
- .getName();
+
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList =ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ String fieldName = definition.getName();
if (values.contains(fieldName)) {
-
properties.add(new PropertySimple(key, values.get(fieldName)));
}
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -33,10 +33,9 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
public class ExecutedOperationResultImpl implements ExecutedResult {
@@ -130,27 +129,19 @@
if (opDef.getName().equals(operationName)) {
if (opDef.getResultsConfigurationDefinition()==null) break;
- Map propDefs = opDef.getResultsConfigurationDefinition()
- .getPropertyDefinitions();
- PropertyDefinition listPropDefinition = (PropertyDefinition) propDefs
- .get(LISTNAME);
+ PropertyDefinitionList listPropDefinition = opDef.getResultsConfigurationDefinition()
+ .getPropertyDefinitionList(LISTNAME);
if (listPropDefinition == null) {
continue;
}
-
- PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) listPropDefinition)
- .getMemberDefinition();
- Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
- .getPropertyDefinitions();
- Iterator simplePropertiesIter = simpleProperties.values()
- .iterator();
- while (simplePropertiesIter.hasNext()) {
- PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
- .next();
- String fieldName = ((PropertyDefinitionSimple) simpleProp)
- .getName();
+ PropertyDefinition propertyDefinitionMap = listPropDefinition.getMemberDefinition();
+
+ List<PropertyDefinition> propDefList = ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ String fieldName = definition.getName();
fieldNameList.add(fieldName);
}
@@ -158,4 +149,6 @@
}
}
}
+
+
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -32,8 +32,7 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
public class ExecutedResourceConfigurationResultImpl implements ExecutedResult {
@@ -122,16 +121,11 @@
PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) listPropDefinition)
.getMemberDefinition();
- Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
- .getPropertyDefinitions();
- Iterator simplePropertiesIter = simpleProperties.values()
- .iterator();
-
- while (simplePropertiesIter.hasNext()) {
- PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
- .next();
- String fieldName = ((PropertyDefinitionSimple) simpleProp)
- .getName();
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList =ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ String fieldName = definition.getName();
fieldNameList.add(fieldName);
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2012-10-30 21:51:45 UTC (rev 4522)
@@ -24,15 +24,19 @@
import java.io.File;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -537,15 +541,24 @@
// at all common)
memberMetaType = null;
} else if (propDef instanceof PropertyDefinitionMap) {
- Map<String, PropertyDefinition> memberPropDefs = ((PropertyDefinitionMap) propDef)
- .getPropertyDefinitions();
- if (memberPropDefs.isEmpty())
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check types.
+ Object object = ((PropertyDefinitionMap) propDef).getPropertyDefinitions();
+ Iterable<PropertyDefinition> propDefIter = null;
+ List<PropertyDefinition> propDefList = null;
+
+ if (object instanceof Map){
+ propDefIter = (Iterable<PropertyDefinition>) ((Map)object).values().iterator();
+ }else{
+ propDefList = (List<PropertyDefinition>)object;
+ }
+
+ if ((propDefIter != null &! propDefIter.iterator().hasNext()) || (propDefList != null && propDefList.isEmpty()))
throw new IllegalStateException(
"PropertyDefinitionMap doesn't contain any member PropertyDefinitions."); //$NON-NLS-1$
// NOTE: We assume member prop defs are all of the same type, since
// for MapCompositeMetaTypes, they have to be.
- PropertyDefinition mapMemberPropDef = memberPropDefs.values()
- .iterator().next();
+ PropertyDefinition mapMemberPropDef = propDefIter != null?propDefIter.iterator().next():propDefList.listIterator().next();
MetaType mapMemberMetaType = convertPropertyDefinitionToMetaType(mapMemberPropDef);
memberMetaType = new MapCompositeMetaType(mapMemberMetaType);
} else {
@@ -641,5 +654,51 @@
}
throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
}
+
+ /**
+ * @return
+ */
+ public static List<PropertyDefinition> reflectivelyInvokeGetMapMethod(PropertyDefinition propertyDefinitionMap) {
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check method availability. getMap() was added for 4.4, so if we can find it via reflection, invoke it.
+ //Otherwise it is less than 4.4 so we will invoke getPropertyDefinitions which returned a map in 4.2.
+ Method method = null;
+ Object object = null;
+
+ try {
+ method = PropertyDefinitionMap.class.getMethod("getMap", null);
+ } catch (SecurityException e) {
+ //Nothing to do here
+ } catch (NoSuchMethodException e) {
+ //This will happen if we are running a version of RHQ less that 4.4
+ }
+
+ try {
+ if (method == null){
+ method = PropertyDefinitionMap.class.getMethod("getPropertyDefinitions", null);
+ }
+ object = method.invoke(propertyDefinitionMap, null);
+ } catch (IllegalArgumentException e) {
+ throwReflectionException(e);
+ } catch (IllegalAccessException e) {
+ throwReflectionException(e);
+ } catch (InvocationTargetException e) {
+ throwReflectionException(e);
+ } catch (SecurityException e) {
+ throwReflectionException(e);
+ } catch (NoSuchMethodException e) {
+ throwReflectionException(e);
+ }
+
+
+ return new ArrayList<PropertyDefinition>(((Map)object).values());
+ }
+ /**
+ * @param object
+ */
+ private static void throwReflectionException(Exception e) {
+ throw new RuntimeException("Error reflectively returning PropertyDefinition map: " + e.getLocalizedMessage());
+ }
+
}
Modified: branches/7.7.x/documentation/javadocs/pom.xml
===================================================================
--- branches/7.7.x/documentation/javadocs/pom.xml 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/documentation/javadocs/pom.xml 2012-10-30 21:51:45 UTC (rev 4522)
@@ -467,13 +467,13 @@
<properties>
<org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
<mysql.connector.version>5.1.5</mysql.connector.version>
- <org.rhq.version>1.3.0.GA</org.rhq.version>
+ <org.rhq.version>4.4.0</org.rhq.version>
<postgresql.version>8.4-702.jdbc4</postgresql.version>
<derby.version>10.2.1.6</derby.version>
<teiid.version>${project.version}</teiid.version>
<site.url>http://www.jboss.org/teiid</site.url>
<ant.version>1.7.0</ant.version>
<apache.ant.version>1.7.0</apache.ant.version>
- <jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
+ <jopr.jboss.as5.plugin.version>4.4.0</jopr.jboss.as5.plugin.version>
</properties>
</project>
12 years, 1 month