package com.sam_chordas.android.stockhawk.data;

import android.net.Uri;
import net.simonvt.schematic.annotation.ContentProvider;
import net.simonvt.schematic.annotation.ContentUri;
import net.simonvt.schematic.annotation.InexactContentUri;
import net.simonvt.schematic.annotation.TableEndpoint;

/**
 * Created by sam_chordas on 10/5/15.
 */
@ContentProvider(authority = QuoteProvider.AUTHORITY, database = QuoteDatabase.class)
public class QuoteProvider {
  public static final String AUTHORITY = "com.sam_chordas.android.stockhawk.data.QuoteProvider";

  static final Uri BASE_CONTENT_URI = Uri.parse("content://" + AUTHORITY);

  interface Path{
    String QUOTES = "quotes";
  }

  private static Uri buildUri(String... paths){
    Uri.Builder builder = BASE_CONTENT_URI.buildUpon();
    for (String path:paths){
      builder.appendPath(path);
    }
    return builder.build();
  }

  @TableEndpoint(table = QuoteDatabase.QUOTES)
  public static class Quotes{
    @ContentUri(
        path = Path.QUOTES,
        type = "vnd.android.cursor.dir/quote"
    )
    public static final Uri CONTENT_URI = buildUri(Path.QUOTES);

    @InexactContentUri(
        name = "QUOTE_ID",
        path = Path.QUOTES + "/*",
        type = "vnd.android.cursor.item/quote",
        whereColumn = QuoteColumns.SYMBOL,
        pathSegment = 1
    )
    public static Uri withSymbol(String symbol){
      return buildUri(Path.QUOTES, symbol);
    }
  }
}

@@ -673,16 +673,55 @@
 uotes%22;%0A
+    String QUOTES_HISTORY = %22history%22;%0A
   %7D%0A%0A  p
@@ -1471,10 +1471,657 @@
   %7D%0A  %7D%0A
+%0A%0A  @TableEndpoint(table = QuoteDatabase.QUOTES_HISTORY)%0A  public static class QuotesHistory%7B%0A    @ContentUri(%0A            path = Path.QUOTES_HISTORY,%0A            type = %22vnd.android.cursor.dir/quote_history%22%0A    )%0A    public static final Uri CONTENT_URI = buildUri(Path.QUOTES_HISTORY);%0A%0A    @InexactContentUri(%0A            name = %22QUOTE_ID%22,%0A            path = Path.QUOTES_HISTORY + %22/*%22,%0A            type = %22vnd.android.cursor.item/quote_history%22,%0A            whereColumn = QuoteStockHistoryColumns.SYMBOL,%0A            pathSegment = 1%0A    )%0A    public static Uri withSymbol(String symbol)%7B%0A      return buildUri(Path.QUOTES, symbol);%0A    %7D%0A  %7D%0A
 %7D%0A

add history table to provider