Search in sources :

Example 56 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class ContentProviderContractGenerator method _generateBuilderSetters.

protected CharSequence _generateBuilderSetters(final CreateViewStatement stmt) {
    StringConcatenation _builder = new StringConcatenation();
    ArrayList<ColumnSource> cols = ModelUtil.getViewResultColumns(stmt);
    _builder.newLineIfNotEmpty();
    {
        final Function1<ColumnSource, Boolean> _function = new Function1<ColumnSource, Boolean>() {

            public Boolean apply(final ColumnSource it) {
                String _name = it.getName();
                boolean _equals = _name.equals("_id");
                return Boolean.valueOf((!_equals));
            }
        };
        Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(cols, _function);
        for (final ColumnSource item : _filter) {
            ResultColumn col = ((ResultColumn) item);
            _builder.newLineIfNotEmpty();
            ColumnType type = ModelUtil.getInferredColumnType(col);
            _builder.newLineIfNotEmpty();
            _builder.append("public Builder set");
            String _name = col.getName();
            String _pascalize = Strings.pascalize(_name);
            _builder.append(_pascalize, "");
            _builder.append("(");
            String _javaTypeName = ModelUtil.toJavaTypeName(type);
            _builder.append(_javaTypeName, "");
            _builder.append(" value) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("mValues.put(");
            String _name_1 = stmt.getName();
            String _pascalize_1 = Strings.pascalize(_name_1);
            _builder.append(_pascalize_1, "\t");
            _builder.append(".");
            String _name_2 = col.getName();
            String _underscore = Strings.underscore(_name_2);
            String _upperCase = _underscore.toUpperCase();
            _builder.append(_upperCase, "\t");
            _builder.append(", value);");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("return this;");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    }
    return _builder;
}
Also used : ColumnType(com.robotoworks.mechanoid.db.sqliteModel.ColumnType) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ResultColumn(com.robotoworks.mechanoid.db.sqliteModel.ResultColumn) ColumnSource(com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)

Example 57 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class ContentProviderContractGenerator method generate.

public CharSequence generate(final Model model, final SqliteDatabaseSnapshot snapshot) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* Generated by Robotoworks Mechanoid");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.append("package ");
    String _packageName = model.getPackageName();
    _builder.append(_packageName, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import android.net.Uri;");
    _builder.newLine();
    _builder.append("import android.provider.BaseColumns;");
    _builder.newLine();
    _builder.append("import com.robotoworks.mechanoid.Mechanoid;");
    _builder.newLine();
    _builder.append("import com.robotoworks.mechanoid.db.AbstractValuesBuilder;");
    _builder.newLine();
    _builder.append("import java.lang.reflect.Field;\t\t\t");
    _builder.newLine();
    _builder.append("import java.util.Collections;");
    _builder.newLine();
    _builder.append("import java.util.HashSet;");
    _builder.newLine();
    _builder.append("import java.util.HashMap;");
    _builder.newLine();
    _builder.append("import java.util.Set;");
    _builder.newLine();
    _builder.append("import java.util.Map;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class ");
    DatabaseBlock _database = model.getDatabase();
    String _name = _database.getName();
    String _pascalize = Strings.pascalize(_name);
    _builder.append(_pascalize, "");
    _builder.append("Contract  {");
    _builder.newLineIfNotEmpty();
    _builder.append("    ");
    _builder.append("public static final String CONTENT_AUTHORITY = initAuthority();");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("private static String initAuthority() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("String authority = \"");
    String _packageName_1 = model.getPackageName();
    _builder.append(_packageName_1, "\t\t");
    _builder.append(".");
    DatabaseBlock _database_1 = model.getDatabase();
    String _name_1 = _database_1.getName();
    String _lowerCase = _name_1.toLowerCase();
    _builder.append(_lowerCase, "\t\t");
    _builder.append("\";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("try {");
    _builder.newLine();
    _builder.append("    \t\t");
    _builder.newLine();
    _builder.append("    \t\t");
    _builder.append("ClassLoader loader = ");
    DatabaseBlock _database_2 = model.getDatabase();
    String _name_2 = _database_2.getName();
    String _pascalize_1 = Strings.pascalize(_name_2);
    _builder.append(_pascalize_1, "    \t\t");
    _builder.append("Contract.class.getClassLoader();");
    _builder.newLineIfNotEmpty();
    _builder.append("    \t\t");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("Class<?> clz = loader.loadClass(\"");
    String _packageName_2 = model.getPackageName();
    _builder.append(_packageName_2, "\t\t\t");
    _builder.append(".");
    DatabaseBlock _database_3 = model.getDatabase();
    String _name_3 = _database_3.getName();
    String _pascalize_2 = Strings.pascalize(_name_3);
    _builder.append(_pascalize_2, "\t\t\t");
    _builder.append("ContentProviderAuthority\");");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("Field declaredField = clz.getDeclaredField(\"CONTENT_AUTHORITY\");");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("authority = declaredField.get(null).toString();");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} catch (ClassNotFoundException e) {} ");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("catch (NoSuchFieldException e) {} ");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("catch (IllegalArgumentException e) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} catch (IllegalAccessException e) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return authority;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("private static final Uri BASE_CONTENT_URI = Uri.parse(\"content://\" + CONTENT_AUTHORITY);");
    _builder.newLine();
    _builder.newLine();
    {
        Collection<CreateTableStatement> _tables = snapshot.getTables();
        final Function1<CreateTableStatement, String> _function = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy = IterableExtensions.<CreateTableStatement, String>sortBy(_tables, _function);
        for (final CreateTableStatement tbl : _sortBy) {
            _builder.append("\t");
            _builder.append("interface ");
            String _name_4 = tbl.getName();
            String _pascalize_3 = Strings.pascalize(_name_4);
            _builder.append(_pascalize_3, "\t");
            _builder.append("Columns {");
            _builder.newLineIfNotEmpty();
            {
                EList<ColumnSource> _columnDefs = tbl.getColumnDefs();
                final Function1<ColumnSource, Boolean> _function_1 = new Function1<ColumnSource, Boolean>() {

                    public Boolean apply(final ColumnSource it) {
                        String _name = it.getName();
                        boolean _equals = _name.equals("_id");
                        return Boolean.valueOf((!_equals));
                    }
                };
                Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(_columnDefs, _function_1);
                for (final ColumnSource col : _filter) {
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("String ");
                    String _name_5 = col.getName();
                    String _underscore = Strings.underscore(_name_5);
                    String _upperCase = _underscore.toUpperCase();
                    _builder.append(_upperCase, "\t\t");
                    _builder.append(" = \"");
                    String _name_6 = col.getName();
                    _builder.append(_name_6, "\t\t");
                    _builder.append("\";");
                    _builder.newLineIfNotEmpty();
                }
            }
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
        }
    }
    {
        Collection<CreateViewStatement> _views = snapshot.getViews();
        final Function1<CreateViewStatement, String> _function_2 = new Function1<CreateViewStatement, String>() {

            public String apply(final CreateViewStatement x) {
                return x.getName();
            }
        };
        List<CreateViewStatement> _sortBy_1 = IterableExtensions.<CreateViewStatement, String>sortBy(_views, _function_2);
        for (final CreateViewStatement vw : _sortBy_1) {
            _builder.append("\t");
            _builder.append("interface ");
            String _name_7 = vw.getName();
            String _pascalize_4 = Strings.pascalize(_name_7);
            _builder.append(_pascalize_4, "\t");
            _builder.append("Columns {");
            _builder.newLineIfNotEmpty();
            {
                ArrayList<ColumnSource> _viewResultColumns = ModelUtil.getViewResultColumns(vw);
                final Function1<ColumnSource, Boolean> _function_3 = new Function1<ColumnSource, Boolean>() {

                    public Boolean apply(final ColumnSource it) {
                        String _name = it.getName();
                        boolean _equals = _name.equals("_id");
                        return Boolean.valueOf((!_equals));
                    }
                };
                Iterable<ColumnSource> _filter_1 = IterableExtensions.<ColumnSource>filter(_viewResultColumns, _function_3);
                for (final ColumnSource col_1 : _filter_1) {
                    _builder.append("\t");
                    _builder.append("\t");
                    CharSequence _generateInterfaceMemberForResultColumn = this.generateInterfaceMemberForResultColumn(col_1);
                    _builder.append(_generateInterfaceMemberForResultColumn, "\t\t");
                    _builder.newLineIfNotEmpty();
                }
            }
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        Collection<CreateTableStatement> _configInitTables = ModelUtil.getConfigInitTables(model);
        final Function1<CreateTableStatement, String> _function_4 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_2 = IterableExtensions.<CreateTableStatement, String>sortBy(_configInitTables, _function_4);
        for (final CreateTableStatement tbl_1 : _sortBy_2) {
            _builder.append("\t");
            _builder.append("interface ");
            String _name_8 = tbl_1.getName();
            String _pascalize_5 = Strings.pascalize(_name_8);
            _builder.append(_pascalize_5, "\t");
            _builder.append("Columns {");
            _builder.newLineIfNotEmpty();
            {
                EList<ColumnSource> _columnDefs_1 = tbl_1.getColumnDefs();
                final Function1<ColumnSource, Boolean> _function_5 = new Function1<ColumnSource, Boolean>() {

                    public Boolean apply(final ColumnSource it) {
                        String _name = it.getName();
                        boolean _equals = _name.equals("_id");
                        return Boolean.valueOf((!_equals));
                    }
                };
                Iterable<ColumnSource> _filter_2 = IterableExtensions.<ColumnSource>filter(_columnDefs_1, _function_5);
                for (final ColumnSource col_2 : _filter_2) {
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("String ");
                    String _name_9 = col_2.getName();
                    String _underscore_1 = Strings.underscore(_name_9);
                    String _upperCase_1 = _underscore_1.toUpperCase();
                    _builder.append(_upperCase_1, "\t\t");
                    _builder.append(" = \"");
                    String _name_10 = col_2.getName();
                    _builder.append(_name_10, "\t\t");
                    _builder.append("\";");
                    _builder.newLineIfNotEmpty();
                }
            }
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
        }
    }
    {
        Collection<CreateViewStatement> _configInitViews = ModelUtil.getConfigInitViews(model);
        final Function1<CreateViewStatement, String> _function_6 = new Function1<CreateViewStatement, String>() {

            public String apply(final CreateViewStatement x) {
                return x.getName();
            }
        };
        List<CreateViewStatement> _sortBy_3 = IterableExtensions.<CreateViewStatement, String>sortBy(_configInitViews, _function_6);
        for (final CreateViewStatement vw_1 : _sortBy_3) {
            _builder.append("\t");
            _builder.append("interface ");
            String _name_11 = vw_1.getName();
            String _pascalize_6 = Strings.pascalize(_name_11);
            _builder.append(_pascalize_6, "\t");
            _builder.append("Columns {");
            _builder.newLineIfNotEmpty();
            {
                ArrayList<ColumnSource> _viewResultColumns_1 = ModelUtil.getViewResultColumns(vw_1);
                final Function1<ColumnSource, Boolean> _function_7 = new Function1<ColumnSource, Boolean>() {

                    public Boolean apply(final ColumnSource it) {
                        String _name = it.getName();
                        boolean _equals = _name.equals("_id");
                        return Boolean.valueOf((!_equals));
                    }
                };
                Iterable<ColumnSource> _filter_3 = IterableExtensions.<ColumnSource>filter(_viewResultColumns_1, _function_7);
                for (final ColumnSource col_3 : _filter_3) {
                    _builder.append("\t");
                    _builder.append("\t");
                    CharSequence _generateInterfaceMemberForResultColumn_1 = this.generateInterfaceMemberForResultColumn(col_3);
                    _builder.append(_generateInterfaceMemberForResultColumn_1, "\t\t");
                    _builder.newLineIfNotEmpty();
                }
            }
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
        }
    }
    _builder.append("\t\t\t");
    _builder.newLine();
    {
        Collection<CreateTableStatement> _tables_1 = snapshot.getTables();
        final Function1<CreateTableStatement, String> _function_8 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_4 = IterableExtensions.<CreateTableStatement, String>sortBy(_tables_1, _function_8);
        for (final CreateTableStatement tbl_2 : _sortBy_4) {
            _builder.append("\t");
            CharSequence _generateContractItem = this.generateContractItem(model, snapshot, tbl_2);
            _builder.append(_generateContractItem, "\t");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    {
        Collection<CreateViewStatement> _views_1 = snapshot.getViews();
        final Function1<CreateViewStatement, String> _function_9 = new Function1<CreateViewStatement, String>() {

            public String apply(final CreateViewStatement x) {
                return x.getName();
            }
        };
        List<CreateViewStatement> _sortBy_5 = IterableExtensions.<CreateViewStatement, String>sortBy(_views_1, _function_9);
        for (final CreateViewStatement vw_2 : _sortBy_5) {
            _builder.append("\t");
            CharSequence _generateContractItem_1 = this.generateContractItem(model, snapshot, vw_2);
            _builder.append(_generateContractItem_1, "\t");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t");
    _builder.newLine();
    {
        Collection<CreateTableStatement> _configInitTables_1 = ModelUtil.getConfigInitTables(model);
        final Function1<CreateTableStatement, String> _function_10 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_6 = IterableExtensions.<CreateTableStatement, String>sortBy(_configInitTables_1, _function_10);
        for (final CreateTableStatement tbl_3 : _sortBy_6) {
            _builder.append("\t");
            CharSequence _generateContractItem_2 = this.generateContractItem(model, snapshot, tbl_3);
            _builder.append(_generateContractItem_2, "\t");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    {
        Collection<CreateViewStatement> _configInitViews_1 = ModelUtil.getConfigInitViews(model);
        final Function1<CreateViewStatement, String> _function_11 = new Function1<CreateViewStatement, String>() {

            public String apply(final CreateViewStatement x) {
                return x.getName();
            }
        };
        List<CreateViewStatement> _sortBy_7 = IterableExtensions.<CreateViewStatement, String>sortBy(_configInitViews_1, _function_11);
        for (final CreateViewStatement vw_3 : _sortBy_7) {
            _builder.append("\t");
            CharSequence _generateContractItem_3 = this.generateContractItem(model, snapshot, vw_3);
            _builder.append(_generateContractItem_3, "\t");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static Map<Uri, Set<Uri>> REFERENCING_VIEWS;");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("Map<Uri, Set<Uri>> map = new HashMap<Uri, Set<Uri>>();");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    {
        Collection<CreateTableStatement> _tables_2 = snapshot.getTables();
        final Function1<CreateTableStatement, String> _function_12 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_8 = IterableExtensions.<CreateTableStatement, String>sortBy(_tables_2, _function_12);
        for (final CreateTableStatement tbl_4 : _sortBy_8) {
            _builder.append("\t\t");
            _builder.append("map.put(");
            String _name_12 = tbl_4.getName();
            String _pascalize_7 = Strings.pascalize(_name_12);
            _builder.append(_pascalize_7, "\t\t");
            _builder.append(".CONTENT_URI, ");
            String _name_13 = tbl_4.getName();
            String _pascalize_8 = Strings.pascalize(_name_13);
            _builder.append(_pascalize_8, "\t\t");
            _builder.append(".VIEW_URIS);");
            _builder.newLineIfNotEmpty();
        }
    }
    {
        Collection<CreateViewStatement> _views_2 = snapshot.getViews();
        final Function1<CreateViewStatement, String> _function_13 = new Function1<CreateViewStatement, String>() {

            public String apply(final CreateViewStatement x) {
                return x.getName();
            }
        };
        List<CreateViewStatement> _sortBy_9 = IterableExtensions.<CreateViewStatement, String>sortBy(_views_2, _function_13);
        for (final CreateViewStatement vw_4 : _sortBy_9) {
            _builder.append("\t\t");
            _builder.append("map.put(");
            String _name_14 = vw_4.getName();
            String _pascalize_9 = Strings.pascalize(_name_14);
            _builder.append(_pascalize_9, "\t\t");
            _builder.append(".CONTENT_URI, ");
            String _name_15 = vw_4.getName();
            String _pascalize_10 = Strings.pascalize(_name_15);
            _builder.append(_pascalize_10, "\t\t");
            _builder.append(".VIEW_URIS);");
            _builder.newLineIfNotEmpty();
        }
    }
    {
        Collection<CreateTableStatement> _configInitTables_2 = ModelUtil.getConfigInitTables(model);
        final Function1<CreateTableStatement, String> _function_14 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_10 = IterableExtensions.<CreateTableStatement, String>sortBy(_configInitTables_2, _function_14);
        for (final CreateTableStatement tbl_5 : _sortBy_10) {
            _builder.append("\t\t");
            _builder.append("map.put(");
            String _name_16 = tbl_5.getName();
            String _pascalize_11 = Strings.pascalize(_name_16);
            _builder.append(_pascalize_11, "\t\t");
            _builder.append(".CONTENT_URI, ");
            String _name_17 = tbl_5.getName();
            String _pascalize_12 = Strings.pascalize(_name_17);
            _builder.append(_pascalize_12, "\t\t");
            _builder.append(".VIEW_URIS);");
            _builder.newLineIfNotEmpty();
        }
    }
    {
        Collection<CreateViewStatement> _configInitViews_2 = ModelUtil.getConfigInitViews(model);
        final Function1<CreateViewStatement, String> _function_15 = new Function1<CreateViewStatement, String>() {

            public String apply(final CreateViewStatement x) {
                return x.getName();
            }
        };
        List<CreateViewStatement> _sortBy_11 = IterableExtensions.<CreateViewStatement, String>sortBy(_configInitViews_2, _function_15);
        for (final CreateViewStatement vw_5 : _sortBy_11) {
            _builder.append("\t\t");
            _builder.append("map.put(");
            String _name_18 = vw_5.getName();
            String _pascalize_13 = Strings.pascalize(_name_18);
            _builder.append(_pascalize_13, "\t\t");
            _builder.append(".CONTENT_URI, ");
            String _name_19 = vw_5.getName();
            String _pascalize_14 = Strings.pascalize(_name_19);
            _builder.append(_pascalize_14, "\t\t");
            _builder.append(".VIEW_URIS);");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("REFERENCING_VIEWS = Collections.unmodifiableMap(map);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    CharSequence _generateContractItemsForActions = this.generateContractItemsForActions(model, snapshot);
    _builder.append(_generateContractItemsForActions, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("private ");
    DatabaseBlock _database_4 = model.getDatabase();
    String _name_20 = _database_4.getName();
    String _pascalize_15 = Strings.pascalize(_name_20);
    _builder.append(_pascalize_15, "\t");
    _builder.append("Contract(){}");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/**");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("* <p>Delete all rows from all tables</p>");
    _builder.newLine();
    _builder.append("\t ");
    _builder.append("*/\t\t\t\t\t\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public static void deleteAll() {");
    _builder.newLine();
    {
        Collection<CreateTableStatement> _tables_3 = snapshot.getTables();
        final Function1<CreateTableStatement, String> _function_16 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_12 = IterableExtensions.<CreateTableStatement, String>sortBy(_tables_3, _function_16);
        for (final CreateTableStatement tbl_6 : _sortBy_12) {
            _builder.append("\t\t");
            String _name_21 = tbl_6.getName();
            String _pascalize_16 = Strings.pascalize(_name_21);
            _builder.append(_pascalize_16, "\t\t");
            _builder.append(".delete();");
            _builder.newLineIfNotEmpty();
        }
    }
    {
        Collection<CreateTableStatement> _configInitTables_3 = ModelUtil.getConfigInitTables(model);
        final Function1<CreateTableStatement, String> _function_17 = new Function1<CreateTableStatement, String>() {

            public String apply(final CreateTableStatement x) {
                return x.getName();
            }
        };
        List<CreateTableStatement> _sortBy_13 = IterableExtensions.<CreateTableStatement, String>sortBy(_configInitTables_3, _function_17);
        for (final CreateTableStatement tbl_7 : _sortBy_13) {
            _builder.append("\t\t");
            String _name_22 = tbl_7.getName();
            String _pascalize_17 = Strings.pascalize(_name_22);
            _builder.append(_pascalize_17, "\t\t");
            _builder.append(".delete();");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : DatabaseBlock(com.robotoworks.mechanoid.db.sqliteModel.DatabaseBlock) CreateViewStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateViewStatement) CreateTableStatement(com.robotoworks.mechanoid.db.sqliteModel.CreateTableStatement) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Collection(java.util.Collection) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ColumnSource(com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)

Example 58 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class ClientGenerator method generateServicePostMethod.

public CharSequence generateServicePostMethod(final HttpMethod method) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("return post(request, parser);");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 59 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class ClientGenerator method printSetHeadersStatements.

public CharSequence printSetHeadersStatements() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("for(String key : headers.keySet()) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("conn.setRequestProperty(key, headers.get(key));");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("for(String key : request.getHeaderKeys()) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("conn.setRequestProperty(key, request.getHeaderValue(key));");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 60 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class ClientGenerator method generateServiceGetMethod.

public CharSequence generateServiceGetMethod(final HttpMethod method) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("return get(request, parser);");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4966 Test (org.junit.Test)4419 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)1231 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)372 AbstractXtendFormatterTest (org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest)214 AbstractXtendContentAssistBugTest (org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest)183 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)182 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)131 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)130 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)129 IFile (org.eclipse.core.resources.IFile)122 QuickfixTestBuilder (org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder)122 AmbiguityValidationTest (org.eclipse.xtend.core.tests.validation.AmbiguityValidationTest)118 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)115 Grammar (org.eclipse.xtext.Grammar)101 EObject (org.eclipse.emf.ecore.EObject)99 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)99 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)99 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)97 AbstractRule (org.eclipse.xtext.AbstractRule)96