Author: shawkins
Date: 2010-05-17 16:23:50 -0400 (Mon, 17 May 2010)
New Revision: 2127
Added:
trunk/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java
Removed:
trunk/api/src/main/java/org/teiid/translator/TranslatorCapabilities.java
Modified:
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/api/src/main/java/org/teiid/translator/TranslatorProperty.java
trunk/client/src/main/java/org/teiid/adminapi/Translator.java
trunk/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java
trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
Log:
TEIID-1056 refining connector changes to remove capabilities interface. also ensuring
that property annotation processing is simplified
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-05-13 19:04:27
UTC (rev 2126)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-05-17 20:23:50
UTC (rev 2127)
@@ -24,10 +24,12 @@
import java.util.List;
+import org.teiid.language.BatchedUpdates;
import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.language.LanguageFactory;
import org.teiid.language.QueryExpression;
+import org.teiid.language.SetQuery;
import org.teiid.metadata.RuntimeMetadata;
@@ -38,18 +40,54 @@
* The deployer instantiates this class through reflection. So it is important to have
no-arg constructor. Once constructed
* the "start" method is called. This class represents the basic capabilities
of the translator.
*/
-public class ExecutionFactory implements TranslatorCapabilities{
+public class ExecutionFactory {
+
+ public enum SupportedJoinCriteria {
+ /**
+ * Indicates that any supported criteria is allowed.
+ */
+ ANY,
+ /**
+ * Indicates that any simple comparison of elements is allowed.
+ */
+ THETA,
+ /**
+ * Indicates that only equality predicates of elements are allowed.
+ */
+ EQUI,
+ /**
+ * Indicates that only equality predicates between
+ * exactly one primary and foreign key is allowed per join.
+ */
+ KEY
+ }
public static final int DEFAULT_MAX_FROM_GROUPS = -1;
+ public static final int DEFAULT_MAX_IN_CRITERIA_SIZE = -1;
+ public static final int DEFAULT_MAX_ROWS = -1;
private static final TypeFacility TYPE_FACILITY = new TypeFacility();
- private boolean immutable = false;
- private boolean exceptionOnMaxRows = false;
- private int maxResultRows = DEFAULT_MAX_FROM_GROUPS;
+ /*
+ * Managed execution properties
+ */
+ private boolean immutable;
+ private boolean exceptionOnMaxRows = true;
+ private int maxResultRows = DEFAULT_MAX_ROWS;
private boolean xaCapable;
private boolean sourceRequired = true;
+ /*
+ * Support properties
+ */
+ private boolean supportsSelectDistinct;
+ private boolean supportsOuterJoins;
+ private SupportedJoinCriteria supportedJoinCriteria = SupportedJoinCriteria.ANY;
+ private boolean supportsOrderBy;
+ private boolean supportsInnerJoins;
+ private boolean supportsFullOuterJoins;
+ private boolean requiresCriteria;
+
/**
* Initialize the connector with supplied configuration
*/
@@ -60,7 +98,7 @@
* Defines if the Connector is read-only connector
* @return
*/
- @TranslatorProperty(name="immutable", display="Is
Immutable",description="Is Immutable, True if the source never
changes.",advanced=true, defaultValue="false")
+ @TranslatorProperty(managed=true, display="Is Immutable",description="Is
Immutable, True if the source never changes.",advanced=true)
public boolean isImmutable() {
return immutable;
}
@@ -73,7 +111,7 @@
* Throw exception if there are more rows in the result set than specified in the
MaxResultRows setting.
* @return
*/
- @TranslatorProperty(name="exception-on-max-rows", display="Exception on
Exceeding Max Rows",description="Indicates if an Exception should be thrown if
the specified value for Maximum Result Rows is exceeded; else no exception and no more
than the maximum will be returned",advanced=true, defaultValue="true")
+ @TranslatorProperty(managed=true, display="Exception on Exceeding Max
Rows",description="Indicates if an Exception should be thrown if the specified
value for Maximum Result Rows is exceeded; else no exception and no more than the maximum
will be returned",advanced=true)
public boolean isExceptionOnMaxRows() {
return exceptionOnMaxRows;
}
@@ -86,9 +124,9 @@
* Maximum result set rows to fetch
* @return
*/
- @TranslatorProperty(name="max-result-rows", display="Maximum Result
Rows", description="Maximum Result Rows allowed", advanced=true,
defaultValue="-1")
+ @TranslatorProperty(managed=true, display="Maximum Result Rows",
description="Maximum Result Rows allowed", advanced=true)
public int getMaxResultRows() {
- return maxResultRows;
+ return maxResultRows = DEFAULT_MAX_ROWS;
}
public void setMaxResultRows(int arg0) {
@@ -99,7 +137,7 @@
* Shows the XA transaction capability of the Connector.
* @return
*/
- @TranslatorProperty(name="xa-capable", display="Is XA Capable",
description="True, if this connector supports XA Transactions",
defaultValue="false")
+ @TranslatorProperty(managed=true, display="Is XA Capable",
description="True, if this connector supports XA Transactions")
public boolean isXaCapable() {
return xaCapable;
}
@@ -168,263 +206,481 @@
throw new TranslatorException("Unsupported Execution");//$NON-NLS-1$
}
- @Override
- public boolean supportsSelectDistinct() {
- return false;
+ /**
+ * Support indicates connector can accept queries with SELECT DISTINCT
+ * @since 3.1 SP2
+ */
+ @TranslatorProperty(display="Supports Select Distinct",
description="True, if this connector supports SELECT DISTINCT", advanced=true)
+ public final boolean supportsSelectDistinct() {
+ return supportsSelectDistinct;
}
+
+ public void setSupportsSelectDistinct(boolean supportsSelectDistinct) {
+ this.supportsSelectDistinct = supportsSelectDistinct;
+ }
- @Override
- public boolean supportsAliasedGroup() {
- return false;
+ /**
+ * Support indicates connector can accept expressions other than element
+ * symbols in the SELECT clause. Specific supports for the expression
+ * type are still checked.
+ * @since 6.1.0
+ */
+ public boolean supportsSelectExpression() {
+ return false;
}
- @Override
- public boolean supportsSelfJoins() {
- return false;
+ /**
+ * Support indicates connector can accept groups with aliases
+ * @since 3.1 SP2
+ */
+ public boolean supportsAliasedTable() {
+ return false;
}
- @Override
- public boolean supportsOuterJoins() {
- return false;
+ /**
+ * Get the supported join criteria. A null return value will be treated
+ * as {@link SupportedJoinCriteria#ANY}
+ * @since 6.1.0
+ */
+ @TranslatorProperty(display="Supported Join Criteria",
description="Returns one of any, theta, equi, or key", advanced=true)
+ public final SupportedJoinCriteria getSupportedJoinCriteria() {
+ return supportedJoinCriteria;
}
+
+ public void setSupportedJoinCriteria(
+ SupportedJoinCriteria supportedJoinCriteria) {
+ this.supportedJoinCriteria = supportedJoinCriteria;
+ }
+
+ /**
+ * Support indicates connector can accept inner or cross joins
+ * @since 6.1.0
+ */
+ @TranslatorProperty(display="Supports Inner Joins", description="True, if
this connector supports inner joins", advanced=true)
+ public final boolean supportsInnerJoins() {
+ return supportsInnerJoins;
+ }
+
+ public void setSupportsInnerJoins(boolean supportsInnerJoins) {
+ this.supportsInnerJoins = supportsInnerJoins;
+ }
+
+ /**
+ * Support indicates connector can accept self-joins where a
+ * group is joined to itself with aliases. Connector must also support
+ * {@link #supportsAliasedTable()}.
+ * @since 3.1 SP2
+ */
+ public boolean supportsSelfJoins() {
+ return false;
+ }
+
+ /**
+ * Support indicates connector can accept left outer joins
+ * @since 3.1 SP2
+ */
+ @TranslatorProperty(display="Supports Outer Joins", description="True, if
this connector supports outer joins", advanced=true)
+ public final boolean supportsOuterJoins() {
+ return supportsOuterJoins;
+ }
+
+ public void setSupportsOuterJoins(boolean supportsOuterJoins) {
+ this.supportsOuterJoins = supportsOuterJoins;
+ }
+
+ /**
+ * Support indicates connector can accept full outer joins
+ * @since 3.1 SP2
+ */
+ @TranslatorProperty(display="Supports Full Outer Joins",
description="True, if this connector supports full outer joins", advanced=true)
+ public final boolean supportsFullOuterJoins() {
+ return supportsFullOuterJoins;
+ }
+
+ public void setSupportsFullOuterJoins(boolean supportsFullOuterJoins) {
+ this.supportsFullOuterJoins = supportsFullOuterJoins;
+ }
- @Override
- public boolean supportsFullOuterJoins() {
- return false;
+ /**
+ * Support indicates connector can accept inline views (subqueries
+ * in the FROM clause).
+ * @since 4.1
+ */
+ public boolean supportsInlineViews() {
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts criteria of form (element BETWEEN constant AND
constant)
+ * <br>NOT CURRENTLY USED - between is rewritten as compound compare criteria
+ * @since 4.0
+ */
public boolean supportsBetweenCriteria() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector accepts criteria of form (element = constant)
+ * @since 3.1 SP2
+ */
public boolean supportsCompareCriteriaEquals() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts criteria of form (element <=|>=
constant)
+ * <br>The query engine will may pushdown queries containing < or
> if NOT is also
+ * supported.
+ * @since 3.1 SP2
+ */
+ public boolean supportsCompareCriteriaOrdered() {
+ return false;
+ }
+
+ /**
+ * Support indicates connector accepts criteria of form (element LIKE constant)
+ * @since 3.1 SP2
+ */
public boolean supportsLikeCriteria() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector accepts criteria of form (element LIKE constant ESCAPE
char)
+ * @since 3.1 SP2
+ */
public boolean supportsLikeCriteriaEscapeCharacter() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts criteria of form (element IN set)
+ * @since 3.1 SP2
+ */
public boolean supportsInCriteria() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts IN criteria with a subquery on the right side
+ * @since 4.0
+ */
public boolean supportsInCriteriaSubquery() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts criteria of form (element IS NULL)
+ * @since 3.1 SP2
+ */
public boolean supportsIsNullCriteria() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts logical criteria connected by OR
+ * @since 3.1 SP2
+ */
public boolean supportsOrCriteria() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts logical criteria NOT
+ * @since 3.1 SP2
+ */
public boolean supportsNotCriteria() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts the EXISTS criteria
+ * @since 4.0
+ */
public boolean supportsExistsCriteria() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts the quantified comparison criteria that
+ * use SOME
+ * @since 4.0
+ */
public boolean supportsQuantifiedCompareCriteriaSome() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector accepts the quantified comparison criteria that
+ * use ALL
+ * @since 4.0
+ */
public boolean supportsQuantifiedCompareCriteriaAll() {
- return false;
+ return false;
}
- @Override
- public boolean supportsOrderBy() {
- return false;
+ /**
+ * Support indicates connector accepts ORDER BY clause, including multiple elements
+ * and ascending and descending sorts.
+ * @since 3.1 SP2
+ */
+ @TranslatorProperty(display="Supports ORDER BY", description="True, if
this connector supports ORDER BY", advanced=true)
+ public final boolean supportsOrderBy() {
+ return supportsOrderBy;
}
+
+ public void setSupportsOrderBy(boolean supportsOrderBy) {
+ this.supportsOrderBy = supportsOrderBy;
+ }
+
+ /**
+ * Support indicates connector accepts ORDER BY clause with columns not from the
select
+ * @since 6.2
+ * @return
+ */
+ public boolean supportsOrderByUnrelated() {
+ return false;
+ }
+
+ /**
+ * Whether the source supports an explicit GROUP BY clause
+ * @since 6.1
+ */
+ public boolean supportsGroupBy() {
+ return false;
+ }
- @Override
+ /**
+ * Whether the source supports the HAVING clause
+ * @since 6.1
+ */
+ public boolean supportsHaving() {
+ return false;
+ }
+
+ /**
+ * Support indicates connector can accept the SUM aggregate function
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesSum() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept the AVG aggregate function
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesAvg() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept the MIN aggregate function
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesMin() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept the MAX aggregate function
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesMax() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept the COUNT aggregate function
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesCount() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept the COUNT(*) aggregate function
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesCountStar() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept DISTINCT within aggregate functions
+ * @since 3.1 SP2
+ */
public boolean supportsAggregatesDistinct() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector can accept scalar subqueries in the SELECT, WHERE,
and
+ * HAVING clauses
+ * @since 4.0
+ */
public boolean supportsScalarSubqueries() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector can accept correlated subqueries wherever subqueries
+ * are accepted
+ * @since 4.0
+ */
public boolean supportsCorrelatedSubqueries() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Support indicates connector can accept queries with non-searched
+ * CASE <expression> WHEN <expression> ... END
+ * <br>NOT CURRENTLY USED - case is pushed down as searched case
+ * @since 4.0
+ */
public boolean supportsCaseExpressions() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Support indicates connector can accept queries with searched CASE WHEN
<criteria> ... END
+ * @since 4.0
+ */
public boolean supportsSearchedCaseExpressions() {
- return false;
+ return false;
}
-
- @Override
- public List<String> getSupportedFunctions() {
- return null;
+
+ /**
+ * Support indicates that the connector supports the UNION of two queries.
+ * @since 4.2
+ */
+ public boolean supportsUnions() {
+ return false;
}
- public boolean supportsInlineViews() {
- return false;
+ /**
+ * Support indicates that the connector supports an ORDER BY on a SetQuery.
+ * @since 5.6
+ */
+ public boolean supportsSetQueryOrderBy() {
+ return false;
}
- @Override
- public boolean supportsUnions() {
- return false;
+ /**
+ * Support indicates that the connector supports the INTERSECT of two queries.
+ * @since 5.6
+ */
+ public boolean supportsIntersect() {
+ return false;
}
- @Override
+ /**
+ * Support indicates that the connector supports the EXCEPT of two queries.
+ * @since 5.6
+ */
+ public boolean supportsExcept() {
+ return false;
+ }
+
+ /**
+ * Get list of all supported function names. Arithmetic functions have names like
+ * "+".
+ * @since 3.1 SP3
+ */
+ public List<String> getSupportedFunctions() {
+ return null;
+ }
+
+ /**
+ * Get the integer value representing the number of values allowed in an IN criteria
+ * in the WHERE clause of a query
+ * @since 5.0
+ */
public int getMaxInCriteriaSize() {
- return DEFAULT_MAX_FROM_GROUPS;
+ return DEFAULT_MAX_IN_CRITERIA_SIZE;
}
- @Override
+ /**
+ * <p>Support indicates that the connector supports functions in GROUP BY, such
as:
+ * <code>SELECT dayofmonth(theDate), COUNT(*) FROM table GROUP BY
dayofmonth(theDate)</code></p>
+ *
+ * <br>NOT CURRENTLY USED - group by expressions create an inline view for
pushdown
+ * @since 5.0
+ */
public boolean supportsFunctionsInGroupBy() {
- return false;
+ return false;
}
- @Override
+ /**
+ * Gets whether the connector can limit the number of rows returned by a query.
+ * @since 5.0 SP1
+ */
public boolean supportsRowLimit() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * Gets whether the connector supports a SQL clause (similar to the LIMIT with an
offset) that can return
+ * result sets that start in the middle of the resulting rows returned by a query
+ * @since 5.0 SP1
+ */
public boolean supportsRowOffset() {
- return false;
+ return false;
}
-
- @Override
+
+ /**
+ * The number of groups supported in the from clause. Added for a Sybase limitation.
+ * @since 5.6
+ * @return the number of groups supported in the from clause, or -1 if there is no
limit
+ */
public int getMaxFromGroups() {
- return DEFAULT_MAX_FROM_GROUPS; //-1 indicates no max
+ return DEFAULT_MAX_FROM_GROUPS;
}
-
- @Override
- public boolean supportsExcept() {
- return false;
+
+ /**
+ * Whether the source prefers to use ANSI style joins.
+ * @since 6.0
+ */
+ public boolean useAnsiJoin() {
+ return false;
}
-
- @Override
- public boolean supportsIntersect() {
- return false;
+
+ /**
+ * Whether the source supports queries without criteria.
+ * @since 6.0
+ */
+ @TranslatorProperty(display="Requries Criteria", description="True, if
this connector requires criteria on source queries", advanced=true)
+ public final boolean requiresCriteria() {
+ return requiresCriteria;
}
-
- @Override
- public boolean supportsSetQueryOrderBy() {
- return false;
- }
+
+ public void setRequiresCriteria(boolean requiresCriteria) {
+ this.requiresCriteria = requiresCriteria;
+ }
- @Override
- public boolean useAnsiJoin() {
+ /**
+ * Whether the source supports {@link BatchedUpdates}
+ * @since 6.0
+ */
+ public boolean supportsBatchedUpdates() {
return false;
}
-
- @Override
- public boolean requiresCriteria() {
+
+ /**
+ * Whether the source supports updates with multiple value sets
+ * @since 6.0
+ */
+ public boolean supportsBulkUpdate() {
return false;
}
-
- @Override
- public boolean supportsBatchedUpdates() {
- return false;
- }
-
- @Override
- public boolean supportsGroupBy() {
- return false;
- }
-
- @Override
- public boolean supportsHaving() {
- return false;
- }
-
- @Override
- public boolean supportsInnerJoins() {
- return false;
- }
-
- @Override
- public boolean supportsSelectExpression() {
- return false;
- }
+
+ /**
+ * Support indicates that the connector can accept INSERTs with
+ * values specified by an {@link SetQuery}.
+ * @since 6.1
+ */
+ public boolean supportsInsertWithQueryExpression() {
+ return false;
+ }
- @Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.ANY;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return false;
- }
-
- @Override
- public boolean supportsInsertWithQueryExpression() {
- return false;
- }
-
- @Override
- public boolean supportsBulkUpdate() {
- return false;
- }
-
- @Override
- public boolean supportsOrderByUnrelated() {
- return false;
- }
-
}
Deleted: trunk/api/src/main/java/org/teiid/translator/TranslatorCapabilities.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/TranslatorCapabilities.java 2010-05-13
19:04:27 UTC (rev 2126)
+++ trunk/api/src/main/java/org/teiid/translator/TranslatorCapabilities.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -1,394 +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.translator;
-
-import java.util.List;
-
-import org.teiid.language.BatchedUpdates;
-import org.teiid.language.SetQuery;
-
-
-/**
- * Allows a connector to specify the capabilities that a connector
- * supports.
- */
-public interface TranslatorCapabilities {
-
- public enum SupportedJoinCriteria {
- /**
- * Indicates that any supported criteria is allowed.
- */
- ANY,
- /**
- * Indicates that any simple comparison of elements is allowed.
- */
- THETA,
- /**
- * Indicates that only equality predicates of elements are allowed.
- */
- EQUI,
- /**
- * Indicates that only equality predicates between
- * exactly one primary and foreign key is allowed per join.
- */
- KEY
- }
-
- /**
- * Support indicates connector can accept queries with SELECT DISTINCT
- * @since 3.1 SP2
- */
- boolean supportsSelectDistinct();
-
- /**
- * Support indicates connector can accept expressions other than element
- * symbols in the SELECT clause. Specific supports for the expression
- * type are still checked.
- * @since 6.1.0
- */
- boolean supportsSelectExpression();
-
- /**
- * Support indicates connector can accept groups with aliases
- * @since 3.1 SP2
- */
- boolean supportsAliasedGroup();
-
- /**
- * Get the supported join criteria. A null return value will be treated
- * as {@link SupportedJoinCriteria#ANY}
- * @since 6.1.0
- */
- SupportedJoinCriteria getSupportedJoinCriteria();
-
- /**
- * Support indicates connector can accept inner or cross joins
- * @since 6.1.0
- */
- boolean supportsInnerJoins();
-
- /**
- * Support indicates connector can accept self-joins where a
- * group is joined to itself with aliases. Connector must also support
- * {@link #supportsAliasedGroup()}.
- * @since 3.1 SP2
- */
- boolean supportsSelfJoins();
-
- /**
- * Support indicates connector can accept left outer joins
- * @since 3.1 SP2
- */
- boolean supportsOuterJoins();
-
- /**
- * Support indicates connector can accept full outer joins
- * @since 3.1 SP2
- */
- boolean supportsFullOuterJoins();
-
- /**
- * Support indicates connector can accept inline views (subqueries
- * in the FROM clause).
- * @since 4.1
- */
- boolean supportsInlineViews();
-
- /**
- * Support indicates connector accepts criteria of form (element BETWEEN constant AND
constant)
- * <br>NOT CURRENTLY USED - between is rewritten as compound compare criteria
- * @since 4.0
- */
- boolean supportsBetweenCriteria();
-
- /**
- * Support indicates connector accepts criteria of form (element = constant)
- * @since 3.1 SP2
- */
- boolean supportsCompareCriteriaEquals();
-
- /**
- * Support indicates connector accepts criteria of form (element <=|>=
constant)
- * <br>The query engine will may pushdown queries containing < or
> if NOT is also
- * supported.
- * @since 3.1 SP2
- */
- boolean supportsCompareCriteriaOrdered();
-
- /**
- * Support indicates connector accepts criteria of form (element LIKE constant)
- * @since 3.1 SP2
- */
- boolean supportsLikeCriteria();
-
- /**
- * Support indicates connector accepts criteria of form (element LIKE constant ESCAPE
char)
- * @since 3.1 SP2
- */
- boolean supportsLikeCriteriaEscapeCharacter();
-
- /**
- * Support indicates connector accepts criteria of form (element IN set)
- * @since 3.1 SP2
- */
- boolean supportsInCriteria();
-
- /**
- * Support indicates connector accepts IN criteria with a subquery on the right side
- * @since 4.0
- */
- boolean supportsInCriteriaSubquery();
-
- /**
- * Support indicates connector accepts criteria of form (element IS NULL)
- * @since 3.1 SP2
- */
- boolean supportsIsNullCriteria();
-
- /**
- * Support indicates connector accepts logical criteria connected by OR
- * @since 3.1 SP2
- */
- boolean supportsOrCriteria();
-
- /**
- * Support indicates connector accepts logical criteria NOT
- * @since 3.1 SP2
- */
- boolean supportsNotCriteria();
-
- /**
- * Support indicates connector accepts the EXISTS criteria
- * @since 4.0
- */
- boolean supportsExistsCriteria();
-
- /**
- * Support indicates connector accepts the quantified comparison criteria that
- * use SOME
- * @since 4.0
- */
- boolean supportsQuantifiedCompareCriteriaSome();
-
- /**
- * Support indicates connector accepts the quantified comparison criteria that
- * use ALL
- * @since 4.0
- */
- boolean supportsQuantifiedCompareCriteriaAll();
-
- /**
- * Support indicates connector accepts ORDER BY clause, including multiple elements
- * and ascending and descending sorts.
- * @since 3.1 SP2
- */
- boolean supportsOrderBy();
-
- /**
- * Support indicates connector accepts ORDER BY clause with columns not from the
select
- * @since 6.2
- * @return
- */
- boolean supportsOrderByUnrelated();
-
- /**
- * Whether the source supports an explicit GROUP BY clause
- * @since 6.1
- */
- boolean supportsGroupBy();
-
- /**
- * Whether the source supports the HAVING clause
- * @since 6.1
- */
- boolean supportsHaving();
-
- /**
- * Support indicates connector can accept the SUM aggregate function
- * @since 3.1 SP2
- */
- boolean supportsAggregatesSum();
-
- /**
- * Support indicates connector can accept the AVG aggregate function
- * @since 3.1 SP2
- */
- boolean supportsAggregatesAvg();
-
- /**
- * Support indicates connector can accept the MIN aggregate function
- * @since 3.1 SP2
- */
- boolean supportsAggregatesMin();
-
- /**
- * Support indicates connector can accept the MAX aggregate function
- * @since 3.1 SP2
- */
- boolean supportsAggregatesMax();
-
- /**
- * Support indicates connector can accept the COUNT aggregate function
- * @since 3.1 SP2
- */
- boolean supportsAggregatesCount();
-
- /**
- * Support indicates connector can accept the COUNT(*) aggregate function
- * @since 3.1 SP2
- */
- boolean supportsAggregatesCountStar();
-
- /**
- * Support indicates connector can accept DISTINCT within aggregate functions
- * @since 3.1 SP2
- */
- boolean supportsAggregatesDistinct();
-
- /**
- * Support indicates connector can accept scalar subqueries in the SELECT, WHERE,
and
- * HAVING clauses
- * @since 4.0
- */
- boolean supportsScalarSubqueries();
-
- /**
- * Support indicates connector can accept correlated subqueries wherever subqueries
- * are accepted
- * @since 4.0
- */
- boolean supportsCorrelatedSubqueries();
-
- /**
- * Support indicates connector can accept queries with non-searched
- * CASE <expression> WHEN <expression> ... END
- * <br>NOT CURRENTLY USED - case is pushed down as searched case
- * @since 4.0
- */
- boolean supportsCaseExpressions();
-
- /**
- * Support indicates connector can accept queries with searched CASE WHEN
<criteria> ... END
- * @since 4.0
- */
- boolean supportsSearchedCaseExpressions();
-
- /**
- * Support indicates that the connector supports the UNION of two queries.
- * @since 4.2
- */
- boolean supportsUnions();
-
- /**
- * Support indicates that the connector supports an ORDER BY on a SetQuery.
- * @since 5.6
- */
- boolean supportsSetQueryOrderBy();
-
- /**
- * Support indicates that the connector supports the INTERSECT of two queries.
- * @since 5.6
- */
- boolean supportsIntersect();
-
- /**
- * Support indicates that the connector supports the EXCEPT of two queries.
- * @since 5.6
- */
- boolean supportsExcept();
-
- /**
- * Get list of all supported function names. Arithmetic functions have names like
- * "+".
- * @since 3.1 SP3
- */
- List<String> getSupportedFunctions();
-
- /**
- * Get the integer value representing the number of values allowed in an IN criteria
- * in the WHERE clause of a query
- * @since 5.0
- */
- int getMaxInCriteriaSize();
-
- /**
- * <p>Support indicates that the connector supports functions in GROUP BY, such
as:
- * <code>SELECT dayofmonth(theDate), COUNT(*) FROM table GROUP BY
dayofmonth(theDate)</code></p>
- *
- * <br>NOT CURRENTLY USED - group by expressions create an inline view for
pushdown
- * @since 5.0
- */
- boolean supportsFunctionsInGroupBy();
-
- /**
- * Gets whether the connector can limit the number of rows returned by a query.
- * @since 5.0 SP1
- */
- boolean supportsRowLimit();
-
- /**
- * Gets whether the connector supports a SQL clause (similar to the LIMIT with an
offset) that can return
- * result sets that start in the middle of the resulting rows returned by a query
- * @since 5.0 SP1
- */
- boolean supportsRowOffset();
-
- /**
- * The number of groups supported in the from clause. Added for a Sybase limitation.
- * @since 5.6
- * @return the number of groups supported in the from clause, or -1 if there is no
limit
- */
- int getMaxFromGroups();
-
- /**
- * Whether the source prefers to use ANSI style joins.
- * @since 6.0
- */
- boolean useAnsiJoin();
-
- /**
- * Whether the source supports queries without criteria.
- * @since 6.0
- */
- boolean requiresCriteria();
-
- /**
- * Whether the source supports {@link BatchedUpdates}
- * @since 6.0
- */
- boolean supportsBatchedUpdates();
-
- /**
- * Whether the source supports updates with multiple value sets
- * @since 6.0
- */
- boolean supportsBulkUpdate();
-
- /**
- * Support indicates that the connector can accept INSERTs with
- * values specified by an {@link SetQuery}.
- * @since 6.1
- */
- boolean supportsInsertWithQueryExpression();
-
-}
Modified: trunk/api/src/main/java/org/teiid/translator/TranslatorProperty.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/TranslatorProperty.java 2010-05-13
19:04:27 UTC (rev 2126)
+++ trunk/api/src/main/java/org/teiid/translator/TranslatorProperty.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -21,6 +21,7 @@
*/
package org.teiid.translator;
+import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
@@ -31,38 +32,44 @@
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
+@Documented
public @interface TranslatorProperty {
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
- public static final String GENERATED = "%GENERATED%"; //$NON-NLS-1$
- // name of the property
- String name() default GENERATED;
-
- // type of the property
- Class type() default java.lang.String.class;
+ /**
+ * Description to be shown in tools
+ * @return
+ */
+ String description() default EMPTY_STRING;
- // description
- String description() default GENERATED;
+ /**
+ * Display name to be shown in tools
+ * @return
+ */
+ String display() default EMPTY_STRING;
- // display name to be used in tools
- String display() default GENERATED;
-
- // is this mandatory property
+ /**
+ * True if a non-null value must be supplied
+ * @return
+ */
boolean required() default false;
- // is it modifiable
- boolean readOnly() default false;
-
- // is advanced?
+ /**
+ * True if this property should be shown in an advanced panel of properties.
+ * @return
+ */
boolean advanced() default false;
- // should mask the values of this property in the tools
+ /**
+ * True if this is property should be masked when displayed - this has no effect on how
the value is persisted.
+ * @return
+ */
boolean masked() default false;
- // if this represents a enum what are the legal values?
- String[] allowed() default {};
-
- // what is the default in the string form
- String defaultValue() default EMPTY_STRING;
+ /**
+ * True if this is a full managed property, rather than just a name value pair
+ * @return
+ */
+ boolean managed() default false;
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Translator.java 2010-05-13 19:04:27 UTC
(rev 2126)
+++ trunk/client/src/main/java/org/teiid/adminapi/Translator.java 2010-05-17 20:23:50 UTC
(rev 2127)
@@ -26,8 +26,6 @@
public String getExecutionFactoryClass();
- public String getCapabilitiesClass();
-
public boolean isImmutable();
public boolean isExceptionOnMaxRows();
@@ -36,9 +34,5 @@
public boolean isXaCapable();
- public String getOverrideCapabilitiesFile();
-
- public void setOverrideCapabilitiesFile(String propsFile);
-
public String getTemplateName();
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java 2010-05-13
19:04:27 UTC (rev 2126)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -21,7 +21,6 @@
*/
package org.teiid.adminapi.impl;
-import java.io.Serializable;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -38,27 +37,23 @@
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="translator"),
properties=ManagementProperties.EXPLICIT)
@XmlAccessorType(XmlAccessType.NONE)
-public class TranslatorMetaData extends AdminObjectImpl implements Translator,
Serializable {
+public class TranslatorMetaData extends AdminObjectImpl implements Translator {
private static final long serialVersionUID = 1680003620274793056L;
public static final String EXECUTION_FACTORY_CLASS =
"execution-factory-class"; //$NON-NLS-1$
- public static final String CAPBILITIES_CLASS = "capabilities-class";
//$NON-NLS-1$
public static final String IMMUTABLE = "immutable"; //$NON-NLS-1$
public static final String EXCEPTION_ON_MAX_ROWS = "exception-on-max-rows";
//$NON-NLS-1$
public static final String MAX_RESULT_ROWS = "max-result-rows"; //$NON-NLS-1$
public static final String XA_CAPABLE = "xa-capable"; //$NON-NLS-1$
- public static final String OVERRIDE_CAPABILITIES_FILE =
"override-capabilities-file"; //$NON-NLS-1$
public static final String NAME = "name"; //$NON-NLS-1$
public static final String TEMPLATE_NAME = "template-name"; //$NON-NLS-1$
// objects are used to keep the jaxb putting verbose xml elements when they are not
defined.
private String executionFactoryClass;
- private String capabilitiesClass;
private boolean immutable = false;
private boolean exceptionOnMaxRows = false;
private int maxResultRows = -1;
private boolean xaCapable = false;
- private String overrideCapabilitiesFile;
private String templateName;
@Override
@@ -74,7 +69,7 @@
}
@Override
- @ManagementProperty(name=EXECUTION_FACTORY_CLASS, description="Connector
Class", mandatory = true)
+ @ManagementProperty(name=EXECUTION_FACTORY_CLASS, description="Execution Factory
Class", mandatory = true)
public String getExecutionFactoryClass() {
return executionFactoryClass;
}
@@ -85,17 +80,6 @@
}
@Override
- @ManagementProperty(name=CAPBILITIES_CLASS, description="The class to use to
provide the Connector Capabilities")
- public String getCapabilitiesClass() {
- return capabilitiesClass;
- }
-
- @XmlElement(name = CAPBILITIES_CLASS)
- public void setCapabilitiesClass(String arg0) {
- this.capabilitiesClass = arg0;
- }
-
- @Override
@ManagementProperty(name=IMMUTABLE, description="Is Immutable, True if the source
never changes.",mandatory=true, defaultValue="false")
public boolean isImmutable() {
return immutable;
@@ -140,17 +124,6 @@
}
@Override
- @ManagementProperty(name=OVERRIDE_CAPABILITIES_FILE, description="Property file
that defines the override capability properties")
- public String getOverrideCapabilitiesFile() {
- return this.overrideCapabilitiesFile;
- }
-
- @XmlElement(name = OVERRIDE_CAPABILITIES_FILE)
- public void setOverrideCapabilitiesFile(String propsFile) {
- this.overrideCapabilitiesFile = propsFile;
- }
-
- @Override
@XmlElement(name = "translator-property", type = PropertyMetadata.class)
@ManagementProperty(name="translator-property", description = "Translator
Properties", managed=true)
@ManagementPropertyFactory(TranslatorPropertyFactory.class)
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -142,9 +142,17 @@
private String databaseTimeZone;
private boolean trimStrings;
private boolean useCommentsInSourceQuery;
- private int fetchSize;
+ private int fetchSize = 1024;
boolean initialConnection = true;
+
+ public JDBCExecutionFactory() {
+ setSupportsFullOuterJoins(true);
+ setSupportsOrderBy(true);
+ setSupportsOuterJoins(true);
+ setSupportsSelectDistinct(true);
+ setSupportsInnerJoins(true);
+ }
@Override
public void start() throws TranslatorException {
@@ -159,8 +167,8 @@
}
}
- @TranslatorProperty(name="UseBindVariables", display="Use Bind
Variables", description="Use prepared statements and bind
variables",advanced=true, defaultValue="false")
- public boolean isUseBindVariables() {
+ @TranslatorProperty(display="Use Bind Variables", description="Use
prepared statements and bind variables",advanced=true)
+ public boolean useBindVariables() {
return this.useBindVariables;
}
@@ -168,7 +176,7 @@
this.useBindVariables = useBindVariables;
}
- @TranslatorProperty(name="DatabaseTimeZone", display="Database time
zone", description="Time zone of the database, if different than Integration
Server", advanced=true)
+ @TranslatorProperty(display="Database time zone", description="Time zone
of the database, if different than Integration Server", advanced=true)
public String getDatabaseTimeZone() {
return this.databaseTimeZone;
}
@@ -177,7 +185,7 @@
this.databaseTimeZone = databaseTimeZone;
}
- @TranslatorProperty(name="TrimStrings",display="Trim string flag",
description="Right Trim fixed character types returned as Strings - note that the
native type must be char or nchar and the source must support the rtrim
function.",advanced=true, defaultValue="false")
+ @TranslatorProperty(display="Trim string flag", description="Right Trim
fixed character types returned as Strings - note that the native type must be char or
nchar and the source must support the rtrim function.",advanced=true)
public boolean isTrimStrings() {
return this.trimStrings;
}
@@ -186,8 +194,8 @@
this.trimStrings = trimStrings;
}
- @TranslatorProperty(name="UseCommentsInSourceQuery", display="Use
informational comments in Source Queries", description="This will embed
/*comment*/ style comment with session/request id in source SQL query for informational
purposes", advanced=true, defaultValue="false")
- public boolean isUseCommentsInSourceQuery() {
+ @TranslatorProperty(display="Use informational comments in Source Queries",
description="This will embed /*comment*/ style comment with session/request id in
source SQL query for informational purposes", advanced=true)
+ public boolean useCommentsInSourceQuery() {
return this.useCommentsInSourceQuery;
}
@@ -196,7 +204,7 @@
}
- @TranslatorProperty(name="FetchSize", display="FetCh Size",
description="fetch size used from the connector to its underlying source.",
advanced=true, defaultValue="1024")
+ @TranslatorProperty(display="Fetch Size", description="fetch size used
from the connector to its underlying source.", advanced=true)
public int getFetchSize() {
return this.fetchSize;
}
@@ -329,7 +337,7 @@
}
@Override
- public boolean supportsAliasedGroup() {
+ public boolean supportsAliasedTable() {
return true;
}
@@ -359,11 +367,6 @@
}
@Override
- public boolean supportsFullOuterJoins() {
- return true;
- }
-
- @Override
public boolean supportsInCriteria() {
return true;
}
@@ -399,21 +402,11 @@
}
@Override
- public boolean supportsOrderBy() {
- return true;
- }
-
- @Override
public boolean supportsOrderByUnrelated() {
return true;
}
@Override
- public boolean supportsOuterJoins() {
- return true;
- }
-
- @Override
public boolean supportsQuantifiedCompareCriteriaAll() {
return true;
}
@@ -429,11 +422,6 @@
}
@Override
- public boolean supportsSelectDistinct() {
- return true;
- }
-
- @Override
public boolean supportsSelfJoins() {
return true;
}
@@ -474,21 +462,11 @@
}
@Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.ANY;
- }
-
- @Override
public boolean supportsHaving() {
return true;
}
@Override
- public boolean supportsInnerJoins() {
- return true;
- }
-
- @Override
public boolean supportsSelectExpression() {
return true;
}
@@ -661,7 +639,7 @@
* indicating the session and request ids.
*/
public boolean addSourceComment() {
- return isUseCommentsInSourceQuery();
+ return useCommentsInSourceQuery();
}
/**
@@ -682,7 +660,7 @@
* can be used to force a literal to be a bind value.
*/
public boolean usePreparedStatements() {
- return isUseBindVariables();
+ return useBindVariables();
}
/**
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -33,6 +33,12 @@
*/
public class SimpleJDBCExecutionFactory extends JDBCExecutionFactory {
+ public SimpleJDBCExecutionFactory() {
+ setSupportsOuterJoins(false);
+ setSupportsFullOuterJoins(false);
+ setSupportsOrderBy(false);
+ }
+
@Override
public int getMaxInCriteriaSize() {
return 250;
@@ -69,12 +75,7 @@
}
@Override
- public boolean supportsSelectDistinct() {
- return true;
- }
-
- @Override
- public boolean supportsAliasedGroup() {
+ public boolean supportsAliasedTable() {
return false;
}
@@ -84,16 +85,6 @@
}
@Override
- public boolean supportsOuterJoins() {
- return false;
- }
-
- @Override
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- @Override
public boolean supportsBetweenCriteria() {
return false;
}
@@ -125,11 +116,6 @@
}
@Override
- public boolean supportsOrderBy() {
- return false;
- }
-
- @Override
public boolean supportsAggregatesSum() {
return false;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -32,6 +32,10 @@
public class AccessExecutionFactory extends SybaseExecutionFactory {
+ public AccessExecutionFactory() {
+ setSupportsOrderBy(false);
+ }
+
@Override
public String translateLiteralBoolean(Boolean booleanValue) {
if(booleanValue.booleanValue()) {
@@ -46,11 +50,6 @@
}
@Override
- public boolean supportsOrderBy() {
- return false;
- }
-
- @Override
public boolean supportsRowLimit() {
return true;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -46,6 +46,10 @@
private String version = TEN_1;
+ public DerbyExecutionFactory() {
+ setSupportsFullOuterJoins(false); //Derby supports only left and right outer joins.
+ }
+
@Override
public void start() throws TranslatorException {
super.start();
@@ -68,7 +72,7 @@
return version.compareTo(TEN_4) >= 0;
}
- @TranslatorProperty(name="DatabaseVersion", description= "Version of
the postgres", defaultValue=TEN_1)
+ @TranslatorProperty(display="Database Version", description= "Derby
Database Version")
public String getDatabaseVersion() {
return this.version;
}
@@ -183,16 +187,7 @@
return false;
}
- /**
- * Derby supports only left and right outer joins.
- * @since 5.0
- */
@Override
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- @Override
public boolean supportsRowLimit() {
return this.version.compareTo(TEN_5) >= 0;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -49,6 +49,10 @@
*/
public class MySQLExecutionFactory extends JDBCExecutionFactory {
+ public MySQLExecutionFactory() {
+ setSupportsFullOuterJoins(false);
+ }
+
/**
* Adds support for the 2 argument form of padding
*/
@@ -378,11 +382,8 @@
// supportedFunctions.add("VALUES"); //$NON-NLS-1$
return supportedFunctions;
}
+
@Override
- public boolean supportsFullOuterJoins() {
- return false;
- }
- @Override
public boolean supportsAggregatesDistinct() {
return false;
}
@@ -391,6 +392,7 @@
public boolean supportsRowLimit() {
return true;
}
+
@Override
public boolean supportsRowOffset() {
return true;
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -462,7 +462,7 @@
return true;
}
- @TranslatorProperty(name="DatabaseVersion", description= "Version of
the postgres", defaultValue=EIGHT_0)
+ @TranslatorProperty(description= "PostgreSQL Database Version")
public String getDatabaseVersion() {
return this.version;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -35,15 +35,9 @@
public class TeradataExecutionFactory extends JDBCExecutionFactory {
public TeradataExecutionFactory() {
+ setSupportsOuterJoins(false);
}
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
@Override
public List getSupportedFunctions() {
List supportedFunctions = new ArrayList();
Modified:
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java
===================================================================
---
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -75,6 +75,7 @@
import org.teiid.metadata.Column;
import org.teiid.metadata.Table;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.ldap.LDAPExecutionFactory.SearchDefaultScope;
@@ -326,7 +327,10 @@
// if there is no search scope specified
// try the default in the connector properties
if(searchScopeString.equals("")) { //$NON-NLS-1$
- searchScopeString = this.executionFactory.getSearchDefaultScope();
+ SearchDefaultScope searchDefaultScope =
this.executionFactory.getSearchDefaultScope();
+ if (searchDefaultScope != null) {
+ searchScopeString = searchDefaultScope.name();
+ }
// protect against getting null back from the property
if(searchScopeString == null) {
searchScopeString = ""; //$NON-NLS-1$
Modified:
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
---
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -43,12 +43,17 @@
*/
public class LDAPExecutionFactory extends ExecutionFactory {
+ public enum SearchDefaultScope {
+ SUBTREE_SCOPE,
+ OBJECT_SCOPE,
+ ONELEVEL_SCOPE
+ }
+
private String searchDefaultBaseDN;
- private boolean restrictToObjectClass = false;
- private String searchDefaultScope = "SUBTREE_SCOPE"; //$NON-NLS-1$
+ private boolean restrictToObjectClass;
+ private SearchDefaultScope searchDefaultScope = SearchDefaultScope.ONELEVEL_SCOPE;
-
- @TranslatorProperty(name="SearchDefaultBaseDN", display="Default
Search Base DN", description="Default Base DN for LDAP
Searches",advanced=true, defaultValue="")
+ @TranslatorProperty(display="Default Search Base DN",
description="Default Base DN for LDAP Searches",required=true)
public String getSearchDefaultBaseDN() {
return searchDefaultBaseDN;
}
@@ -57,7 +62,7 @@
this.searchDefaultBaseDN = searchDefaultBaseDN;
}
- @TranslatorProperty(name="RestrictToObjectClass", display="Restrict
Searches To Named Object Class", description="Restrict Searches to objectClass
named in the Name field for a table", advanced=true, defaultValue="false")
+ @TranslatorProperty(display="Restrict Searches To Named Object Class",
description="Restrict Searches to objectClass named in the Name field for a
table", advanced=true)
public boolean isRestrictToObjectClass() {
return restrictToObjectClass;
}
@@ -66,12 +71,12 @@
this.restrictToObjectClass = restrictToObjectClass;
}
- @TranslatorProperty(name="SearchDefaultScope", display="Default Search
Scope", description="Default Scope for LDAP Searches",
allowed={"OBJECT_SCOPE","ONELEVEL_SCOPE","SUBTREE_SCOPE"},required=true,
defaultValue="SUBTREE_SCOPE")
- public String getSearchDefaultScope() {
+ @TranslatorProperty(display="Default Search Scope", description="Default
Scope for LDAP Searches")
+ public SearchDefaultScope getSearchDefaultScope() {
return searchDefaultScope;
}
- public void setSearchDefaultScope(String searchDefaultScope) {
+ public void setSearchDefaultScope(SearchDefaultScope searchDefaultScope) {
this.searchDefaultScope = searchDefaultScope;
}
@@ -123,12 +128,6 @@
}
@Override
- public boolean supportsOrderBy() {
- // Removed this support -- see LDAPSyncQueryExecution comments for details.
- return false;
- }
-
- @Override
public boolean supportsRowLimit() {
// GHH 20080408 - turned this on, because I fixed issue
// in nextBatch that was causing this to fail
Modified:
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
===================================================================
---
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -43,7 +43,15 @@
private boolean throwError = false;
private long pollIntervalInMilli = -1;
- @TranslatorProperty(name="wait-time", display="Max Random Wait
Time",required=true, advanced=true, defaultValue="0")
+ public LoopbackExecutionFactory() {
+ setSupportsFullOuterJoins(true);
+ setSupportsOrderBy(true);
+ setSupportsOuterJoins(true);
+ setSupportsSelectDistinct(true);
+ setSupportsInnerJoins(true);
+ }
+
+ @TranslatorProperty(display="Max Random Wait Time", advanced=true)
public int getWaitTime() {
return waitTime;
}
@@ -52,7 +60,7 @@
this.waitTime = waitTime.intValue();
}
- @TranslatorProperty(name="row-count", display="Rows Per
Query",required=true, advanced=true, defaultValue="1")
+ @TranslatorProperty(display="Rows Per Query", advanced=true)
public int getRowCount() {
return rowCount;
}
@@ -61,7 +69,7 @@
this.rowCount = rowCount;
}
- @TranslatorProperty(name="throw-error", display="Always Throw
Error", defaultValue="false")
+ @TranslatorProperty(display="Always Throw Error")
public boolean isThrowError() {
return this.throwError;
}
@@ -70,7 +78,7 @@
this.throwError = error.booleanValue();
}
- @TranslatorProperty(name="poll-intervel", display="Poll interval if using
a Asynchronous Connector", defaultValue="-1")
+ @TranslatorProperty(display="Poll interval if using a Asynchronous
Connector")
public long getPollIntervalInMilli() {
return this.pollIntervalInMilli;
}
@@ -154,7 +162,7 @@
}
@Override
- public boolean supportsAliasedGroup() {
+ public boolean supportsAliasedTable() {
return true;
}
@@ -184,11 +192,6 @@
}
@Override
- public boolean supportsFullOuterJoins() {
- return true;
- }
-
- @Override
public boolean supportsInCriteria() {
return true;
}
@@ -224,16 +227,6 @@
}
@Override
- public boolean supportsOrderBy() {
- return true;
- }
-
- @Override
- public boolean supportsOuterJoins() {
- return true;
- }
-
- @Override
public boolean supportsQuantifiedCompareCriteriaAll() {
return true;
}
@@ -249,14 +242,10 @@
}
@Override
- public boolean supportsSelectDistinct() {
- return true;
- }
-
- @Override
public boolean supportsSelfJoins() {
return true;
}
+
@Override
public boolean supportsInlineViews() {
return true;
@@ -292,11 +281,6 @@
}
@Override
- public boolean supportsInnerJoins() {
- return true;
- }
-
- @Override
public boolean supportsExcept() {
return true;
}
Modified:
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
---
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -51,8 +51,15 @@
private String connectorStateClass;
private boolean auditModelFields = false;
-
+ public SalesForceExecutionFactory() {
+ //
http://jira.jboss.org/jira/browse/JBEDSP-306
+ // Salesforce supports ORDER BY, but not on all column types
+ setSupportsOrderBy(false);
+ setSupportsOuterJoins(true);
+ setSupportedJoinCriteria(SupportedJoinCriteria.KEY);
+ }
+
public String getConnectorStateClass() {
return this.connectorStateClass;
}
@@ -60,7 +67,7 @@
this.connectorStateClass = connectorStateClass;
}
- @TranslatorProperty(name="ModelAuditFields", display="Audit Model
Fields", advanced=true, defaultValue="false")
+ @TranslatorProperty(display="Audit Model Fields", advanced=true)
public boolean isModelAuditFields() {
return this.auditModelFields;
}
@@ -140,14 +147,7 @@
return true;
}
- //
http://jira.jboss.org/jira/browse/JBEDSP-306
- // Salesforce supports ORDER BY, but not on all column types
@Override
- public boolean supportsOrderBy() {
- return false;
- }
-
- @Override
public boolean supportsAggregatesCountStar() {
return true;
}
@@ -167,13 +167,4 @@
return true;
}
- @Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.KEY;
- }
-
- @Override
- public boolean supportsOuterJoins() {
- return true;
- }
}
Modified:
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java
===================================================================
---
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -72,7 +72,7 @@
initMetaDataProps();
}
- @TranslatorProperty(name="EnforceColumnCount", display="Enforce Column
Count",description="This forces the number of columns in text file to match what
was modeled", defaultValue="false")
+ @TranslatorProperty(display="Enforce Column Count",description="This
forces the number of columns in text file to match what was modeled")
public boolean isEnforceColumnCount() {
return enforceColumnCount;
}
@@ -81,7 +81,7 @@
this.enforceColumnCount = enforceColumnCount.booleanValue();
}
- @TranslatorProperty(name="DateResultFormatsDelimiter", display="Date
Result Formats Delimiter", advanced=true)
+ @TranslatorProperty(display="Date Result Formats Delimiter", advanced=true)
public String getDateResultFormatsDelimiter() {
return dateResultFormatsDelimiter;
}
@@ -90,7 +90,7 @@
this.dateResultFormatsDelimiter = dateResultFormatsDelimiter;
}
- @TranslatorProperty(name="DateResultFormats", display="Date Result
Formats",advanced=true)
+ @TranslatorProperty(display="Date Result Formats",advanced=true)
public String getDateResultFormats() {
return dateResultFormats;
}
@@ -99,7 +99,7 @@
this.dateResultFormats = dateResultFormats;
}
- @TranslatorProperty(name="DescriptorFile", display="Descriptor
File",required=true)
+ @TranslatorProperty(display="Descriptor File",required=true)
public String getDescriptorFile() {
return descriptorFile;
}
@@ -108,7 +108,7 @@
this.descriptorFile = descriptorFile;
}
- @TranslatorProperty(name="Encoding", display="File
Encoding",advanced=true)
+ @TranslatorProperty(display="File Encoding",advanced=true)
public String getEncoding() {
return encoding;
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -28,7 +28,7 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
-import org.teiid.translator.TranslatorCapabilities;
+import org.teiid.translator.ExecutionFactory;
/**
@@ -40,16 +40,16 @@
private CapabilitiesConverter() {
}
- public static SourceCapabilities convertCapabilities(TranslatorCapabilities srcCaps)
{
+ public static SourceCapabilities convertCapabilities(ExecutionFactory srcCaps) {
return convertCapabilities(srcCaps, null, false);
}
- public static BasicSourceCapabilities convertCapabilities(TranslatorCapabilities
srcCaps, String connectorID, boolean isXa) {
+ public static BasicSourceCapabilities convertCapabilities(ExecutionFactory srcCaps,
String connectorID, boolean isXa) {
BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION,
srcCaps.supportsSelectExpression());
tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT,
srcCaps.supportsSelectDistinct());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS,
srcCaps.supportsAliasedGroup());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS,
srcCaps.supportsAliasedTable());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER,
srcCaps.supportsInnerJoins());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN,
srcCaps.supportsSelfJoins());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER,
srcCaps.supportsOuterJoins());
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-05-13
19:04:27 UTC (rev 2126)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -56,11 +56,10 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Scope;
import org.teiid.query.sql.lang.Command;
-import org.teiid.translator.TranslatorCapabilities;
-import org.teiid.translator.TranslatorException;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.TranslatorException;
/**
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -45,7 +45,7 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
-import org.teiid.translator.TranslatorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
/**
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -52,7 +52,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.Permutation;
-import org.teiid.translator.TranslatorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
/**
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -54,7 +54,7 @@
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.util.CommandContext;
-import org.teiid.translator.TranslatorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
public final class RuleRaiseAccess implements OptimizerRule {
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -27,7 +27,7 @@
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.unittest.FakeMetadataFactory;
-import org.teiid.translator.TranslatorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
public class TestJoinPushdownRestrictions {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java 2010-05-13
19:04:27 UTC (rev 2126)
+++ trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -21,6 +21,8 @@
*/
package org.teiid.deployers;
+import java.io.Serializable;
+import java.lang.reflect.Method;
import java.util.HashSet;
import org.jboss.managed.api.Fields;
@@ -31,15 +33,68 @@
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.translator.TranslatorProperty;
public class ManagedPropertyUtil {
+ private static final String[] EMPTY_ALLOWED = new String[0];
private static final String TEIID_PROPERTY = "teiid-property"; //$NON-NLS-1$
- public static ManagedProperty convert(TranslatorProperty prop) {
- return createProperty(prop.name(), SimpleMetaType.resolve(prop.type().getName()),
- prop.display(), prop.description(), prop.required(), prop.readOnly(),
prop.defaultValue(),
- prop.advanced(), prop.masked(), prop.allowed());
+ public static ManagedProperty convert(Object instance, Method method, TranslatorProperty
prop) {
+ Class<?> type = method.getReturnType();
+ String[] allowedValues = EMPTY_ALLOWED;
+ Method getter = null;
+ boolean readOnly = false;
+ if (type == Void.TYPE) { //check for setter
+ Class<?>[] types = method.getParameterTypes();
+ if (types.length != 1) {
+ throw new TeiidRuntimeException("TranslatorProperty annotation should be placed
on valid getter or setter method, " + method + " is not valid.");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ type = types[0];
+ try {
+ getter = instance.getClass().getMethod("get" + method.getName(),
(Class[])null); //$NON-NLS-1$
+ } catch (Exception e) {
+ try {
+ getter = instance.getClass().getMethod("get" +
method.getName().substring(3), (Class[])null); //$NON-NLS-1$
+ } catch (Exception e1) {
+ //can't find getter, won't set the default value
+ }
+ }
+ } else if (method.getParameterTypes().length != 0) {
+ throw new TeiidRuntimeException("TranslatorProperty annotation should be placed
on valid getter or setter method, " + method + " is not valid.");
//$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ getter = method;
+ try {
+ TranslatorDeployer.getSetter(instance.getClass(), method);
+ } catch (Exception e) {
+ readOnly = true;
+ }
+ }
+ Object defaultValue = null;
+ if (!prop.required() && getter != null) {
+ try {
+ defaultValue = getter.invoke(instance, (Object[])null);
+ } catch (Exception e) {
+ //no simple default value
+ }
+ }
+ if (type.isEnum()) {
+ Object[] constants = type.getEnumConstants();
+ allowedValues = new String[constants.length];
+ for( int i=0; i<constants.length; i++ ) {
+ allowedValues[i] = ((Enum<?>)constants[i]).name();
+ }
+ type = String.class;
+ if (defaultValue != null) {
+ defaultValue = ((Enum<?>)defaultValue).name();
+ }
+ }
+ if (!(defaultValue instanceof Serializable)) {
+ defaultValue = null; //TODO
+ }
+ return createProperty(TranslatorDeployer.getPropertyName(method),
SimpleMetaType.resolve(type.getName()),
+ prop.display(), prop.description(), prop.required(), readOnly,
(Serializable)defaultValue,
+ prop.advanced(), prop.masked(), allowedValues);
}
public static ManagedProperty convert(ExtendedPropertyMetadata prop) {
@@ -50,7 +105,7 @@
public static ManagedProperty createProperty(String name,
MetaType type, String displayName, String description,
- boolean mandatory, boolean readOnly, String defaultValue) {
+ boolean mandatory, boolean readOnly, Serializable defaultValue) {
DefaultFieldsImpl fields = new DefaultFieldsImpl(name);
fields.setDescription(description);
@@ -68,7 +123,7 @@
public static ManagedProperty createProperty(String name,
SimpleMetaType type, String displayName, String description,
- boolean mandatory, boolean readOnly, String defaultValue, boolean advanced,
+ boolean mandatory, boolean readOnly, Serializable defaultValue, boolean advanced,
boolean masked, String[] allowed) {
ManagedProperty mp = createProperty(name, type, displayName, description, mandatory,
readOnly, defaultValue);
Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java 2010-05-13
19:04:27 UTC (rev 2126)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -28,10 +28,10 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.impl.TranslatorMetaData;
import org.teiid.core.TeiidException;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.core.util.StringUtil;
import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -108,43 +108,58 @@
throw new DeploymentException(e);
} catch (IllegalAccessException e) {
throw new DeploymentException(e);
+ }
+ }
+
+ public static String getPropertyName(Method method) {
+ String result = method.getName();
+ if (result.startsWith("get") || result.startsWith("set")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ return result.substring(3);
+ }
+ else if (result.startsWith("is")) { //$NON-NLS-1$
+ return result.substring(2);
+ }
+ return result;
+ }
+
+ public static Method getSetter(Class<?> clazz, Method method) throws
SecurityException, DeploymentException {
+ String setter = method.getName();
+ if (method.getName().startsWith("get")) { //$NON-NLS-1$
+ setter = "set"+setter.substring(3);//$NON-NLS-1$
+ }
+ else if (method.getName().startsWith("is")) { //$NON-NLS-1$
+ setter = "set"+setter.substring(2); //$NON-NLS-1$
+ }
+ try {
+ return clazz.getMethod(setter, method.getReturnType());
} catch (NoSuchMethodException e) {
- throw new DeploymentException(e);
+ throw new DeploymentException(RuntimePlugin.Util.getString("no_set_method",
setter, method.getName())); //$NON-NLS-1$
}
}
-
- private void injectProperties(ExecutionFactory ef, final TranslatorMetaData data) throws
InvocationTargetException, IllegalAccessException, NoSuchMethodException,
DeploymentException{
+
+ private void injectProperties(ExecutionFactory ef, final TranslatorMetaData data) throws
InvocationTargetException, IllegalAccessException, DeploymentException{
Map<Method, TranslatorProperty> props =
TranslatorPropertyUtil.getTranslatorProperties(ef.getClass());
for (Method method:props.keySet()) {
TranslatorProperty tp = props.get(method);
- Object value = data.getPropertyValue(tp.name());
- if (value == null) {
- Method[] sourceMethods = data.getClass().getMethods();
- for (Method sm:sourceMethods) {
- ManagementProperty mp = sm.getAnnotation(ManagementProperty.class);
- if (mp != null && mp.name().equals(tp.name())) {
- value = sm.invoke(data);
- break;
- }
- }
+ if (tp.managed()) {
+ continue;
}
+ String propertyName = getPropertyName(method);
+ Object value = data.getPropertyValue(propertyName);
if (value != null) {
- String setter = method.getName();
- if (method.getName().startsWith("get")) { //$NON-NLS-1$
- setter = "set"+method.getName().substring(3);//$NON-NLS-1$
- }
- else if (method.getName().startsWith("is")) { //$NON-NLS-1$
- setter = "set"+method.getName().substring(2); //$NON-NLS-1$
- }
- Method setterMethod = ef.getClass().getMethod(setter, method.getReturnType());
- if (setterMethod == null) {
- throw new
DeploymentException(RuntimePlugin.Util.getString("no_set_method", setter,
tp.name())); //$NON-NLS-1$
- }
+ Method setterMethod = getSetter(ef.getClass(), method);
setterMethod.invoke(ef, convert(value, method.getReturnType()));
+ } else if (tp.required()) {
+ throw new
DeploymentException(RuntimePlugin.Util.getString("required_property_not_exists",
tp.display())); //$NON-NLS-1$
}
}
+
+ ef.setExceptionOnMaxRows(data.isExceptionOnMaxRows());
+ ef.setImmutable(data.isImmutable());
+ ef.setMaxResultRows(data.getMaxResultRows());
+ ef.setXaCapable(data.isXaCapable());
}
public void setTranslatorRepository(TranslatorRepository repo) {
@@ -155,31 +170,14 @@
this.vdbChecker = checker;
}
- Object convert(Object value, Class type) {
+ Object convert(Object value, Class<?> type) {
if(value.getClass() == type) {
return value;
}
if (value instanceof String) {
String str = (String)value;
- if (type == int.class || type == Integer.class) {
- return Integer.parseInt(str);
- }
- else if (type == boolean.class || type == Boolean.class) {
- return Boolean.parseBoolean(str);
- }
- else if (type == long.class || type == Long.class) {
- return Long.parseLong(str);
- }
- else if (type == byte.class || type == Byte.class) {
- return Byte.parseByte(str);
- }
- else if (type == short.class || type == Short.class) {
- return Short.parseShort(str);
- }
- else if (type == float.class || type == Float.class) {
- return Float.parseFloat(str);
- }
+ return StringUtil.valueOf(str, type);
}
return value;
}
Modified:
trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java
===================================================================
---
trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java 2010-05-13
19:04:27 UTC (rev 2126)
+++
trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -23,7 +23,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -48,20 +47,26 @@
*/
public DeploymentTemplateInfo createTemplateInfo(Class<? extends
DeploymentTemplateInfo> infoClass, Class<?> attachmentClass, String name, String
description) throws Exception {
+ Map<String, ManagedProperty> infoProps = getProperties(attachmentClass);
+ Class<?>[] parameterTypes = { String.class, String.class, Map.class };
+ Constructor<? extends DeploymentTemplateInfo> ctor =
infoClass.getConstructor(parameterTypes);
+ DeploymentTemplateInfo info = ctor.newInstance(name, description,infoProps);
+ return info;
+ }
+
+ public static Map<String, ManagedProperty> getProperties(
+ Class<?> attachmentClass)
+ throws InstantiationException, IllegalAccessException {
Map<Method, TranslatorProperty> props =
TranslatorPropertyUtil.getTranslatorProperties(attachmentClass);
Map<String, ManagedProperty> infoProps = new HashMap<String,
ManagedProperty>();
- Collection<TranslatorProperty> propertyInfos = props.values();
- if (propertyInfos != null && !propertyInfos.isEmpty()) {
- for (TranslatorProperty propertyInfo : propertyInfos) {
- ManagedProperty mp = ManagedPropertyUtil.convert(propertyInfo);
- infoProps.put(mp.getName(), mp);
- }
+ Object factory = attachmentClass.newInstance();
+
+ for (Map.Entry<Method, TranslatorProperty> entry : props.entrySet()) {
+ ManagedProperty mp = ManagedPropertyUtil.convert(factory, entry.getKey(),
entry.getValue());
+ infoProps.put(mp.getName(), mp);
}
- Class<?>[] parameterTypes = { String.class, String.class, Map.class };
- Constructor<? extends DeploymentTemplateInfo> ctor =
infoClass.getConstructor(parameterTypes);
- DeploymentTemplateInfo info = ctor.newInstance(name, description,infoProps);
- return info;
+ return infoProps;
}
}
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2010-05-13 19:04:27
UTC (rev 2126)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2010-05-17 20:23:50
UTC (rev 2127)
@@ -303,6 +303,6 @@
class_not_found=Class {0} not found.
translator_stopped=Teiid translator "{0}" stopped
no_set_method=No {0} method found for translator property {1}
-required_property_not_exists=Required property "{0}" and its value not
specified. Deployment is incomplete.
+required_property_not_exists=Required property "{0}" has no value. Deployment
is incomplete.
name_not_found=Translator property "name" not defined for the deployment
"{0}"
executionfactory_not_found=Translator "execution-factory-class" property not
defined for deployment "{0}"
\ No newline at end of file
Added: trunk/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java
(rev 0)
+++
trunk/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java 2010-05-17
20:23:50 UTC (rev 2127)
@@ -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.deployers;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.junit.Test;
+import org.teiid.deployers.TestManagedPropertyUtil.FakeExecutionFactory.PropEnum;
+import org.teiid.templates.TranslatorTemplateInfoFactory;
+import org.teiid.translator.TranslatorProperty;
+
+@SuppressWarnings("nls")
+public class TestManagedPropertyUtil {
+
+ public static class FakeExecutionFactory {
+
+ public enum PropEnum {
+ A, B, C
+ }
+
+ private PropEnum val = PropEnum.A;
+
+ @TranslatorProperty(display="Read Only")
+ public int readonly() {
+ return 1;
+ }
+
+ @TranslatorProperty(display="Setter Property")
+ public void x(@SuppressWarnings("unused") String y) {
+
+ }
+
+ @TranslatorProperty(display="Enum Property")
+ public PropEnum getEnum() {
+ return val;
+ }
+
+ public void setEnum(PropEnum value) {
+ this.val = value;
+ }
+
+ }
+
+ @Test public void testAnnotationProcessing() throws Exception {
+ FakeExecutionFactory ef = new FakeExecutionFactory();
+
+ Map<String, ManagedProperty> properties =
TranslatorTemplateInfoFactory.getProperties(ef.getClass());
+ ManagedProperty mp = properties.get("readonly");
+ assertTrue(mp.isReadOnly());
+ assertEquals(Integer.valueOf(1),
MetaValueFactory.getInstance().unwrap(mp.getDefaultValue()));
+
+ mp = properties.get("x");
+ assertFalse(mp.isReadOnly());
+ assertNull(mp.getDefaultValue());
+
+ mp = properties.get("Enum");
+ assertFalse(mp.isReadOnly());
+ assertEquals(PropEnum.A.name(),
MetaValueFactory.getInstance().unwrap(mp.getDefaultValue()));
+ }
+
+}
Property changes on:
trunk/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain