Search in sources :

Example 1 with SelectStatement

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

the class InsertStatementImpl method basicSetSelectStatement.

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

Example 2 with SelectStatement

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

the class CreateViewStatementImpl method basicSetSelectStatement.

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

Example 3 with SelectStatement

use of com.robotoworks.mechanoid.db.sqliteModel.SelectStatement 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;
}
Also used : SelectStatement(com.robotoworks.mechanoid.db.sqliteModel.SelectStatement) SingleSourceSelectStatement(com.robotoworks.mechanoid.db.sqliteModel.SingleSourceSelectStatement) DDLStatement(com.robotoworks.mechanoid.db.sqliteModel.DDLStatement) SingleSourceSelectStatement(com.robotoworks.mechanoid.db.sqliteModel.SingleSourceSelectStatement) SelectCoreExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression) EObject(org.eclipse.emf.ecore.EObject) IScope(org.eclipse.xtext.scoping.IScope) SingleSourceTable(com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition) SelectSource(com.robotoworks.mechanoid.db.sqliteModel.SelectSource)

Example 4 with SelectStatement

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

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

the class StatementSequenceValidator method _validateStatement.

protected void _validateStatement(final StatementSequenceValidatorResult result, final CreateViewStatement stmt) {
    String _name = stmt.getName();
    boolean _nameExists = this.nameExists(_name);
    if (_nameExists) {
        result.valid = false;
        result.message = "Name conflict, use another name";
        result.feature = SqliteModelPackage.Literals.TABLE_DEFINITION__NAME;
    } else {
        SelectStatement _selectStatement = stmt.getSelectStatement();
        SelectCoreExpression _core = _selectStatement.getCore();
        this.validateTablesInExpression(result, _core);
    }
}
Also used : SelectStatement(com.robotoworks.mechanoid.db.sqliteModel.SelectStatement) SelectCoreExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression)

Aggregations

SelectStatement (com.robotoworks.mechanoid.db.sqliteModel.SelectStatement)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)4 SelectCoreExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression)3 SingleSourceSelectStatement (com.robotoworks.mechanoid.db.sqliteModel.SingleSourceSelectStatement)2 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)1 DDLStatement (com.robotoworks.mechanoid.db.sqliteModel.DDLStatement)1 SelectCore (com.robotoworks.mechanoid.db.sqliteModel.SelectCore)1 SelectExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectExpression)1 SelectList (com.robotoworks.mechanoid.db.sqliteModel.SelectList)1 SelectSource (com.robotoworks.mechanoid.db.sqliteModel.SelectSource)1 SingleSourceTable (com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable)1 TableDefinition (com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)1 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 IScope (org.eclipse.xtext.scoping.IScope)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1