@Test
  public void testSchema() throws Exception {
    translator = new ODataExecutionFactory();
    translator.start();

    MetadataFactory mf = tripPinMetadata();
    TransformationMetadata metadata = getTransformationMetadata(mf, this.translator);

    String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
    // System.out.println(ddl);

    MetadataFactory mf2 =
        new MetadataFactory(
            null,
            1,
            "northwind",
            SystemMetadata.getInstance().getRuntimeTypeMap(),
            new Properties(),
            null);
    QueryParser.getQueryParser().parseDDL(mf2, ddl);

    Procedure p = mf.getSchema().getProcedure("ResetDataSource");
    assertNotNull(p);
    assertEquals(0, p.getParameters().size());
  }
예제 #2
0
  private void visit(Procedure procedure) {
    if (this.filter != null && !filter.matcher(procedure.getName()).matches()) {
      return;
    }

    append(CREATE).append(SPACE);
    if (procedure.isVirtual()) {
      append(VIRTUAL);
    } else {
      append(FOREIGN);
    }
    append(SPACE)
        .append(procedure.isFunction() ? FUNCTION : PROCEDURE)
        .append(SPACE)
        .append(SQLStringVisitor.escapeSinglePart(procedure.getName()));
    append(LPAREN);

    boolean first = true;
    for (ProcedureParameter pp : procedure.getParameters()) {
      if (first) {
        first = false;
      } else {
        append(COMMA).append(SPACE);
      }
      visit(pp);
    }
    append(RPAREN);

    if (procedure.getResultSet() != null) {
      append(SPACE).append(RETURNS);
      appendOptions(procedure.getResultSet());
      append(SPACE).append(TABLE).append(SPACE);
      addColumns(procedure.getResultSet().getColumns(), true);
    }
    /* The parser treats the RETURN clause as optional for a procedure if using the RESULT param
      for (ProcedureParameter pp: procedure.getParameters()) {
    	if (pp.getType().equals(Type.ReturnValue)) {
    		append(SPACE).append(RETURNS).append(SPACE);
    		appendColumn(buffer, pp, false, true);
    		break;
    	}
    }*/

    // options
    String options = buildProcedureOptions(procedure);
    if (!options.isEmpty()) {
      append(NEWLINE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
    }
    // block
    if (procedure.isVirtual()) {
      append(NEWLINE).append(SQLConstants.Reserved.AS).append(NEWLINE);
      String plan = procedure.getQueryPlan();
      append(plan);
    }

    append(SEMICOLON);
  }
예제 #3
0
  @Test
  public void testStreaming() throws Exception {
    WSExecutionFactory ef = new WSExecutionFactory();
    MetadataFactory mf =
        new MetadataFactory(
            "vdb",
            1,
            "x",
            SystemMetadata.getInstance().getRuntimeTypeMap(),
            new Properties(),
            null);
    ef.getMetadata(mf, null);
    Procedure p = mf.getSchema().getProcedure(WSExecutionFactory.INVOKE_HTTP);
    assertEquals(7, p.getParameters().size());

    TransformationMetadata tm =
        RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "vdb");
    RuntimeMetadataImpl rm = new RuntimeMetadataImpl(tm);
    WSConnection mockConnection = Mockito.mock(WSConnection.class);
    Dispatch<Object> mockDispatch = mockDispatch();
    DataSource mock = Mockito.mock(DataSource.class);
    ByteArrayInputStream baos = new ByteArrayInputStream(new byte[100]);
    Mockito.stub(mock.getInputStream()).toReturn(baos);
    Mockito.stub(mockDispatch.invoke(Mockito.any(DataSource.class))).toReturn(mock);
    Mockito.stub(
            mockConnection.createDispatch(
                Mockito.any(String.class),
                Mockito.any(String.class),
                Mockito.any(Class.class),
                Mockito.any(Service.Mode.class)))
        .toReturn(mockDispatch);
    CommandBuilder cb = new CommandBuilder(tm);

    Call call = (Call) cb.getCommand("call invokeHttp('GET', null, null, true)");
    BinaryWSProcedureExecution pe =
        new BinaryWSProcedureExecution(
            call, rm, Mockito.mock(ExecutionContext.class), ef, mockConnection);
    pe.execute();
    List<?> result = pe.getOutputParameterValues();

    Blob b = (Blob) result.get(0);
    assertEquals(100, ObjectConverterUtil.convertToByteArray(b.getBinaryStream()).length);
    try {
      ObjectConverterUtil.convertToByteArray(b.getBinaryStream());
      fail();
    } catch (SQLException e) {
      // should only be able to read once
    }
  }
예제 #4
0
  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();
  }
  @Test
  public void testAction() throws Exception {
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("Edm.String");

    MetadataFactory mf = actionMetadata("invoke", returnType, null);
    Procedure p = mf.getSchema().getProcedure("invoke");
    assertNotNull(p);
    assertEquals(3, p.getParameters().size());
    assertNull(p.getResultSet());
    assertNotNull(getReturnParameter(p));
    ProcedureParameter pp = getReturnParameter(p);
    assertEquals("string", pp.getRuntimeType());
    ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.ACTION, type);
  }
 private ProcedureParameter getReturnParameter(Procedure procedure) {
   for (ProcedureParameter pp : procedure.getParameters()) {
     if (pp.getType() == ProcedureParameter.Type.ReturnValue) {
       return pp;
     }
   }
   return null;
 }
예제 #7
0
  @Test
  public void testMultipleCommands() throws Exception {
    String ddl =
        "CREATE VIEW V1 AS SELECT * FROM PM1.G1 "
            + "CREATE PROCEDURE FOO(P1 integer) RETURNS (e1 integer, e2 varchar) AS SELECT * FROM PM1.G1;";

    Schema s = helpParse(ddl, "model").getSchema();
    Map<String, Table> tableMap = s.getTables();
    Table table = tableMap.get("V1");
    assertNotNull(table);
    assertEquals("SELECT * FROM PM1.G1", table.getSelectTransformation());

    Map<String, Procedure> procedureMap = s.getProcedures();
    Procedure p = procedureMap.get("FOO");
    assertNotNull(p);
    assertEquals("SELECT * FROM PM1.G1;", p.getQueryPlan());
  }
예제 #8
0
  @Test
  public void testTypeLength() throws Exception {
    String ddl =
        "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, p2 varchar, INOUT p3 decimal) "
            + "RETURNS (r1 varchar(10), r2 decimal(11,2), r3 object(1), r4 clob(10000))"
            + "OPTIONS(RANDOM 'any', UUID 'uuid', NAMEINSOURCE 'nis', ANNOTATION 'desc', UPDATECOUNT '2');";

    Schema s = helpParse(ddl, "model").getSchema();
    Procedure proc = s.getProcedure("myProc");
    assertNotNull(proc);

    List<Column> cols = proc.getResultSet().getColumns();
    assertEquals(10, cols.get(0).getLength());
    assertEquals(11, cols.get(1).getPrecision());
    assertEquals(1, cols.get(2).getLength());
    assertEquals(10000, cols.get(3).getLength());
  }
