use of org.teiid.query.sql.lang.Update in project teiid by teiid.
the class TestGroupCollectorVisitor method testBatchedUpdateCommand.
public void testBatchedUpdateCommand() {
GroupSymbol g1 = exampleGroupSymbol(1);
GroupSymbol g2 = exampleGroupSymbol(2);
GroupSymbol g3 = exampleGroupSymbol(3);
Insert insert = new Insert();
insert.setGroup(g1);
Update update = new Update();
update.setGroup(g2);
Delete delete = new Delete();
delete.setGroup(g3);
List updates = new ArrayList(3);
updates.add(insert);
updates.add(update);
updates.add(delete);
Set groups = new HashSet();
groups.add(g1);
groups.add(g2);
groups.add(g3);
helpTestGroups(new BatchedUpdateCommand(updates), true, groups);
}
use of org.teiid.query.sql.lang.Update in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testVisitUpdate1.
public void testVisitUpdate1() {
Update update = new Update();
update.setGroup(exampleGroup(true, 0));
// $NON-NLS-1$
update.addChange(exampleElement(true, 0), new Constant("abc"));
// $NON-NLS-1$
update.addChange(exampleElement(true, 1), new Constant("abc"));
helpTest(update, getSymbolMap());
}
use of org.teiid.query.sql.lang.Update in project teiid by teiid.
the class LanguageBridgeFactory method translate.
public org.teiid.language.Command translate(Command command) {
try {
if (command == null) {
return null;
}
if (command instanceof Query) {
Select result = translate((Query) command);
result.setDependentValues(this.dependentSets);
setProjected(result);
return result;
} else if (command instanceof SetQuery) {
org.teiid.language.SetQuery result = translate((SetQuery) command);
setProjected(result);
return result;
} else if (command instanceof Insert) {
return translate((Insert) command);
} else if (command instanceof Update) {
return translate((Update) command);
} else if (command instanceof Delete) {
return translate((Delete) command);
} else if (command instanceof StoredProcedure) {
return translate((StoredProcedure) command);
} else if (command instanceof BatchedUpdateCommand) {
return translate((BatchedUpdateCommand) command);
}
// $NON-NLS-1$
throw new AssertionError(command.getClass().getName() + " " + command);
} finally {
this.allValues.clear();
this.dependentSets = null;
this.valueIndex = 0;
}
}
use of org.teiid.query.sql.lang.Update in project teiid by teiid.
the class TestAccessNode method testShouldExecuteUpdate.
@Test
public void testShouldExecuteUpdate() throws Exception {
Update update = new Update();
// $NON-NLS-1$
update.setGroup(new GroupSymbol("test"));
// $NON-NLS-1$ //$NON-NLS-2$
update.addChange(new ElementSymbol("e1"), new Constant("1"));
assertTrue(RelationalNodeUtil.shouldExecute(update, false));
update.setChangeList(new SetClauseList());
assertFalse(RelationalNodeUtil.shouldExecute(update, false));
}
use of org.teiid.query.sql.lang.Update in project teiid by teiid.
the class RuleAccessPatternValidation method validateAccessPatterns.
/**
* @param node
* @throws QueryPlannerException
*/
private void validateAccessPatterns(PlanNode node) throws QueryPlannerException {
if (!node.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) {
return;
}
Criteria criteria = null;
if (node.hasProperty(NodeConstants.Info.ATOMIC_REQUEST)) {
Object req = node.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
if (req instanceof Insert) {
return;
}
if (req instanceof Delete) {
criteria = ((Delete) req).getCriteria();
} else if (req instanceof Update) {
criteria = ((Update) req).getCriteria();
}
}
List accessPatterns = (List) node.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
if (criteria != null) {
for (Criteria crit : Criteria.separateCriteriaByAnd(criteria)) {
Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(crit, true);
if (RulePushSelectCriteria.satisfyAccessPatterns(accessPatterns, elements)) {
return;
}
}
}
Object groups = node.getGroups();
throw new QueryPlannerException(QueryPlugin.Event.TEIID30278, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30278, new Object[] { groups, accessPatterns }));
}
Aggregations