Commit 31f371cc authored by Varun Patil's avatar Varun Patil

Remove column info decorators

parent 91205c38
......@@ -10,54 +10,36 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
@Entity(tableName = "bodies")
public class Body {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String bodyID;
@ColumnInfo(name = "str_id")
@SerializedName("str_id")
String bodyStrID;
@ColumnInfo(name = "name")
@SerializedName("name")
String bodyName;
@ColumnInfo(name = "short_description")
@SerializedName("short_description")
String bodyShortDescription;
@ColumnInfo(name = "description")
@SerializedName("description")
String bodyDescription;
@ColumnInfo(name = "image_url")
@SerializedName("image_url")
String bodyImageURL;
@ColumnInfo(name = "children")
@SerializedName("children")
List<Body> bodyChildren;
@ColumnInfo(name = "parents")
@SerializedName("parents")
List<Body> bodyParents;
@ColumnInfo(name = "events")
@SerializedName("events")
List<Event> bodyEvents;
@ColumnInfo(name = "followers_count")
@SerializedName("followers_count")
int bodyFollowersCount;
@ColumnInfo(name = "website_url")
@SerializedName("website_url")
String bodyWebsiteURL;
@ColumnInfo(name = "blog_url")
@SerializedName("blog_url")
String bodyBlogURL;
@ColumnInfo(name = "user_follows")
@SerializedName("user_follows")
boolean bodyUserFollows;
@ColumnInfo(name = "roles")
@SerializedName("roles")
List<Role> bodyRoles;
@Ignore
public Body(@NonNull String bodyID) {
this.bodyID = bodyID;
}
......
package app.insti.data;
import android.arch.persistence.room.TypeConverter;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.util.List;
public class Converters {
@TypeConverter
public static List<Event> eventsfromString(String value) {
Type listType = new TypeToken<List<Event>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromEvents(List<Event> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<User> usersfromString(String value) {
Type listType = new TypeToken<List<User>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromUsers(List<User> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<Venue> venuesfromString(String value) {
Type listType = new TypeToken<List<Venue>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromVenues(List<Venue> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<Body> bodiesfromString(String value) {
Type listType = new TypeToken<List<Body>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromBodies(List<Body> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
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 {
return new Gson().fromJson(value, Timestamp.class);
} catch (JsonSyntaxException e) {
Log.d("Converters", "timestampfromString: " + value);
e.printStackTrace();
return null;
}
}
@TypeConverter
public static String stringfromTimestamp(Timestamp timestamp) {
Gson gson = new Gson();
String json = gson.toJson(timestamp);
return json;
}
@TypeConverter
public static Body bodyfromString(String value) {
Type listType = new TypeToken<Body>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromBody(Body body) {
Gson gson = new Gson();
String json = gson.toJson(body);
return json;
}
@TypeConverter
public static Object objectFromString(String value) {
Type listType = new TypeToken<Object>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringFromObject(Object object) {
Gson gson = new Gson();
String json = gson.toJson(object);
return json;
}
@TypeConverter
public static List<String> stringsfromString(String value) {
Type listType = new TypeToken<List<String>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromStrings(List<String> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
@TypeConverter
public static List<MessMenu> messMenusfromString(String value) {
Type listType = new TypeToken<List<MessMenu>>() {
}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String stringfromMessMenus(List<MessMenu> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
}
\ No newline at end of file
package app.insti.data;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import java.util.List;
@Dao
public interface DbDao {
@Query("SELECT * FROM events")
List<Event> getAllEvents();
@Query("SELECT * FROM events WHERE user_ues <> 0")
List<Event> getFollowingEvents();
@Query("SELECT * FROM bodies")
List<Body> getAllBodies();
@Query("SELECT * FROM venues")
List<Venue> getAllVenues();
@Query("SELECT * FROM users")
List<User> getAllUsers();
@Query("SELECT * FROM roles")
List<Role> getAllRoles();
@Query("SELECT * FROM placementBlogPosts")
List<PlacementBlogPost> getAllPlacementBlogPosts();
@Query("SELECT * FROM trainingBlogPosts")
List<TrainingBlogPost> getAllTrainingBlogPosts();
@Query("SELECT * FROM hostelMessMenus")
List<HostelMessMenu> getAllHostelMessMenus();
@Query("SELECT * FROM news")
List<NewsArticle> getAllNewsArticles();
@Query("SELECT COUNT(*) from events")
int countEvents();
@Query("SELECT * FROM bodies WHERE id == :id")
public Body[] getBody(String id);
@Query("SELECT COUNT(*) from venues")
int countVenues();
@Query("SELECT COUNT(*) from bodies")
int countBodies();
@Query("SELECT COUNT(*) from users")
int countUsers();
@Query("SELECT COUNT(*) from roles")
int countRoles();
@Query("SELECT COUNT(*) from hostelMessMenus")
int countHostelMessMenus();
@Insert
void insertEvents(List<Event> events);
@Insert
void insertEvent(Event event);
@Update
void updateEvent(Event event);
@Insert
void insertBodies(List<Body> bodies);
@Insert
void insertBody(Body body);
@Update
void updateBody(Body body);
@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);
@Insert
void insertPlacementBlogPost(PlacementBlogPost post);
@Insert
void insertPlacementBlogPosts(List<PlacementBlogPost> posts);
@Insert
void insertTrainingBlogPost(TrainingBlogPost post);
@Insert
void insertTrainingBlogPosts(List<TrainingBlogPost> posts);
@Insert
void insertHostelMessMenu(HostelMessMenu hostelMessMenu);
@Insert
void insertHostelMessMenus(List<HostelMessMenu> hostelMessMenus);
@Insert
void insertNewsArticle(NewsArticle newsArticle);
@Insert
void insertNewsArticles(List<NewsArticle> newsArticles);
@Delete
void deleteEvent(Event event);
@Delete
void deleteVenue(Venue venue);
@Delete
void deleteBody(Body body);
@Delete
void deleteUser(User user);
@Delete
void deleteRole(Role role);
@Query("DELETE from events")
void deleteEvents();
@Query("DELETE from venues")
void deleteVenues();
@Query("DELETE from bodies")
void deleteBodies();
@Query("DELETE from users")
void deleteUsers();
@Query("DELETE from roles")
void deleteRoles();
@Query("DELETE from placementBlogPosts")
void deletePlacementBlogPosts();
@Query("DELETE from trainingBlogPosts")
void deleteTrainingBlogPosts();
@Query("DELETE from hostelMessMenus")
void deleteHostelMessMenus();
@Query("DELETE from news")
void deleteNewsArticles();
}
......@@ -12,61 +12,56 @@ import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
import java.util.List;
@Entity(tableName = "events")
public class Event {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String eventID;
@ColumnInfo(name = "str_id")
@SerializedName("str_id")
String eventStrID;
@ColumnInfo(name = "name")
@SerializedName("name")
String eventName;
@ColumnInfo(name = "description")
@SerializedName("description")
String eventDescription;
@ColumnInfo(name = "image_url")
@SerializedName("image_url")
String eventImageURL;
@ColumnInfo(name = "start_time")
@SerializedName("start_time")
Timestamp eventStartTime;
@ColumnInfo(name = "end_time")
@SerializedName("end_time")
Timestamp eventEndTime;
@ColumnInfo(name = "all_day")
@SerializedName("all_day")
boolean allDayEvent;
@ColumnInfo(name = "venues")
@SerializedName("venues")
List<Venue> eventVenues;
@ColumnInfo(name = "bodies")
@SerializedName("bodies")
List<Body> eventBodies;
@ColumnInfo(name = "interested_count")
@SerializedName("interested_count")
int eventInterestedCount;
@ColumnInfo(name = "going_count")
@SerializedName("going_count")
int eventGoingCount;
@ColumnInfo(name = "interested")
@SerializedName("interested")
List<User> eventInterested;
@ColumnInfo(name = "going")
@SerializedName("going")
List<User> eventGoing;
@ColumnInfo(name = "website_url")
@SerializedName("website_url")
String eventWebsiteURL;
@ColumnInfo(name = "user_ues")
@SerializedName("user_ues")
int eventUserUes;
@Ignore
boolean eventBigImage = false;
public Event(String eventID, String eventStrID, String eventName, String eventDescription, String eventImageURL, Timestamp eventStartTime, Timestamp eventEndTime, boolean allDayEvent, List<Venue> eventVenues, List<Body> eventBodies, int eventInterestedCount, int eventGoingCount, List<User> eventInterested, List<User> eventGoing, String eventWebsiteURL, int eventUserUes) {
......
......@@ -9,27 +9,20 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
@Entity(tableName = "hostelMessMenus")
public class HostelMessMenu {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String menuID;
@ColumnInfo(name = "name")
@SerializedName("name")
private String name;
@ColumnInfo(name = "short_name")
@SerializedName("short_name")
private String shortName;
@ColumnInfo(name = "long_name")
@SerializedName("long_name")
private String longName;
@ColumnInfo(name = "mess")
@SerializedName("mess")
private List<MessMenu> messMenus;
......
......@@ -7,7 +7,6 @@ import com.google.gson.annotations.SerializedName;
public class MessMenu {
@NonNull()
@PrimaryKey()
@SerializedName("id")
private String mealID;
......
......@@ -9,32 +9,23 @@ import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
@Entity(tableName = "news")
public class NewsArticle {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String articleID;
@ColumnInfo(name = "link")
@SerializedName("link")
private String link;
@ColumnInfo(name = "title")
@SerializedName("title")
private String title;
@ColumnInfo(name = "content")
@SerializedName("content")
private String content;
@ColumnInfo(name = "published")
@SerializedName("published")
private Timestamp published;
@ColumnInfo(name = "body")
@SerializedName("body")
private Body body;
......
......@@ -7,28 +7,21 @@ import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
@Entity(tableName = "news")
public class Notification {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private Integer notificationId;
@ColumnInfo(name = "verb")
@SerializedName("verb")
private String notificationVerb;
@ColumnInfo(name = "unread")
@SerializedName("unread")
private boolean notificationUnread;
@ColumnInfo(name = "actor_type")
@SerializedName("actor_type")
private String notificationActorType;
@ColumnInfo(name = "actor")
@SerializedName("actor")
private Object notificationActor;
......
......@@ -9,28 +9,20 @@ import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
@Entity(tableName = "placementBlogPosts")
public class PlacementBlogPost {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String postID;
@ColumnInfo(name = "link")
@SerializedName("link")
private String link;
@ColumnInfo(name = "title")
@SerializedName("title")
private String title;
@ColumnInfo(name = "content")
@SerializedName("content")
private String content;
@ColumnInfo(name = "published")
@SerializedName("published")
private Timestamp published;
......
......@@ -9,46 +9,32 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
@Entity(tableName = "roles")
public class Role {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String roleID;
@ColumnInfo(name = "name")
@SerializedName("name")
String roleName;
@ColumnInfo(name = "inheritable")
@SerializedName("inheritable")
boolean roleInheritable;
@ColumnInfo(name = "body")
@SerializedName("body")
String roleBody;
@ColumnInfo(name = "body_detail")
@SerializedName("body_detail")
Body roleBodyDetails;
@ColumnInfo(name = "bodies")
@SerializedName("bodies")
List<Body> roleBodies;
@ColumnInfo(name = "permissions")
@SerializedName("permissions")
List<String> rolePermissions;
@ColumnInfo(name = "users")
@SerializedName("users")
List<String> roleUsers;
@ColumnInfo(name = "users_detail")
@SerializedName("users_detail")
List<User> roleUsersDetail;
......
......@@ -9,28 +9,20 @@ import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
@Entity(tableName = "trainingBlogPosts")
public class TrainingBlogPost {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String postID;
@ColumnInfo(name = "link")
@SerializedName("link")
private String link;
@ColumnInfo(name = "title")
@SerializedName("title")
private String title;
@ColumnInfo(name = "content")
@SerializedName("content")
private String content;
@ColumnInfo(name = "published")
@SerializedName("published")
private Timestamp published;
......
......@@ -11,66 +11,61 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
@Entity(tableName = "users")
public class User {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String userID;
@ColumnInfo(name = "name")
@SerializedName("name")
String userName;
@ColumnInfo(name = "profile_pic")
@SerializedName("profile_pic")
String userProfilePictureUrl;
@ColumnInfo(name = "events_interested")
@SerializedName("events_interested")
List<Event> userInterestedEvents;
@ColumnInfo(name = "events_going")
@SerializedName("events_going")
List<Event> userGoingEvents;
@ColumnInfo(name = "email")
@SerializedName("email")
String userEmail;
@ColumnInfo(name = "roll_no")
@SerializedName("roll_no")
String userRollNumber;
@ColumnInfo(name = "contact_no")
@SerializedName("contact_no")
String userContactNumber;
@ColumnInfo(name = "about")
@SerializedName("about")
String userAbout;
@ColumnInfo(name = "followed_bodies")
@SerializedName("followed_bodies")
List<Body> userFollowedBodies;
@ColumnInfo(name = "followed_bodies_id")
@SerializedName("followed_bodies_id")
List<String> userFollowedBodiesID;
@ColumnInfo(name = "roles")
@SerializedName("roles")
List<Role> userRoles;
@ColumnInfo(name = "institute_roles")
@SerializedName("institute_roles")
List<Role> userInstituteRoles;
@ColumnInfo(name = "former_roles")
@SerializedName("former_roles")
List<Role> userFormerRoles;
@ColumnInfo(name = "website_url")
@SerializedName("website_url")
String userWebsiteURL;
@ColumnInfo(name = "ldap_id")
@SerializedName("ldap_id")
String userLDAPId;
@ColumnInfo(name = "hostel")
@SerializedName("hostel")
String hostel;
/**
* Not in database
*/
@Ignore
String currentRole;
public User(@NonNull String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, String userRollNumber, String userContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID, List<Role> userRoles, List<Role> userInstituteRoles, List<Role> userFormerRoles, String userWebsiteURL, String userLDAPId, String hostel) {
......
......@@ -7,44 +7,41 @@ import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
@Entity(tableName = "venues")
public class Venue {
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String venueID;
@ColumnInfo(name = "name")
@SerializedName("name")
String venueName;
@ColumnInfo(name = "short_name")
@SerializedName("short_name")
String venueShortName;
@ColumnInfo(name = "description")
@SerializedName("description")
String venueDescripion;
@ColumnInfo(name = "parent")
@SerializedName("parent")
String venueParentId;
@ColumnInfo(name = "parent_relation")
@SerializedName("parent_relation")
String venueParentRelation;
@ColumnInfo(name = "group_id")
@SerializedName("group_id")
Integer venueGroupId;
@ColumnInfo(name = "pixel_x")
@SerializedName("pixel_x")
Integer venuePixelX;
@ColumnInfo(name = "pixel_y")
@SerializedName("pixel_y")
Integer venuePixelY;
@ColumnInfo(name = "reusable")
@SerializedName("reusable")
Boolean venueReusable;
@ColumnInfo(name = "lat")
@SerializedName("lat")
double venueLatitude;
@ColumnInfo(name = "lng")
@SerializedName("lng")
double venueLongitude;
......
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