}
List filteredTuples = new ArrayList();
for(int i=0; i<tuples.length; i++) {
try {
if(new Evaluator(lookupMap, null, null).evaluate(query.getCriteria(), tuples[i])) {
filteredTuples.add(tuples[i]);
}
} catch(ExpressionEvaluationException e) {
throw new TeiidComponentException(e, e.getMessage());
}
}
tuples = new List[filteredTuples.size()];
filteredTuples.toArray(tuples);
}
} else if ( command instanceof Insert || command instanceof Update || command instanceof Delete) {
// add single update command to a list to be executed
updateCommands.add(command);
} else if ( command instanceof BatchedUpdateCommand ) {
// add all update commands to a list to be executed
updateCommands.addAll(((BatchedUpdateCommand) command).getUpdateCommands());
}
// if we had update commands added to the list, execute them now
if ( updateCommands.size() > 0 ) {
List<List<Integer>> filteredTuples = new ArrayList<List<Integer>>();
for ( int c = 0; c < updateCommands.size(); c++ ) {
Command cmd = updateCommands.get(c);
if (cmd instanceof TranslatableProcedureContainer) {
TranslatableProcedureContainer update = (TranslatableProcedureContainer)cmd;
if ( update.getCriteria() != null ) {
// Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
Map<Object, Integer> lookupMap = new HashMap<Object, Integer>();
for(int i=0; i<elements.size(); i++) {
Object element = elements.get(i);
mapElementToIndex(lookupMap, element, new Integer(i), group);
}
for(int i=0; i<projectedSymbols.size(); i++) {
Object element = projectedSymbols.get(i);
mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
}
int updated = 0;
for(int i=0; i<tuples.length; i++) {
try {
if(new Evaluator(lookupMap, null, null).evaluate(update.getCriteria(), tuples[i])) {
updated++;
}
} catch(ExpressionEvaluationException e) {
throw new TeiidComponentException(e, e.getMessage());
}