Commit 66f25a39 authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #110 from yashkhem1/master

Updated the data package
parents ad2d39a9 77291a74
......@@ -10,7 +10,7 @@ import android.content.Context;
* Created by mrunz on 14/3/18.
*/
@Database(entities = {Event.class, Body.class, Venue.class}, version = 1)
@Database(entities = {Event.class, Body.class, Venue.class, User.class, Role.class}, version = 1)
@TypeConverters({Converters.class})
public abstract class AppDatabase extends RoomDatabase {
......
......@@ -72,6 +72,20 @@ public class Converters {
return json;
}
@TypeConverter
public static List<Role> rolesfromString(String value){
Type listType = new TypeToken<List<Role>>(){
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromRoles(List<Role> list){
Gson gson = new Gson();
String json= gson.toJson(list);
return json;
}
@TypeConverter
public static Timestamp timestampfromString(String value) {
try {
......
......@@ -21,6 +21,12 @@ public interface DbDao {
@Query("SELECT * FROM venues")
List<Venue> getAllVenues();
@Query("SELECT * FROM users")
List<User> getAllUsers();
@Query("SELECT * FROM roles")
List<Role> getAllRoles();
@Query("SELECT * FROM bodies WHERE id == :id")
public Body[] getBody(String id);
......@@ -33,9 +39,18 @@ public interface DbDao {
@Query("SELECT COUNT(*) from bodies")
int countBodies();
@Query("SELECT COUNT(*) from users")
int countUsers();
@Query("SELECT COUNT(*) from roles")
int countRoles();
@Insert
void insertEvents(List<Event> events);
@Insert
void insertEvent(Event event);
@Insert
void insertBodies(List<Body> bodies);
......@@ -45,6 +60,21 @@ public interface DbDao {
@Insert
void insertVenues(List<Venue> venues);
@Insert
void insertVenue(Venue venue);
@Insert
void insertUsers(List<User> users);
@Insert
void insertUser(User user);
@Insert
void insertRoles(List<Role> roles);
@Insert
void insertRole(Role role);
@Delete
void deleteEvent(Event event);
......@@ -54,6 +84,12 @@ public interface DbDao {
@Delete
void deleteBody(Body body);
@Delete
void deleteUser(User user);
@Delete
void deleteRole(Role role);
@Query("DELETE from events")
void deleteEvents();
......@@ -62,4 +98,10 @@ public interface DbDao {
@Query("DELETE from bodies")
void deleteBodies();
@Query("DELETE from users")
void deleteUsers();
@Query("DELETE from roles")
void deleteRoles();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment