package com.justeat.mickeydb.generator;

import com.justeat.mickeydb.ContentUris;
import com.justeat.mickeydb.MickeyDatabaseModel;
import com.justeat.mickeydb.Strings;
import com.justeat.mickeydb.generator.SqliteDatabaseSnapshot;
import com.justeat.mickeydb.mickeyLang.ActionStatement;
import com.justeat.mickeydb.mickeyLang.TableDefinition;
import org.eclipse.xtend2.lib.StringConcatenation;

@SuppressWarnings("all")
public class ContentProviderGenerator {
  public CharSequence generate(final MickeyDatabaseModel model, final ContentUris content) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method getSnapshot() from the type MickeyDatabaseModel refers to the missing type SqliteDatabaseSnapshot");
  }
  
  public String asString(final ActionStatement action) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\n== cannot be resolved");
  }
  
  public String generateContentTypeConstantReference(final ActionStatement action, final String databaseName) {
    boolean _isUnique = action.isUnique();
    if (_isUnique) {
      String _pascalize = Strings.pascalize(databaseName);
      String _plus = (_pascalize + "Contract.");
      TableDefinition _type = action.getType();
      String _name = _type.getName();
      String _pascalize_1 = Strings.pascalize(_name);
      String _plus_1 = (_plus + _pascalize_1);
      return (_plus_1 + ".ITEM_CONTENT_TYPE");
    } else {
      String _pascalize_2 = Strings.pascalize(databaseName);
      String _plus_2 = (_pascalize_2 + "Contract.");
      TableDefinition _type_1 = action.getType();
      String _name_1 = _type_1.getName();
      String _pascalize_3 = Strings.pascalize(_name_1);
      String _plus_3 = (_plus_2 + _pascalize_3);
      return (_plus_3 + ".CONTENT_TYPE");
    }
  }
  
  public CharSequence generateStub(final MickeyDatabaseModel model, final SqliteDatabaseSnapshot snapshot) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/*******************************************************************************");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* Copyright (c) 2012, Robotoworks Limited");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* All rights reserved. This program and the accompanying materials");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* are made available under the terms of the Eclipse Public License v1.0");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* which accompanies this distribution, and is available at");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* http://www.eclipse.org/legal/epl-v10.html");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* ");
    _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 ");
    String _packageName_1 = model.getPackageName();
    _builder.append(_packageName_1, "");
    _builder.append(".Abstract");
    String _databaseName = model.getDatabaseName();
    String _pascalize = Strings.pascalize(_databaseName);
    _builder.append(_pascalize, "");
    _builder.append("ContentProvider;");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("public class ");
    String _databaseName_1 = model.getDatabaseName();
    String _pascalize_1 = Strings.pascalize(_databaseName_1);
    _builder.append(_pascalize_1, "");
    _builder.append("ContentProvider extends Abstract");
    String _databaseName_2 = model.getDatabaseName();
    String _pascalize_2 = Strings.pascalize(_databaseName_2);
    _builder.append(_pascalize_2, "");
    _builder.append("ContentProvider {}");
    _builder.newLineIfNotEmpty();
    return _builder;
  }
}