예제 #9
0
  @Test
  public void testAlterProcedureOptions() throws Exception {
    String ddl =
        "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, p2 varchar, INOUT p3 decimal) "
            + "RETURNS (r1 varchar, r2 decimal)"
            + "OPTIONS(RANDOM 'any', UUID 'uuid', NAMEINSOURCE 'nis', ANNOTATION 'desc', UPDATECOUNT '2');"
            + "ALTER FOREIGN PROCEDURE myProc OPTIONS(SET NAMEINSOURCE 'x')"
            + "ALTER FOREIGN PROCEDURE myProc ALTER PARAMETER p2 OPTIONS (ADD x 'y');"
            + "ALTER FOREIGN PROCEDURE myProc OPTIONS(DROP UPDATECOUNT);";

    Schema s = helpParse(ddl, "model").getSchema();
    Procedure proc = s.getProcedure("myProc");
    assertNotNull(proc);

    assertEquals("x", proc.getNameInSource());
    assertEquals("p2", proc.getParameters().get(1).getName());
    assertEquals("y", proc.getParameters().get(1).getProperty("x", false));
    assertEquals(1, proc.getUpdateCount());
  }
  @Test
  public void testFunctionReturnComplex() throws Exception {
    CsdlComplexType complex = complexType("Address");

    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");

    MetadataFactory mf = functionMetadata("invoke", returnType, complex);
    Procedure p = mf.getSchema().getProcedure("invoke");
    assertNotNull(p);
    assertEquals(2, p.getParameters().size());
    assertNotNull(p.getResultSet());
    assertNull(getReturnParameter(p));
    ColumnSet<Procedure> table = p.getResultSet();
    ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.FUNCTION, type);

    type = ODataType.valueOf(table.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.COMPLEX, type);
  }
  private static void buildFunctionImports(MetadataStore metadataStore, List<Builder> edmSchemas) {
    for (Schema schema : metadataStore.getSchemaList()) {

      EdmSchema.Builder odataSchema = findSchema(edmSchemas, schema.getName());
      EdmEntityContainer.Builder entityContainer =
          findEntityContainer(edmSchemas, schema.getName());

      // procedures
      for (Procedure proc : schema.getProcedures().values()) {
        EdmFunctionImport.Builder edmProcedure = EdmFunctionImport.newBuilder();
        edmProcedure.setName(proc.getName());
        String httpMethod = "POST";

        for (ProcedureParameter pp : proc.getParameters()) {
          if (pp.getName().equals("return")) {
            httpMethod = "GET";
            edmProcedure.setReturnType(
                ODataTypeManager.odataType(pp.getDatatype().getRuntimeTypeName()));
            continue;
          }

          EdmFunctionParameter.Builder param = EdmFunctionParameter.newBuilder();
          param.setName(pp.getName());
          param.setType(ODataTypeManager.odataType(pp.getDatatype().getRuntimeTypeName()));

          if (pp.getType() == ProcedureParameter.Type.In) {
            param.setMode(Mode.In);
          } else if (pp.getType() == ProcedureParameter.Type.InOut) {
            param.setMode(Mode.InOut);
          } else if (pp.getType() == ProcedureParameter.Type.Out) {
            param.setMode(Mode.Out);
          }

          param.setNullable(pp.getNullType() == NullType.Nullable);
          edmProcedure.addParameters(param);
        }

        // add a complex type for return resultset.
        ColumnSet<Procedure> returnColumns = proc.getResultSet();
        if (returnColumns != null) {
          httpMethod = "GET";
          EdmComplexType.Builder complexType = EdmComplexType.newBuilder();
          complexType.setName(proc.getName() + "_" + returnColumns.getName());
          complexType.setNamespace(schema.getName());
          for (Column c : returnColumns.getColumns()) {
            EdmProperty.Builder property =
                EdmProperty.newBuilder(c.getName())
                    .setType(ODataTypeManager.odataType(c.getDatatype().getRuntimeTypeName()))
                    .setNullable(c.getNullType() == NullType.Nullable);
            if (c.getDatatype()
                .getRuntimeTypeName()
                .equals(DataTypeManager.DefaultDataTypes.STRING)) {
              property
                  .setFixedLength(c.isFixedLength())
                  .setMaxLength(c.getLength())
                  .setUnicode(true);
            }
            complexType.addProperties(property);
          }
          odataSchema.addComplexTypes(complexType);
          edmProcedure.setIsCollection(true);
          edmProcedure.setReturnType(
              EdmCollectionType.newBuilder()
                  .setCollectionType(complexType)
                  .setKind(CollectionKind.Collection));
        }
        edmProcedure.setHttpMethod(httpMethod);
        entityContainer.addFunctionImports(edmProcedure);
      }
    }
  }
