use of com.robotoworks.mechanoid.db.sqliteModel.TableDefinition in project mechanoid by robotoworks.
the class XSqliteModelScopeProvider method scope_OldColumn_column.
public IScope scope_OldColumn_column(final OldColumn context, final EReference reference) {
CreateTriggerStatement trigger = ModelUtil.<CreateTriggerStatement>getAncestorOfType(context, CreateTriggerStatement.class);
boolean _notEquals = (!Objects.equal(trigger, null));
if (_notEquals) {
TableDefinition _table = trigger.getTable();
ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(trigger, _table);
return Scopes.scopeFor(_findColumnDefs);
}
return IScope.NULLSCOPE;
}
use of com.robotoworks.mechanoid.db.sqliteModel.TableDefinition in project mechanoid by robotoworks.
the class XSqliteModelScopeProvider method scope_ColumnSourceRef_column.
public IScope scope_ColumnSourceRef_column(final ColumnSourceRef context, final EReference reference) {
SelectSource _source = context.getSource();
boolean _equals = Objects.equal(_source, null);
if (_equals) {
IScope scope = this.buildScopeForColumnSourceRef_column(context, context);
return scope;
} else {
SelectSource _source_1 = context.getSource();
if ((_source_1 instanceof SingleSourceTable)) {
SelectSource _source_2 = context.getSource();
SingleSourceTable tableSource = ((SingleSourceTable) _source_2);
DDLStatement _ancestorOfType = ModelUtil.<DDLStatement>getAncestorOfType(tableSource, DDLStatement.class);
TableDefinition _tableReference = tableSource.getTableReference();
ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(_ancestorOfType, _tableReference);
return Scopes.scopeFor(_findColumnDefs);
} else {
SelectSource _source_3 = context.getSource();
if ((_source_3 instanceof SingleSourceSelectStatement)) {
SelectSource _source_4 = context.getSource();
SingleSourceSelectStatement selectStmtSource = ((SingleSourceSelectStatement) _source_4);
SelectStatement _selectStatement = selectStmtSource.getSelectStatement();
SelectCoreExpression _core = _selectStatement.getCore();
ArrayList<EObject> _allReferenceableColumns = ModelUtil.getAllReferenceableColumns(_core);
return Scopes.scopeFor(_allReferenceableColumns);
}
}
}
return IScope.NULLSCOPE;
}
use of com.robotoworks.mechanoid.db.sqliteModel.TableDefinition in project mechanoid by robotoworks.
the class XSqliteModelScopeProvider method scope_UpdateColumnExpression_columnName.
public IScope scope_UpdateColumnExpression_columnName(final UpdateColumnExpression context, final EReference reference) {
UpdateStatement updateStmt = ModelUtil.<UpdateStatement>getAncestorOfType(context, UpdateStatement.class);
DDLStatement containingStmt = ModelUtil.<DDLStatement>getAncestorOfType(context, DDLStatement.class);
TableDefinition _table = updateStmt.getTable();
ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(containingStmt, _table);
return Scopes.scopeFor(_findColumnDefs, IScope.NULLSCOPE);
}
use of com.robotoworks.mechanoid.db.sqliteModel.TableDefinition in project mechanoid by robotoworks.
the class XSqliteModelScopeProvider method scopeForTableDefinitionsBeforeStatement.
public IScope scopeForTableDefinitionsBeforeStatement(final DDLStatement stmt, final boolean inclusive) {
ArrayList<TableDefinition> refs = ModelUtil.<TableDefinition>findPreviousStatementsOfType(stmt, TableDefinition.class, inclusive);
final HashMap<String, EObject> map = new HashMap<String, EObject>();
List<TableDefinition> _reverse = ListExtensions.<TableDefinition>reverse(refs);
for (final TableDefinition ref : _reverse) {
{
String _name = ref.getName();
boolean _equals = Objects.equal(_name, null);
if (_equals) {
return IScope.NULLSCOPE;
}
String _name_1 = ref.getName();
boolean _containsKey = map.containsKey(_name_1);
boolean _not = (!_containsKey);
if (_not) {
String _name_2 = ref.getName();
map.put(_name_2, ref);
}
}
}
Collection<EObject> _values = map.values();
final Function<EObject, QualifiedName> _function = new Function<EObject, QualifiedName>() {
public QualifiedName apply(final EObject it) {
return NameHelper.getName(((TableDefinition) it));
}
};
return Scopes.<EObject>scopeFor(_values, _function, IScope.NULLSCOPE);
}
use of com.robotoworks.mechanoid.db.sqliteModel.TableDefinition 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;
}
Aggregations