org.teiid.metadata.Procedure类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(14.0k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.teiid.metadata.Procedure类的一些代码示例,展示了Procedure类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Procedure类的具体详情如下:
包路径:org.teiid.metadata.Procedure
类名称:Procedure

Procedure介绍

[英]Represents Teiid and source procedures. Can also represent a function with restrictions.
Parameter positions start with 1 for consistency with BaseColumn.
See also FunctionMethod
[中]表示TEID和源程序。也可以表示有限制的函数。
为了与BaseColumn保持一致,参数位置以1开头。
另请参见函数方法

代码示例

代码示例来源:origin: org.teiid.connectors/translator-jdbc

private boolean isTVF(Procedure proc) {
  String value = proc.getProperty(PIMetadataProcessor.TVF, false);
  return Boolean.parseBoolean(value); 
}

代码示例来源:origin: teiid/teiid

@Override
protected Collection<? extends BaseColumn> getChildren(final Procedure parent, CommandContext cc) {
  Collection<ProcedureParameter> params = parent.getParameters();
  if (parent.getResultSet() == null) {
    return params;
  }
  //TODO: don't incur the gc cost of the temp list
  Collection<Column> rsColumns = parent.getResultSet().getColumns();
  ArrayList<BaseColumn> result = new ArrayList<BaseColumn>(params.size() + rsColumns.size());
  result.addAll(params);
  result.addAll(rsColumns);
  return result;
}

代码示例来源:origin: org.teiid/teiid-engine

@Override
  public void fillRow(List<Object> row, Procedure proc,
      VDBMetaData v, TransformationMetadata metadata,
      CommandContext cc, SimpleIterator<Procedure> iter) {
    row.add(v.getName());
    row.add(proc.getParent().getName());
    row.add(proc.getName());
    row.add(proc.getNameInSource());
    row.add(proc.getResultSet() != null);
    row.add(proc.getUUID());
    row.add(proc.getAnnotation());
    row.add(proc.getParent().getUUID());
  }
});

代码示例来源:origin: teiid/teiid

public Type getType() {
  if (isFunction()) {
    if (isVirtual()) {
      return Type.UDF;
    }
    return Type.Function;
  }
  if (isVirtual()) {
    return Type.StoredQuery;
  }
  return Type.StoredProc;
}

代码示例来源:origin: teiid/teiid

private static void removeProcedureOption(String key, Procedure proc) {
  if (proc.getProperty(key, false) != null) {
    proc.setProperty(key, null);
  }       
  removeCommonProperty(key, proc);
  
  if (key.equals("UPDATECOUNT")) { //$NON-NLS-1$
    proc.setUpdateCount(1);
  }
}

代码示例来源:origin: org.teiid/teiid-engine

