package com.gaiagps.iburn.database;

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;

/**
 * ContentProvider definition. This defines a familiar API
 * for Android framework components to utilize.
 *
 * Created by davidbrodsky on 7/28/14.
 */
@ContentProvider(authority = PlayaContentProvider.AUTHORITY, database = PlayaDatabase.class)
public final class PlayaContentProvider {

    public static final String AUTHORITY      = "com.gaiagps.iburn.playacontentprovider";
    private static final Uri BASE_CONTENT_URI = Uri.parse("content://" + AUTHORITY);

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

    /** Art API **/

    @TableEndpoint(table = PlayaDatabase.ART)
    public static class Art {

        private static final String ENDPOINT = "art";

        @ContentUri(
                path = ENDPOINT,
                type = "vnd.android.cursor.dir/list",
                defaultSort = ArtTable.name + " ASC")
        public static final Uri ART = buildUri(ENDPOINT);

        @InexactContentUri(
                path = "query/#",
                name = "LIST_ID",
                type = "vnd.android.cursor.item/list",
                whereColumn = "title LIKE ",
                pathSegment = 1)
        public static Uri withQuery(String query) {
            return buildUri("query", String.valueOf(query));
        }
    }

    /** Camps API **/

    @TableEndpoint(table = PlayaDatabase.CAMPS)
    public static class Camps {

        private static final String ENDPOINT = "camps";

        @ContentUri(
                path = ENDPOINT,
                type = "vnd.android.cursor.dir/list",
                defaultSort = CampTable.name + " ASC")
        public static final Uri CAMPS = buildUri(ENDPOINT);

    }

    /** Events API **/

    @TableEndpoint(table = PlayaDatabase.EVENTS)
    public static class Events {

        private static final String ENDPOINT = "events";

        @ContentUri(
                path = ENDPOINT,
                type = "vnd.android.cursor.dir/list",
                defaultSort = EventTable.startTime + " ASC")
        public static final Uri EVENTS = buildUri(ENDPOINT);
    }

    /** User POI API **/

    @TableEndpoint(table = PlayaDatabase.POIS)
    public static class Pois {

        private static final String ENDPOINT = "pois";

        @ContentUri(
                path = ENDPOINT,
                type = "vnd.android.cursor.dir/list",
                defaultSort = UserPoiTable.name + " ASC")
        public static final Uri POIS = buildUri(ENDPOINT);
    }
}

@@ -1360,360 +1360,8 @@
 );%0A%0A
-        @InexactContentUri(%0A                path = %22query/#%22,%0A                name = %22LIST_ID%22,%0A                type = %22vnd.android.cursor.item/list%22,%0A                whereColumn = %22title LIKE %22,%0A                pathSegment = 1)%0A        public static Uri withQuery(String query) %7B%0A            return buildUri(%22query%22, String.valueOf(query));%0A        %7D%0A
     

remove unused ContentProvider Uri