package com.justeat.mickeydb.generator;

import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
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.ColumnSource;
import com.justeat.mickeydb.mickeyLang.ContentUri;
import com.justeat.mickeydb.mickeyLang.ContentUriParamSegment;
import com.justeat.mickeydb.mickeyLang.ContentUriSegment;
import com.justeat.mickeydb.mickeyLang.CreateTableStatement;
import com.justeat.mickeydb.mickeyLang.CreateViewStatement;
import com.justeat.mickeydb.mickeyLang.TableDefinition;
import java.util.Arrays;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

@SuppressWarnings("all")
public class ContentProviderContractGenerator {
  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"
      + "\nThe field MickeyDatabaseModel.initTables refers to the missing type CreateTableStatement"
      + "\nThe field MickeyDatabaseModel.initViews refers to the missing type CreateViewStatement"
      + "\nThe field MickeyDatabaseModel.initTables refers to the missing type CreateTableStatement"
      + "\nThe field MickeyDatabaseModel.initViews refers to the missing type CreateViewStatement"
      + "\nThe field MickeyDatabaseModel.initTables refers to the missing type CreateTableStatement"
      + "\nThe field MickeyDatabaseModel.initViews refers to the missing type CreateViewStatement"
      + "\nThe field MickeyDatabaseModel.initTables refers to the missing type CreateTableStatement"
      + "\ntables cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\ncolumnDefs cannot be resolved"
      + "\nfilter cannot be resolved"
      + "\nname cannot be resolved"
      + "\nunderscore cannot be resolved"
      + "\ntoUpperCase cannot be resolved"
      + "\nname cannot be resolved"
      + "\nviews cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\ngetViewResultColumns cannot be resolved"
      + "\nfilter cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\ncolumnDefs cannot be resolved"
      + "\nfilter cannot be resolved"
      + "\nname cannot be resolved"
      + "\nunderscore cannot be resolved"
      + "\ntoUpperCase cannot be resolved"
      + "\nname cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\ngetViewResultColumns cannot be resolved"
      + "\nfilter cannot be resolved"
      + "\ntables cannot be resolved"
      + "\nviews cannot be resolved"
      + "\ntables cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nviews cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\ntables cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved");
  }
  
  public CharSequence createActionUriBuilder(final ActionStatement action) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\n!= cannot be resolved"
      + "\ntoJavaTypeName cannot be resolved"
      + "\n== cannot be resolved"
      + "\n== cannot be resolved");
  }
  
  public String asString(final ContentUri uri) {
    StringBuilder builder = new StringBuilder();
    EList<ContentUriSegment> _segments = uri.getSegments();
    for (final ContentUriSegment seg : _segments) {
      {
        builder.append("/");
        if ((seg instanceof ContentUriParamSegment)) {
          ContentUriParamSegment param = ((ContentUriParamSegment) seg);
          StringBuilder _append = builder.append("{");
          ColumnSource _param = param.getParam();
          String _name = _param.getName();
          StringBuilder _append_1 = _append.append(_name);
          _append_1.append("}");
        } else {
          String _name_1 = seg.getName();
          builder.append(_name_1);
        }
      }
    }
    return builder.toString();
  }
  
  /**
   * Find all actions associated to the given definition,
   * actions are associated to the definition via the first
   * part of an action uri, for instance /recipes/a/b/c is
   * associated to recipes
   */
  public Iterable<ActionStatement> findActionsForDefinition(final MickeyDatabaseModel model, final String defName) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe field MickeyDatabaseModel.actions refers to the missing type ActionStatement"
      + "\ntype cannot be resolved"
      + "\nname cannot be resolved"
      + "\nequals cannot be resolved");
  }
  
  public String toMethodArgsSig(final ContentUri uri) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\n!= cannot be resolved");
  }
  
  public String toMethodArgs(final ContentUri uri) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field inferredColumnType is undefined for the type ColumnSource"
      + "\n!= cannot be resolved");
  }
  
  public boolean hasMethodArgs(final ContentUri uri) {
    EList<ContentUriSegment> _segments = uri.getSegments();
    Iterable<ContentUriParamSegment> _filter = Iterables.<ContentUriParamSegment>filter(_segments, ContentUriParamSegment.class);
    int _size = IterableExtensions.size(_filter);
    return (_size > 0);
  }
  
  public CharSequence generateContractItem(final MickeyDatabaseModel model, final SqliteDatabaseSnapshot snapshot, final TableDefinition stmt, final ContentUris content) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method getAllViewsReferencingTable(TableDefinition) is undefined for the type SqliteDatabaseSnapshot"
      + "\nThe method hasAndroidPrimaryKey(TableDefinition) from the type ContentProviderContractGenerator refers to the missing type Object"
      + "\nThere is no context to infer the closure\'s argument types from. Consider typing the arguments or put the closures into a typed context."
      + "\nThe method getAllViewsInConfigInitReferencingTable(MickeyDatabaseModel, TableDefinition) from the type ModelUtil refers to the missing type CreateViewStatement"
      + "\nsortBy cannot be resolved"
      + "\nname cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved"
      + "\nname cannot be resolved"
      + "\npascalize cannot be resolved");
  }
  
  protected CharSequence _generateBuilderSetters(final CreateTableStatement stmt) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field toJavaTypeName is undefined for the type ColumnType");
  }
  
  protected CharSequence _generateBuilderSetters(final CreateViewStatement stmt) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field viewResultColumns is undefined for the type CreateViewStatement"
      + "\nThe method or field inferredColumnType is undefined for the type ResultColumn"
      + "\nfilter cannot be resolved"
      + "\ntoJavaTypeName cannot be resolved");
  }
  
  protected String _getName(final CreateTableStatement stmt) {
    return stmt.getName();
  }
  
  protected String _getName(final CreateViewStatement stmt) {
    return stmt.getName();
  }
  
  protected Object _hasAndroidPrimaryKey(final CreateTableStatement stmt) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method hasAndroidPrimaryKey(CreateTableStatement) from the type ModelUtil refers to the missing type Object");
  }
  
  protected Object _hasAndroidPrimaryKey(final CreateViewStatement stmt) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method hasAndroidPrimaryKey(CreateTableStatement) from the type ModelUtil refers to the missing type Object");
  }
  
  public CharSequence createMethodArgsFromColumns(final CreateTableStatement tbl) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method toJavaTypeName() is undefined for the type ColumnType");
  }
  
  public CharSequence generateInterfaceMemberForResultColumn(final ColumnSource expr) {
    StringConcatenation _builder = new StringConcatenation();
    {
      if ((((!Objects.equal(expr.getName(), null)) && (!expr.getName().equals(""))) && (!expr.getName().equals("_id")))) {
        _builder.append("String ");
        String _name = expr.getName();
        String _underscore = Strings.underscore(_name);
        String _upperCase = _underscore.toUpperCase();
        _builder.append(_upperCase, "");
        _builder.append(" = \"");
        String _name_1 = expr.getName();
        _builder.append(_name_1, "");
        _builder.append("\";");
        _builder.newLineIfNotEmpty();
      }
    }
    return _builder;
  }
  
  public CharSequence generateBuilderSetters(final TableDefinition stmt) {
    if (stmt instanceof CreateTableStatement) {
      return _generateBuilderSetters((CreateTableStatement)stmt);
    } else if (stmt instanceof CreateViewStatement) {
      return _generateBuilderSetters((CreateViewStatement)stmt);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(stmt).toString());
    }
  }
  
  public String getName(final TableDefinition stmt) {
    if (stmt instanceof CreateTableStatement) {
      return _getName((CreateTableStatement)stmt);
    } else if (stmt instanceof CreateViewStatement) {
      return _getName((CreateViewStatement)stmt);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(stmt).toString());
    }
  }
  
  public Object hasAndroidPrimaryKey(final TableDefinition stmt) {
    if (stmt instanceof CreateTableStatement) {
      return _hasAndroidPrimaryKey((CreateTableStatement)stmt);
    } else if (stmt instanceof CreateViewStatement) {
      return _hasAndroidPrimaryKey((CreateViewStatement)stmt);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(stmt).toString());
    }
  }
}
