use of com.robotoworks.mechanoid.db.sqliteModel.DDLStatement in project mechanoid by robotoworks.
the class ModelUtil method findPreviousStatementsOfType.
public static <T extends DDLStatement> ArrayList<T> findPreviousStatementsOfType(final DDLStatement stmt, final Class<T> statementType, final boolean inclusive) {
ArrayList<T> list = new ArrayList<T>();
DatabaseBlock db = ModelUtil.<DatabaseBlock>getAncestorOfType(stmt, DatabaseBlock.class);
EList<MigrationBlock> _migrations = db.getMigrations();
for (final MigrationBlock migration : _migrations) {
EList<DDLStatement> _statements = migration.getStatements();
for (final DDLStatement ddl : _statements) {
{
if ((!inclusive)) {
boolean _equals = Objects.equal(ddl, stmt);
if (_equals) {
return list;
}
}
Class<? extends DDLStatement> _class = ddl.getClass();
boolean _isAssignableFrom = statementType.isAssignableFrom(_class);
if (_isAssignableFrom) {
list.add(((T) ddl));
}
boolean _equals_1 = Objects.equal(ddl, stmt);
if (_equals_1) {
return list;
}
}
}
}
InitBlock _ancestorOfType = ModelUtil.<InitBlock>getAncestorOfType(stmt, InitBlock.class);
boolean _notEquals = (!Objects.equal(_ancestorOfType, null));
if (_notEquals) {
InitBlock _init = db.getInit();
EList<DDLStatement> _statements_1 = _init.getStatements();
for (final DDLStatement ddl_1 : _statements_1) {
{
if ((!inclusive)) {
boolean _equals = Objects.equal(ddl_1, stmt);
if (_equals) {
return list;
}
}
Class<? extends DDLStatement> _class = ddl_1.getClass();
boolean _isAssignableFrom = statementType.isAssignableFrom(_class);
if (_isAssignableFrom) {
list.add(((T) ddl_1));
}
boolean _equals_1 = Objects.equal(ddl_1, stmt);
if (_equals_1) {
return list;
}
}
}
}
return list;
}
use of com.robotoworks.mechanoid.db.sqliteModel.DDLStatement in project mechanoid by robotoworks.
the class ModelUtil method getConfigInitTables.
public static Collection<CreateTableStatement> getConfigInitTables(final Model model) {
final ArrayList<CreateTableStatement> items = Lists.<CreateTableStatement>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<CreateTableStatement> _filter = Iterables.<CreateTableStatement>filter(_statements, CreateTableStatement.class);
Iterables.<CreateTableStatement>addAll(items, _filter);
}
return items;
}
use of com.robotoworks.mechanoid.db.sqliteModel.DDLStatement in project mechanoid by robotoworks.
the class ModelUtil method findPreviousStatementsOfType.
public static <T extends DDLStatement> ArrayList<T> findPreviousStatementsOfType(final DatabaseBlock db, final DDLStatement stmt, final Class<T> statementType, final boolean inclusive) {
ArrayList<T> list = new ArrayList<T>();
EList<MigrationBlock> _migrations = db.getMigrations();
for (final MigrationBlock migration : _migrations) {
EList<DDLStatement> _statements = migration.getStatements();
for (final DDLStatement ddl : _statements) {
{
if ((!inclusive)) {
boolean _equals = Objects.equal(ddl, stmt);
if (_equals) {
return list;
}
}
Class<? extends DDLStatement> _class = ddl.getClass();
boolean _isAssignableFrom = statementType.isAssignableFrom(_class);
if (_isAssignableFrom) {
list.add(((T) ddl));
}
boolean _equals_1 = Objects.equal(ddl, stmt);
if (_equals_1) {
return list;
}
}
}
}
InitBlock _init = db.getInit();
boolean _notEquals = (!Objects.equal(_init, null));
if (_notEquals) {
InitBlock _init_1 = db.getInit();
EList<DDLStatement> _statements_1 = _init_1.getStatements();
for (final DDLStatement ddl_1 : _statements_1) {
{
if ((!inclusive)) {
boolean _equals = Objects.equal(ddl_1, stmt);
if (_equals) {
return list;
}
}
Class<? extends DDLStatement> _class = ddl_1.getClass();
boolean _isAssignableFrom = statementType.isAssignableFrom(_class);
if (_isAssignableFrom) {
list.add(((T) ddl_1));
}
boolean _equals_1 = Objects.equal(ddl_1, stmt);
if (_equals_1) {
return list;
}
}
}
}
return list;
}
use of com.robotoworks.mechanoid.db.sqliteModel.DDLStatement in project mechanoid by robotoworks.
the class ModelUtil method findStatementsOfTypeBetween.
public static <T extends DDLStatement> ArrayList<T> findStatementsOfTypeBetween(final Class<T> statementType, final DDLStatement from, final DDLStatement to) {
ArrayList<T> list = new ArrayList<T>();
boolean between = false;
DatabaseBlock db = ModelUtil.<DatabaseBlock>getAncestorOfType(from, DatabaseBlock.class);
EList<MigrationBlock> _migrations = db.getMigrations();
for (final MigrationBlock migration : _migrations) {
EList<DDLStatement> _statements = migration.getStatements();
for (final DDLStatement ddl : _statements) {
{
boolean _equals = Objects.equal(ddl, to);
if (_equals) {
return list;
}
Class<? extends DDLStatement> _class = ddl.getClass();
boolean _isAssignableFrom = statementType.isAssignableFrom(_class);
if (_isAssignableFrom) {
if (between) {
list.add(((T) ddl));
}
}
boolean _equals_1 = Objects.equal(ddl, from);
if (_equals_1) {
between = true;
}
}
}
}
return list;
}
use of com.robotoworks.mechanoid.db.sqliteModel.DDLStatement in project mechanoid by robotoworks.
the class XSqliteModelScopeProvider method scope_InsertStatement_columnNames.
public IScope scope_InsertStatement_columnNames(final InsertStatement context, final EReference reference) {
DDLStatement stmt = ModelUtil.<DDLStatement>getAncestorOfType(context, DDLStatement.class);
TableDefinition _table = context.getTable();
ArrayList<EObject> _findColumnDefs = ModelUtil.findColumnDefs(stmt, _table);
return Scopes.scopeFor(_findColumnDefs, IScope.NULLSCOPE);
}
Aggregations