use of com.robotoworks.mechanoid.db.sqliteModel.AlterTableAddColumnStatement in project mechanoid by robotoworks.
the class ModelUtil method findColumnDefs.
/**
* Find column definitions from caller going back to the definition
*/
public static ArrayList<EObject> findColumnDefs(final DDLStatement caller, final TableDefinition definition) {
final ArrayList<EObject> columns = new ArrayList<EObject>();
LinkedList<TableDefinition> tableHistory = ModelUtil.getHistory(definition);
TableDefinition last = tableHistory.peekLast();
if ((last instanceof CreateViewStatement)) {
CreateViewStatement view = ((CreateViewStatement) last);
ArrayList<ColumnSource> _viewResultColumns = ModelUtil.getViewResultColumns(view);
columns.addAll(_viewResultColumns);
return columns;
}
EList<ColumnSource> _columnDefs = ((CreateTableStatement) last).getColumnDefs();
columns.addAll(_columnDefs);
while ((!tableHistory.isEmpty())) {
{
final TableDefinition stmt = tableHistory.removeLast();
ArrayList<AlterTableAddColumnStatement> _findStatementsOfTypeBetween = ModelUtil.<AlterTableAddColumnStatement>findStatementsOfTypeBetween(AlterTableAddColumnStatement.class, stmt, caller);
final Function1<AlterTableAddColumnStatement, Boolean> _function = new Function1<AlterTableAddColumnStatement, Boolean>() {
public Boolean apply(final AlterTableAddColumnStatement it) {
TableDefinition _table = it.getTable();
return Boolean.valueOf(Objects.equal(_table, stmt));
}
};
Iterable<AlterTableAddColumnStatement> _filter = IterableExtensions.<AlterTableAddColumnStatement>filter(_findStatementsOfTypeBetween, _function);
final Consumer<AlterTableAddColumnStatement> _function_1 = new Consumer<AlterTableAddColumnStatement>() {
public void accept(final AlterTableAddColumnStatement it) {
ColumnSource _columnDef = it.getColumnDef();
columns.add(_columnDef);
}
};
_filter.forEach(_function_1);
}
}
return columns;
}
use of com.robotoworks.mechanoid.db.sqliteModel.AlterTableAddColumnStatement in project mechanoid by robotoworks.
the class SqliteModelProposalProvider method getDisplayString.
@Override
protected String getDisplayString(EObject element, String qualifiedNameAsString, String shortName) {
if (element instanceof ColumnDef) {
ColumnDef def = (ColumnDef) element;
EObject container = def.eContainer();
if (container instanceof TableDefinition) {
return def.getName() + ":" + def.getType().getName() + " - " + ((TableDefinition) def.eContainer()).getName();
} else if (container instanceof AlterTableAddColumnStatement) {
return def.getName() + ":" + def.getType().getName() + " - " + ((AlterTableAddColumnStatement) def.eContainer()).getTable().getName();
} else {
return def.getName() + ":" + def.getType().getName();
}
} else if (element instanceof SingleSourceTable) {
SingleSourceTable t = (SingleSourceTable) element;
return (t.getName() == null ? t.getTableReference().getName() : t.getName() + " - " + t.getTableReference().getName());
} else if (element instanceof CreateTableStatement) {
CreateTableStatement t = (CreateTableStatement) element;
return t.getName();
} else if (element instanceof ResultColumn) {
ResultColumn r = (ResultColumn) element;
if (r.getName() != null) {
return r.getName() + ":" + ModelUtil.getInferredColumnType(r).getName();
}
}
return super.getDisplayString(element, qualifiedNameAsString, shortName);
}
Aggregations