예제 #12
0
  @Test
  public void testPre81Procedure() throws Exception {
    WSExecutionFactory ef = new WSExecutionFactory();
    MetadataFactory mf =
        new MetadataFactory(
            "vdb",
            1,
            "x",
            SystemMetadata.getInstance().getRuntimeTypeMap(),
            new Properties(),
            null);
    ef.getMetadata(mf, null);
    Procedure p = mf.getSchema().getProcedure(WSExecutionFactory.INVOKE_HTTP);
    assertEquals(7, p.getParameters().size());
    p.getParameters().remove(4);
    p.getParameters().remove(5);
    p = mf.getSchema().getProcedure("invoke");
    assertEquals(6, p.getParameters().size());
    p.getParameters().remove(5);
    // designer treated the result as an out parameter
    p.getParameters().get(0).setType(Type.Out);
    p.getParameters().add(p.getParameters().remove(0));
    for (int i = 0; i < p.getParameters().size(); i++) {
      p.getParameters().get(i).setPosition(i + 1);
    }

    TransformationMetadata tm =
        RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "vdb");
    RuntimeMetadataImpl rm = new RuntimeMetadataImpl(tm);
    WSConnection mockConnection = Mockito.mock(WSConnection.class);
    Dispatch<Object> mockDispatch = mockDispatch();
    DataSource source = Mockito.mock(DataSource.class);
    Mockito.stub(mockDispatch.invoke(Mockito.any(DataSource.class))).toReturn(source);
    Mockito.stub(
            mockConnection.createDispatch(
                Mockito.any(String.class),
                Mockito.any(String.class),
                Mockito.any(Class.class),
                Mockito.any(Service.Mode.class)))
        .toReturn(mockDispatch);
    CommandBuilder cb = new CommandBuilder(tm);

    Call call = (Call) cb.getCommand("call invokeHttp('GET', null, null)");
    BinaryWSProcedureExecution pe =
        new BinaryWSProcedureExecution(
            call, rm, Mockito.mock(ExecutionContext.class), ef, mockConnection);
    pe.execute();
    pe.getOutputParameterValues();

    mockConnection = Mockito.mock(WSConnection.class);
    mockDispatch = Mockito.mock(Dispatch.class);
    StAXSource ssource = Mockito.mock(StAXSource.class);
    Mockito.stub(mockDispatch.invoke(Mockito.any(StAXSource.class))).toReturn(ssource);
    Mockito.stub(
            mockConnection.createDispatch(
                Mockito.any(String.class),
                Mockito.any(String.class),
                Mockito.any(Class.class),
                Mockito.any(Service.Mode.class)))
        .toReturn(mockDispatch);
    call = (Call) cb.getCommand("call invoke()");
    WSProcedureExecution wpe =
        new WSProcedureExecution(
            call, rm, Mockito.mock(ExecutionContext.class), ef, mockConnection);
    wpe.execute();
    wpe.getOutputParameterValues();
  }
