Skip to content

Commit

Permalink
TEIID-2737 renaming native query procedure to direct query procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Nov 14, 2013
1 parent 9cab7da commit a777f77
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 33 deletions.
Expand Up @@ -446,12 +446,12 @@ public boolean supportsArrayType() {
return delegate.supportsArrayType();
}
@Override
public String getNativeQueryProcedureName() {
return delegate.getNativeQueryProcedureName();
}

public boolean supportsNativeQueries() {
return delegate.supportsNativeQueries();
public String getDirectQueryProcedureName() {
return delegate.getDirectQueryProcedureName();
}
@Override
public boolean supportsDirectQueryProcedure() {
return delegate.supportsDirectQueryProcedure();
}
@Override
public ProcedureExecution createDirectExecution(List<Argument> arguments,
Expand Down
59 changes: 49 additions & 10 deletions api/src/main/java/org/teiid/translator/ExecutionFactory.java
Expand Up @@ -296,7 +296,7 @@ public Execution createExecution(Command command, ExecutionContext executionCont
//to explicitly set this proc as direct.
//the other approach would be to addd a native system stored procedure, but that would require
//special security semantics, whereas this proc can be secured on a schema basis
if (supportsNativeQueries() && obj.getMetadataObject().getName().equals(getNativeQueryProcedureName())) {
if (supportsDirectQueryProcedure() && obj.getMetadataObject().getName().equals(getDirectQueryProcedureName())) {
List<Argument> arguments = obj.getArguments();
return createDirectExecution(arguments, command, executionContext, metadata, connection);
}
Expand Down Expand Up @@ -1102,31 +1102,70 @@ public boolean supportsArrayType() {
}

/**
* True, if this translator supports execution of source specific commands unaltered through 'native' procedure.
* True, if this translator supports execution of source specific commands unaltered through a direct procedure.
* @deprecated
* @see #supportsDirectQueryProcedure()
* @return
*/
@TranslatorProperty(display="Supports Native Queries", description="True, if this translator supports execution of source specific commands unaltered through a 'native' procedure", advanced=true)
public boolean supportsNativeQueries() {
@TranslatorProperty(display="Supports direct query procedure", description="True, if this translator supports execution of source specific commands unaltered through a direct procedure", advanced=true)
final public boolean supportsNativeQueries() {
return this.supportsNativeQueries;
}

public void setSupportsNativeQueries(boolean state) {
/**
* @deprecated
* @see #setSupportsDirectQueryProcedure(boolean)
*/
final public void setSupportsNativeQueries(boolean state) {
this.supportsNativeQueries = state;
}

/**
* True, if this translator supports execution of source specific commands unaltered through a direct procedure.
* @return
*/
@TranslatorProperty(display="Supports direct query procedure", description="True, if this translator supports execution of source specific commands unaltered through a direct procedure", advanced=true)
public boolean supportsDirectQueryProcedure() {
return this.supportsNativeQueries;
}

public void setSupportsDirectQueryProcedure(boolean state) {
this.supportsNativeQueries = state;
}

/**
* Defines the name of the procedure that need to be treated as "native" query processing procedure. This metadata or signature
* Defines the name of the direct processing procedure. This metadata or signature
* of the procedure is defined automatically.
* @deprecated
* @see #getDirectQueryProcedureName()
* @return
*/
@TranslatorProperty(display="Name of the direct query procedure", description="The name of the direct query procedure", advanced=true)
final public String getNativeQueryProcedureName() {
return this.nativeProcedureName;
}

/**
* @deprecated
* @see #setDirectQueryProcedureName(String)
*/
final public void setNativeQueryProcedureName(String name) {
this.nativeProcedureName = name;
}

/**
* Defines the name of the direct processing procedure. This metadata or signature
* of the procedure is defined automatically.
* @return
*/
@TranslatorProperty(display="Name of the native query", description="The name of the direct query procedure", advanced=true)
public String getNativeQueryProcedureName() {
@TranslatorProperty(display="Name of the direct query procedure", description="The name of the direct query procedure", advanced=true)
public String getDirectQueryProcedureName() {
return this.nativeProcedureName;
}

public void setNativeQueryProcedureName(String name) {
public void setDirectQueryProcedureName(String name) {
this.nativeProcedureName = name;
}
}

/**
* @return true if only correlated subqueries are supported.
Expand Down
Expand Up @@ -38,7 +38,7 @@ public class TestBaseDelegatingExecutionFactory {
Method[] methods = ExecutionFactory.class.getDeclaredMethods();
Method[] proxyMethods = BaseDelegatingExecutionFactory.class.getDeclaredMethods();
//excluding the setter methods the counts should be equal
assertEquals(methods.length - 14, proxyMethods.length);
assertEquals(methods.length - 18, proxyMethods.length);
}

@Test public void testExecution() throws TranslatorException {
Expand Down
1 change: 1 addition & 0 deletions build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
Expand Up @@ -45,6 +45,7 @@ <h2><a name="Compatibility">Compatibility Issues</a></h2>
<h4>from 8.5</h4>
<ul>
<li>TEIID-2667 The jdbc importer importKeys parameter is now correctly defaulted to true.
<li>TEIID-2737 The 'native' procedure exposed by translators has been renames as the direct query feature. The related ExecutionFactory methods supportsNativeQueries and nativeQueryProcedure name have been deprecated and replaced with supportsDirectQueryProcedure and directQueryProcedureName.
<ul>

<h4>from 8.4</h4>
Expand Down
Expand Up @@ -48,7 +48,7 @@ public class TestNativeCassandra {

@Test public void testDirect() throws TranslatorException {
CassandraExecutionFactory cef = new CassandraExecutionFactory();
cef.setSupportsNativeQueries(true);
cef.setSupportsDirectQueryProcedure(true);

String input = "call native('select $1', 'a')";

Expand All @@ -75,7 +75,7 @@ public class TestNativeCassandra {

@Test public void testNativeQuery() throws Exception {
CassandraExecutionFactory cef = new CassandraExecutionFactory();
cef.setSupportsNativeQueries(true);
cef.setSupportsDirectQueryProcedure(true);

String input = "call proc('a', 1)";

Expand Down
Expand Up @@ -61,7 +61,7 @@ public class TestJDBCDirectQueryExecution {
Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));

JDBCExecutionFactory ef = new JDBCExecutionFactory();
ef.setSupportsNativeQueries(true);
ef.setSupportsDirectQueryProcedure(true);
ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, Mockito.mock(ExecutionContext.class), Mockito.mock(RuntimeMetadata.class), connection);
execution.execute();
assertArrayEquals(new Object[] {5, "five"}, (Object[])execution.next().get(0));
Expand All @@ -86,7 +86,7 @@ public class TestJDBCDirectQueryExecution {
Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));

JDBCExecutionFactory ef = new JDBCExecutionFactory();
ef.setSupportsNativeQueries(true);
ef.setSupportsDirectQueryProcedure(true);
ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, new FakeExecutionContextImpl(), Mockito.mock(RuntimeMetadata.class), connection);
execution.execute();
assertArrayEquals(new Object[] {5, "five"}, (Object[])execution.next().get(0));
Expand All @@ -108,7 +108,7 @@ public class TestJDBCDirectQueryExecution {
Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));

JDBCExecutionFactory ef = new JDBCExecutionFactory();
ef.setSupportsNativeQueries(true);
ef.setSupportsDirectQueryProcedure(true);
ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, new FakeExecutionContextImpl(), Mockito.mock(RuntimeMetadata.class), connection);
execution.execute();
assertArrayEquals(new Object[] {5}, (Object[])execution.next().get(0));
Expand Down
Expand Up @@ -21,9 +21,7 @@
*/
package org.teiid.translator.jpa;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;

import javax.persistence.EntityManager;
import javax.persistence.Query;
Expand All @@ -47,7 +45,7 @@ public class TestJPADirectQueryExecution {
@BeforeClass
public static void setUp() throws TranslatorException {
TRANSLATOR = new JPA2ExecutionFactory();
TRANSLATOR.setSupportsNativeQueries(true);
TRANSLATOR.setSupportsDirectQueryProcedure(true);
TRANSLATOR.start();
}

Expand Down
Expand Up @@ -47,7 +47,7 @@ public class TestLDAPDirectQueryExecution {
@BeforeClass
public static void setUp() throws TranslatorException {
TRANSLATOR = new LDAPExecutionFactory();
TRANSLATOR.setSupportsNativeQueries(true);
TRANSLATOR.setSupportsDirectQueryProcedure(true);
TRANSLATOR.start();
}

Expand Down
Expand Up @@ -99,7 +99,7 @@ public void start() throws TranslatorException {
super.start();
setSupportsOrderBy(true);
setSupportsSelectDistinct(true);
setSupportsNativeQueries(false);
setSupportsDirectQueryProcedure(false);
setSourceRequiredForMetadata(false);
//setSupportsInnerJoins(true);
setSupportsOuterJoins(true);
Expand Down
Expand Up @@ -48,8 +48,8 @@ public class OlapExecutionFactory extends ExecutionFactory<DataSource, Connectio

public OlapExecutionFactory() {
setSourceRequiredForMetadata(false);
setSupportsNativeQueries(true);
setNativeQueryProcedureName(INVOKE_MDX);
setSupportsDirectQueryProcedure(true);
setDirectQueryProcedureName(INVOKE_MDX);
}

@Override
Expand Down
Expand Up @@ -51,7 +51,7 @@ public class TestSalesForceDirectQueryExecution {
@BeforeClass
public static void setUp() throws TranslatorException {
TRANSLATOR = new SalesForceExecutionFactory();
TRANSLATOR.setSupportsNativeQueries(true);
TRANSLATOR.setSupportsDirectQueryProcedure(true);
TRANSLATOR.start();
}

Expand Down
Expand Up @@ -39,8 +39,8 @@ public class DirectQueryMetadataRepository extends MetadataRepository {
@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {

if (executionFactory != null && executionFactory.supportsNativeQueries()) {
Procedure p = factory.addProcedure(executionFactory.getNativeQueryProcedureName());
if (executionFactory != null && executionFactory.supportsDirectQueryProcedure()) {
Procedure p = factory.addProcedure(executionFactory.getDirectQueryProcedureName());
p.setAnnotation("Invokes translator with a native query that returns results in array of values"); //$NON-NLS-1$

ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
Expand Down

0 comments on commit a777f77

Please sign in to comment.