-
Notifications
You must be signed in to change notification settings - Fork 16
Content provider
As viewed in the introduction, Kripton to generate DAO and data source implementations need the definition of DAOs and data source interfaces. One of the Kripton's big feature is the capability to generate the content provider is an easy way. This goal is achieved with some annotation like @BindContentProvider, @BindContentProviderPath, @BindContentProviderEntry.
We can take the previous Person
example to see how to generate a content provider too.
@BindTable(name="persons")
public class Person{
public long id;
public String name;
public String surname;
public String email;
public Date birthDate;
}
The DAO interface definition is:
@BindContentProviderPath(path = "persons")
@BindDao(Person.class)
public interface PersonDao {
@BindContentProviderEntry
@BindSqlSelect(orderBy="name")
List<Person> selectAll();
@BindSqlSelect(jql="select * from person order by name")
List<Person> selectTwo();
@BindSqlSelect()
List<Person> selectThree(@BindSqlDynamicOrderBy String orderBy);
@BindSqlSelect(where = "id=${work.id}")
List<E> selectById(@BindSqlParam("work") E bean);
@BindContentProviderEntry
@BindSqlInsert
void insert(Person bean);
@BindContentProviderEntry
@BindSqlUpdate(where = "id=${work.id}")
boolean update(@BindSqlParam("work") Person bean);
@BindContentProviderEntry
@BindSqlDelete(where = "id=${work.id}")
boolean delete(@BindSqlParam("work") Person bean);
}
The data source definition:
@BindContentProvider(authority="com.abubusoft.kripton")
@BindDataSource(daoSet= { PersonDao.class }, fileName = "person.db", log=true)
public interface PersonDataSource {
}
As you notice in the source code there are other used annotations, needed if you want to generate a Content Provider too:
- BindContentProvider: allows to generate a content provider
- BindContentProviderPath: include DAO in the content provider definition
- BindContentProviderEntry: include DAO’s method in the content provider definition
Given a data source definition, Kripton can generate a content provider just with a couple of extra annotations. In your application, to use generated an implementation of data-source you can use code like this:
- Introduction
- Goals & Features
- Kotlin
- Immutable or Mutable Pojo
- Annotation Processor Args
- Credits
- Articles
- Benchmarks
- Setup
- Tutorial
- Usage
- Dependencies and inspirations
- Stackoverflow
- Documentation
- SQL logging
- Data source options
- Indices
- SQL Type adapter
- Global SQL Type adapter
- Constraints
- Live data: welcome Architectural components!!
- Paged Live data
- Dynamic parts
- Transactional and batch operations
- Async Transactional and batch operations
- Global transaction
- Support for immutable POJO
- Generate Content provider
- Generate Database schema generation
- Database migration
- BindSqlColumn
- BindContentProvider
- BindContentProviderEntry
- BindContentProviderPath
- BindDao
- BindDaoMany2Many
- BindDataSource
- BindDataSourceOptions
- BindDataSourceUpdateTask
- BindIndex
- BindSqlRelation
- BindSqlAdapter
- BindSqlChildSelect
- BindSqlDelete
- BindSqlDynamicOrderBy
- BindSqlDynamicWhere
- BindSqlDynamicWhereParams
- BindSqlInsert
- BindSqlPageSize
- BindSqlParam
- BindSqlSelect
- BindSqlUpdate
- BindSqlType
- BindSqlTransaction