/** * Helper to quickly get the commands from obj * @param obj Language object * @param elements Collection to collect commands in */ public static final List<Command> getCommands(Command command) { return getCommands(command, false); }
public static final List<Command> getCommands(Command command, boolean includeExpanded) { CommandCollectorVisitor visitor = new CommandCollectorVisitor(); visitor.collectExpanded = includeExpanded; final boolean visitCommands = command instanceof SetQuery; PreOrderNavigator navigator = new PreOrderNavigator(visitor) { @Override protected void visitNode(LanguageObject obj) { if (!visitCommands && obj instanceof Command) { return; } super.visitNode(obj); } }; command.acceptVisitor(navigator); return visitor.getCommands(); }
/** * Helper to quickly get the commands from obj * @param obj Language object * @param elements Collection to collect commands in */ public static final List<Command> getCommands(Command command) { return getCommands(command, false); }
public static final List<Command> getCommands(Command command, boolean includeExpanded) { CommandCollectorVisitor visitor = new CommandCollectorVisitor(); visitor.collectExpanded = includeExpanded; final boolean visitCommands = command instanceof SetQuery; PreOrderNavigator navigator = new PreOrderNavigator(visitor) { @Override protected void visitNode(LanguageObject obj) { if (!visitCommands && obj instanceof Command) { return; } super.visitNode(obj); } }; command.acceptVisitor(navigator); return visitor.getCommands(); }
/** * Helper to quickly get the commands from obj * @param obj Language object * @param elements Collection to collect commands in */ public static final List<Command> getCommands(Command command) { return getCommands(command, false); }
public static final List<Command> getCommands(Command command, boolean includeExpanded) { CommandCollectorVisitor visitor = new CommandCollectorVisitor(); visitor.collectExpanded = includeExpanded; final boolean visitCommands = command instanceof SetQuery; PreOrderNavigator navigator = new PreOrderNavigator(visitor) { @Override protected void visitNode(LanguageObject obj) { if (!visitCommands && obj instanceof Command) { return; } super.visitNode(obj); } }; command.acceptVisitor(navigator); return visitor.getCommands(); }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata, AbstractValidationVisitor visitor) throws TeiidComponentException { // Execute on this command executeValidation(object, metadata, visitor); // Construct combined runtime / query metadata if necessary if(object instanceof Command) { // Recursively validate subcommands Iterator<Command> iter = CommandCollectorVisitor.getCommands((Command)object).iterator(); while(iter.hasNext()) { Command subCommand = iter.next(); validate(subCommand, metadata, visitor); } } // Otherwise, return a report return visitor.getReport(); }
public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata, AbstractValidationVisitor visitor) throws TeiidComponentException { // Execute on this command executeValidation(object, metadata, visitor); // Construct combined runtime / query metadata if necessary if(object instanceof Command) { // Recursively validate subcommands Iterator<Command> iter = CommandCollectorVisitor.getCommands((Command)object).iterator(); while(iter.hasNext()) { Command subCommand = iter.next(); validate(subCommand, metadata, visitor); } } // Otherwise, return a report return visitor.getReport(); }
public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata, AbstractValidationVisitor visitor) throws TeiidComponentException { // Execute on this command executeValidation(object, metadata, visitor); // Construct combined runtime / query metadata if necessary if(object instanceof Command) { // Recursively validate subcommands Iterator<Command> iter = CommandCollectorVisitor.getCommands((Command)object).iterator(); while(iter.hasNext()) { Command subCommand = iter.next(); validate(subCommand, metadata, visitor); } } // Otherwise, return a report return visitor.getReport(); }
@Test public void testUnionWithSubQuery() { String sql = "select 1 from pm1.g1 where exists (select 1) union select 2"; //$NON-NLS-1$ SetQuery command = (SetQuery)helpResolve(sql); assertEquals(1, CommandCollectorVisitor.getCommands(command).size()); } @Test public void testOrderBy_J658a() {
assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$ Command subCommand = CommandCollectorVisitor.getCommands(command).get(0); tempIDs = subCommand.getTemporaryMetadata().getData(); assertNotNull(tempIDs); assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$ subCommand = CommandCollectorVisitor.getCommands(command).get(1); tempIDs = subCommand.getTemporaryMetadata().getData(); assertNotNull(tempIDs);
for (Command c : CommandCollectorVisitor.getCommands(plannedResult.query)) {
for (Command c : CommandCollectorVisitor.getCommands(plannedResult.query)) {
for (Command c : CommandCollectorVisitor.getCommands(plannedResult.query)) {
planner.executeRules(stack, plan); List<Command> commands = CommandCollectorVisitor.getCommands(command, true); while (!commands.isEmpty()) { Command cmd = commands.remove(commands.size() - 1); commands.addAll(CommandCollectorVisitor.getCommands(cmd, true)); try {
while (!toExplore.isEmpty()) { Command cmd = toExplore.remove(toExplore.size() - 1); for (Command subCommand : CommandCollectorVisitor.getCommands(cmd, true)) { if (commands.add(subCommand)) { toExplore.add(subCommand);
while (!toExplore.isEmpty()) { Command cmd = toExplore.remove(toExplore.size() - 1); for (Command subCommand : CommandCollectorVisitor.getCommands(cmd, true)) { if (commands.add(subCommand)) { toExplore.add(subCommand);