robotoworks/mechanoid — pull request #93 by fluxtah (2013-03-04 12:16:57+00:00)
Title: Custom Action Updates, Fixes #81

Custom actions are slightly more mature now.

You can define a custom action like this

database RecipesDB {
config {
action GetRecipesByAuthorName /recipes/by-author/{name:*}
}
}

URI's are similar (almost exactly the same) as Content URI's described in the Android content provider docs with one enhancement, parameterized segments are enclosed in ``{}`` and given a name, such as ``{myParam:#}`` for a string param, and ``{myParam:*}`` for a numeric param, where ``myParam`` gives a name to that particular segment.

The generator will then attempt to generate into an existing Contract Item, for instance, RecipesDBContract.Recipes will gain a new static help method:

public static Uri buildGetRecipesByAuthorNameUri(String name) ...

Where each parameter specified in the URI will become a method argument.

To implement actions for a given URI, a method is generated into the abstract content provider

public ContentProviderActions createRecipesByAuthorNameActions() ...

which should be overriden to provide an implementation of ContentProviderActions that acts upon the URI