Search in sources :

Example 6 with ContentUri

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

the class ContentProviderContractGenerator method generateContractItemsForActions.

public CharSequence generateContractItemsForActions(final Model model, final SqliteDatabaseSnapshot snapshot) {
    StringConcatenation _builder = new StringConcatenation();
    {
        DatabaseBlock _database = model.getDatabase();
        ConfigBlock _config = _database.getConfig();
        boolean _notEquals = (!Objects.equal(_config, null));
        if (_notEquals) {
            {
                DatabaseBlock _database_1 = model.getDatabase();
                ConfigBlock _config_1 = _database_1.getConfig();
                EList<ConfigurationStatement> _statements = _config_1.getStatements();
                Iterable<ActionStatement> _filter = Iterables.<ActionStatement>filter(_statements, ActionStatement.class);
                final Function1<ActionStatement, Boolean> _function = new Function1<ActionStatement, Boolean>() {

                    public Boolean apply(final ActionStatement it) {
                        ContentUri _uri = it.getUri();
                        String _type = _uri.getType();
                        boolean _containsDefinition = snapshot.containsDefinition(_type);
                        return Boolean.valueOf((!_containsDefinition));
                    }
                };
                Iterable<ActionStatement> _filter_1 = IterableExtensions.<ActionStatement>filter(_filter, _function);
                for (final ActionStatement action : _filter_1) {
                    _builder.append("public static class ");
                    ContentUri _uri = action.getUri();
                    String _type = _uri.getType();
                    String _pascalize = Strings.pascalize(_type);
                    _builder.append(_pascalize, "");
                    _builder.append(" {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    CharSequence _createActionUriBuilderMethod = this.createActionUriBuilderMethod(action);
                    _builder.append(_createActionUriBuilderMethod, "\t");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("public static final String CONTENT_TYPE =");
                    _builder.newLine();
                    _builder.append("\t        ");
                    _builder.append("\"vnd.android.cursor.dir/vnd.");
                    DatabaseBlock _database_2 = model.getDatabase();
                    String _name = _database_2.getName();
                    String _lowerCase = _name.toLowerCase();
                    _builder.append(_lowerCase, "\t        ");
                    _builder.append(".");
                    ContentUri _uri_1 = action.getUri();
                    String _type_1 = _uri_1.getType();
                    _builder.append(_type_1, "\t        ");
                    _builder.append("\";");
                    _builder.newLineIfNotEmpty();
                    _builder.append("}");
                    _builder.newLine();
                    _builder.newLine();
                }
            }
        }
    }
    return _builder;
}
Also used : ActionStatement(com.robotoworks.mechanoid.db.sqliteModel.ActionStatement) DatabaseBlock(com.robotoworks.mechanoid.db.sqliteModel.DatabaseBlock) ContentUri(com.robotoworks.mechanoid.db.sqliteModel.ContentUri) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ConfigurationStatement(com.robotoworks.mechanoid.db.sqliteModel.ConfigurationStatement) ConfigBlock(com.robotoworks.mechanoid.db.sqliteModel.ConfigBlock) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Aggregations

ContentUri (com.robotoworks.mechanoid.db.sqliteModel.ContentUri)6 DatabaseBlock (com.robotoworks.mechanoid.db.sqliteModel.DatabaseBlock)4 ActionStatement (com.robotoworks.mechanoid.db.sqliteModel.ActionStatement)3 ConfigBlock (com.robotoworks.mechanoid.db.sqliteModel.ConfigBlock)3 ConfigurationStatement (com.robotoworks.mechanoid.db.sqliteModel.ConfigurationStatement)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)3 ContentUriParamSegment (com.robotoworks.mechanoid.db.sqliteModel.ContentUriParamSegment)1 ContentUriSegment (com.robotoworks.mechanoid.db.sqliteModel.ContentUriSegment)1 CreateTableStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateTableStatement)1 CreateViewStatement (com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 EList (org.eclipse.emf.common.util.EList)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1