use of com.robotoworks.mechanoid.db.sqliteModel.ColumnSource 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.ColumnSource in project mechanoid by robotoworks.
the class ModelUtil method getAllReferenceableColumns.
public static ArrayList<EObject> getAllReferenceableColumns(final SelectExpression expr, final boolean includeAliases) {
final ArrayList<EObject> items = Lists.<EObject>newArrayList();
boolean _and = false;
SelectList _selectList = expr.getSelectList();
boolean _notEquals = (!Objects.equal(_selectList, null));
if (!_notEquals) {
_and = false;
} else {
_and = includeAliases;
}
if (_and) {
SelectList _selectList_1 = expr.getSelectList();
EList<ColumnSource> _resultColumns = _selectList_1.getResultColumns();
final Function1<ColumnSource, Boolean> _function = new Function1<ColumnSource, Boolean>() {
public Boolean apply(final ColumnSource it) {
String _name = it.getName();
return Boolean.valueOf((!Objects.equal(_name, null)));
}
};
Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(_resultColumns, _function);
Iterables.<EObject>addAll(items, _filter);
}
ArrayList<SingleSource> _findAllSingleSources = ModelUtil.findAllSingleSources(expr);
final Function1<SingleSource, Boolean> _function_1 = new Function1<SingleSource, Boolean>() {
public Boolean apply(final SingleSource item) {
if ((item instanceof SingleSourceTable)) {
String _name = ((SingleSourceTable) item).getName();
return Boolean.valueOf(Objects.equal(_name, null));
}
return Boolean.valueOf(false);
}
};
Iterable<SingleSource> _filter_1 = IterableExtensions.<SingleSource>filter(_findAllSingleSources, _function_1);
final Consumer<SingleSource> _function_2 = new Consumer<SingleSource>() {
public void accept(final SingleSource item) {
SingleSourceTable source = ((SingleSourceTable) item);
DDLStatement _ancestorOfType = ModelUtil.<DDLStatement>getAncestorOfType(item, DDLStatement.class);
TableDefinition _tableReference = source.getTableReference();
ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(_ancestorOfType, _tableReference);
items.addAll(_findColumnDefs);
}
};
_filter_1.forEach(_function_2);
return items;
}
use of com.robotoworks.mechanoid.db.sqliteModel.ColumnSource in project mechanoid by robotoworks.
the class OldColumnImpl method setColumn.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setColumn(ColumnSource newColumn) {
ColumnSource oldColumn = column;
column = newColumn;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SqliteModelPackage.OLD_COLUMN__COLUMN, oldColumn, column));
}
use of com.robotoworks.mechanoid.db.sqliteModel.ColumnSource in project mechanoid by robotoworks.
the class ColumnSourceRefImpl method setColumn.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setColumn(ColumnSource newColumn) {
ColumnSource oldColumn = column;
column = newColumn;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SqliteModelPackage.COLUMN_SOURCE_REF__COLUMN, oldColumn, column));
}
use of com.robotoworks.mechanoid.db.sqliteModel.ColumnSource in project mechanoid by robotoworks.
the class NewColumnImpl method setColumn.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setColumn(ColumnSource newColumn) {
ColumnSource oldColumn = column;
column = newColumn;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SqliteModelPackage.NEW_COLUMN__COLUMN, oldColumn, column));
}
Aggregations