@Override @TranslatorProperty(display="Direct Query Procedure Name", advanced=true) public String getDirectQueryProcedureName() { return delegate.getDirectQueryProcedureName(); } public void setDirectQueryProcedureName(String name) {
/** * Create an execution object for the specified command * @param command the command * @param executionContext Provides information about the context that this command is * executing within, such as the identifiers for the command being executed * @param metadata Access to runtime metadata if needed to translate the command * @param connection connection factory object to the data source * @return An execution object that can use to execute the command */ public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, C connection) throws TranslatorException { if (command instanceof Call) { Call obj = (Call)command; //TODO: our extension property support in designer makes ad-hoc properties impossible, so //we just match based upon name. it would be better to have the metadatarepository/tooling add a teiid property //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 (supportsDirectQueryProcedure() && obj.getMetadataObject().getName().equals(getDirectQueryProcedureName())) { List<Argument> arguments = obj.getArguments(); return createDirectExecution(arguments, command, executionContext, metadata, connection); } } if (command instanceof QueryExpression) { return createResultSetExecution((QueryExpression)command, executionContext, metadata, connection); } if (command instanceof Call) { return createProcedureExecution((Call)command, executionContext, metadata, connection); } return createUpdateExecution(command, executionContext, metadata, connection); }
@Override public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException { if (executionFactory != null && executionFactory.supportsDirectQueryProcedure() && factory.getSchema().getProcedure(executionFactory.getDirectQueryProcedureName()) == null) { Procedure p = factory.addProcedure(executionFactory.getDirectQueryProcedureName()); p.setAnnotation("Invokes translator with a native query that returns results in an array of values"); //$NON-NLS-1$ ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$ param.setAnnotation("The native query to execute"); //$NON-NLS-1$ param.setNullType(NullType.No_Nulls); param = factory.addProcedureParameter("variable", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$ param.setAnnotation("Any number of varaibles; usage will vary by translator"); //$NON-NLS-1$ param.setNullType(NullType.Nullable); param.setVarArg(true); factory.addProcedureResultSetColumn("tuple", DataTypeManager.getDataTypeName(DataTypeManager.getArrayType(TypeFacility.RUNTIME_TYPES.OBJECT)), p); //$NON-NLS-1$ } } }
@Override public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException { if (executionFactory != null && executionFactory.supportsDirectQueryProcedure() && factory.getSchema().getProcedure(executionFactory.getDirectQueryProcedureName()) == null) { Procedure p = factory.addProcedure(executionFactory.getDirectQueryProcedureName()); p.setAnnotation("Invokes translator with a native query that returns results in an array of values"); //$NON-NLS-1$ ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$ param.setAnnotation("The native query to execute"); //$NON-NLS-1$ param.setNullType(NullType.No_Nulls); param = factory.addProcedureParameter("variable", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$ param.setAnnotation("Any number of varaibles; usage will vary by translator"); //$NON-NLS-1$ param.setNullType(NullType.Nullable); param.setVarArg(true); factory.addProcedureResultSetColumn("tuple", DataTypeManager.getDataTypeName(DataTypeManager.getArrayType(TypeFacility.RUNTIME_TYPES.OBJECT)), p); //$NON-NLS-1$ } } }
@Override public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException { if (executionFactory != null && executionFactory.supportsDirectQueryProcedure() && factory.getSchema().getProcedure(executionFactory.getDirectQueryProcedureName()) == null) { Procedure p = factory.addProcedure(executionFactory.getDirectQueryProcedureName()); p.setAnnotation("Invokes translator with a native query that returns results in an array of values"); //$NON-NLS-1$ ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$ param.setAnnotation("The native query to execute"); //$NON-NLS-1$ param.setNullType(NullType.No_Nulls); param = factory.addProcedureParameter("variable", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$ param.setAnnotation("Any number of varaibles; usage will vary by translator"); //$NON-NLS-1$ param.setNullType(NullType.Nullable); param.setVarArg(true); factory.addProcedureResultSetColumn("tuple", DataTypeManager.getDataTypeName(DataTypeManager.getArrayType(TypeFacility.RUNTIME_TYPES.OBJECT)), p); //$NON-NLS-1$ } } }