if (getUnionBranches().isEmpty()) {
return findUpdateMapping(insert.getVariables(), true);
}
if (insert.getQueryExpression() != null) {
//TODO: this could be done in a loop, see about adding a validation
throw new QueryValidatorException(QueryPlugin.Util.getString("ValidationVisitor.insert_qe_partition", insert.getGroup())); //$NON-NLS-1$
}
int partition = -1;
List<ElementSymbol> filteredColumns = new LinkedList<ElementSymbol>();
for (Map.Entry<ElementSymbol, List<Set<Constant>>> entry : partitionInfo.entrySet()) {
int index = insert.getVariables().indexOf(entry.getKey());
if (index == -1) {
continue;
}
Expression value = (Expression)insert.getValues().get(index);
if (!(value instanceof Constant)) {
continue;
}
for (int i = 0; i < entry.getValue().size(); i++) {
if (entry.getValue().get(i).contains(value)) {
if (entry.getValue().get(i).size() == 1) {
filteredColumns.add(entry.getKey());
}
if (partition == -1) {
partition = i;
} else if (partition != i) {
throw new QueryValidatorException(QueryPlugin.Util.getString("ValidationVisitor.insert_no_partition", insert.getGroup(), insert.getVariables())); //$NON-NLS-1$
}
}
}
}
if (partition == -1) {
throw new QueryValidatorException(QueryPlugin.Util.getString("ValidationVisitor.insert_no_partition", insert.getGroup(), insert.getVariables())); //$NON-NLS-1$
}
UpdateInfo info = this;
if (partition > 0) {
info = info.getUnionBranches().get(partition - 1);
}