Search in sources :

Example 1 with SelectExpression

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

the class XSqliteModelScopeProvider method scope_ColumnSourceRef_column.

public IScope scope_ColumnSourceRef_column(final SelectList context, final EReference reference) {
    SelectExpression expr = ModelUtil.<SelectExpression>getAncestorOfType(context, SelectExpression.class);
    ArrayList<EObject> _allReferenceableColumns = ModelUtil.getAllReferenceableColumns(expr, false);
    return Scopes.scopeFor(_allReferenceableColumns);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) SelectExpression(com.robotoworks.mechanoid.db.sqliteModel.SelectExpression)

Example 2 with SelectExpression

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

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

the class ModelUtil method getAllReferenceableColumns.

public static ArrayList<EObject> getAllReferenceableColumns(final SelectCoreExpression expr) {
    final ArrayList<EObject> items = Lists.<EObject>newArrayList();
    if ((expr instanceof SelectCore)) {
        SelectCoreExpression _left = ((SelectCore) expr).getLeft();
        ArrayList<EObject> _allReferenceableColumns = ModelUtil.getAllReferenceableColumns(_left);
        items.addAll(_allReferenceableColumns);
        SelectCoreExpression _right = ((SelectCore) expr).getRight();
        ArrayList<EObject> _allReferenceableColumns_1 = ModelUtil.getAllReferenceableColumns(_right);
        items.addAll(_allReferenceableColumns_1);
    } else {
        if ((expr instanceof SelectExpression)) {
            ArrayList<EObject> _allReferenceableColumns_2 = ModelUtil.getAllReferenceableColumns(((SelectExpression) expr), true);
            items.addAll(_allReferenceableColumns_2);
        }
    }
    return items;
}
Also used : 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 4 with SelectExpression

use of com.robotoworks.mechanoid.db.sqliteModel.SelectExpression 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)

Aggregations

SelectExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectExpression)4 SelectCore (com.robotoworks.mechanoid.db.sqliteModel.SelectCore)3 SelectCoreExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression)3 EObject (org.eclipse.emf.ecore.EObject)3 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)1 SelectList (com.robotoworks.mechanoid.db.sqliteModel.SelectList)1 SelectStatement (com.robotoworks.mechanoid.db.sqliteModel.SelectStatement)1 SingleSource (com.robotoworks.mechanoid.db.sqliteModel.SingleSource)1 ArrayList (java.util.ArrayList)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1