Search in sources :

Example 1 with SelectList

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

the class SelectExpressionImpl method basicSetSelectList.

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

Example 2 with SelectList

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

the class ModelUtil method getViewResultColumns.

public static ArrayList<ColumnSource> getViewResultColumns(final CreateViewStatement stmt) {
    ArrayList<ColumnSource> result = new ArrayList<ColumnSource>();
    SelectStatement _selectStatement = stmt.getSelectStatement();
    SelectCoreExpression coreExpr = _selectStatement.getCore();
    if ((coreExpr instanceof SelectCore)) {
        SelectCore core = ((SelectCore) coreExpr);
        SelectCoreExpression _right = core.getRight();
        SelectList selectList = ((SelectExpression) _right).getSelectList();
        boolean _notEquals = (!Objects.equal(selectList, null));
        if (_notEquals) {
            EList<ColumnSource> _resultColumns = selectList.getResultColumns();
            final Function1<ColumnSource, Boolean> _function = new Function1<ColumnSource, Boolean>() {

                public Boolean apply(final ColumnSource it) {
                    boolean _and = false;
                    String _name = it.getName();
                    boolean _notEquals = (!Objects.equal(_name, null));
                    if (!_notEquals) {
                        _and = false;
                    } else {
                        String _name_1 = it.getName();
                        boolean _equals = _name_1.equals("");
                        boolean _not = (!_equals);
                        _and = _not;
                    }
                    return Boolean.valueOf(_and);
                }
            };
            Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(_resultColumns, _function);
            Iterables.<ColumnSource>addAll(result, _filter);
        }
    } else {
        SelectList selectList_1 = ((SelectExpression) coreExpr).getSelectList();
        boolean _notEquals_1 = (!Objects.equal(selectList_1, null));
        if (_notEquals_1) {
            EList<ColumnSource> _resultColumns_1 = selectList_1.getResultColumns();
            final Function1<ColumnSource, Boolean> _function_1 = new Function1<ColumnSource, Boolean>() {

                public Boolean apply(final ColumnSource it) {
                    boolean _and = false;
                    String _name = it.getName();
                    boolean _notEquals = (!Objects.equal(_name, null));
                    if (!_notEquals) {
                        _and = false;
                    } else {
                        String _name_1 = it.getName();
                        boolean _equals = _name_1.equals("");
                        boolean _not = (!_equals);
                        _and = _not;
                    }
                    return Boolean.valueOf(_and);
                }
            };
            Iterable<ColumnSource> _filter_1 = IterableExtensions.<ColumnSource>filter(_resultColumns_1, _function_1);
            Iterables.<ColumnSource>addAll(result, _filter_1);
        }
    }
    return result;
}
Also used : SelectList(com.robotoworks.mechanoid.db.sqliteModel.SelectList) SelectCoreExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression) ArrayList(java.util.ArrayList) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) SelectExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectExpression) SelectCore(com.robotoworks.mechanoid.db.sqliteModel.SelectCore) SelectStatement(com.robotoworks.mechanoid.db.sqliteModel.SelectStatement) ColumnSource(com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)

Example 3 with SelectList

use of com.robotoworks.mechanoid.db.sqliteModel.SelectList 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 4 with SelectList

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

the class SqliteModelProposalProvider method completePrimaryExpression_Column.

@Override
public void completePrimaryExpression_Column(EObject model, Assignment assignment, ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    EObject lastObj = NodeModelUtils.findActualSemanticObjectFor(context.getLastCompleteNode());
    EObject currentObj = NodeModelUtils.findActualSemanticObjectFor(context.getCurrentNode());
    ICompositeNode node = NodeModelUtils.getNode(lastObj);
    if (lastObj instanceof ColumnSourceRef) {
        ColumnSourceRef ref = (ColumnSourceRef) lastObj;
        if (ref.getColumn() == null) {
            lookupCrossReference(ref, SqliteModelPackage.Literals.COLUMN_SOURCE_REF__COLUMN, acceptor, Predicates.<IEObjectDescription>alwaysTrue(), getProposalFactory("column", context));
            return;
        }
    }
    SelectList selectList = ModelUtil.getAncestorOfType(currentObj, SelectList.class);
    if (selectList != null) {
        lookupCrossReference(selectList, SqliteModelPackage.Literals.COLUMN_SOURCE_REF__COLUMN, acceptor, Predicates.<IEObjectDescription>alwaysTrue(), getProposalFactory("column", context));
        return;
    }
    super.completePrimaryExpression_Column(model, assignment, context, acceptor);
}
Also used : SelectList(com.robotoworks.mechanoid.db.sqliteModel.SelectList) ColumnSourceRef(com.robotoworks.mechanoid.db.sqliteModel.ColumnSourceRef) EObject(org.eclipse.emf.ecore.EObject) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode)

Aggregations

SelectList (com.robotoworks.mechanoid.db.sqliteModel.SelectList)4 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)2 EObject (org.eclipse.emf.ecore.EObject)2 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)2 ColumnSourceRef (com.robotoworks.mechanoid.db.sqliteModel.ColumnSourceRef)1 DDLStatement (com.robotoworks.mechanoid.db.sqliteModel.DDLStatement)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 SelectStatement (com.robotoworks.mechanoid.db.sqliteModel.SelectStatement)1 SingleSource (com.robotoworks.mechanoid.db.sqliteModel.SingleSource)1 SingleSourceTable (com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable)1 TableDefinition (com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)1 ArrayList (java.util.ArrayList)1 Consumer (java.util.function.Consumer)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)1