예제 #1
0
  /**
   * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command,
   *     TempMetadataAdapter, boolean)
   */
  public void resolveCommand(
      Command command, TempMetadataAdapter metadata, boolean resolveNullLiterals)
      throws QueryMetadataException, QueryResolverException, TeiidComponentException {

    // by creating a new group context here it means that variables will resolve with a higher
    // precedence than input/changing
    GroupContext externalGroups = command.getExternalGroupContexts();

    List<ElementSymbol> symbols = new LinkedList<ElementSymbol>();

    String countVar =
        ProcedureReservedWords.VARIABLES + Symbol.SEPARATOR + ProcedureReservedWords.ROWCOUNT;
    ElementSymbol updateCount = new ElementSymbol(countVar);
    updateCount.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    symbols.add(updateCount);

    ProcedureContainerResolver.addScalarGroup(
        ProcedureReservedWords.VARIABLES, metadata.getMetadataStore(), externalGroups, symbols);

    if (command instanceof TriggerAction) {
      TriggerAction ta = (TriggerAction) command;
      CreateProcedureCommand cmd = new CreateProcedureCommand(ta.getBlock());
      cmd.setVirtualGroup(ta.getView());
      // TODO: this is not generally correct - we should update the api to set the appropriate type
      cmd.setUpdateType(Command.TYPE_INSERT);
      resolveBlock(cmd, ta.getBlock(), ta.getExternalGroupContexts(), metadata);
      return;
    }

    CreateProcedureCommand procCommand = (CreateProcedureCommand) command;

    resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata);
  }
 @Override
 public void visit(TriggerAction obj) {
   preVisitVisitor(obj);
   visitNode(obj.getBlock());
   postVisitVisitor(obj);
 }