/*
* Generated by Robotoworks Mechanoid
*/
package com.robotoworks.example.recipes.content;
import android.content.Context;
import android.content.UriMatcher;
import android.net.Uri;
import java.util.Set;
import com.robotoworks.mechanoid.db.MechanoidContentProvider;
import com.robotoworks.mechanoid.db.MechanoidSQLiteOpenHelper;
import com.robotoworks.mechanoid.db.DefaultContentProviderActions;
import com.robotoworks.mechanoid.db.ContentProviderActions;
import com.robotoworks.example.recipes.content.AbstractRecipesDBOpenHelper.Sources;
import com.robotoworks.example.recipes.content.RecipesRecord;
import com.robotoworks.example.recipes.content.AuthorsRecord;
import com.robotoworks.example.recipes.content.IngredientsRecord;
public abstract class AbstractRecipesDBContentProvider extends MechanoidContentProvider {
public static final int RECIPES = 0;
public static final int RECIPES_ID = 1;
public static final int AUTHORS = 2;
public static final int AUTHORS_ID = 3;
public static final int INGREDIENTS = 4;
public static final int INGREDIENTS_ID = 5;
public static final int RECIPES_WITH_AUTHORS = 6;
public static final int RECIPES_WITH_AUTHORS_ID = 7;
public static final int RECIPES_AND_INGREDIENTS = 8;
public static final int RECIPES_AND_INGREDIENTS_ID = 9;
public static final int NUM_URI_MATCHERS = 10;
@Override
protected UriMatcher createUriMatcher() {
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = RecipesDBContract.CONTENT_AUTHORITY;
matcher.addURI(authority, "recipes", RECIPES);
matcher.addURI(authority, "recipes/#", RECIPES_ID);
matcher.addURI(authority, "authors", AUTHORS);
matcher.addURI(authority, "authors/#", AUTHORS_ID);
matcher.addURI(authority, "ingredients", INGREDIENTS);
matcher.addURI(authority, "ingredients/#", INGREDIENTS_ID);
matcher.addURI(authority, "recipes_with_authors", RECIPES_WITH_AUTHORS);
matcher.addURI(authority, "recipes_with_authors/#", RECIPES_WITH_AUTHORS_ID);
matcher.addURI(authority, "recipes_and_ingredients", RECIPES_AND_INGREDIENTS);
matcher.addURI(authority, "recipes_and_ingredients/#", RECIPES_AND_INGREDIENTS_ID);
// User Actions
return matcher;
}
@Override
protected String[] createContentTypes() {
String[] contentTypes = new String[NUM_URI_MATCHERS];
contentTypes[RECIPES] = RecipesDBContract.Recipes.CONTENT_TYPE;
contentTypes[RECIPES_ID] = RecipesDBContract.Recipes.ITEM_CONTENT_TYPE;
contentTypes[AUTHORS] = RecipesDBContract.Authors.CONTENT_TYPE;
contentTypes[AUTHORS_ID] = RecipesDBContract.Authors.ITEM_CONTENT_TYPE;
contentTypes[INGREDIENTS] = RecipesDBContract.Ingredients.CONTENT_TYPE;
contentTypes[INGREDIENTS_ID] = RecipesDBContract.Ingredients.ITEM_CONTENT_TYPE;
contentTypes[RECIPES_WITH_AUTHORS] = RecipesDBContract.RecipesWithAuthors.CONTENT_TYPE;
contentTypes[RECIPES_WITH_AUTHORS_ID] = RecipesDBContract.RecipesWithAuthors.ITEM_CONTENT_TYPE;
contentTypes[RECIPES_AND_INGREDIENTS] = RecipesDBContract.RecipesAndIngredients.CONTENT_TYPE;
contentTypes[RECIPES_AND_INGREDIENTS_ID] = RecipesDBContract.RecipesAndIngredients.ITEM_CONTENT_TYPE;
return contentTypes;
}
@Override
protected MechanoidSQLiteOpenHelper createOpenHelper(Context context) {
return new RecipesDBOpenHelper(context);
}
@Override
protected Set<Uri> getRelatedUris(Uri uri) {
return RecipesDBContract.REFERENCING_VIEWS.get(uri);
}
@Override
protected ContentProviderActions createActions(int id) {
switch(id) {
case RECIPES:
return createRecipesActions();
case RECIPES_ID:
return createRecipesByIdActions();
case AUTHORS:
return createAuthorsActions();
case AUTHORS_ID:
return createAuthorsByIdActions();
case INGREDIENTS:
return createIngredientsActions();
case INGREDIENTS_ID:
return createIngredientsByIdActions();
case RECIPES_WITH_AUTHORS:
return createRecipesWithAuthorsActions();
case RECIPES_WITH_AUTHORS_ID:
return createRecipesWithAuthorsByIdActions();
case RECIPES_AND_INGREDIENTS:
return createRecipesAndIngredientsActions();
case RECIPES_AND_INGREDIENTS_ID:
return createRecipesAndIngredientsByIdActions();
default:
throw new UnsupportedOperationException("Unknown id: " + id);
}
}
protected ContentProviderActions createRecipesByIdActions() {
return new DefaultContentProviderActions(Sources.RECIPES, true, RecipesRecord.getFactory());
}
protected ContentProviderActions createRecipesActions() {
return new DefaultContentProviderActions(Sources.RECIPES, false, RecipesRecord.getFactory());
}
protected ContentProviderActions createAuthorsByIdActions() {
return new DefaultContentProviderActions(Sources.AUTHORS, true, AuthorsRecord.getFactory());
}
protected ContentProviderActions createAuthorsActions() {
return new DefaultContentProviderActions(Sources.AUTHORS, false, AuthorsRecord.getFactory());
}
protected ContentProviderActions createIngredientsByIdActions() {
return new DefaultContentProviderActions(Sources.INGREDIENTS, true, IngredientsRecord.getFactory());
}
protected ContentProviderActions createIngredientsActions() {
return new DefaultContentProviderActions(Sources.INGREDIENTS, false, IngredientsRecord.getFactory());
}
protected ContentProviderActions createRecipesWithAuthorsByIdActions() {
return new DefaultContentProviderActions(Sources.RECIPES_WITH_AUTHORS, true, RecipesWithAuthorsRecord.getFactory());
}
protected ContentProviderActions createRecipesWithAuthorsActions() {
return new DefaultContentProviderActions(Sources.RECIPES_WITH_AUTHORS, false, RecipesWithAuthorsRecord.getFactory());
}
protected ContentProviderActions createRecipesAndIngredientsByIdActions() {
return new DefaultContentProviderActions(Sources.RECIPES_AND_INGREDIENTS, true, RecipesAndIngredientsRecord.getFactory());
}
protected ContentProviderActions createRecipesAndIngredientsActions() {
return new DefaultContentProviderActions(Sources.RECIPES_AND_INGREDIENTS, false, RecipesAndIngredientsRecord.getFactory());
}
}