Search in sources :

Example 11 with CreateViewStatement

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

the class StatementSequenceValidator method _sequence.

protected void _sequence(final DropViewStatement stmt) {
    CreateViewStatement _view = stmt.getView();
    String _name = _view.getName();
    this.views.remove(_name);
}
Also used : CreateViewStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement)

Example 12 with CreateViewStatement

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

the class DropViewStatementImpl method setView.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public void setView(CreateViewStatement newView) {
    CreateViewStatement oldView = view;
    view = newView;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, SqliteModelPackage.DROP_VIEW_STATEMENT__VIEW, oldView, view));
}
Also used : CreateViewStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 13 with CreateViewStatement

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

the class ModelUtil method isDefinitionReferencedByView.

public static boolean isDefinitionReferencedByView(final TableDefinition tableDef, final CreateViewStatement view) {
    TreeIterator<EObject> _eAllContents = view.eAllContents();
    final Function1<EObject, Boolean> _function = new Function1<EObject, Boolean>() {

        public Boolean apply(final EObject obj) {
            if ((obj instanceof SingleSourceTable)) {
                SingleSourceTable sourceTable = ((SingleSourceTable) obj);
                TableDefinition _tableReference = sourceTable.getTableReference();
                if ((!(_tableReference instanceof CreateViewStatement))) {
                    TableDefinition _tableReference_1 = sourceTable.getTableReference();
                    String _name = _tableReference_1.getName();
                    String _name_1 = tableDef.getName();
                    boolean _equals = _name.equals(_name_1);
                    if (_equals) {
                        return Boolean.valueOf(true);
                    }
                } else {
                    TableDefinition _tableReference_2 = sourceTable.getTableReference();
                    return Boolean.valueOf(ModelUtil.isDefinitionReferencedByView(tableDef, ((CreateViewStatement) _tableReference_2)));
                }
            }
            return Boolean.valueOf(false);
        }
    };
    return IteratorExtensions.<EObject>exists(_eAllContents, _function);
}
Also used : CreateViewStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement) EObject(org.eclipse.emf.ecore.EObject) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) SingleSourceTable(com.robotoworks.mechanoid.db.sqliteModel.SingleSourceTable) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Example 14 with CreateViewStatement

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

the class ModelUtil method getConfigInitViews.

public static Collection<CreateViewStatement> getConfigInitViews(final Model model) {
    final ArrayList<CreateViewStatement> items = Lists.<CreateViewStatement>newArrayList();
    DatabaseBlock _database = model.getDatabase();
    InitBlock _init = _database.getInit();
    boolean _notEquals = (!Objects.equal(_init, null));
    if (_notEquals) {
        DatabaseBlock _database_1 = model.getDatabase();
        InitBlock _init_1 = _database_1.getInit();
        EList<DDLStatement> _statements = _init_1.getStatements();
        Iterable<CreateViewStatement> _filter = Iterables.<CreateViewStatement>filter(_statements, CreateViewStatement.class);
        Iterables.<CreateViewStatement>addAll(items, _filter);
    }
    return items;
}
Also used : CreateViewStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement) DatabaseBlock(com.robotoworks.mechanoid.db.sqliteModel.DatabaseBlock) DDLStatement(com.robotoworks.mechanoid.db.sqliteModel.DDLStatement) InitBlock(com.robotoworks.mechanoid.db.sqliteModel.InitBlock)

Example 15 with CreateViewStatement

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

the class ModelUtil method getAllViewsInConfigInitReferencingTable.

public static HashSet<CreateViewStatement> getAllViewsInConfigInitReferencingTable(final Model model, final TableDefinition tableDef) {
    HashSet<CreateViewStatement> matches = new HashSet<CreateViewStatement>();
    Collection<CreateViewStatement> _configInitViews = ModelUtil.getConfigInitViews(model);
    for (final CreateViewStatement view : _configInitViews) {
        boolean _isDefinitionReferencedByView = ModelUtil.isDefinitionReferencedByView(tableDef, view);
        if (_isDefinitionReferencedByView) {
            matches.add(view);
        }
    }
    return matches;
}
Also used : CreateViewStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement) HashSet(java.util.HashSet)

Aggregations

CreateViewStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement)15 CreateTableStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateTableStatement)6 DatabaseBlock (com.robotoworks.mechanoid.db.sqliteModel.DatabaseBlock)6 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)5 EObject (org.eclipse.emf.ecore.EObject)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 TableDefinition (com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3 EList (org.eclipse.emf.common.util.EList)3 ActionStatement (com.robotoworks.mechanoid.db.sqliteModel.ActionStatement)2 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)2 InitBlock (com.robotoworks.mechanoid.db.sqliteModel.InitBlock)2 MigrationBlock (com.robotoworks.mechanoid.db.sqliteModel.MigrationBlock)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 Function (com.google.common.base.Function)1 SqliteDatabaseSnapshot (com.robotoworks.mechanoid.db.generator.SqliteDatabaseSnapshot)1 AlterTableAddColumnStatement (com.robotoworks.mechanoid.db.sqliteModel.AlterTableAddColumnStatement)1