Search in sources :

Example 21 with TableDefinition

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

the class AlterTableRenameStatementImpl method setTable.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public void setTable(TableDefinition newTable) {
    TableDefinition oldTable = table;
    table = newTable;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, SqliteModelPackage.ALTER_TABLE_RENAME_STATEMENT__TABLE, oldTable, table));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Example 22 with TableDefinition

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 UpdateStatement context, final EReference reference) {
    DDLStatement containingStmt = ModelUtil.<DDLStatement>getAncestorOfType(context, DDLStatement.class);
    TableDefinition _table = context.getTable();
    ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(containingStmt, _table);
    return Scopes.scopeFor(_findColumnDefs, IScope.NULLSCOPE);
}
Also used : DDLStatement(com.robotoworks.mechanoid.db.sqliteModel.DDLStatement) EObject(org.eclipse.emf.ecore.EObject) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Example 23 with TableDefinition

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

the class XSqliteModelScopeProvider method scope_NewColumn_column.

public IScope scope_NewColumn_column(final NewColumn 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;
}
Also used : CreateTriggerStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateTriggerStatement) EObject(org.eclipse.emf.ecore.EObject) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Example 24 with TableDefinition

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

the class XSqliteModelScopeProvider method scope_ColumnSourceRef_source.

public IScope scope_ColumnSourceRef_source(final DeleteStatement context, final EReference reference) {
    DDLStatement ddl = ModelUtil.<DDLStatement>getAncestorOfType(context, DDLStatement.class);
    TableDefinition _table = context.getTable();
    ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(ddl, _table);
    return Scopes.scopeFor(_findColumnDefs, IScope.NULLSCOPE);
}
Also used : DDLStatement(com.robotoworks.mechanoid.db.sqliteModel.DDLStatement) EObject(org.eclipse.emf.ecore.EObject) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Example 25 with TableDefinition

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

the class XSqliteModelScopeProvider method scopeForTableDefinitionsBeforeStatement.

public IScope scopeForTableDefinitionsBeforeStatement(final DatabaseBlock db, final DDLStatement stmt, final boolean inclusive) {
    ArrayList<TableDefinition> refs = ModelUtil.<TableDefinition>findPreviousStatementsOfType(db, 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);
}
Also used : Function(com.google.common.base.Function) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Aggregations

TableDefinition (com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)33 EObject (org.eclipse.emf.ecore.EObject)16 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)9 DDLStatement (com.robotoworks.mechanoid.db.sqliteModel.DDLStatement)7 SingleSourceTable (com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable)5 Function (com.google.common.base.Function)3 CreateViewStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement)3 HashMap (java.util.HashMap)3 QualifiedName (org.eclipse.xtext.naming.QualifiedName)3 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)3 AlterTableAddColumnStatement (com.robotoworks.mechanoid.db.sqliteModel.AlterTableAddColumnStatement)2 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)2 CreateTableStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateTableStatement)2 CreateTriggerStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateTriggerStatement)2 Consumer (java.util.function.Consumer)2 AlterTableRenameStatement (com.robotoworks.mechanoid.db.sqliteModel.AlterTableRenameStatement)1 ColumnDef (com.robotoworks.mechanoid.db.sqliteModel.ColumnDef)1 ResultColumn (com.robotoworks.mechanoid.db.sqliteModel.ResultColumn)1 SelectCoreExpression (com.robotoworks.mechanoid.db.sqliteModel.SelectCoreExpression)1 SelectList (com.robotoworks.mechanoid.db.sqliteModel.SelectList)1