Search in sources :

Example 1 with SingleSource

use of com.robotoworks.mechanoid.db.sqliteModel.SingleSource 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;
}
Also used : SelectList(com.robotoworks.mechanoid.db.sqliteModel.SelectList) SingleSource(com.robotoworks.mechanoid.db.sqliteModel.SingleSource) DDLStatement(com.robotoworks.mechanoid.db.sqliteModel.DDLStatement) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) SingleSourceTable(com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable) Consumer(java.util.function.Consumer) EObject(org.eclipse.emf.ecore.EObject) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition) ColumnSource(com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)

Example 2 with SingleSource

use of com.robotoworks.mechanoid.db.sqliteModel.SingleSource in project mechanoid by robotoworks.

the class ModelUtil method getAllReferenceableSingleSources.

public static ArrayList<EObject> getAllReferenceableSingleSources(final SelectCoreExpression expr) {
    final ArrayList<EObject> items = Lists.<EObject>newArrayList();
    if ((expr instanceof SelectCore)) {
        SelectCoreExpression _left = ((SelectCore) expr).getLeft();
        ArrayList<EObject> _allReferenceableSingleSources = ModelUtil.getAllReferenceableSingleSources(_left);
        items.addAll(_allReferenceableSingleSources);
        SelectCoreExpression _right = ((SelectCore) expr).getRight();
        ArrayList<EObject> _allReferenceableSingleSources_1 = ModelUtil.getAllReferenceableSingleSources(_right);
        items.addAll(_allReferenceableSingleSources_1);
    } else {
        if ((expr instanceof SelectExpression)) {
            ArrayList<SingleSource> _findAllSingleSources = ModelUtil.findAllSingleSources(((SelectExpression) expr));
            items.addAll(_findAllSingleSources);
        }
    }
    return items;
}
Also used : SingleSource(com.robotoworks.mechanoid.db.sqliteModel.SingleSource) SelectCoreExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression) EObject(org.eclipse.emf.ecore.EObject) SelectExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectExpression) SelectCore(com.robotoworks.mechanoid.db.sqliteModel.SelectCore)

Example 3 with SingleSource

use of com.robotoworks.mechanoid.db.sqliteModel.SingleSource in project mechanoid by robotoworks.

the class ModelUtil method findAllSingleSources.

public static ArrayList<SingleSource> findAllSingleSources(final SelectExpression expr) {
    final ArrayList<SingleSource> items = Lists.<SingleSource>newArrayList();
    JoinSource _source = expr.getSource();
    SingleSource _source_1 = _source.getSource();
    items.add(_source_1);
    JoinSource _source_2 = expr.getSource();
    EList<JoinStatement> _joinStatements = _source_2.getJoinStatements();
    for (final JoinStatement join : _joinStatements) {
        SingleSource _singleSource = join.getSingleSource();
        items.add(_singleSource);
    }
    return items;
}
Also used : JoinSource(com.robotoworks.mechanoid.db.sqliteModel.JoinSource) SingleSource(com.robotoworks.mechanoid.db.sqliteModel.SingleSource) JoinStatement(com.robotoworks.mechanoid.db.sqliteModel.JoinStatement)

Example 4 with SingleSource

use of com.robotoworks.mechanoid.db.sqliteModel.SingleSource in project mechanoid by robotoworks.

the class JoinSourceImpl method basicSetSource.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public NotificationChain basicSetSource(SingleSource newSource, NotificationChain msgs) {
    SingleSource oldSource = source;
    source = newSource;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SqliteModelPackage.JOIN_SOURCE__SOURCE, oldSource, newSource);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : SingleSource(com.robotoworks.mechanoid.db.sqliteModel.SingleSource) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 5 with SingleSource

use of com.robotoworks.mechanoid.db.sqliteModel.SingleSource in project mechanoid by robotoworks.

the class JoinStatementImpl method basicSetSingleSource.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public NotificationChain basicSetSingleSource(SingleSource newSingleSource, NotificationChain msgs) {
    SingleSource oldSingleSource = singleSource;
    singleSource = newSingleSource;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SqliteModelPackage.JOIN_STATEMENT__SINGLE_SOURCE, oldSingleSource, newSingleSource);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : SingleSource(com.robotoworks.mechanoid.db.sqliteModel.SingleSource) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

SingleSource (com.robotoworks.mechanoid.db.sqliteModel.SingleSource)5 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)1 DDLStatement (com.robotoworks.mechanoid.db.sqliteModel.DDLStatement)1 JoinSource (com.robotoworks.mechanoid.db.sqliteModel.JoinSource)1 JoinStatement (com.robotoworks.mechanoid.db.sqliteModel.JoinStatement)1 SelectCore (com.robotoworks.mechanoid.db.sqliteModel.SelectCore)1 SelectCoreExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression)1 SelectExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectExpression)1 SelectList (com.robotoworks.mechanoid.db.sqliteModel.SelectList)1 SingleSourceTable (com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable)1 TableDefinition (com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)1 Consumer (java.util.function.Consumer)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1