}
@Override
public StatementGeneratorResult generateStatement() {
StatementGeneratorResult result = new StatementGeneratorResult();
MessageBundle messages = result.getMessages();
Set<DBDataset> datasets = new TreeSet<DBDataset>(DATASET_COMPARATOR);
Set<DBColumn> columns = new TreeSet<DBColumn>(COLUMN_COMPARATOR);
for (DBObject object : objects) {
if (object instanceof DBColumn) {
DBColumn column = (DBColumn) object;
columns.add(column);
datasets.add(column.getDataset());
} else if (object instanceof DBDataset) {
DBDataset dataset = (DBDataset) object;
datasets.add(dataset);
columns.addAll(dataset.getColumns());
} else {
messages.addErrorMessage(
"Only objects of type DATASET and COLUMN are supported for select statement generation.\n" +
"Please review your selection and try again.");
}
}
DatasetJoinBundle joinBundle = null;
if (datasets.size() > 1) {
joinBundle = new DatasetJoinBundle(datasets, true);
for (DBDataset dataset : datasets) {
if (!joinBundle.contains(dataset)) {
messages.addWarningMessage("Could not join table " +
dataset.getName() + ". No references found to the other tables.");
}
}
}