public static FunctionMethod createFunctionMethod(Procedure proc) {
  FunctionMethod method = new FunctionMethod();
  method.setName(proc.getName());
  method.setPushdown(proc.isVirtual()?FunctionMethod.PushDown.CAN_PUSHDOWN:FunctionMethod.PushDown.MUST_PUSHDOWN);
  for (ProcedureParameter pp:proc.getParameters()) {
    if (pp.getType() == ProcedureParameter.Type.InOut || pp.getType() == ProcedureParameter.Type.Out) {
      throw new MetadataException(QueryPlugin.Util.getString("SQLParser.function_in", proc.getName())); //$NON-NLS-1$
      throw new MetadataException(QueryPlugin.Util.getString("SQLParser.function_default", proc.getName())); //$NON-NLS-1$
  if (proc.getResultSet() != null || method.getOutputParameter() == null) {
    throw new MetadataException(QueryPlugin.Util.getString("SQLParser.function_return", proc.getName())); //$NON-NLS-1$
  method.setAnnotation(proc.getAnnotation());
  method.setNameInSource(proc.getNameInSource());
  method.setUUID(proc.getUUID());
  Map<String, String> props = proc.getProperties();

代码示例来源:origin: org.teiid/teiid-metadata

for (int i = 0; i < procedureRecord.getParameters().size(); i++) {
  ProcedureParameter paramRecord = (ProcedureParameter) this.getRecordByType(procedureRecord.getParameters().get(i).getUUID(), MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
  setDataType(paramRecord);
  procedureRecord.getParameters().set(i, paramRecord);
  paramRecord.setProcedure(procedureRecord);
ColumnSet<Procedure> result = procedureRecord.getResultSet();
if(result != null) {
  ColumnSet<Procedure> resultRecord = (ColumnSet<Procedure>) getRecordByType(result.getUUID(), MetadataConstants.RECORD_TYPE.RESULT_SET, false);
    resultRecord.setName(RecordFactory.getShortName(resultRecord.getName()));
    loadColumnSetRecords(resultRecord, null);
    procedureRecord.setResultSet(resultRecord);
if (procedureRecord.isFunction()) {
  FunctionParameter outputParam = null;
  List<FunctionParameter> args = new ArrayList<FunctionParameter>(procedureRecord.getParameters().size() - 1);
  boolean valid = true;
  for (ProcedureParameter param : procedureRecord.getParameters()) {
    FunctionParameter fp = new FunctionParameter();
    fp.setName(param.getName());
    FunctionMethod function = new FunctionMethod(procedureRecord.getName(), procedureRecord.getAnnotation(), model.getName(), procedureRecord.isVirtual()?PushDown.CAN_PUSHDOWN:PushDown.MUST_PUSHDOWN, 
        null, null, args, outputParam, false, Determinism.DETERMINISTIC);
    function.setUUID(procedureRecord.getUUID());
    FunctionMethod.convertExtensionMetadata(procedureRecord, function);
    if (function.getInvocationMethod() != null) {
if(procedureRecord.isVirtual()) {

代码示例来源:origin: teiid/teiid

assertNotNull(proc);
assertFalse(proc.isVirtual());
assertFalse(proc.isFunction());
assertEquals(3, proc.getParameters().size());
assertEquals("p1", proc.getParameters().get(0).getName());
assertEquals("boolean", proc.getParameters().get(0).getDatatype().getName());
assertEquals(ProcedureParameter.Type.Out, proc.getParameters().get(0).getType());
assertEquals("p2", proc.getParameters().get(1).getName());
assertEquals("string", proc.getParameters().get(1).getDatatype().getName());
assertEquals(ProcedureParameter.Type.In, proc.getParameters().get(1).getType());
assertEquals("p3", proc.getParameters().get(2).getName());
assertEquals("bigdecimal", proc.getParameters().get(2).getDatatype().getName());
assertEquals(ProcedureParameter.Type.InOut, proc.getParameters().get(2).getType());		
ColumnSet<Procedure> ret = proc.getResultSet();
assertNotNull(ret);
assertEquals(2, ret.getColumns().size());
assertEquals("uuid", proc.getUUID());
assertEquals("nis", proc.getNameInSource());
assertEquals("desc", proc.getAnnotation());
assertEquals(2, proc.getUpdateCount());
assertEquals("any", proc.getProperties().get("RANDOM"));

代码示例来源:origin: teiid/teiid

private void visit(Procedure procedure) {
  append(CREATE).append(SPACE);
  if (procedure.isVirtual()) {
    append(VIRTUAL);
    append(FOREIGN);
  append(SPACE).append(procedure.isFunction()?FUNCTION:PROCEDURE).append(SPACE).append(SQLStringVisitor.escapeSinglePart(procedure.getName()));
  append(LPAREN);
  for (ProcedureParameter pp:procedure.getParameters()) {
    if (first) {
      first = false;
  if (procedure.getResultSet() != null) {
    append(SPACE).append(RETURNS);
    appendOptions(procedure.getResultSet());
    append(SPACE).append(TABLE).append(SPACE);
    addColumns(procedure.getResultSet().getColumns(), true);
  if (procedure.isVirtual()) {
    append(NEWLINE).append(SQLConstants.Reserved.AS).append(NEWLINE);
    String plan = procedure.getQueryPlan();
    append(plan);

代码示例来源:origin: org.jboss.teiid/teiid-engine

private String buildProcedureOptions(Procedure procedure) {
  StringBuilder options = new StringBuilder();
  addCommonOptions(options, procedure);
  
  if (procedure.getUpdateCount() != Procedure.AUTO_UPDATECOUNT) {
    addOption(options, UPDATECOUNT, procedure.getUpdateCount());
  }    
  
  if (!procedure.getProperties().isEmpty()) {
    for (String key:procedure.getProperties().keySet()) {
      addOption(options, key, procedure.getProperty(key, false));
    }
  }        
  
  return options.toString();
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

AbstractMetadataRecord getColumn(String paramName, Procedure proc, boolean parameter) throws MetadataException {
  if (proc.getResultSet() != null) {
    Column result = proc.getResultSet().getColumnByName(paramName);
    if (result != null) {
      return result;
    }
  }
  if (parameter) {
    List<ProcedureParameter> params = proc.getParameters();
    for (ProcedureParameter param:params) {
      if (param.getName().equalsIgnoreCase(paramName)) {
        return param;
      }
    }
  }
  throw new MetadataException(QueryPlugin.Util.getString("SQLParser.alter_procedure_param_doesnot_exist", paramName, proc.getName())); //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

public static void convertExtensionMetadata(Procedure procedureRecord,
    FunctionMethod function) {
  String deterministic = procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "deterministic", true); //$NON-NLS-1$
  boolean nullOnNull = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "null-on-null", true)); //$NON-NLS-1$
  String varargs = procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "varargs", true); //$NON-NLS-1$
  String javaClass = procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "java-class", true); //$NON-NLS-1$
  String javaMethod = procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "java-method", true); //$NON-NLS-1$
  if (function.getInvocationClass() == null) {
    function.setInvocationClass(javaClass);
    function.setInvocationMethod(javaMethod);
  if (!procedureRecord.getParameters().isEmpty()) {
    function.setProperties(procedureRecord.getProperties());
  boolean aggregate = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "aggregate", true)); //$NON-NLS-1$
  if (deterministic != null) {
    function.setDeterminism(Boolean.valueOf(deterministic)?Determinism.DETERMINISTIC:Determinism.NONDETERMINISTIC);
    boolean analytic = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "analytic", true)); //$NON-NLS-1$
    boolean allowsOrderBy = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "allows-orderby", true)); //$NON-NLS-1$
    boolean usesDistinctRows = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "uses-distinct-rows", true)); //$NON-NLS-1$
    boolean allowsDistinct = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "allows-distinct", true)); //$NON-NLS-1$
    boolean decomposable = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "decomposable", true)); //$NON-NLS-1$
    AggregateAttributes aa = new AggregateAttributes();
    aa.setAnalytic(analytic);

代码示例来源:origin: teiid/teiid

public ProcedureParameter getReturnParameter() {
  for (ProcedureParameter param : this.metadataObject.getParameters()) {
    if (param.getType() == Type.ReturnValue) {
      return param;
    }
  }
  return null;
}

代码示例来源:origin: org.teiid/teiid-olingo

private boolean hasResultSet() {
  return this.procedure.getResultSet() != null;
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory,
    Procedure proc) throws MetadataException {
  if (proc.isFunction() && proc.getQueryPlan() != null) {
    return null;
  }
  FunctionMethod method = createFunctionMethod(proc);
  //remove the old proc
  factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1);
  factory.getSchema().getProcedures().remove(proc.getName());
  
  factory.getSchema().addFunction(method);
  return method;
}

代码示例来源:origin: teiid/teiid

@Test 
public void testCreateProcedure() throws Exception {
  String ddl = "CREATE DATABASE FOO;"
      + "USE DATABASE FOO;"
      + "CREATE FOREIGN DATA WRAPPER postgresql;"
      + "CREATE SERVER pgsql TYPE 'custom' FOREIGN DATA WRAPPER postgresql OPTIONS (\"jndi-name\" 'jndiname');"  
      + "CREATE  SCHEMA test SERVER pgsql;"
      + "SET SCHEMA test;"
      + "CREATE FOREIGN PROCEDURE procG1(P1 integer) RETURNS (e1 integer, e2 varchar)";
  
  Database db = helpParse(ddl);
  Schema s = db.getSchema("test");
  Procedure p = s.getProcedure("procG1");
  assertNotNull(p);  
  assertEquals(1, p.getParameters().size());
  assertNotNull(p.getParameterByName("P1"));
  assertEquals(2, p.getResultSet().getColumns().size());
  assertEquals("e1", p.getResultSet().getColumns().get(0).getName());
}

代码示例来源:origin: teiid/teiid

public void alterBaseColumn(String objectName, Database.ResourceType type, String childName, ParsedDataType datatype, boolean autoIncrement, boolean notNull) {
  MetadataFactory factory = DatabaseStore.createMF(this);
  BaseColumn column = null;
  if (type == Database.ResourceType.TABLE){
    Table table = (Table)getSchemaRecord(objectName, type); 
    assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.TABLE, table);
    column = table.getColumnByName(childName);
    if (column == null){
      throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_table_column_found", childName, table.getName())); //$NON-NLS-1$
    }
  } else {
    Procedure proc = (Procedure)getSchemaRecord(objectName, type);
    assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.PROCEDURE, proc);
    column = proc.getParameterByName(childName);
    if (column == null){
      throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_proc_column_found", childName, proc.getName())); //$NON-NLS-1$
    }            
  }
  MetadataFactory.setDataType(datatype.getType(), column, factory.getDataTypes(), notNull);
  SQLParserUtil.setTypeInfo(datatype, column);
  if (notNull) {
    column.setNullType(Column.NullType.No_Nulls);
  }
  if (type == Database.ResourceType.TABLE){
    //must be called after setDataType as that will pull the defaults
    ((Column)column).setAutoIncremented(autoIncrement);
  }
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

@Override
public void visit(AlterProcedure obj) {
  Procedure p = (Procedure)obj.getTarget().getMetadataID();
  String sql = obj.getDefinition().toString();
  if (getMetadataRepository(vdb, p.getParent().getName()) != null) {
    getMetadataRepository(vdb, p.getParent().getName()).setProcedureDefinition(workContext.getVdbName(), workContext.getVdbVersion(), p, sql);
  }
  alterProcedureDefinition(vdb, p, sql, false);
  if (pdm.getEventDistributor() != null) {
    pdm.getEventDistributor().setProcedureDefinition(workContext.getVdbName(), workContext.getVdbVersion(), p.getParent().getName(), p.getName(), sql);
  }
}

代码示例来源:origin: org.teiid/teiid-olingo

public String getName() {
  return procedure.getName();
}

代码示例来源:origin: org.teiid/teiid-olingo

private static void addOperationAnnotations(Procedure proc,
    CsdlOperation operation, CsdlSchema csdlSchema) {
  if (proc.getAnnotation() != null) {
    addStringAnnotation(operation, "Core.Description", proc.getAnnotation());
  }
  
  if (proc.getNameInSource() != null) {
    addStringAnnotation(operation, "teiid.NAMEINSOURCE", proc.getNameInSource());
  }
  if (proc.getUpdateCount() != Procedure.AUTO_UPDATECOUNT) {
    addIntAnnotation(operation, "teiid.UPDATECOUNT", proc.getUpdateCount());
  }   
  // add all custom properties
  for (String str:proc.getProperties().keySet()) {
    addTerm(normalizeTermName(str), new String[] {"Action", "Function"}, csdlSchema);
    addStringAnnotation(operation, csdlSchema.getAlias()+"."+normalizeTermName(str), proc.getProperties().get(str));
  }         
}

相关文章