예제 #13
0
  @Test
  public void testSourceProcedure() throws Exception {
    String ddl =
        "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, p2 varchar, INOUT p3 decimal) "
            + "RETURNS (r1 varchar, r2 decimal)"
            + "OPTIONS(RANDOM 'any', UUID 'uuid', NAMEINSOURCE 'nis', ANNOTATION 'desc', UPDATECOUNT '2');";

    Schema s = helpParse(ddl, "model").getSchema();

    Procedure proc = s.getProcedure("myProc");
    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("r1", ret.getColumns().get(0).getName());
    assertEquals("string", ret.getColumns().get(0).getDatatype().getName());
    assertEquals("r2", ret.getColumns().get(1).getName());
    assertEquals("bigdecimal", ret.getColumns().get(1).getDatatype().getName());

    assertEquals("uuid", proc.getUUID());
    assertEquals("nis", proc.getNameInSource());
    assertEquals("desc", proc.getAnnotation());
    assertEquals(2, proc.getUpdateCount());
    assertEquals("any", proc.getProperties().get("RANDOM"));
  }
  private void validate(
      VDBMetaData vdb,
      ModelMetaData model,
      AbstractMetadataRecord record,
      ValidatorReport report,
      IQueryMetadataInterface metadata,
      MetadataFactory mf) {
    ValidatorReport resolverReport = null;
    try {
      if (record instanceof Procedure) {
        Procedure p = (Procedure) record;
        Command command = queryParser.parseProcedure(p.getQueryPlan(), false);
        GroupSymbol gs = createASTNode(ASTNodes.GROUP_SYMBOL);
        gs.setName(p.getFullName());
        QueryResolver resolver = new QueryResolver(queryParser);
        resolver.resolveCommand(command, gs, ICommand.TYPE_STORED_PROCEDURE, metadata, false);
        Validator validator = new Validator();
        resolverReport = validator.validate(command, metadata);
        determineDependencies(p, command);
      } else if (record instanceof Table) {
        Table t = (Table) record;

        GroupSymbol symbol = createASTNode(ASTNodes.GROUP_SYMBOL);
        symbol.setName(t.getFullName());
        ResolverUtil.resolveGroup(symbol, metadata);
        String selectTransformation = t.getSelectTransformation();

        boolean columnsIsEmpty = t.getColumns() == null || t.getColumns().isEmpty();

        // Consider columns if teid 8.11 or lower
        boolean considerColumns_811 =
            isTeiidOrGreater(Version.TEIID_8_12_4) ? true : columnsIsEmpty;
        // Consider columns if teiid 8.12.4+
        boolean considerColumns_8124 =
            isTeiidOrGreater(Version.TEIID_8_12_4) ? columnsIsEmpty : true;

        if (t.isVirtual() && considerColumns_811) {
          QueryCommand command = (QueryCommand) queryParser.parseCommand(selectTransformation);
          QueryResolver resolver = new QueryResolver(queryParser);
          resolver.resolveCommand(command, metadata);
          Validator validator = new Validator();
          resolverReport = validator.validate(command, metadata);

          if (!resolverReport.hasItems() && considerColumns_8124) {
            List<Expression> symbols = command.getProjectedSymbols();
            for (Expression column : symbols) {
              try {
                addColumn(Symbol.getShortName(column), column.getType(), t, mf);
              } catch (Exception e) {
                log(report, model, e.getMessage());
              }
            }
          }

          if (considerColumns_8124) {
            determineDependencies(t, command);
            if (t.getInsertPlan() != null && t.isInsertPlanEnabled()) {
              validateUpdatePlan(
                  model, report, metadata, t, t.getInsertPlan(), Command.TYPE_INSERT);
            }
            if (t.getUpdatePlan() != null && t.isUpdatePlanEnabled()) {
              validateUpdatePlan(
                  model, report, metadata, t, t.getUpdatePlan(), Command.TYPE_UPDATE);
            }
            if (t.getDeletePlan() != null && t.isDeletePlanEnabled()) {
              validateUpdatePlan(
                  model, report, metadata, t, t.getDeletePlan(), Command.TYPE_DELETE);
            }
          }
        }

        boolean addCacheHint = false;
        if (t.isMaterialized() && t.getMaterializedTable() == null) {
          List<KeyRecord> fbis = t.getFunctionBasedIndexes();
          List<GroupSymbol> groups = Arrays.asList(symbol);
          if (fbis != null && !fbis.isEmpty()) {
            for (KeyRecord fbi : fbis) {
              for (int j = 0; j < fbi.getColumns().size(); j++) {
                Column c = fbi.getColumns().get(j);
                if (c.getParent() != fbi) {
                  continue;
                }
                String exprString = c.getNameInSource();
                try {
                  Expression ex = queryParser.parseExpression(exprString);
                  ResolverVisitor resolverVisitor = new ResolverVisitor(teiidVersion);
                  resolverVisitor.resolveLanguageObject(ex, groups, metadata);
                  if (!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(ex)
                      .isEmpty()) {
                    log(
                        report,
                        model,
                        Messages.gs(Messages.TEIID.TEIID31114, exprString, fbi.getFullName()));
                  }
                  EvaluatableVisitor ev = new EvaluatableVisitor(teiidVersion);
                  PreOrPostOrderNavigator.doVisit(ex, ev, PostOrderNavigator.PRE_ORDER);
                  if (ev.getDeterminismLevel().compareTo(Determinism.VDB_DETERMINISTIC) < 0) {
                    log(
                        report,
                        model,
                        Messages.gs(Messages.TEIID.TEIID31115, exprString, fbi.getFullName()));
                  }
                } catch (QueryResolverException e) {
                  log(
                      report,
                      model,
                      Messages.gs(
                          Messages.TEIID.TEIID31116,
                          exprString,
                          fbi.getFullName(),
                          e.getMessage()));
                }
              }
            }
          }
        } else {
          addCacheHint = true;
        }

        // this seems to parse, resolve and validate.
        QueryResolver resolver = new QueryResolver(queryParser);
        QueryNode node =
            resolver.resolveView(
                symbol,
                new QueryNode(t.getSelectTransformation()),
                SQLConstants.Reserved.SELECT,
                metadata);
        CacheHint cacheHint = node.getCommand().getCacheHint();
        Long ttl = -1L;
        if (cacheHint != null
            && cacheHint.getTtl() != null
            && addCacheHint
            && t.getProperty(MATVIEW_TTL, false) == null) {
          ttl = cacheHint.getTtl();
          t.setProperty(MATVIEW_TTL, String.valueOf(ttl));
        }
      }
      if (resolverReport != null && resolverReport.hasItems()) {
        for (ValidatorFailure v : resolverReport.getItems()) {
          log(
              report,
              model,
              v.getStatus() == IValidatorFailure.VFStatus.ERROR ? Severity.ERROR : Severity.WARNING,
              v.getMessage());
        }
      }
      processReport(model, record, report, resolverReport);
    } catch (Exception e) {
      log(
          report,
          model,
          Messages.gs(Messages.TEIID.TEIID31080, record.getFullName(), e.getMessage()));
    }
  }
    @Override
    public void execute(
        VDBMetaData vdb,
        MetadataStore store,
        ValidatorReport report,
        MetadataValidator metadataValidator) {
      IQueryMetadataInterface metadata = vdb.getAttachment(IQueryMetadataInterface.class);
      metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
      for (Schema schema : store.getSchemaList()) {
        if (vdb.getImportedModels().contains(schema.getName())) {
          continue;
        }
        ModelMetaData model = vdb.getModel(schema.getName());
        MetadataFactory mf =
            new MetadataFactory(
                teiidVersion, vdb.getName(), vdb.getVersion(), metadataValidator.typeMap, model) {
              @Override
              protected void setUUID(AbstractMetadataRecord record) {
                if (count >= 0) {
                  count = Integer.MIN_VALUE;
                }
                super.setUUID(record);
              }
            };
        mf.setBuiltinDataTypes(store.getDatatypes());
        for (AbstractMetadataRecord record : schema.getResolvingOrder()) {
          if (record instanceof Table) {
            Table t = (Table) record;
            // no need to verify the transformation of the xml mapping document,
            // as this is very specific and designer already validates it.
            if (t.getTableType() == Table.Type.Document
                || t.getTableType() == Table.Type.XmlMappingClass
                || t.getTableType() == Table.Type.XmlStagingTable) {
              continue;
            }
            if (t.isVirtual() && t.getTableType() != Table.Type.TemporaryTable) {
              if (t.getSelectTransformation() == null) {
                metadataValidator.log(
                    report,
                    model,
                    Messages.gs(Messages.TEIID.TEIID31079, t.getFullName(), model.getName()));
              } else {
                metadataValidator.validate(vdb, model, t, report, metadata, mf);
              }
            }
          } else if (record instanceof Procedure) {
            Procedure p = (Procedure) record;

            boolean test = p.isVirtual();
            if (teiidVersion.isLessThan(Version.TEIID_8_11)) test = test && !p.isFunction();

            if (test) {
              if (p.getQueryPlan() == null) {
                metadataValidator.log(
                    report,
                    model,
                    Messages.gs(Messages.TEIID.TEIID31081, p.getFullName(), model.getName()));
              } else {
                metadataValidator.validate(vdb, model, p, report, metadata, mf);
              }
            }
          }
        }
      }
    }
    @Override
    public void execute(
        VDBMetaData vdb,
        MetadataStore store,
        ValidatorReport report,
        MetadataValidator metadataValidator) {
      for (Schema schema : store.getSchemaList()) {
        if (vdb.getImportedModels().contains(schema.getName())) {
          continue;
        }
        ModelMetaData model = vdb.getModel(schema.getName());
        for (Table t : schema.getTables().values()) {
          if (t.isPhysical() && !model.isSource()) {
            metadataValidator.log(
                report,
                model,
                Messages.gs(Messages.TEIID.TEIID31075, t.getFullName(), model.getName()));
          }
        }

        Set<String> names = new HashSet<String>();
        for (Procedure p : schema.getProcedures().values()) {
          boolean hasReturn = false;
          names.clear();
          for (int i = 0; i < p.getParameters().size(); i++) {
            ProcedureParameter param = p.getParameters().get(i);
            if (param.isVarArg() && param != p.getParameters().get(p.getParameters().size() - 1)) {
              // check that the rest of the parameters are optional
              // this accommodates variadic multi-source procedures
              // effective this and the resolving logic ensure that you can used named parameters
              // for everything,
              // or call the vararg procedure as normal
              if (isTeiidOrGreater(Version.TEIID_8_10)) {
                for (int j = i + 1; j < p.getParameters().size(); j++) {
                  ProcedureParameter param1 = p.getParameters().get(j);
                  if ((param1.getType() == Type.In || param1.getType() == Type.InOut)
                      && (param1.isVarArg()
                          || (param1.getNullType() != NullType.Nullable
                              && param1.getDefaultValue() == null))) {
                    metadataValidator.log(
                        report, model, Messages.gs(Messages.TEIID.TEIID31112, p.getFullName()));
                  }
                }
              } else {
                metadataValidator.log(
                    report, model, Messages.gs(Messages.TEIID.TEIID31112, p.getFullName()));
              }
            }
            if (param.getType() == ProcedureParameter.Type.ReturnValue) {
              if (hasReturn) {
                metadataValidator.log(
                    report, model, Messages.gs(Messages.TEIID.TEIID31107, p.getFullName()));
              }
              hasReturn = true;
            } else if (p.isFunction()
                && param.getType() != ProcedureParameter.Type.In
                && teiidVersion.isGreaterThanOrEqualTo(Version.TEIID_8_11)) {
              metadataValidator.log(
                  report,
                  model,
                  Messages.gs(Messages.TEIID.TEIID31165, p.getFullName(), param.getFullName()));
            }
            if (!names.add(param.getName())) {
              metadataValidator.log(
                  report,
                  model,
                  Messages.gs(Messages.TEIID.TEIID31106, p.getFullName(), param.getFullName()));
            }
          }
          if (!p.isVirtual() && !model.isSource()) {
            metadataValidator.log(
                report,
                model,
                Messages.gs(Messages.TEIID.TEIID31077, p.getFullName(), model.getName()));
          }

          if (p.isFunction() && teiidVersion.isGreaterThanOrEqualTo(Version.TEIID_8_11)) {
            if (!hasReturn) {
              metadataValidator.log(
                  report, model, Messages.gs(Messages.TEIID.TEIID31166, p.getFullName()));
            }
            if (p.isVirtual() && p.getQueryPlan() == null) {
              metadataValidator.log(
                  report, model, Messages.gs(Messages.TEIID.TEIID31167, p.getFullName()));
            }
          }
        }

        for (FunctionMethod func : schema.getFunctions().values()) {
          for (FunctionParameter param : func.getInputParameters()) {
            if (param.isVarArg()
                && param != func.getInputParameters().get(func.getInputParameterCount() - 1)) {
              metadataValidator.log(
                  report, model, Messages.gs(Messages.TEIID.TEIID31112, func.getFullName()));
            }
          }
          if (func.getPushdown().equals(FunctionMethod.PushDown.MUST_PUSHDOWN)
              && !model.isSource()) {
            metadataValidator.log(
                report,
                model,
                Messages.gs(Messages.TEIID.TEIID31078, func.getFullName(), model.getName()));
          }
        }
      }
    }